OceanParcels/oceanparcels_website

[BUG] Broken linking of tutorial notebooks

Closed this issue · 3 comments

Recreation

  • Go to tutorials section
  • Ctrl + click a tutorial
  • Notebook opens in new tab, and current tab relocates to a 404 (eg. https://oceanparcels.org/documentation_stuck)

Initial thoughts
Clicking a link such as:

<a class="tutorialLink" href="https://nbviewer.jupyter.org/github/OceanParcels/parcels/blob/master/parcels/examples/documentation_stuck_particles.ipynb" onclick="captureTutorialLink('documentation_stuck');">

uses the captureTutorialLink callback:

<script>
/**
* Function that records clicks on tutorial links
* The function takes the tutorial link as an argument and sends it to Google Analytics as an event
* These clicks can be seen under Behaviour -> Events
* The hit is sent when 'navigator.sendBeacon' is used in a compatible browser
*/
var captureTutorialLink = function(url) {
ga('send', 'event', 'tutorial', 'click', url, {
'transport': 'beacon',
'hitCallback': function(){document.location = url;}
});
}

I think the fix is just removing 'hitCallback': function(){document.location = url;}.


Happy to work on this in the coming week or two when I have time. Feel free to claim if someone else wants to patch this beforehand.

I think that @reint-fischer added this functionality to better track - using Google Analytics - which tutorials were being opened (since they are hosted on a different website). Not sure if that functionality would still work if we remove the hitCallback call, because I don't know exactly what it does?

Looking deeper into this, I think you're right (removing the hitCallback call can result in a redirect before the query is hit, hence defeating the purpose). I'm not sure the fix is simple

No longer relevant