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

Add more structure and info to redirection page #518

Merged
merged 8 commits into from
Jun 2, 2020
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
8 changes: 8 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,11 @@ progress::-webkit-progress-value {
progress::-webkit-progress-bar {
background: #ffa200;
}

.redirect {
font-family: monospace, monospace;
}

.redirect::before {
content: "↷ "
}
2 changes: 1 addition & 1 deletion docs/artwork
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
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ Appendix
teaching
acknowledgements
intro/user_types
r

########################
Code lists from chapters
Expand All @@ -116,3 +115,4 @@ Code lists from chapters
:hidden:

usecases/datasets
r
87 changes: 67 additions & 20 deletions docs/r.rst
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>
Copy link
Collaborator Author

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 ...


.. 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>