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:
parent
22ae56dad1
commit
0601a39829
4 changed files with 45 additions and 1 deletions
|
@ -99,6 +99,25 @@ h5 {
|
||||||
border-bottom: 1px solid #e0e0e0;
|
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 */
|
/* Responsive Styles */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.navbar .container {
|
.navbar .container {
|
||||||
|
|
20
main.py
20
main.py
|
@ -3,6 +3,7 @@ from jinja2 import TemplateNotFound
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import os
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
|
@ -21,15 +22,32 @@ def catch_all(path):
|
||||||
services = json.loads(
|
services = json.loads(
|
||||||
(pathlib.Path(__file__).parent / "services.json").read_text()
|
(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:
|
except TemplateNotFound:
|
||||||
return "404 Not Found", 404
|
return "404 Not Found", 404
|
||||||
|
|
||||||
|
|
||||||
|
app.development_mode = False
|
||||||
|
|
||||||
|
if os.environ.get("PRIVATECOFFEE_DEV"):
|
||||||
|
app.development_mode = True
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = ArgumentParser(description="Run the private.coffee web server.")
|
parser = ArgumentParser(description="Run the private.coffee web server.")
|
||||||
parser.add_argument("--port", type=int, default=9810)
|
parser.add_argument("--port", type=int, default=9810)
|
||||||
parser.add_argument("--debug", action="store_true")
|
parser.add_argument("--debug", action="store_true")
|
||||||
|
parser.add_argument("--dev", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
app.development_mode = args.dev or app.development_mode
|
||||||
|
|
||||||
app.run(port=args.port, debug=args.debug)
|
app.run(port=args.port, debug=args.debug)
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
</ul><a class="btn btn-primary shadow navbar-btn" role="button" href="/membership.html">JOIN & REBEL</a>
|
</ul><a class="btn btn-primary shadow navbar-btn" role="button" href="/membership.html">JOIN & REBEL</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
{% if warning %}{{ warning|safe }}{% endif %}
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
<footer class="bg-primary-gradient">
|
<footer class="bg-primary-gradient">
|
||||||
<div class="container py-4 py-lg-5">
|
<div class="container py-4 py-lg-5">
|
||||||
|
|
6
templates/prod-warning.html
Normal file
6
templates/prod-warning.html
Normal 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>
|
Loading…
Reference in a new issue