From 8d635a3f71b2535f3d2f4deee2d07f983ad6fe04 Mon Sep 17 00:00:00 2001 From: Alexis Hassler Date: Sat, 4 May 2019 21:52:13 +0200 Subject: [PATCH] Fix #2 List of tags --- _data/i18n/en.yml | 6 ++++ _data/i18n/fr.yml | 6 ++++ _global/Special:Tags.html | 18 ++++++++++ _includes/functions/wiki-tags.html | 33 ++++++++++++++++++ _includes/global.html | 8 +++++ _layouts/default.html | 12 +++---- _layouts/redirect.html | 5 +-- _layouts/{user.html => simple.html} | 1 + _layouts/tag.html | 54 +++++++++++------------------ _layouts/wiki.html | 1 + _special/User:Alexis.html | 3 +- _wiki/Main.md | 3 +- 12 files changed, 101 insertions(+), 49 deletions(-) create mode 100644 _global/Special:Tags.html create mode 100644 _includes/functions/wiki-tags.html create mode 100644 _includes/global.html rename _layouts/{user.html => simple.html} (69%) diff --git a/_data/i18n/en.yml b/_data/i18n/en.yml index 9eb2fef..4a6d9eb 100644 --- a/_data/i18n/en.yml +++ b/_data/i18n/en.yml @@ -10,6 +10,12 @@ label: redirect: "Redirect to" tag_pages: "Pages with tag" main_page: "Main page" + global_pages: "Special pages" prefix: tag: "Tag:" user: "User:" +global_pages: + - url: /Main + text: Home page + - url: /Special:Tags + text: All the tags diff --git a/_data/i18n/fr.yml b/_data/i18n/fr.yml index bcd592a..e7d5f99 100644 --- a/_data/i18n/fr.yml +++ b/_data/i18n/fr.yml @@ -10,6 +10,12 @@ label: redirect: "Rediriger vers" tag_pages: "Pages dans la catégorie" main_page: "Page principale" + global_pages: "Pages spéciales" prefix: tag: "Tag:" user: "Utilisateur:" +global_pages: + - url: /Accueil + text: Accueil + - url: /Special:Tags + text: Toutes les catégories diff --git a/_global/Special:Tags.html b/_global/Special:Tags.html new file mode 100644 index 0000000..402595d --- /dev/null +++ b/_global/Special:Tags.html @@ -0,0 +1,18 @@ +--- +layout: default +title: Tags +menu: ['global'] +--- +{%- include /functions/wiki-tags.html -%} + diff --git a/_includes/functions/wiki-tags.html b/_includes/functions/wiki-tags.html new file mode 100644 index 0000000..09ac6c3 --- /dev/null +++ b/_includes/functions/wiki-tags.html @@ -0,0 +1,33 @@ +{%- comment -%} +======================= +The following part extracts all the tags from your posts and sort tags, so that you do not need to manually collect your tags to a place. +======================= +{%- endcomment -%} +{%- assign rawtags = "" -%} +{%- include /functions/wiki-pages.html -%} + +{%- for wiki_page in wiki_pages -%} + {%- assign ttags = wiki_page.tags | join:'|' | append:'|' -%} + {%- assign rawtags = rawtags | append:ttags -%} +{%- endfor -%} +{%- assign rawtags = rawtags | split:'|' | sort -%} + +{%- comment -%} +======================= +The following part removes dulpicated tags and invalid tags like blank tag. +======================= +{%- endcomment -%} + +{%- assign tags = "" -%} +{%- for tag in rawtags -%} + {%- if tag != "" -%} + {%- if tags == "" -%} + {%- assign tags = tag | split:'|' -%} + {%- endif -%} + {%- unless tags contains tag -%} + {%- assign tags = tags | join:'|' | append:'|' | append:tag | split:'|' -%} + {%- endunless -%} + {%- endif -%} +{%- endfor -%} + +{%- assign wiki_tags = tags -%} diff --git a/_includes/global.html b/_includes/global.html new file mode 100644 index 0000000..f01763d --- /dev/null +++ b/_includes/global.html @@ -0,0 +1,8 @@ +
+

{{ site.data.i18n[site.lang].label.global_pages }}

+ +
diff --git a/_layouts/default.html b/_layouts/default.html index e541f76..6044199 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -2,20 +2,18 @@ {% include head.html %} -

{{ page.title }}

{{ content | inject_anchors }}
- {% include footer.html %} diff --git a/_layouts/redirect.html b/_layouts/redirect.html index 4c4958b..a7bb11a 100644 --- a/_layouts/redirect.html +++ b/_layouts/redirect.html @@ -1,11 +1,9 @@ - + {%- include /functions/redirect-page.html -%} - {%- assign redirect_url = redirect_page.url | default: site.data.i18n[site.lang].home | append: ".html" -%} {%- include head.html redirect_url = redirect_url -%} -

{{ redirect_page.title }}

@@ -18,7 +16,6 @@
- diff --git a/_layouts/user.html b/_layouts/simple.html similarity index 69% rename from _layouts/user.html rename to _layouts/simple.html index 73dae17..b89154f 100644 --- a/_layouts/user.html +++ b/_layouts/simple.html @@ -1,4 +1,5 @@ --- layout: default +menu: ['global'] --- {{ content }} diff --git a/_layouts/tag.html b/_layouts/tag.html index c00d525..2af6f8f 100644 --- a/_layouts/tag.html +++ b/_layouts/tag.html @@ -1,34 +1,20 @@ - - - {% include head.html %} - - - -
-

{{ page.tags }}

-
- {{ content | inject_anchors }} -
-
-

{{ site.data.i18n[site.lang].label.tag_pages }} {{ page.tags }}

-
-
    - {% include /functions/wiki-pages.html %} - {% for tag in page.tags %} - {% for other_page in wiki_pages %} - {% if other_page.tags contains tag and other_page.slug != page.slug %} -
  • {{ other_page.title }}
  • - {% endif %} - {% endfor %} - {% endfor %} -
-
-
-
- - - {% include footer.html %} - - +--- +layout: default +menu: ['global'] +--- +{{ content | inject_anchors }} +
+

{{ site.data.i18n[site.lang].label.tag_pages }} {{ page.tags }}

+
+
    + {% include /functions/wiki-pages.html %} + {% for tag in page.tags %} + {% for other_page in wiki_pages %} + {% if other_page.tags contains tag and other_page.slug != page.slug %} +
  • {{ other_page.title }}
  • + {% endif %} + {% endfor %} + {% endfor %} +
+
+
diff --git a/_layouts/wiki.html b/_layouts/wiki.html index 73dae17..f9afb6c 100644 --- a/_layouts/wiki.html +++ b/_layouts/wiki.html @@ -1,4 +1,5 @@ --- layout: default +menu: ['user', 'toc', 'links', 'tags'] --- {{ content }} diff --git a/_special/User:Alexis.html b/_special/User:Alexis.html index 96c11a2..b76db9a 100644 --- a/_special/User:Alexis.html +++ b/_special/User:Alexis.html @@ -1,7 +1,6 @@ --- -layout: user +layout: simple title: Alexis -toc: false created: 2019-04-12 modified: 2019-04-12 revisions: diff --git a/_wiki/Main.md b/_wiki/Main.md index 9cb260e..86b909b 100644 --- a/_wiki/Main.md +++ b/_wiki/Main.md @@ -1,7 +1,6 @@ --- -layout: wiki +layout: simple title: Main Page -toc: false created: 2009-04-12 modified: 2009-04-12 revisions: