From 0f49d5df2dc06c737352fffb94e89560a69ab641 Mon Sep 17 00:00:00 2001 From: Meitar M Date: Mon, 14 May 2018 16:02:30 -0400 Subject: [PATCH] Add syndication module to provide easy configuration for update hints. (#31) This commit adds the `` and `` elements to all feeds. These elements are defined in the RSS 1.0 Syndication Modules specification, described here: http://web.resource.org/rss/1.0/modules/syndication/ The purpose of these elements is to provide hints for automated feed consumers regarding how often to expect updates, which assists in scheduling polling times so as not to overly tax a given server. The templates use the default values intentionally so as to avoid changing the default behavior of the feeds as-is. Configuration options have been provided to make changing the values easier, since all that's needed is an edit to `_config.yml`. --- README.md | 4 ++++ feed.articles.xml | 7 ++++++- feed.category.xml | 10 ++++++++-- feed.links.xml | 7 ++++++- feed.xml | 13 ++++++++++--- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 596ce8e..ed713b6 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,13 @@ These templates rely on a customized version of \_config.yml. The name: Your Blog's Name description: A description for your blog url: http://your-blog-url.example.com + feed_items: 10 + feed_update_period: daily + feed_update_frequency: 1 This makes it easy to reference the title, description and URL for your site in the feed templates using {{ site.name }}, {{ site.description }} and {{ site.url }}. Even if you're not using these feed templates, you might find these variables useful when you're designing your layouts. +The `feed_*` items shown above are the default. You can safely omit them. Miscellany ----------- diff --git a/feed.articles.xml b/feed.articles.xml index 8abf2f0..3cf150e 100644 --- a/feed.articles.xml +++ b/feed.articles.xml @@ -1,10 +1,15 @@ --- --- - + {{ site.name | xml_escape }} - Articles {% if site.description %}{{ site.description | xml_escape }}{% endif %} + {{ site.feed_update_period | default: "daily" | xml_escape }} + {{ site.feed_update_frequency | default: 1 | xml_escape }} {{ site.url }} {% for post in site.posts limit:1 %}{% unless post.link %}{{ post.date | date_to_rfc822 }}{% endunless %}{% endfor %} diff --git a/feed.category.xml b/feed.category.xml index 0755c2f..b627215 100644 --- a/feed.category.xml +++ b/feed.category.xml @@ -1,14 +1,20 @@ --- --- - + {{ site.name | xml_escape }} - Miscellaneous Posts categorized as 'miscellaneous' + {{ site.feed_update_period | default: "daily" | xml_escape }} + {{ site.feed_update_frequency | default: 1 | xml_escape }} {{ site.url }} {% for post in site.categories.miscellaneous limit:1 %}{{ post.date | date_to_rfc822 }}{% endfor %} - {% for post in site.categories.miscellaneous limit:10 %} + {% assign feed_items = site.feed_items | default: 10 %} + {% for post in site.categories.miscellaneous limit:feed_items %} {{ post.title | xml_escape }} {% if post.excerpt %} diff --git a/feed.links.xml b/feed.links.xml index 4d7f82b..3937cb8 100644 --- a/feed.links.xml +++ b/feed.links.xml @@ -1,10 +1,15 @@ --- --- - + {{ site.name | xml_escape }} - Links {% if site.description %}{{ site.description | xml_escape }}{% endif %} + {{ site.feed_update_period | default: "daily" | xml_escape }} + {{ site.feed_update_frequency | default: 1 | xml_escape }} {{ site.url }} {% for post in site.posts limit:1 %}{% if post.link %}{{ post.date | date_to_rfc822 }}{% ifunless %}{% endfor %} diff --git a/feed.xml b/feed.xml index 2438013..7e5f655 100644 --- a/feed.xml +++ b/feed.xml @@ -1,19 +1,26 @@ --- --- - + {{ site.name | xml_escape }} {% if site.description %}{{ site.description | xml_escape }}{% endif %} + {{ site.feed_update_period | default: "daily" | xml_escape }} + {{ site.feed_update_frequency | default: 1 | xml_escape }} {{ site.url }} {% for post in site.posts limit:1 %}{{ post.date | date_to_rfc822 }}{% endfor %} - {% for post in site.posts limit:10 %} + {% assign feed_items = site.feed_items | default: 10 %} + {% for post in site.posts limit:feed_items %} {{ post.title | xml_escape }} {% if post.author.name %} {{ post.author.name | xml_escape }} - {% endif %} + {% endif %} {% if post.excerpt %} {{ post.excerpt | xml_escape }} {% else %}