diff options
Diffstat (limited to 'pysite/views/main/info/resources.py')
-rw-r--r-- | pysite/views/main/info/resources.py | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/pysite/views/main/info/resources.py b/pysite/views/main/info/resources.py deleted file mode 100644 index 541b9ba1..00000000 --- a/pysite/views/main/info/resources.py +++ /dev/null @@ -1,58 +0,0 @@ -import json -from logging import getLogger - -from pysite.base_route import RouteView - -ICON_STYLES = { - "branding": "fab", - "regular": "far", - "solid": "fas", - "light": "fal" -} - -logger = getLogger("Resources") - -try: - with open("static/resources.json") as fh: - categories = json.load(fh) - - for category, items in categories.items(): - to_remove = [] - - for name, resource in items["resources"].items(): - for url_obj in resource["urls"]: - icon = url_obj["icon"].lower() - - if "/" not in icon: - to_remove.append(name) - logger.error( - f"Resource {name} in category {category} has an invalid icon. Icons should be of the" - f"form `style/name`." - ) - continue - - style, icon_name = icon.split("/") - - if style not in ICON_STYLES: - to_remove.append(name) - logger.error( - f"Resource {name} in category {category} has an invalid icon style. Icon style must " - f"be one of {', '.join(ICON_STYLES.keys())}." - ) - continue - - url_obj["classes"] = f"{ICON_STYLES[style]} fa-{icon_name}" - - for name in to_remove: - del items["resources"][name] -except Exception: - getLogger("Resources").exception("Failed to load resources.json") - categories = None - - -class ResourcesView(RouteView): - path = "/info/resources" - name = "info.resources" - - def get(self): - return self.render("main/info/resources.html", categories=categories) |