From 4332aa0f3b524db13fbc8efd5dfbae3a3b86fe34 Mon Sep 17 00:00:00 2001 From: Tomasz Karbownicki Date: Tue, 21 Sep 2021 00:52:59 +0200 Subject: [PATCH] =?UTF-8?q?Dodanie=20makra=20generuj=C4=85cego=20spis=20tr?= =?UTF-8?q?e=C5=9Bci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/uzytkownicy/_index.md | 2 ++ themes/tale-zola/templates/macros.html | 29 +++++++++++++++++++++++-- themes/tale-zola/templates/page.html | 2 +- themes/tale-zola/templates/section.html | 3 ++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/content/uzytkownicy/_index.md b/content/uzytkownicy/_index.md index 438a5e1..89e0e6d 100644 --- a/content/uzytkownicy/_index.md +++ b/content/uzytkownicy/_index.md @@ -3,6 +3,8 @@ title = "Dla użytkowników" template = "section.html" +++ +[TOC] + Zanim przejdziemy do konkretnych platform trzeba wspomnieć o niezwykle ważnym dla serwisów zdecentralizowanych projekcie **Fediwersum** (ang. Fediverse). Sama nazwa powstała ze zlepienia słów **federacja** i **uniwersum**. Celem projektu jest stworzenie rozległej sieci serwerów, które poprzez implementację tych samych protokołów komunikacyjnych mogłyby bez przeszkód wymieniać pomiędzy sobą informacje. W skład Fediwersum wchodzą różnego rodzaju platformy (m.in. mikroblogowe, społecznościowe, wideo). Posiadając konto na platformnie wchodzącej w skład Fediwersum możemy bez problemu obserwować użytkowników innych platform czy np. używać naszego konta na platformie mikroblogowej aby komentować filmy na platformie wideo. Dzięki temu Fediwersum rozwiązuje problem tożsamości i nie wymusza na nas tworzenia osobnych kont na każdej z tych platform. Dla odpowiedniego porównania wyobraźmy sobie sytuację, w której mamy możliwość użycia naszego konta Facebookowego do skomentowania filmu na YouTube lub konta Twitterowego do śledzenia znajomego na Facebooku. W sieci Fediwersum takie interakcje są możliwe bo wszystkie platformy się ze sobą dogadują. diff --git a/themes/tale-zola/templates/macros.html b/themes/tale-zola/templates/macros.html index a872d7e..3af8896 100644 --- a/themes/tale-zola/templates/macros.html +++ b/themes/tale-zola/templates/macros.html @@ -1,16 +1,41 @@ +{%- macro toc(toc, depth, heading=true) %} +{%- if heading %} +

Spis treści

+{%- endif %} +
    +{%- for heading in toc %} +
  1. + {{ heading.title }} + {% if heading.children and depth > 1 -%} + {{ self::toc(toc=heading.children, depth=depth - 1, heading=false) }} + {%- endif %} +
  2. +{%- endfor %} +
+
+{%- endmacro %} + +{%- macro replace_toc(resource) %} + {%- set content = resource.content %} + {%- if content is containing("[TOC]") %} + {%- set content = content | replace(from="[TOC]", to=self::toc(toc=resource.toc, level=1, depth=resource.extra.toc_depth | default(value=6))) %} + {%- endif -%} + {{ content | safe }} +{%- endmacro %} + {%- macro time() -%} {%- if config.extra.footer.start_year -%} {%- set start_year = config.extra.footer.start_year -%} {%- else -%} {%- set start_year = now() | date(format="%Y") -%} {%- endif -%} - + {%- if config.extra.footer.end_year -%} {%- set end_year = config.extra.footer.end_year -%} {%- else -%} {%- set end_year = now() | date(format="%Y") -%} {%- endif -%} - + {%- if start_year == end_year -%} {%- set year = start_year -%} {%- else -%} diff --git a/themes/tale-zola/templates/page.html b/themes/tale-zola/templates/page.html index 242590d..95fbb9c 100644 --- a/themes/tale-zola/templates/page.html +++ b/themes/tale-zola/templates/page.html @@ -38,7 +38,7 @@ {% endif -%} {% set web_type = "BlogPosting" -%} - + {{ macros::seo(title=title, og_title=og_title, author=author, description=description, site_url=site_url, image=image, image_height=image_height, image_width=image_width, web_type=web_type) }} {%- endblock seo %} diff --git a/themes/tale-zola/templates/section.html b/themes/tale-zola/templates/section.html index eeff084..6aa93ac 100644 --- a/themes/tale-zola/templates/section.html +++ b/themes/tale-zola/templates/section.html @@ -29,10 +29,11 @@ {% block content %} +

{{ section.title }}

- {{ section.content | safe }} + {{ macros::replace_toc(resource=section) }}