Fixed bugs when generating URLs
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
.venv/
|
||||
__pycache__/
|
||||
helpers/
|
||||
config.json
|
||||
config.json
|
||||
priv/
|
||||
21
app.py
21
app.py
@@ -23,6 +23,7 @@ from colorsys import rgb_to_hsv
|
||||
from flask import Flask, render_template, request, redirect, url_for, session, abort
|
||||
from flask_pymongo import PyMongo
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from werkzeug.routing.exceptions import BuildError
|
||||
from bson import ObjectId
|
||||
import bson.json_util as bson
|
||||
import requests
|
||||
@@ -126,16 +127,25 @@ def render_main():
|
||||
else None
|
||||
)
|
||||
results = {"ade": {}, "bea": {}, "cam": {}, "des": {}}
|
||||
short_results = {"ade": {}, "bea": {}, "cam": {}, "des": {}}
|
||||
for ddata in dsdata:
|
||||
if not can_access(ddata, udata):
|
||||
continue
|
||||
if ddata["cat"] not in results[ddata["quad"]]:
|
||||
results[ddata["quad"]][ddata["cat"]] = {}
|
||||
results[ddata["quad"]][ddata["cat"]][ddata["name"]] = ddata["id"]
|
||||
if not can_access(ddata, udata):
|
||||
results[ddata["quad"]][ddata["cat"]][ddata["name"]] = None
|
||||
continue
|
||||
try:
|
||||
url = url_for(ddata["id"])
|
||||
results[ddata["quad"]][ddata["cat"]][ddata["name"]] = url
|
||||
short_results[ddata["quad"]][ddata["name"]] = url
|
||||
except BuildError:
|
||||
results[ddata["quad"]][ddata["cat"]][ddata["name"]] = None
|
||||
|
||||
return render_template(
|
||||
"index.html",
|
||||
fpdata=fpdata,
|
||||
domains=results,
|
||||
sdomains=short_results,
|
||||
quad=(request.endpoint or "ade")[-3:],
|
||||
)
|
||||
|
||||
@@ -472,3 +482,8 @@ def lighting():
|
||||
@app.errorhandler(HTTPException)
|
||||
def handle_error(error):
|
||||
return render_template("error.html", error=error), error.code
|
||||
|
||||
|
||||
@app.route("/swt/basic")
|
||||
def swt_basic():
|
||||
return render_template("priv/swtbasic.html")
|
||||
|
||||
@@ -25,6 +25,11 @@ nav#sidebar {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.failed {
|
||||
color: #777777;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
}
|
||||
@@ -121,6 +126,11 @@ hr#sectorbar {
|
||||
color: var(--color);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.failed {
|
||||
color: #777777;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
#other>div {
|
||||
|
||||
@@ -9,14 +9,12 @@
|
||||
<nav id="sidebar">
|
||||
{% set quads = {"ade":"♢", "bea":"♡", "cam":"♧", "des":"♤"} %}
|
||||
{% for quad in quads %}
|
||||
{% if domains[quad] %}
|
||||
{% if sdomains[quad] %}
|
||||
<div style="--hue: var(--{{ quad }});">
|
||||
<h2>{{ quads[quad] }}</h2>
|
||||
<ul>
|
||||
{% for category in domains[quad] %}
|
||||
{% for domain in domains[quad][category] %}
|
||||
<li><a href="{{ url_for(domains[quad][category][domain]) }}">{{ domain }}</a></li>
|
||||
{% endfor %}
|
||||
{% for domain in sdomains[quad] %}
|
||||
<li><a href="{{ sdomains[quad][domain] }}">{{ domain }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
@@ -38,7 +36,11 @@
|
||||
<h2>{{ category }}</h2>
|
||||
<ul>
|
||||
{% for domain in domains[quad][category] %}
|
||||
<li><a href="{{ url_for(domains[quad][category][domain]) }}">{{ domain }}</a></li>
|
||||
{% if domains[quad][category][domain] %}
|
||||
<li><a href="{{ domains[quad][category][domain] }}">{{ domain }}</a></li>
|
||||
{% else %}
|
||||
<li><a class="failed">{{ domain }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user