Browse Source

add back the parts that make an RSS/atom feed...

these are based upon slight modifications from the basic template...
main
John-Mark Gurney 3 years ago
parent
commit
59ecb12a97
3 changed files with 94 additions and 0 deletions
  1. +5
    -0
      content/atom.xml
  2. +49
    -0
      layout/atom.j2
  3. +40
    -0
      layout/macros.j2

+ 5
- 0
content/atom.xml View File

@@ -0,0 +1,5 @@
===
title: encthenet ramblings
extends: atom.j2
listable: false
===

+ 49
- 0
layout/atom.j2 View File

@@ -0,0 +1,49 @@
{% from "macros.j2" import render_excerpt, render_post with context %}
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>
{% block title %}{{ resource.meta.title|default(feed_title) }}{% endblock %}
</title>
{% block self_url %}
<link href="{{ resource.url }}" rel="self" />
{% endblock %}

{% block site_url %}
<link href="{{ content_url('') }}"/>
{% endblock %}

{% block feed_extra %}
{% endblock %}

<updated>{{ time_now|xmldatetime }}</updated>

<id>{{ content_url(resource.url) }}/</id>

{% for res in resource.node.walk_resources_sorted_by_time() %}
<entry>
<title type="html">{{ res.meta.title|forceescape }}</title>
<author><name>{{ res.meta.author }}</name></author>
<link href="{{ content_url(res.url) }}"/>
<updated>{{ res.meta.created|xmldatetime }}</updated>
<published>{{ res.meta.created|xmldatetime }}</published>
<id>{{ content_url(res.url) }}</id>
{% for tag in res.meta.tags %}
<category scheme="{{ content_url('search/label') }}"
term="{{tag}}"
label="{{ tag|title }}" />
{% endfor %}

<content type="html">
{% refer to res.relative_path as article -%}
{% filter forceescape -%}
{% if resource.meta.excerpts_only -%}
{{ article.image|markdown|typogrify }}
{{ article.excerpt|markdown|typogrify }}
{%- else %}
{{ article.post|markdown|typogrify }}
{%- endif %}
{%- endfilter %}
</content>
</entry>
{% endfor %}
</feed>

+ 40
- 0
layout/macros.j2 View File

@@ -0,0 +1,40 @@
{% macro render_excerpt(res, class=None) %}
{% refer to res.relative_path as post %}
<article {{'class='~class if class }}>
<h3><a href="{{ content_url(res.url) }}">{{ res.meta.title }}</a></h3>
<a href="{{ content_url(res.url) }}">{{ post.image|markdown|typogrify }}</a>
{{ post.excerpt|markdown|typogrify }}
<time datetime="{{ res.meta.created.strftime('%Y-%m-%d') }}">
Posted: {{ res.meta.created.strftime('%a, %d %b %Y') }}
</time>
</article>
{% endmacro %}

{% macro render_nav(menu, cls=None) -%}
{% if menu -%}
<nav {{'class='~cls if cls }}>
<ul>
{% for item in menu -%}
{% set active = False -%}
{% if item.type == 'page' -%}
{% set active = (resource.url ==
site.content.resource_from_relative_path(item.url).url) -%}
{% else -%}
{% set active = (node ==
site.content.node_from_relative_path(item.url)) -%}
{%- endif %}
{% set classes = ['button', 'white'] -%}
{% do classes.append('active') if active -%}
{% do classes.append(item.css_class) if item.css_class -%}
<li>
<a title="{{ item.description }}"
class="{{ classes|join(' ') }}"
href="{{ content_url(item.url) }}">
{{ item.name }}
</a>
</li>
{%- endfor %}
</ul>
</nav>
{%- endif %}
{%- endmacro %}

Loading…
Cancel
Save