From f91ccba437a8b5acd22134c2b81c731220255da9 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 19 Aug 2024 19:00:43 +0200 Subject: [PATCH] feat: enhance category links display and functionality Transformed specific 'link' elements into anchor tags with improved styling for better readability and usability. Added CSS styling for category links to ensure they are displayed inline with appropriate spacing, improving the user experience. --- src/wikimore/app.py | 5 +++++ src/wikimore/static/css/style.css | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/wikimore/app.py b/src/wikimore/app.py index 463171c..cc47899 100644 --- a/src/wikimore/app.py +++ b/src/wikimore/app.py @@ -315,6 +315,11 @@ def wiki_article( for video in soup.find_all("video"): video["poster"] = get_proxy_url(video["poster"]) + for link in soup.find_all("link", rel="mw:PageProp/Category"): + link.name = "a" + link.string = link["href"][2:].replace("_", " ") + link["class"] = "category-link" + for li in soup.find_all("li"): if any(cls in li.get("class", []) for cls in ["nv-view", "nv-talk", "nv-edit"]): li.decompose() diff --git a/src/wikimore/static/css/style.css b/src/wikimore/static/css/style.css index 49ff30c..e609922 100644 --- a/src/wikimore/static/css/style.css +++ b/src/wikimore/static/css/style.css @@ -206,6 +206,12 @@ h1 { text-align: center; } +.category-link { + display: inline; + margin-right: 5px; + font-size: 0.8em; +} + /* General table styling */ .table { margin: 1em auto;