Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 Page handling w/ issue form (#362) #365

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/form404.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Broken Link Report
description: File a broken link report
title: "Broken Link:"
labels: ["bug"]
projects: ["ros-infrastructure/rosindex"]
body:

- type: input
id: 404page
attributes:
label: 404 Page URL
description: Enter the url of the page that doesn't exist
placeholder: Failed to automatically detect 404 page. Please enter url here.
validations:
required: true

- type: input
id: referer
attributes:
label: Referrer URL
description: Enter the URL of the referring page which has the wrong link.
placeholder: Automatic detection of the referrer page failed, please enter it here.
validations:
required: true

- type: textarea
id: description
attributes:
label: Description
placeholder: Please describe where the link is that you followed if it might not be obvious on the referring page. If any additional information is needed, please provide it here too.
validations:
required: false
42 changes: 38 additions & 4 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h2>Move along.</h2>
</div>
<div class="row">
<div class="col-xs-offset-3 col-xs-6 text-center">
<a target="_blank" href="https://github.com/ros-infrastructure/rosindex/issues/new?title=Broken%20Link:%20" class="btn btn-sm btn-default btn-block">Report Broken Link</a>
<a id="github_issue_link" target="_blank" href="" class="btn btn-sm btn-default btn-block">Report Broken Link</a>
</div>
</div>
<div class="row">
Expand All @@ -42,7 +42,41 @@ <h2>Move along.</h2>
</div>

<script>
$(function () {
// TODO add url to the report button
};)
$(function () {
function updateGitHref() {
let githubLink = "https://github.com/ros-infrastructure/rosindex/issues/new?labels=bug&template=form404.yml";

// Get current url
var currentUrl = window.location.href;
if (!currentUrl) {
currentUrl = "";
}

// Get the url that brought us here
var referrerUrl = document.referrer;
if (!referrerUrl) {
referrerUrl = "";
}

// Encode the urls
var title = "title=Broken+Link:" + encodeURIComponent(currentUrl);
var currentUrl_encoded = "404page=" + encodeURIComponent(currentUrl);
var referrerUrl_encoded = "referer=" + encodeURIComponent(referrerUrl);

// Update the href
githubLink += "&" + title + "&" + currentUrl_encoded + "&" + referrerUrl_encoded;

// Set the href
var githubIssueLink = $("#github_issue_link");
if (!githubIssueLink.length) {
console.error("Github issue link element is not available");
return;
}
githubIssueLink.attr("href", githubLink);
}

// Update the href
updateGitHref();

});
</script>
Loading