QuantEcon / quantecon-book-theme

A Jupyter Book Theme for QuantEcon Book Style Projects
BSD 3-Clause "New" or "Revised" License
40 stars 20 forks source link

ENH: Added ability to redirect to external pages #246

Open AakashGfude opened 6 months ago

AakashGfude commented 6 months ago

Added a config variable to specify redirects.

An Example:-

If in lecture-python, _config.yml file

redirects: 
        heavy_tails: 
          "url" : "file:///Users/u6533564/Documents/Office/Quantecon/lecture-python-intro/lectures/_build/html/heavy_tails.html"
          "redirect_text": "This page has been redirected from intro/heavy_tails.html"

Then, the page at heavy_tails in lecture-python will be redirected to the target URL, with information about where it is redirected from and the content in the URL. Like:- ?redirected_from=/Users/u6533564/Documents/Office/Quantecon/lecture-python.myst/lectures/_build/html/heavy_tails.html&content=This page has been redirected from intro/heavy_tails.html

The target page, on detecting the variables in the URL, displays the following admonition:

Screen Shot 2024-03-18 at 12 04 18 am
codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 73.07%. Comparing base (e65778b) to head (56fc4d2). Report is 7 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #246 +/- ## ========================================== - Coverage 73.18% 73.07% -0.11% ========================================== Files 2 2 Lines 261 260 -1 ========================================== - Hits 191 190 -1 Misses 70 70 ``` | [Flag](https://app.codecov.io/gh/QuantEcon/quantecon-book-theme/pull/246/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantEcon) | Coverage Δ | | |---|---|---| | [pytests](https://app.codecov.io/gh/QuantEcon/quantecon-book-theme/pull/246/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantEcon) | `73.07% <ø> (-0.11%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantEcon#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

mmcky commented 5 months ago

thanks @AakashGfude I will take a closer look at this soon.

So this detects incoming redirect and would display the admonition for any traffic coming from the old location?

AakashGfude commented 5 months ago

So this detects incoming redirect and would display the admonition for any traffic coming from the old location?

Yes, that's right @mmcky.