mirror of
https://github.com/DarrylNixon/ghostforge
synced 2024-04-22 06:27:20 -07:00
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import importlib.metadata
|
|
|
|
from fastapi.templating import Jinja2Templates
|
|
|
|
templates = Jinja2Templates(directory="ghostforge/templates")
|
|
|
|
# Inject version string and Github URL into every template for navbar display.
|
|
try:
|
|
gf_version = importlib.metadata.version(__package__)
|
|
except ValueError:
|
|
gf_version = "Local"
|
|
templates.env.globals["gf_version"] = f"v{gf_version}"
|
|
templates.env.globals["gf_repository_url"] = "https://github.com/DarrylNixon/ghostforge"
|
|
|
|
# Same, but build the navbar from an ordered dictionary for centralization.
|
|
# Since 3.7 (we require >= 3.9), dicts are guaranteed ordered as inserted.
|
|
templates.env.globals["gf_navbar"] = {
|
|
"Ghosts": {"Dashboard": "/dashboard", "Browse": "/ghosts"},
|
|
"Research": {
|
|
"Guidebook": "/guidebook",
|
|
"Cheat Sheet": "/cheatsheet",
|
|
},
|
|
"Settings": {
|
|
"Your Profile": "/profile",
|
|
"Configuration": "/configuration",
|
|
"Integrations": "/integrations",
|
|
"Manage Users": "/manage",
|
|
},
|
|
"Meta": {
|
|
"About GhostForge": "/about",
|
|
"System Logs": "/logs",
|
|
"Logout": "/logout",
|
|
},
|
|
}
|
|
|
|
templates.env.globals["avatar_menu"] = {
|
|
"Dashboard": "/dashboard",
|
|
"Your Profile": "/profile",
|
|
"Logout": "/logout",
|
|
}
|