From a0fd2990d435fae07fb9824c81bf5231f4eff8ec Mon Sep 17 00:00:00 2001 From: Lakshmi Vyasarajan Date: Mon, 21 Mar 2011 11:05:40 +0530 Subject: [PATCH] Adding atom feed --- hyde/layouts/basic/content/blog/atom.xml | 5 +++ hyde/layouts/basic/content/blog/excerpts.xml | 6 +++ hyde/layouts/basic/content/index.html | 4 +- hyde/layouts/basic/layout/atom.j2 | 40 ++++++++++++++++++++ hyde/layouts/basic/layout/blog.j2 | 4 +- hyde/layouts/basic/layout/macros.j2 | 12 ++++++ hyde/layouts/basic/site.yaml | 1 + 7 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 hyde/layouts/basic/content/blog/atom.xml create mode 100644 hyde/layouts/basic/content/blog/excerpts.xml create mode 100644 hyde/layouts/basic/layout/atom.j2 diff --git a/hyde/layouts/basic/content/blog/atom.xml b/hyde/layouts/basic/content/blog/atom.xml new file mode 100644 index 0000000..7d37140 --- /dev/null +++ b/hyde/layouts/basic/content/blog/atom.xml @@ -0,0 +1,5 @@ +=== +title: BASIC blog full text feed +extends: atom.j2 +listable: false +=== diff --git a/hyde/layouts/basic/content/blog/excerpts.xml b/hyde/layouts/basic/content/blog/excerpts.xml new file mode 100644 index 0000000..aa803e8 --- /dev/null +++ b/hyde/layouts/basic/content/blog/excerpts.xml @@ -0,0 +1,6 @@ +=== +title: BASIC blog excerpts feed +extends: atom.j2 +excerpts_only: true +listable: false +=== diff --git a/hyde/layouts/basic/content/index.html b/hyde/layouts/basic/content/index.html index d34ee51..c52c770 100644 --- a/hyde/layouts/basic/content/index.html +++ b/hyde/layouts/basic/content/index.html @@ -9,12 +9,12 @@ description: Home page for the BASIC hyde template
{% set latest = site.content.walk_resources_sorted_by_time()|first %} ---- if latest: +{% if latest -%} {{ render_excerpt(latest, 'post') }} Read more… ---- endif +{%- endif %}
\ No newline at end of file diff --git a/hyde/layouts/basic/layout/atom.j2 b/hyde/layouts/basic/layout/atom.j2 new file mode 100644 index 0000000..e03c40b --- /dev/null +++ b/hyde/layouts/basic/layout/atom.j2 @@ -0,0 +1,40 @@ +{% from "macros.j2" import render_excerpt, render_post with context %} + + + + {% block title %}{{ resource.meta.title|default(feed_title) }}{% endblock %} + + {% block self_url %} + + {% endblock %} + + {% block site_url %} + + {% endblock %} + + {% block feed_extra %} + {% endblock %} + + {{ now|xmldatetime }} + + {{ content_url(resource.url) }}/ + + {% for res in resource.node.walk_resources_sorted_by_time() %} + + {{ res.meta.title }} + {{ res.meta.author }} + + {{ res.meta.created|xmldatetime }} + {{ res.meta.created|xmldatetime }} + {{ content_url(res.url) }} + + {% if resource.meta.excerpts_only -%} + {{ render_excerpt(res) }} + {%- else %} + {{ render_post(res) }} + {%- endif %} + {{ res.text }} + + + {% endfor %} + \ No newline at end of file diff --git a/hyde/layouts/basic/layout/blog.j2 b/hyde/layouts/basic/layout/blog.j2 index bf187ec..1e5fe2e 100644 --- a/hyde/layouts/basic/layout/blog.j2 +++ b/hyde/layouts/basic/layout/blog.j2 @@ -56,9 +56,9 @@ {% endif %} {% filter markdown|typogrify -%} - +{% mark post -%} {% block post -%}{%- endblock %} - +{%- endmark %} {%- endfilter %} diff --git a/hyde/layouts/basic/layout/macros.j2 b/hyde/layouts/basic/layout/macros.j2 index d60c8d3..c1172e8 100644 --- a/hyde/layouts/basic/layout/macros.j2 +++ b/hyde/layouts/basic/layout/macros.j2 @@ -1,3 +1,15 @@ +{% macro render_post(res) %} +{% refer to res.url as article %} +
+

{{ res.meta.title }}

+ +{{ article.post|markdown|typogrify }} +
+{% endmacro %} + + {% macro render_excerpt(res, class=None) %} {% refer to res.url as post %}