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