Files

55 lines
1.7 KiB
Python

"""Single source of truth for the page names (URL parts) of the website.
The names must match the files in the content repository:
``contents/static/<name>.html`` (and optionally ``<name>_sidebar.html``).
The jinja templates get the same names via the ``pages`` global.
"""
from dataclasses import dataclass
@dataclass(frozen=True)
class Page:
name: str
# Template in templates/html/ used as fallback if the content repository
# has no static page with this name.
template: str | None = None
# Never index this page: robots meta tag + Disallow in robots.txt (e.g. contact details).
noindex: bool = False
# Pages whose body comes from contents/static/<name>.html.
PAGES = (
Page("prov"),
Page("vad_ar_amatorradio"),
Page("info"),
Page("sok"),
Page("kurser_karta", template="kurser-karta"),
Page("kurser_lista", template="kurser-lista"),
Page("mentorer", template="mentorer"),
Page("kontakt", noindex=True),
)
# Robots directives for pages marked noindex (meta tag; the nginx configs send the same as X-Robots-Tag).
NOINDEX_DIRECTIVES = "noindex, nofollow, noarchive, nosnippet"
# Pages generated by the generator itself. The last two only exist if the
# content repository contains a question pool.
INDEX = "index"
EXAM_SIMULATOR = "simulering"
EXAM_RESULT = "resultat"
HOMEWORK = "ovning"
def page_urls() -> dict[str, str]:
"""Maps page names to their html file name (for use in templates)."""
urls = {page.name: f"{page.name}.html" for page in PAGES}
urls.update(
{
INDEX: f"{INDEX}.html",
EXAM_SIMULATOR: f"{EXAM_SIMULATOR}.html",
HOMEWORK: f"{HOMEWORK}.html",
}
)
return urls