12 Commits 3a88368276 ... 79d046799a

Auteur SHA1 Bericht Datum
  ohnonot 79d046799a Merge branch 'feed-content' of raspbeguy/tagblog into master 4 jaren geleden
  Guy Godfroy 54ecb60bc6 document feed/content variable in default config file 4 jaren geleden
  Guy Godfroy 0383282821 fix non defined variable in configuration 4 jaren geleden
  ohnonot d4d175fecb Revert "Merge branch 'feed-content' of raspbeguy/tagblog into master" 4 jaren geleden
  ohnonot 9761109cda Merge branch 'feed-content' of raspbeguy/tagblog into master 4 jaren geleden
  Guy Godfroy 499acb145e feed: remove useless xmlns 4 jaren geleden
  ohnonot 53fde24f90 necessary for PR 3 4 jaren geleden
  ohnonot 41131f951f Merge branch 'author-page' of raspbeguy/tagblog into master 4 jaren geleden
  ohnonot 1ef1c98c93 Merge branch 'toc-raw' of raspbeguy/tagblog into master 4 jaren geleden
  Guy Godfroy b197984a2f Do not escape TOC plugin output 4 jaren geleden
  Guy Godfroy 72d5586087 Add articles content in feed 4 jaren geleden
  Guy Godfroy 0e07270e00 Introducing the author page 4 jaren geleden
6 gewijzigde bestanden met toevoegingen van 66 en 10 verwijderingen
  1. 40 0
      authors.twig
  2. 3 0
      content-base/authors.md
  3. 4 0
      feed.twig
  4. 16 8
      index.twig
  5. 2 2
      post.twig
  6. 1 0
      res/tagblog.yml

+ 40 - 0
authors.twig

@@ -0,0 +1,40 @@
+{% extends "index.twig" %}
+{% block content %}
+
+    {% set astring = url_param('q','string') %}
+    {% set length = aut_count[astring] %}
+    {% if length == 1 %}
+        <h4>{{astring}} wrote 1 post</h4>
+    {% else %}
+        <h4>{{astring}} wrote {{ length }} posts</h4>
+    {% endif %}
+
+    {% if config.tagblog.paging > 0 and length > config.tagblog.paging %}
+
+        {% set p = url_param('p','int',1) %}
+        {% set offset = (p - 1) * config.tagblog.paging %}
+        {% set lastpage = length//config.tagblog.paging %}
+        {% if length%config.tagblog.paging > 0 %}{% set lastpage = lastpage + 1 %}{% endif %}
+
+        {% for page_id in aut_pages[astring]|slice(1)|split('#')|slice(offset,config.tagblog.paging) %}
+            {% set page = pages[page_id] %}
+            {% include 'includes/postlistitem.twig' %}
+        {% endfor %}
+        <div class="pagination clearfix">
+            {% if offset >= config.tagblog.paging %}
+                <div class="previous"><a href="/authors?q={{astring}}&p={{ p - 1 }}">&lt;Previous Page</a></div>
+            {% endif %}
+            {# {% if offset >= config.tagblog.paging and offset + config.tagblog.paging < length %} | {% endif %} #}
+            <div class="current">- {{ p }}/{{ lastpage }} -</div>
+            {% if offset + config.tagblog.paging < length %}
+                <div class="next"><a href="/authors?q={{astring}}&p={{ p + 1 }}">Next Page&gt;</a></div>
+            {% endif %}
+        </div>
+    {% else %}
+        {% for page_id in aut_pages[astring]|slice(1)|split('#') %}
+            {% set page = pages[page_id] %}
+            {% include 'includes/postlistitem.twig' %}
+        {% endfor %}
+    {% endif %}
+
+{% endblock content %}

+ 3 - 0
content-base/authors.md

@@ -0,0 +1,3 @@
+---
+template: authors
+---

+ 4 - 0
feed.twig

@@ -38,6 +38,10 @@
                     {% endfor %}
                     <guid>{{ page.url }}</guid>
                     <description><![CDATA[{% if page.description %}{{ page.description }}{% else %}{{ page.id|content|striptags|slice(0, 300) }}...{% endif %}]]></description>
+                    {% if config.tagblog.feed.content is defined and config.tagblog.feed.content %}
+                        <content:encoded><![CDATA[{{ page.id|content }}]]></content:encoded>
+                    {% endif %}
+
                 </item>
                 {% set count = count + 1 %}
                 {% if count == limit %}{% set break = true %}{% endif %}

+ 16 - 8
index.twig

@@ -48,15 +48,23 @@
             {# looping over all pages to pick out what we need (i.e. pages with tags) #}
             {% set tag_count = {} %} {# tag_count contains: tag : count of occurences #}
             {% set tag_pages = {} %} {# tag_pages contains: tag : page ids of occurences hash '#' separated #}
+            {% set aut_count = {} %} {# aut_count contains: author : count of occurences #}
+            {% set aut_pages = {} %} {# aut_pages contains: author : page ids of occurences hash '#' separated #}
             {% set tbpages = {} %} {# contains ALL pages to be considered, saves some cycles later on #}
-            {% for page in pages if page.meta.tags %}
-                {% set tbpages = tbpages|merge([page]) %}
-                {% for tag in page.meta.tags|split(',') %}
-                    {# tag_count contains: tag : count of occurences #}
-                    {% set tag_count = tag_count|merge({(tag):(tag_count[tag] + 1)}) %}
-                    {# tag_pages contains: tag : page ids of occurences hash '#' separated #}
-                    {% set tag_pages = tag_pages|merge( { (tag) : (tag_pages[tag] ~ '#' ~ page.id) } ) %}
-                {% endfor %}
+            {% for page in pages if page.meta.tags or page.meta.author %}
+                {% if page.meta.tags %}
+                    {% set tbpages = tbpages|merge([page]) %}
+                    {% for tag in page.meta.tags|split(',') %}
+                        {# tag_count contains: tag : count of occurences #}
+                        {% set tag_count = tag_count|merge({(tag):(tag_count[tag] + 1)}) %}
+                        {# tag_pages contains: tag : page ids of occurences hash '#' separated #}
+                        {% set tag_pages = tag_pages|merge( { (tag) : (tag_pages[tag] ~ '#' ~ page.id) } ) %}
+                    {% endfor %}
+                {% endif %}
+                {% if page.meta.author %}
+                    {% set aut_count = aut_count|merge({(page.meta.author):(aut_count[page.meta.author] + 1)}) %}
+                    {% set aut_pages = aut_pages|merge({(page.meta.author):(aut_pages[page.meta.author]~'#'~page.id)}) %}
+                {% endif %}
             {% endfor %}
 
             {# sort tag_count into tag_sorting, according to config options #}

+ 2 - 2
post.twig

@@ -15,7 +15,7 @@
             </span>
         {% endif %}
         {% if meta.author is not empty %}
-            <span class="author">by {{ meta.author }}</span>
+            <span class="author">by <a href="/authors?q={{ meta.author }}">{{ meta.author }}</a></span>
         {% endif %}
         {% if meta.tags is not empty %}
             {% for tag in meta.tags|split(',') %}
@@ -24,7 +24,7 @@
         {% endif %}
     </aside>
     <div>
-        {{ tableofcontent }}
+        {{ tableofcontent|raw }}
         {{ content }}
     </div>
 </article>

+ 1 - 0
res/tagblog.yml

@@ -20,6 +20,7 @@ tagblog:
     paging: 8 # positive integer - or 0 (zero) to diable
     feed:
         enabled: true
+        content: false # set to true to enable full content in feed entries
     search:
         enabled: true
         minlength: 2 # minimum string length of search query