1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,28 @@ |
0 |
+--- |
|
1 |
+layout: nil |
|
2 |
+--- |
|
3 |
+<?xml version="1.0" encoding="utf-8"?> |
|
4 |
+<feed xmlns="http://www.w3.org/2005/Atom"> |
|
5 |
+ |
|
6 |
+ <title>{{ page.title | xml_escape }} | {{ site.title | xml_escape }}</title> |
|
7 |
+ <title><![CDATA[{{ page.title }} | {{ site.title }}]]></title> |
|
8 |
+ <link href="{{ site.url }}/{{ page.feed_url }}" rel="self"/> |
|
9 |
+ <link href="{{ site.url }}/"/> |
|
10 |
+ <updated>{{ site.time | date_to_xmlschema }}</updated> |
|
11 |
+ <id>{{ site.url }}/</id> |
|
12 |
+ <author> |
|
13 |
+ <name><![CDATA[{{ site.author | strip_html }}]]></name> |
|
14 |
+ {% if site.email %}<email><![CDATA[{{ site.email }}]]></email>{% endif %} |
|
15 |
+ </author> |
|
16 |
+ <generator uri="http://octopress.org/">Octopress</generator> |
|
17 |
+ |
|
18 |
+ {% for post in site.categories[page.category] limit: 5 %} |
|
19 |
+ <entry> |
|
20 |
+ <title type="html"><![CDATA[{{ post.title | cdata_escape }}]]></title> |
|
21 |
+ <link href="{{ site.url }}{{ post.url }}"/> |
|
22 |
+ <updated>{{ post.date | date_to_xmlschema }}</updated> |
|
23 |
+ <id>{{ site.url }}{{ post.id }}</id> |
|
24 |
+ <content type="html"><![CDATA[{{ post.content | expand_urls: site.url | markdownify | cdata_escape }}]]></content> |
|
25 |
+ </entry> |
|
26 |
+ {% endfor %} |
|
27 |
+</feed> |
... | ... |
@@ -48,6 +48,35 @@ module Jekyll |
48 | 48 |
|
49 | 49 |
end |
50 | 50 |
|
51 |
+ # The CategoryFeed class creates an Atom feed for the specified category. |
|
52 |
+ class CategoryFeed < Page |
|
53 |
+ |
|
54 |
+ # Initializes a new CategoryFeed. |
|
55 |
+ # |
|
56 |
+ # +base+ is the String path to the <source>. |
|
57 |
+ # +category_dir+ is the String path between <source> and the category folder. |
|
58 |
+ # +category+ is the category currently being processed. |
|
59 |
+ def initialize(site, base, category_dir, category) |
|
60 |
+ @site = site |
|
61 |
+ @base = base |
|
62 |
+ @dir = category_dir |
|
63 |
+ @name = 'atom.xml' |
|
64 |
+ self.process(@name) |
|
65 |
+ # Read the YAML data from the layout page. |
|
66 |
+ self.read_yaml(File.join(base, '_includes/custom'), 'category_feed.xml') |
|
67 |
+ self.data['category'] = category |
|
68 |
+ # Set the title for this page. |
|
69 |
+ title_prefix = site.config['category_title_prefix'] || 'Category: ' |
|
70 |
+ self.data['title'] = "#{title_prefix}#{category}" |
|
71 |
+ # Set the meta-description for this page. |
|
72 |
+ meta_description_prefix = site.config['category_meta_description_prefix'] || 'Category: ' |
|
73 |
+ self.data['description'] = "#{meta_description_prefix}#{category}" |
|
74 |
+ |
|
75 |
+ # Set the correct feed URL. |
|
76 |
+ self.data['feed_url'] = "#{category_dir}/#{name}" |
|
77 |
+ end |
|
78 |
+ |
|
79 |
+ end |
|
51 | 80 |
|
52 | 81 |
# The Site class is a built-in Jekyll class with access to global site config information. |
53 | 82 |
class Site |
... | ... |
@@ -63,6 +92,13 @@ module Jekyll |
63 | 63 |
index.write(self.dest) |
64 | 64 |
# Record the fact that this page has been added, otherwise Site::cleanup will remove it. |
65 | 65 |
self.pages << index |
66 |
+ |
|
67 |
+ # Create an Atom-feed for each index. |
|
68 |
+ feed = CategoryFeed.new(self, self.source, category_dir, category) |
|
69 |
+ feed.render(self.layouts, site_payload) |
|
70 |
+ feed.write(self.dest) |
|
71 |
+ # Record the fact that this page has been added, otherwise Site::cleanup will remove it. |
|
72 |
+ self.pages << feed |
|
66 | 73 |
end |
67 | 74 |
|
68 | 75 |
# Loops through the list of category pages and processes each one. |