motd implemented

This commit is contained in:
Yaroslav Polyakov 2025-05-30 01:17:35 +07:00
parent 4f0fe23031
commit 57740fecaa
3 changed files with 16 additions and 1 deletions

View file

@ -68,10 +68,17 @@ def render(request, template_name, context: dict):
@app.get("/", response_class=HTMLResponse)
async def home(request: Request):
# index page
if settings.motd and os.path.exists(settings.motd):
motd_html = markdown.markdown(open(settings.motd).read())
else:
motd_html = None
return render(request, "index.html",
{
"request": request,
"motd": motd_html
}
)

View file

@ -69,11 +69,14 @@ class Settings():
# Other system parameters
self.proxy = os.getenv('HTTPS_PROXY', None)
# web UI
self.turnstile_sitekey = os.getenv('TURNSTILE_SITEKEY', None)
self.turnstile_secret = os.getenv('TURNSTILE_SECRET', None)
self.gtag = os.getenv('GTAG', None)
self.motd = os.getenv('MOTD', None)
# Debugging
self.skip_oids = list(filter(None, os.getenv('SKIP_OIDS', '').split(' ')))
self.debug_uids = list(filter(None, os.getenv('DEBUG_UIDS', '').split(' ')))

View file

@ -34,6 +34,11 @@
<a class="logo-link" href="/"><img src="/static/img/logo.png" alt="Logo" class="logo"></a>
<h1>{% block header %}{% endblock %}</h1>
</div>
{% if motd %}
<div>
{{motd | safe}}
</div>
{% endif %}
<div class="search-container">
<form class="search-form" id="search-form" method="GET" action="/search">
<input type="text" id="oid" name="query" value="{{query}}" placeholder="Введите название компании или 2GIS object_id" required>