Skip to content

Commit

Permalink
hoist last-known-good to docs sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Dec 15, 2023
1 parent 14c8a75 commit 377368c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
28 changes: 28 additions & 0 deletions docs/_templates/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,31 @@
</p>
</div>
</div>

{% if last_known_good_links %}
<br/>

<div class="work-sidebar">
<div class="work-sidebar-header">
<i class="fas fa-square-arrow-up-right"></i>
last-known-good preview site
</div>
<div class="work-sidebar-content">
<blockquote>
The current build seems to have failed, but a last-known-good site is available.
</blockquote>
<p>
{% for frag, info in lite_links.items() %}
<a
href="{{ pathto('last-known-good/' ~ frag ~ '/index') }}"
class="btn btn-primary"
target="_blank"
title="Try {{ info.label }} in your browser."
>
<i class="{{ info.icon }}"></i> {{ info.label }}
</a>
{% endfor %}
</p>
</div>
</div>
{% endif %}
22 changes: 18 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
REPO_INFO = re.search(RE_GH, PROJ_DATA["project"]["urls"]["Source"])
NOW = datetime.datetime.now(tz=datetime.timezone.utc).date()
WORK_DIST = HERE / "_static/work"
LAST_KNOWN_GOOD = HERE / "_static/last-known-good"
JUPYAK_CONF_CANDIDATES = [
ROOT / f"jupyak_config.{ext}"
for ext in ["toml", "yaml", "yml", "json"]
Expand Down Expand Up @@ -103,10 +104,8 @@
html_context["prjsf_url"] = f"{gh_pages}/_static/prjsf/prjsf.js"

if ALLOW_NO_CONFIG or JUPYAK_CONF_CANDIDATES:
html_sidebars["*"] = [
"demo",
*html_sidebars["*"],
]
if "demo" not in html_sidebars["*"]:
html_sidebars["*"] = ["demo", *html_sidebars["*"]]
if WORK_DIST.exists():
html_context["lite_links"] = {
"lab": {"label": "Lab", "icon": "fas fa-flask"},
Expand All @@ -118,3 +117,18 @@
f"preview/{frag}/index": f"_static/work/lite/{frag}/index"
for frag in html_context["lite_links"]
}

if LAST_KNOWN_GOOD.exists():
if "demo" not in html_sidebars["*"]:
html_sidebars["*"] = ["demo", *html_sidebars["*"]]

html_context["last_known_good_links"] = {
"lab": {"label": "Lab", "icon": "fas fa-flask"},
"repl": {"label": "Console", "icon": "fas fa-terminal"},
"tree": {"label": "File Tree", "icon": "fas fa-folder-tree"},
}

rediraffe_redirects = {
f"last-known-good/{frag}/index": f"_static/last-known-good/{frag}/index"
for frag in html_context["last_known_good_links"]
}

0 comments on commit 377368c

Please sign in to comment.