Fix #2 List of tags

This commit is contained in:
Alexis Hassler 2019-05-04 21:52:13 +02:00
parent 6773809206
commit 8d635a3f71
12 changed files with 101 additions and 49 deletions

View File

@ -10,6 +10,12 @@ label:
redirect: "Redirect to" redirect: "Redirect to"
tag_pages: "Pages with tag" tag_pages: "Pages with tag"
main_page: "Main page" main_page: "Main page"
global_pages: "Special pages"
prefix: prefix:
tag: "Tag:" tag: "Tag:"
user: "User:" user: "User:"
global_pages:
- url: /Main
text: Home page
- url: /Special:Tags
text: All the tags

View File

@ -10,6 +10,12 @@ label:
redirect: "Rediriger vers" redirect: "Rediriger vers"
tag_pages: "Pages dans la catégorie" tag_pages: "Pages dans la catégorie"
main_page: "Page principale" main_page: "Page principale"
global_pages: "Pages spéciales"
prefix: prefix:
tag: "Tag:" tag: "Tag:"
user: "Utilisateur:" user: "Utilisateur:"
global_pages:
- url: /Accueil
text: Accueil
- url: /Special:Tags
text: Toutes les catégories

18
_global/Special:Tags.html Normal file
View File

@ -0,0 +1,18 @@
---
layout: default
title: Tags
menu: ['global']
---
{%- include /functions/wiki-tags.html -%}
<ul>
{%- for tag in tags -%}
{%- assign counter = 0 -%}
{%- for other_page in wiki_pages %}
{%- if other_page.tags contains tag -%}
{%- assign counter = counter | plus: 1 -%}
{%- endif -%}
{%- endfor -%}
<li id="n-tag-{{ tag }}"><a href="/{{ site.data.i18n[site.lang].prefix.tag }}{{ tag }}.html">{{ tag }}</a> ({{counter}} pages)</li>
{%- endfor -%}
</ul>

View File

@ -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 -%}

8
_includes/global.html Normal file
View File

@ -0,0 +1,8 @@
<div id="global" class="portlet">
<h3>{{ site.data.i18n[site.lang].label.global_pages }}</h3>
<ul class="portlet-body">
{%- for link in site.data.i18n[site.lang].global_pages -%}
<li><a href="{{link.url}}.html">{{link.text}}</a></li>
{%- endfor -%}
</ul>
</div>

View File

@ -2,20 +2,18 @@
<head> <head>
{% include head.html %} {% include head.html %}
</head> </head>
<body> <body>
<div id="main"> <div id="main">
<h1 id="title">{{ page.title }}</h1> <h1 id="title">{{ page.title }}</h1>
<div id="content">{{ content | inject_anchors }}</div> <div id="content">{{ content | inject_anchors }}</div>
</div> </div>
<div id="menu"> <div id="menu">
{% include logo.html %} {%- include logo.html -%}
{% include user.html %} {%- assign menu = page.menu | default: layout.menu -%}
{% include toc.html %} {%- for item in menu -%}
{% include links.html %} {%- include {{item}}.html -%}
{% include tags.html %} {%- endfor -%}
</div> </div>
{% include footer.html %} {% include footer.html %}
</body> </body>
</html> </html>

View File

@ -1,11 +1,9 @@
<html dir="ltr" class="client-js" lang="fr"> <html>
{%- include /functions/redirect-page.html -%} {%- include /functions/redirect-page.html -%}
<head> <head>
{%- assign redirect_url = redirect_page.url | default: site.data.i18n[site.lang].home | append: ".html" -%} {%- assign redirect_url = redirect_page.url | default: site.data.i18n[site.lang].home | append: ".html" -%}
{%- include head.html redirect_url = redirect_url -%} {%- include head.html redirect_url = redirect_url -%}
</head> </head>
<body> <body>
<div id="main"> <div id="main">
<h1 id="title">{{ redirect_page.title }}</h1> <h1 id="title">{{ redirect_page.title }}</h1>
@ -18,7 +16,6 @@
</div> </div>
</div> </div>
</div> </div>
<div id="menu"> <div id="menu">
{%- include logo.html -%} {%- include logo.html -%}
</div> </div>

View File

@ -1,4 +1,5 @@
--- ---
layout: default layout: default
menu: ['global']
--- ---
{{ content }} {{ content }}

View File

@ -1,15 +1,9 @@
<html dir="ltr" class="client-js" lang="fr"> ---
<head> layout: default
{% include head.html %} menu: ['global']
</head> ---
{{ content | inject_anchors }}
<body> <div id="pages">
<div id="main">
<h1 id="title">{{ page.tags }}</h1>
<div id="content">
{{ content | inject_anchors }}
</div>
<div id="pages">
<h3>{{ site.data.i18n[site.lang].label.tag_pages }} {{ page.tags }}</h3> <h3>{{ site.data.i18n[site.lang].label.tag_pages }} {{ page.tags }}</h3>
<div class="columns"> <div class="columns">
<ul> <ul>
@ -23,12 +17,4 @@
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
</div> </div>
</div>
<div id="menu">
{% include logo.html %}
</div>
{% include footer.html %}
</body>
</html>

View File

@ -1,4 +1,5 @@
--- ---
layout: default layout: default
menu: ['user', 'toc', 'links', 'tags']
--- ---
{{ content }} {{ content }}

View File

@ -1,7 +1,6 @@
--- ---
layout: user layout: simple
title: Alexis title: Alexis
toc: false
created: 2019-04-12 created: 2019-04-12
modified: 2019-04-12 modified: 2019-04-12
revisions: revisions:

View File

@ -1,7 +1,6 @@
--- ---
layout: wiki layout: simple
title: Main Page title: Main Page
toc: false
created: 2009-04-12 created: 2009-04-12
modified: 2009-04-12 modified: 2009-04-12
revisions: revisions: