Skip to content

Commit edef971

Browse files
committed
Testing Edit this page along with select and report feature
1 parent 34b73c7 commit edef971

File tree

12 files changed

+118
-0
lines changed

12 files changed

+118
-0
lines changed

layouts/blog/list.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ <h1 class="pf-c-title pf-m-4xl">
3232
</div>
3333
</section>
3434
{{ partial "footer.html" . }}
35+
{{ partial "select-report-issue.html" }}
3536
</main>
3637
{{ end }}

layouts/blog/single.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ <h1>
4949
</div>
5050
</section>
5151
{{ partial "footer.html" . }}
52+
{{ partial "select-report-issue.html" }}
5253
</main>
5354
{{ end }}

layouts/contribute/list.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ <h1 class="pf-c-title pf-m-4xl">
3434
</div>
3535
</section>
3636
{{ partial "footer.html" . }}
37+
{{ partial "select-report-issue.html" }}
3738
</main>
3839
{{ end }}

layouts/contribute/single.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
</div>
1616
</section>
1717
{{ partial "footer.html" . }}
18+
{{ partial "select-report-issue.html" }}
1819
</main>
1920
{{ end }}

layouts/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ <h1 class="pf-c-title pf-m-4xl">Latest Blog Post</h1>
5555
</div>
5656
</section>
5757
{{ partial "footer.html" . }}
58+
{{ partial "select-report-issue.html" }}
5859
</main>
5960
{{ end }}

layouts/learn/list.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ <h1 class="pf-c-title pf-m-4xl">
3030
</div>
3131
</section>
3232
{{ partial "footer.html" . }}
33+
{{ partial "select-report-issue.html" }}
3334
</main>
3435
{{ end }}

layouts/learn/single.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
</div>
1616
</section>
1717
{{ partial "footer.html" . }}
18+
{{ partial "select-report-issue.html" }}
1819
</main>
1920
{{ end }}

layouts/partials/patterns-browser.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ <h1 class="pf-c-title pf-m-4xl">
5858
<script src="{{ "js/patterns-browser-v2.js" | relURL }}"></script>
5959
</section>
6060
{{ partial "footer.html" . }}
61+
{{ partial "select-report-issue.html" }}
6162
</main>

layouts/partials/patterns-index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ <h1 class="pf-c-title pf-m-4xl">{{ .Title }}</h1>
8282
</div>
8383
</section>
8484
{{ partial "footer.html" . }}
85+
{{ partial "select-report-issue.html" }}
8586
</main>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// static/js/bug-reporter.js (or wherever you prefer to store static assets)
2+
3+
document.addEventListener('mouseup', function() {
4+
const selectedText = window.getSelection().toString().trim();
5+
6+
if (selectedText.length > 0) {
7+
// You might want to add a small button or popup here instead of direct confirmation
8+
// For simplicity, we'll keep the confirmation for now.
9+
10+
const currentPageUrl = window.location.href;
11+
const githubFilePath = getGitHubFilePath(); // This will now be more accurate for Hugo
12+
13+
const issueTitle = `Bug Report: Issue on "${selectedText.substring(0, 50).replace(/\n/g, ' ')}..."`;
14+
let issueBody = `
15+
**Description of the issue:**
16+
\`\`\`
17+
${selectedText}
18+
\`\`\`
19+
20+
---
21+
**Context:**
22+
- **Page URL:** ${currentPageUrl}
23+
- **GitHub Source File:** ${githubFilePath}
24+
`;
25+
26+
const encodedTitle = encodeURIComponent(issueTitle);
27+
const encodedBody = encodeURIComponent(issueBody);
28+
29+
const githubRepo = 'validatedpatterns/docs'; // Your GitHub repository
30+
const githubIssueUrl = `https://github.com/${githubRepo}/issues/new?title=${encodedTitle}&body=${encodedBody}`;
31+
32+
const confirmation = confirm("Do you want to report this as a bug on GitHub for the selected text?");
33+
if (confirmation) {
34+
window.open(githubIssueUrl, '_blank');
35+
}
36+
}
37+
});
38+
39+
40+
// Hugo-specific function to get the GitHub file path
41+
function getGitHubFilePath() {
42+
// This assumes you've added a data-github-file attribute to your body or a container.
43+
const bodyElement = document.querySelector('body');
44+
if (bodyElement && bodyElement.dataset.githubFile) {
45+
// Construct the full GitHub blob URL
46+
// Assuming your source files are in the 'content' directory of your repo
47+
// And you're using the 'main' branch
48+
const repoBaseUrl = 'https://github.com/validatedpatterns/docs/blob/main/';
49+
return repoBaseUrl + bodyElement.dataset.githubFile;
50+
}
51+
52+
// Fallback if the data attribute isn't found (shouldn't happen with Hugo setup)
53+
return "Could not determine source file automatically. Please specify if known.";
54+
}

0 commit comments

Comments
 (0)