Skip to content

Commit

Permalink
update config
Browse files Browse the repository at this point in the history
  • Loading branch information
ukukas committed Sep 16, 2024
1 parent 9d1db40 commit 12d7318
Showing 1 changed file with 52 additions and 10 deletions.
62 changes: 52 additions & 10 deletions source/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import json
import os
import sys
from datetime import date
from urllib.parse import urljoin
from urllib.parse import urljoin, urlparse

from pygit2 import GitError, Repository

sys.path.append(os.path.abspath("_ext"))

project = "Tufts RT Guides"
author = "Tufts University"
Expand All @@ -10,9 +15,20 @@
github_user = "tuftsrt"
github_repo = "guides"

copyright = "{:04} {}".format(date.today().year, author)
dev_label = "dev"
pub_label = "pub"
switcher_json_file = "_static/switcher.json"

sys.path.append(os.path.abspath("_ext"))
version = date.today().strftime("%Y%m%d")
release = dev_label

try:
if Repository(".").head.shorthand == "main":
release = pub_label
except GitError:
pass

copyright = f"{date.today().year}, {author}"

extensions = [
"gallery_directive",
Expand All @@ -31,11 +47,11 @@

autosectionlabel_prefix_document = True

html_baseurl = "https://{}.github.io/{}/".format(github_user, github_repo)
html_baseurl = os.environ.get(key="BASEURL", default="/")
html_favicon = "_static/favicon.ico"
html_last_updated_fmt = ""
html_logo = "_static/jumbo.png"
html_static_path = ['_static']
html_static_path = ["_static"]
html_theme = "pydata_sphinx_theme"
html_title = project

Expand All @@ -49,7 +65,7 @@
icon_links = [
{
"name": "Tags",
"url": "/{}/tags/index.html".format(github_repo),
"url": urljoin(html_baseurl, "tags/index.html"),
"icon": "fa-solid fa-tags",
"attributes": {"target": "_self"},
},
Expand All @@ -66,14 +82,18 @@
]

html_theme_options = {
"announcement": ("Incomplete and under active development. "
"Subject to change without notice."),
"footer_end": ["last-updated"],
"announcement": (
"Incomplete and under active development. Subject to change without notice."
),
"collapse_navigation": True,
"footer_center": ["last-updated"],
"footer_end": ["version-switcher"],
"footer_start": ["copyright"],
"header_links_before_dropdown": 8,
"icon_links": icon_links,
"logo": {"text": project},
"navbar_align": "content",
"navigation_depth": 1,
"navigation_with_keys": False,
"search_bar_text": "",
"secondary_sidebar_items": [
Expand All @@ -82,6 +102,11 @@
"edit-this-page",
"sourcelink",
],
"show_nav_level": 0,
"switcher": {
"json_url": urljoin(html_baseurl, switcher_json_file),
"version_match": release,
},
"use_edit_page_button": True,
}

Expand All @@ -99,6 +124,23 @@
".Rmd": "rmd.convert",
}

notfound_urls_prefix = "/{}/".format(github_repo)
notfound_urls_prefix = urlparse(html_baseurl).path

templates_path = ["_templates"]

with open(file=switcher_json_file, mode="w") as f:
json.dump(
obj=[
{
"version": pub_label,
"url": html_baseurl,
"preferred": True,
},
{
"version": dev_label,
"url": urljoin(html_baseurl, "dev/"),
},
],
fp=f,
indent=4,
)

0 comments on commit 12d7318

Please sign in to comment.