feat: add dev mode warning and styling

Introduced a development mode toggle for the app, which, when enabled, displays a distinctive warning on every page to inform users they are viewing a development version of the site. This warning is styled for clear visibility. Development mode is toggled with a new `--dev` command line argument or by setting an environment variable. The change aims to prevent confusion between the development and production environments for both developers and early users.

- Added new CSS rules for a warning alert style in `base.css`.
- Modified `main.py` to check for a development mode flag and pass a warning message to the template if the flag is set.
- Updated `base.html` to include the warning message when present.
- Added a new template for the development warning message.
This commit is contained in:
Kumi 2024-05-27 17:37:30 +02:00
parent 22ae56dad1
commit 0601a39829
Signed by: kumi
GPG key ID: ECBCC9082395383F
4 changed files with 45 additions and 1 deletions

View file

@ -99,6 +99,25 @@ h5 {
border-bottom: 1px solid #e0e0e0;
}
.alert-warning {
background-color: #fff3cd;
border-color: #ffeeba;
color: #856404;
padding: 15px;
margin-bottom: 20px;
border-radius: 4px;
}
.alert-warning .alert-link {
color: #856404;
font-weight: bold;
text-decoration: underline;
}
.alert-warning .alert-link:hover {
color: #604c2e;
}
/* Responsive Styles */
@media (max-width: 768px) {
.navbar .container {

20
main.py
View file

@ -3,6 +3,7 @@ from jinja2 import TemplateNotFound
import json
import pathlib
import os
from argparse import ArgumentParser
@ -21,15 +22,32 @@ def catch_all(path):
services = json.loads(
(pathlib.Path(__file__).parent / "services.json").read_text()
)
return render_template(f"{path}.html", services=services)
warning = None
if app.development_mode:
warning = render_template("prod-warning.html")
return render_template(
f"{path}.html", services=services, warning=warning
)
except TemplateNotFound:
return "404 Not Found", 404
app.development_mode = False
if os.environ.get("PRIVATECOFFEE_DEV"):
app.development_mode = True
if __name__ == "__main__":
parser = ArgumentParser(description="Run the private.coffee web server.")
parser.add_argument("--port", type=int, default=9810)
parser.add_argument("--debug", action="store_true")
parser.add_argument("--dev", action="store_true")
args = parser.parse_args()
app.development_mode = args.dev or app.development_mode
app.run(port=args.port, debug=args.debug)

View file

@ -51,6 +51,7 @@
</ul><a class="btn btn-primary shadow navbar-btn" role="button" href="/membership.html">JOIN &amp; REBEL</a>
</div>
</nav>
{% if warning %}{{ warning|safe }}{% endif %}
{% block content %}{% endblock %}
<footer class="bg-primary-gradient">
<div class="container py-4 py-lg-5">

View file

@ -0,0 +1,6 @@
<div class="alert alert-warning text-center" role="alert">
This is a development version of the Private.coffee website. For the live
version, please visit
<a href="https://private.coffee" class="alert-link">https://private.coffee</a
>.
</div>