From ce6593a8fd3ef5c2ac09539a8d514dcb8cd5bbfa Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 13 Jun 2019 00:15:09 +0200 Subject: [PATCH] Update wiki related stuff --- royalnet/web/blueprints/wikiview/__init__.py | 17 ++++------------- .../wikiview/templates/wikiview_index.html | 2 +- .../wikiview/templates/wikiview_page.html | 2 +- royalnet/web/templates/base.html | 4 ++-- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/royalnet/web/blueprints/wikiview/__init__.py b/royalnet/web/blueprints/wikiview/__init__.py index cd15676b..436f308d 100644 --- a/royalnet/web/blueprints/wikiview/__init__.py +++ b/royalnet/web/blueprints/wikiview/__init__.py @@ -55,20 +55,11 @@ def wikiview_index(): return f.render_template("wikiview_index.html", pages=pages) -@bp.route("/id/") -def wikiview_by_id(page_id: str): +@bp.route("/", defaults={"title": ""}) +@bp.route("//") +def wikiview_by_id(page_id: uuid.UUID, title: str): from ...alchemyhandler import alchemy, alchemy_session - page_uuid = uuid.UUID(page_id) - page = alchemy_session.query(alchemy.WikiPage).filter(alchemy.WikiPage.page_id == page_uuid).one_or_none() - if page is None: - return "No such page", 404 - return prepare_page(page) - - -@bp.route("/title/<title>") -def wikiview_by_title(title: str): - from ...alchemyhandler import alchemy, alchemy_session - page = alchemy_session.query(alchemy.WikiPage).filter(alchemy.WikiPage.title == title).one_or_none() + page = alchemy_session.query(alchemy.WikiPage).filter(alchemy.WikiPage.page_id == page_id).one_or_none() if page is None: return "No such page", 404 return prepare_page(page) diff --git a/royalnet/web/blueprints/wikiview/templates/wikiview_index.html b/royalnet/web/blueprints/wikiview/templates/wikiview_index.html index 63d39ca3..4afb2780 100644 --- a/royalnet/web/blueprints/wikiview/templates/wikiview_index.html +++ b/royalnet/web/blueprints/wikiview/templates/wikiview_index.html @@ -14,7 +14,7 @@ <div class="bot"> <ul> {% for page in pages %} - <li><a href="{{ url_for("wikiview.wikiview_by_id", page_id=page.page_id|string) }}">{{ page.title }}</a></li> + <li><a href="{{ url_for("wikiview.wikiview_by_id", page_id=page.page_id|string, title=page.title) }}">{{ page.title }}</a></li> {% endfor %} </ul> </div> diff --git a/royalnet/web/blueprints/wikiview/templates/wikiview_page.html b/royalnet/web/blueprints/wikiview/templates/wikiview_page.html index 60b46dca..e6999bec 100644 --- a/royalnet/web/blueprints/wikiview/templates/wikiview_page.html +++ b/royalnet/web/blueprints/wikiview/templates/wikiview_page.html @@ -11,7 +11,7 @@ {{ page.title }} </span> <span class="right"> - <a class="permalink no-icon" href="{{ url_for("wikiview.wikiview_by_id", page_id=page.page_id|string) }}">#</a> + <a class="permalink no-icon" href="{{ url_for("wikiview.wikiview_by_id", page_id=page.page_id|string, title=page.title) }}">#</a> </span> </div> <div class="bot"> diff --git a/royalnet/web/templates/base.html b/royalnet/web/templates/base.html index cbc57690..1becdaed 100644 --- a/royalnet/web/templates/base.html +++ b/royalnet/web/templates/base.html @@ -20,10 +20,10 @@ <body> <nav> <div class="nav-left"> - <span class="nav-site"> + <a class="nav-site no-icon" href="{{ url_for("home.home_index") }}"> <img class="nav-image" alt="" src="{{ url_for("static", filename="logo.svg") }}"> <span class="nav-sitename">Royal Games</span> - </span> + </a> <span class="nav-modules"> <a class="no-icon" href="{{ url_for("wikiview.wikiview_index") }}">Wiki</a> </span>