]> git.ipfire.org Git - ipfire.org.git/commitdiff
docs: Refactor showing pages
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Jun 2023 08:51:29 +0000 (08:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Jun 2023 08:51:29 +0000 (08:51 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/docs/base.html
src/templates/docs/modules/header.html
src/templates/docs/page.html
src/web/__init__.py
src/web/docs.py
src/web/wiki.py

index 442714518168a682da1adfdda784bac8144cfafe..8277a70636dc03c730f0ee8880dc919f1b292e50 100644 (file)
@@ -189,6 +189,17 @@ templates_donate_messages_DATA = \
 
 templates_donate_messagesdir = $(templates_donatedir)/messages
 
+templates_docs_DATA = \
+       src/templates/docs/base.html \
+       src/templates/docs/page.html
+
+templates_docsdir = $(templatesdir)/docs
+
+templates_docs_modules_DATA = \
+       src/templates/docs/modules/header.html
+
+templates_docs_modulesdir = $(templates_docsdir)/modules
+
 templates_downloads_DATA = \
        src/templates/downloads/mirrors.html \
        src/templates/downloads/release.html \
@@ -315,12 +326,10 @@ templates_users_modulesdir = $(templates_usersdir)/modules
 
 templates_wiki_DATA = \
        src/templates/wiki/404.html \
-       src/templates/wiki/base.html \
        src/templates/wiki/confirm-delete.html \
        src/templates/wiki/confirm-restore.html \
        src/templates/wiki/diff.html \
        src/templates/wiki/edit.html \
-       src/templates/wiki/page.html \
        src/templates/wiki/recent-changes.html \
        src/templates/wiki/revisions.html \
        src/templates/wiki/search-results.html \
@@ -342,8 +351,7 @@ templates_wiki_messagesdir = $(templates_wikidir)/messages
 
 templates_wiki_modules_DATA = \
        src/templates/wiki/modules/diff.html \
-       src/templates/wiki/modules/list.html \
-       src/templates/wiki/modules/navbar.html
+       src/templates/wiki/modules/list.html
 
 templates_wiki_modulesdir = $(templates_wikidir)/modules
 
index b3acb4b51576bc995964c1b530fd70542f392b56..f151cbe1d7d86f931ddb4a8e2272cc6e202d0d72 100644 (file)
@@ -1,7 +1,7 @@
 {% extends "../base.html" %}
 
-{% block content %}
-       {% module WikiNavbar() %}
+{% block container %}
+       {% module DocsHeader() %}
 
        {% block main %}{% end block %}
 {% end block %}
index c8c1c3f35d1d178bb45831afdac5345e9e9169e5..10114f4aed2793a7c49bb56f7d6ed4085467bb9b 100644 (file)
@@ -1,17 +1,43 @@
-{% if len(breadcrumbs) >= 1 %}
-       <ol class="breadcrumb">
-               {% for p, title in breadcrumbs %}
-                       <li class="breadcrumb-item">
-                               <a href="{{ p }}">{{ title }}</a>
-                       </li>
-               {% end %}
+<section class="hero is-light">
+       <div class="hero-body">
+               <div class="container">
+                       <nav class="breadcrumb is-medium" aria-label="breadcrumbs">
+                               <ul>
+                                       <li>
+                                               <a href="/">
+                                                       {{ _("Home") }}
+                                               </a>
+                                       </li>
 
-               <li class="breadcrumb-item {% if not suffix %}active{% end %}">
-                       <a href="{{ page }}">{{ page_title }}</a>
-               </li>
+                                       <li>
+                                               <a href="/docs">
+                                                       {{ _("Docs") }}
+                                               </a>
+                                       </li>
 
-               {% if suffix %}
-                       <li class="breadcrumb-item active">{{ suffix }}</li>
-               {% end %}
-       </ol>
-{% end %}
+                                       {% for p, title in breadcrumbs %}
+                                               <li>
+                                                       <a href="/docs{{ p }}">{{ title }}</a>
+                                               </li>
+                                       {% end %}
+
+                                       {% if page_title %}
+                                               <li {% if not suffix %}class="is-active"{% end %}>
+                                                       <a href="/docs{{ page }}" {% if not suffix %}aria-current="page"{% end %}>
+                                                               {{ page_title }}
+                                                       </a>
+                                               </li>
+                                       {% end %}
+
+                                       {% if suffix %}
+                                               <li class="is-active">
+                                                       <a href="#" aria-current="page">{{ suffix }}</a>
+                                               </li>
+                                       {% end %}
+                               </ul>
+                       </nav>
+
+                       <h1 class="title is-1">{{ page_title or _("IPFire Docs") }}</h1>
+               </div>
+       </div>
+</section>
index 9edd25387e0a873507ad57ad0fea74fd776e56e1..5ada046b9b767e175b91a726b417c5defcbb4270 100644 (file)
 {% block main %}
        {% import os.path %}
 
-       <div class="card mb-3">
-               <div class="card-body wiki-content">
-                       {% raw page.html %}
+       <section class="section">
+               <div class="container">
+                       <div class="content">
+                               {% raw page.html %}
+                       </div>
                </div>
-       </div>
+       </section>
 
-       <div class="d-grid">
-               <a class="btn btn-primary mb-3" href="{{ os.path.join(request.path, "_edit") }}">
-                       <span class="fas fa-edit mr-2"></span> {{ _("Edit Page") }}
-                       {% if not current_user %}&dash; {{ _("Yes, you can edit!") }}{% end %}
-               </a>
-       </div>
+       <section class="section">
+               <div class="container">
+                       <div class="block">
+                               <a class="button is-primary is-fullwidth" href="{{ os.path.join(request.path, "_edit") }}">
+                                       <span class="icon-text">
+                                               <span class="icon">
+                                                       <i class="fas fa-edit"></i>
+                                               </span>
+                                               <span>
+                                                       {{ _("Edit Page") }}
+                                                       {% if not current_user %}&dash; {{ _("Yes, you can edit!") }}{% end %}
+                                               </span>
+                                       </span>
+                               </a>
+                       </div>
 
-       <p class="small text-muted">
-               {% if current_user %}
-                       {% if page.is_watched_by(current_user) %}
-                               <a href="{{ os.path.join(page.url, "_unwatch") }}"><span class="fas fa-star" title="{{ _("Stop watching this page") }}"></span></a>
-                       {% else %}
-                               <a href="{{ os.path.join(page.url, "_watch") }}"><span class="far fa-star" title="{{ _("Watch this page") }}"></span></a>
-                       {% end %} &bull;
-               {% end %}
+                       <div class="block">
+                               <div class="level">
+                                       <div class="level-left">
+                                               {% if current_user %}
+                                                       {% if page.is_watched_by(current_user) %}
+                                                               <a class="level-item" href="{{ os.path.join(page.url, "_unwatch") }}">
+                                                                       <i class="fas fa-star" title="{{ _("Stop watching this page") }}"></i>
+                                                               </a>
+                                                       {% else %}
+                                                               <a class="level-item" href="{{ os.path.join(page.url, "_watch") }}">
+                                                                       <i class="far fa-star" title="{{ _("Watch this page") }}"></i>
+                                                               </a>
+                                                       {% end %}
+                                               {% end %}
 
-               <a href="{{ request.path }}?action=revisions">
-                       {{ _("Older Revisions") }}
-               </a>
+                                               <a class="level-item" href="{{ request.path }}?action=revisions">
+                                                       {{ _("Older Revisions") }}
+                                               </a>
 
-               &bull;
+                                               <div class="level-item">
+                                                       {{ locale.format_date(page.timestamp) }}
+                                               </div>
 
-               {{ locale.format_date(page.timestamp) }}
-
-               {% if page.author %}
-                       &bull;
-
-                       <a href="/users/{{ page.author.uid }}">
-                               {{ page.author }}
-                       </a>
-               {% end %}
-       </p>
+                                               {% if page.author %}
+                                                       <a class="level-item" href="/users/{{ page.author.uid }}">
+                                                               {{ page.author }}
+                                                       </a>
+                                               {% end %}
+                                       </div>
+                               </div>
+                       </div>
+               </div>
+       </section>
 {% end block %}
index 633d923e2d42617cbf80a7721bfb5ed4acd9292d..5e95bc933155f67124820742ce67a8c868cd997f 100644 (file)
@@ -70,6 +70,9 @@ class Application(tornado.web.Application):
                                "BootMenuHeader"       : boot.MenuHeaderModule,
                                "BootMenuSeparator"    : boot.MenuSeparatorModule,
 
+                               # Docs
+                               "DocsHeader"           : docs.HeaderModule,
+
                                # People
                                "Agent"                : people.AgentModule,
                                "CDR"                  : people.CDRModule,
@@ -91,7 +94,6 @@ class Application(tornado.web.Application):
 
                                # Wiki
                                "WikiDiff"             : wiki.WikiDiffModule,
-                               "WikiNavbar"           : wiki.WikiNavbarModule,
                                "WikiList"             : wiki.WikiListModule,
 
                                # Misc
index 0e87bb6c970fd6267d213b8f624239c339548823..4f20b5d975241f96b4541b1114b196a0e562e9e1 100644 (file)
@@ -4,6 +4,7 @@ import difflib
 import tornado.web
 
 from . import base
+from . import ui_modules
 
 class PageHandler(base.BaseHandler):
        @property
@@ -85,4 +86,29 @@ class PageHandler(base.BaseHandler):
                latest_revision = page.get_latest_revision()
 
                # Render page
-               self.render("wiki/page.html", page=page, latest_revision=latest_revision)
+               self.render("docs/page.html", page=page, latest_revision=latest_revision)
+
+
+class HeaderModule(ui_modules.UIModule):
+       @property
+       def page(self):
+               """
+                       Returns the path of the page (without any actions)
+               """
+               path = self.request.path.removeprefix("/docs")
+
+               return "/".join((p for p in path.split("/") if not p.startswith("_")))
+
+       def render(self, suffix=None):
+               _ = self.locale.translate
+
+               breadcrumbs = self.backend.wiki.make_breadcrumbs(self.page)
+               title = self.backend.wiki.get_page_title(self.page)
+
+               if self.request.path.endswith("/_edit"):
+                       suffix = _("Edit")
+               elif self.request.path.endswith("/_files"):
+                       suffix = _("Files")
+
+               return self.render_string("docs/modules/header.html",
+                       breadcrumbs=breadcrumbs, page=self.page, page_title=title, suffix=suffix)
index 42876fc28045e7486d643a48a619db4b76182647..674ebba08429004fd8ec3c9f536f7d03717eb5b2 100644 (file)
@@ -391,40 +391,3 @@ class WikiListModule(ui_modules.UIModule):
                return self.render_string("wiki/modules/list.html", link_revision=link_revision,
                        pages=pages, show_breadcrumbs=show_breadcrumbs,
                        show_author=show_author, show_changes=show_changes)
-
-
-class WikiNavbarModule(ui_modules.UIModule):
-       @property
-       def path(self):
-               """
-                       Returns the path of the page (without any actions)
-               """
-               path = self.request.path.split("/")
-
-               if path and path[-1].startswith("_"):
-                       path.pop()
-
-               return "/".join(path)
-
-       def render(self, suffix=None):
-               _ = self.locale.translate
-
-               # Make the path
-               page = self.request.path.split("/")
-
-               # Drop the action bit
-               if page and page[-1].startswith("_"):
-                       page.pop()
-
-               page = "/".join(page)
-
-               breadcrumbs = self.backend.wiki.make_breadcrumbs(page)
-               title = self.backend.wiki.get_page_title(page)
-
-               if self.request.path.endswith("/_edit"):
-                       suffix = _("Edit")
-               elif self.request.path.endswith("/_files"):
-                       suffix = _("Files")
-
-               return self.render_string("wiki/modules/navbar.html",
-                       breadcrumbs=breadcrumbs, page=page, page_title=title, suffix=suffix)