-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add more structure and info to redirection page #518
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b9d051d
Add more structure and info to redirection page
mih da7d679
Make the redirection page more informative
adswa 692ceaa
update submodule
adswa f8980f5
hide the redirection page from the main toctree
adswa 547001a
Fix message paragraph ID
mih 2a21cf2
Make default success message vanish on error
mih 3294d15
Keep error bold
mih 462d7e6
Use custom role to replace the JS-based mapping
mih File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule artwork
updated
4 files
+1 −0 | LICENSE | |
+713 −4,330 | src/funding.svg | |
+1,342 −0 | src/hospital.svg | |
+466 −0 | src/redirection.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,71 @@ | ||
Redirection | ||
----------- | ||
|
||
This page exists for redirection purposes only. | ||
|
||
.. raw:: HTML | ||
|
||
<html> | ||
<head> | ||
<p id="demo"></p> | ||
|
||
<script> | ||
let redirects = new Map([ | ||
['demo', 'url1'], | ||
['GIN', 'basics/101-139-gin.html'] | ||
]); | ||
redirect = redirects.get(window.location.href.replace(/.*\?/, "")); | ||
if (redirect == undefined) { | ||
document.getElementById("demo").innerHTML = "no idea" | ||
} else { | ||
window.location.replace(window.location.href.replace(/r.html\?.*/, redirect)) | ||
} | ||
</script> | ||
</head> | ||
</html> | ||
.. | ||
Include a named paragraph in the page, where the javascript code below will | ||
place any message. | ||
|
||
.. raw:: html | ||
|
||
<p><strong id="successmessage"> | ||
You will be redirected to your target page in a few seconds. | ||
</strong></p> | ||
|
||
.. figure:: artwork/src/redirection.svg | ||
|
||
.. | ||
use a custom role to identify redirect codes so that a bit of JS can find | ||
them again | ||
|
||
.. role:: redirect | ||
:class: redirect | ||
|
||
If you continue to see this page, you've ended up in here accidentally and redirection | ||
failed -- sorry about this. | ||
|
||
**Here are some links that may take you to where you need to go:** | ||
|
||
.. | ||
This defines a mapping of redirect codes to their present URLs | ||
|
||
:redirect:`GIN` | ||
:ref:`gin` | ||
:redirect:`HCP-dataset` | ||
:ref:`usecase_HCP_dataset` | ||
:redirect:`reproducible-paper` | ||
:ref:`usecase_reproducible_paper` | ||
|
||
Alternatively, try searching in the "Quick Search" at the left-hand side, or | ||
scan the handbook's front page at `handbook.datalad.org <http://handbook.datalad.org/en/latest/>`_ | ||
for directions. | ||
|
||
.. | ||
This code replaces the r.html?key part with the final URL, while keeping | ||
the rest of URL intact. | ||
|
||
.. raw:: html | ||
|
||
<script> | ||
// take everything after "?" as a code to identify the redirect | ||
redirect_code = window.location.href.replace(/.*\?/, ""); | ||
success = false; | ||
// loop over all redirect definitions (see above) | ||
for (rd of document.getElementsByClassName('redirect')){ | ||
if (rd.innerText != redirect_code) {continue;} | ||
// read the href from the link in the <dd> matching the <dt> of the redirect | ||
// this assumes a very simple, and particular structure | ||
// let's hope that sphinx doesn't break it | ||
target = rd.parentElement.nextElementSibling.getElementsByTagName("a")[0].href; | ||
// and jump | ||
window.location.replace(target); | ||
success = true; | ||
break; | ||
} | ||
// if we get here, we didn't find a match | ||
if (success == false) { | ||
document.getElementById("successmessage" | ||
).innerHTML = "Whoops - redirection went wrong, we are lost!" | ||
} | ||
</script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could turn this
<strong>
into CSS ...