From c43053f3455ec0ba324a059a3d1c86f219c24b62 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Thu, 11 Feb 2021 00:56:12 -0800 Subject: [PATCH] Rename CSS classes, add subtags, style links, implement hyperlink option --- redstring/parser.py | 3 -- redstring/templates/base.jinja | 52 +++++++++++++++++++--------------- redstring/templates/doc.jinja | 46 ++++++++++++++++++++---------- 3 files changed, 60 insertions(+), 41 deletions(-) diff --git a/redstring/parser.py b/redstring/parser.py index 40284ba..3215c25 100644 --- a/redstring/parser.py +++ b/redstring/parser.py @@ -130,9 +130,6 @@ class DocumentTab: self.tags: List[DocumentTag] = tags self.options: TabOptions = options - def __iter__(self): - return self.tags.__iter__() - class Document: """ diff --git a/redstring/templates/base.jinja b/redstring/templates/base.jinja index d34ef50..7a6c328 100644 --- a/redstring/templates/base.jinja +++ b/redstring/templates/base.jinja @@ -11,12 +11,12 @@ {% block page_scripts %}{% endblock %} diff --git a/redstring/templates/doc.jinja b/redstring/templates/doc.jinja index c73cdf0..eb45ec8 100644 --- a/redstring/templates/doc.jinja +++ b/redstring/templates/doc.jinja @@ -10,14 +10,14 @@ function selectTab(name) { if (tab) { // Unselect all tabs and content - Array.from(document.getElementsByClassName("tab")) - .forEach(e => e.classList.remove("tab-selected")); Array.from(document.getElementsByClassName("tab-content")) - .forEach(e => e.classList.remove("tab-selected-content")); + .forEach(e => e.classList.remove("tab-down")); + Array.from(document.getElementsByClassName("tab-page")) + .forEach(e => e.classList.remove("tab-page-selected")); // Select the new tab and content - tab.classList.add("tab-selected"); - let content = document.getElementById(name + "-content"); - content.classList.add("tab-selected-content"); + tab.classList.add("tab-down"); + let content = document.getElementById(name + "-page"); + content.classList.add("tab-page-selected"); } } @@ -30,24 +30,40 @@ window.onload = function () { {% endblock page_scripts %} -{% macro make_tab(tab, selected) -%} -
{{ tab.name }}
+{% macro make_content_tab(tab, selected) -%} +
{{ tab.name }}
{%- endmacro %} -{% macro make_tab_content(tab, selected) %} -
- -{% for tag in tab %} +{% macro make_tab_page(tab, selected) %} +
+
+{% for tag in tab.tags %} - + +{% for subtag in tag.subtags %} + + + + +{% endfor %} {% endfor %}
{{ tag.name }}{{ tag.value }}{{ make_tag_value(tag) }}
{% if loop.last %}└{% else %}├{% endif %} {{ subtag.name }}{{ make_tag_value(subtag) }}
{% endmacro %} +{# TODO: tag.interlink and tag.private support #} +{% macro make_tag_value(tag) -%} +{%- if tag.options.hyperlink -%} +{{ tag.value }} +{%- else -%} +{{ tag.value }} +{%- endif -%} +{%- endmacro %} + +{# TODO: tab.priority and tab.private support #} {% block page_content %} -{% for tab in document %}{{ make_tab(tab, loop.first) }}{% endfor %}
index
-{% for tab in document %}{{ make_tab_content(tab, loop.first) }}{% endfor %} +{% for tab in document %}{{ make_content_tab(tab, loop.first) }}{% endfor %}
index
+{% for tab in document %}{{ make_tab_page(tab, loop.first) }}{% endfor %} {% endblock page_content %} \ No newline at end of file