From 653740cc3abfdd0f2aaf045ea9c248258412035d Mon Sep 17 00:00:00 2001 From: Morgana Date: Thu, 16 Apr 2026 09:14:35 -0500 Subject: [PATCH] Fixed bugs when generating URLs --- .gitignore | 3 ++- app.py | 21 ++++++++++++++++++--- static/index.css | 10 ++++++++++ templates/index.html | 14 ++++++++------ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 8368331..2ba46cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .venv/ __pycache__/ helpers/ -config.json \ No newline at end of file +config.json +priv/ \ No newline at end of file diff --git a/app.py b/app.py index 0d9020c..e81a0e2 100644 --- a/app.py +++ b/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") diff --git a/static/index.css b/static/index.css index e81b9b4..7ce31ce 100644 --- a/static/index.css +++ b/static/index.css @@ -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 { diff --git a/templates/index.html b/templates/index.html index a1a3880..342e8a6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -9,14 +9,12 @@