From aa227c7dc69a97a94f05e2236653c9010c729aa5 Mon Sep 17 00:00:00 2001
From: Philipp Oppermann
Date: Sat, 2 Jan 2021 18:09:06 +0100
Subject: [PATCH] Restructure macros
- Split macros.html in per-edition files
- Create new snippets.html macro file with utterances snippet
- Move support.html to snippets.html as new macro
- Create new `latest_post` macro in 2nd edition macros.html
---
blog/templates/edition-1/index.html | 2 +-
blog/templates/edition-1/macros.html | 39 +++++++++++++++++++
blog/templates/edition-1/section.html | 2 +-
blog/templates/edition-2/extra.html | 4 +-
blog/templates/edition-2/index.html | 5 ++-
blog/templates/{ => edition-2}/macros.html | 15 +++----
blog/templates/edition-2/page.html | 7 ++--
blog/templates/news-page.html | 4 +-
blog/templates/news-section.html | 2 -
.../templates/{support.html => snippets.html} | 14 ++++++-
blog/templates/status-update-page.html | 4 +-
blog/templates/status-update-section.html | 2 -
12 files changed, 72 insertions(+), 28 deletions(-)
create mode 100644 blog/templates/edition-1/macros.html
rename blog/templates/{ => edition-2}/macros.html (85%)
rename blog/templates/{support.html => snippets.html} (71%)
diff --git a/blog/templates/edition-1/index.html b/blog/templates/edition-1/index.html
index 31d4aae7..0d8a68ab 100644
--- a/blog/templates/edition-1/index.html
+++ b/blog/templates/edition-1/index.html
@@ -1,6 +1,6 @@
{% extends "edition-1/base.html" %}
-{% import "macros.html" as macros %}
+{% import "edition-1/macros.html" as macros %}
{% block title %}{{ config.title }}{% endblock title %}
diff --git a/blog/templates/edition-1/macros.html b/blog/templates/edition-1/macros.html
new file mode 100644
index 00000000..a6197dad
--- /dev/null
+++ b/blog/templates/edition-1/macros.html
@@ -0,0 +1,39 @@
+{% macro post_link(page) %}
+ {% set translations = page.translations | filter(attribute="lang", value=lang) -%}
+ {%- if translations -%}
+ {%- set post = get_page(path = translations.0.path) -%}
+ {%- else -%}
+ {%- set post = page -%}
+ {%- set not_translated = true -%}
+ {%- endif -%}
+
+
+
+ {{ post.summary | safe }}
+
read more ยป
+
+ {%- if lang and not_translated and lang != config.default_language -%}
+
+ {%- endif -%}
+
+
+{% endmacro post_link %}
+
+{% macro toc(toc) %}
+
+ Table of Contents
+
+
+{% endmacro toc %}
diff --git a/blog/templates/edition-1/section.html b/blog/templates/edition-1/section.html
index 3bbe0a8a..45d12fa3 100644
--- a/blog/templates/edition-1/section.html
+++ b/blog/templates/edition-1/section.html
@@ -1,6 +1,6 @@
{% extends "edition-1/base.html" %}
-{% import "macros.html" as macros %}
+{% import "edition-1/macros.html" as macros %}
{% block title %}{{ section.title }} | {{ config.title }}{% endblock title %}
diff --git a/blog/templates/edition-2/extra.html b/blog/templates/edition-2/extra.html
index bdd5a16a..93c98f59 100644
--- a/blog/templates/edition-2/extra.html
+++ b/blog/templates/edition-2/extra.html
@@ -1,6 +1,6 @@
{% extends "edition-2/base.html" %}
-{% import "macros.html" as macros %}
+{% import "snippets.html" as snippets %}
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
@@ -17,6 +17,6 @@
Comments
- {{ macros::utterances() }}
+ {{ snippets::utterances() }}
{% endblock after_main %}
diff --git a/blog/templates/edition-2/index.html b/blog/templates/edition-2/index.html
index b8303d4b..dbf3762d 100644
--- a/blog/templates/edition-2/index.html
+++ b/blog/templates/edition-2/index.html
@@ -1,6 +1,7 @@
{% extends "edition-2/base.html" %}
-{% import "macros.html" as macros %}
+{% import "edition-2/macros.html" as macros %}
+{% import "snippets.html" as snippets %}
{% block title %}{{ config.title }}{% endblock title %}
@@ -71,7 +72,7 @@
Support Me
- {% include "support.html" %}
+ {{ snippets::support() }}
{% endblock main %}
diff --git a/blog/templates/macros.html b/blog/templates/edition-2/macros.html
similarity index 85%
rename from blog/templates/macros.html
rename to blog/templates/edition-2/macros.html
index a7c700a9..a28a44bb 100644
--- a/blog/templates/macros.html
+++ b/blog/templates/edition-2/macros.html
@@ -1,3 +1,8 @@
+{% macro latest_post(posts) %}
+ {% set post = posts|last %}
+ {{ post.title }}
+{% endmacro latest_post %}
+
{% macro post_link(page) %}
{% set translations = page.translations | filter(attribute="lang", value=lang) -%}
{%- if translations -%}
@@ -21,16 +26,6 @@
{% endmacro post_link %}
-{% macro utterances() %}
-
-{% endmacro utterances %}
-
{% macro toc(toc) %}
Table of Contents
diff --git a/blog/templates/edition-2/page.html b/blog/templates/edition-2/page.html
index ef440314..13a70d79 100644
--- a/blog/templates/edition-2/page.html
+++ b/blog/templates/edition-2/page.html
@@ -1,6 +1,7 @@
{% extends "edition-2/base.html" %}
-{% import "macros.html" as macros %}
+{% import "edition-2/macros.html" as macros %}
+{% import "snippets.html" as snippets %}
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
{% block header %}
@@ -75,7 +76,7 @@
@@ -98,7 +99,7 @@
{% endif %}
- {{ macros::utterances() }}
+ {{ snippets::utterances() }}