From 4462606df4a9a9d482aa4bf8973500586d04d6c7 Mon Sep 17 00:00:00 2001 From: Adam Collard Date: Fri, 21 Apr 2023 15:58:55 +0100 Subject: [PATCH] Upgrade Discourse docs to v5, use revised index topic (#772) * feat: port to discourse docs v5, extract init_docs, init_tutorials --------- Co-authored-by: Francisco Jimenez Cabrera Co-authored-by: Peter Makowski --- konf/site.yaml | 10 + requirements.txt | 2 +- templates/docs/document.html | 282 ++++++++++++++++++++--- templates/tutorials/index.html | 112 +-------- tests/test_doc_parser.py | 154 ------------- webapp/app.py | 143 +++--------- webapp/doc_parser.py | 403 --------------------------------- webapp/openapi_parser.py | 3 +- webapp/views/__init__.py | 0 webapp/views/docs.py | 44 ++++ webapp/views/tutorials.py | 70 ++++++ 11 files changed, 419 insertions(+), 804 deletions(-) delete mode 100644 tests/test_doc_parser.py delete mode 100644 webapp/doc_parser.py create mode 100644 webapp/views/__init__.py create mode 100644 webapp/views/docs.py create mode 100644 webapp/views/tutorials.py diff --git a/konf/site.yaml b/konf/site.yaml index 9dd928ca..4b2ef6e9 100644 --- a/konf/site.yaml +++ b/konf/site.yaml @@ -11,6 +11,16 @@ env: key: google-custom-search-key name: google-api + - name: DISCOURSE_API_KEY + secretKeyRef: + key: maas-api-key + name: discourse-api + + - name: DISCOURSE_API_USERNAME + secretKeyRef: + key: maas-api-username + name: discourse-api + extraHosts: - domain: docs.maas.io - domain: maas.ubuntu.com diff --git a/requirements.txt b/requirements.txt index 839b6554..b7d2c917 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ canonicalwebteam.flask_base==1.1.0 canonicalwebteam.blog==6.4.0 -canonicalwebteam.discourse-docs==1.0.1 +canonicalwebteam.discourse==5.4.1 canonicalwebteam.http==1.0.3 canonicalwebteam.templatefinder==1.0.0 canonicalwebteam.search==1.3.0 diff --git a/templates/docs/document.html b/templates/docs/document.html index a9ca4491..c42f4285 100644 --- a/templates/docs/document.html +++ b/templates/docs/document.html @@ -8,6 +8,40 @@ {% block og_title %}{{ document.title }}{% endblock %} {% block og_description %}{% endblock %} +{% macro create_navigation(nav_items, expandable=False, expanded=False) %} +
    + {% for element in nav_items %} +
  • + {% if element.navlink_href %} + + {% else %} + + {% endif %} + + {% if expandable %} + {% if element.children %} + + {% endif %} + {{ create_navigation(element.children, expandable, element.is_active or element.has_active_child) }} + {% else %} + {% if element.children %} + {{ create_navigation(element.children, expandable) }} + {% endif %} + {% endif %} +
  • + {% endfor %} +
+{% endmacro %} + {% block content %}
@@ -18,68 +52,252 @@
+
-
+{% endblock %} +{% block js_extra %}