jekyll-rss 1.0.0alpha2 → 1.0.0alpha3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 928bba17413b6e43f9129b005e3fe4772c16615d
4
- data.tar.gz: f21c1cab6b14457ee4141e08afa196c1b55fa354
3
+ metadata.gz: f860afda8f82875a87e4116a6d85db1cb9efe8fd
4
+ data.tar.gz: e0a9ec3ad58c251b011d690496cabf5bec257420
5
5
  SHA512:
6
- metadata.gz: 63cf555a9bc5294c71a13b98728703f5cec064251cdd832d49ca98629d16811935a99333cc99c2165acef215c52e1723aa926ebc0f96b7b6823c2751b6edc20b
7
- data.tar.gz: 7439284699a851f07fdcf067a288aa7377640525169bcf2d24438517fa9341e640793727632ada87000ff973a49327dd45af7922f97a8d36c9d4a224b50549a2
6
+ metadata.gz: 1dcbcd71ffa08877d0acd7b89aea4fcfff54ebdd1bc202e8aaebb66234b3e83b4a7e47e635d40650ada1141ea91f10aa9eea8f1b48a4fd3686bd23fc876ce659
7
+ data.tar.gz: fb6d493aa0b07f7223fb605948f525cd137101eaadbaad71b43a0b7f43f3355b7bd3ebe2eebf64fb8a1d8dec9e139519d49a5b4095328a031814f5b30e29caa0
data/lib/jekyll-rss.rb CHANGED
@@ -2,6 +2,7 @@ require 'jekyll-rss/version'
2
2
  require 'jekyll-rss/generator'
3
3
  require 'jekyll-rss/rss_feed'
4
4
  require 'jekyll-rss/category_feed'
5
+ require 'jekyll-rss/tag_feed'
5
6
  require 'jekyll-rss/pager'
6
7
  require 'jekyll-rss/pagination'
7
8
  require 'jekyll-rss/rss_templates_command'
@@ -9,6 +9,8 @@ module Jekyll
9
9
  @category = category
10
10
  @category_slug = category.strip.gsub(' ', '-').gsub(NON_SLUG_REGEX, '')
11
11
  super site, path
12
+ self.data['category'] = category.split(' ').map(&:capitalize).join(' ')
13
+ self.data['category_slug'] = @category_slug
12
14
  end
13
15
 
14
16
  def url_placeholders
@@ -5,6 +5,7 @@ module Jekyll
5
5
  return nil unless site.config['rss']
6
6
  generate_blog_feed site if File.exists? File.join(site.source, '_rss', 'blog.xml')
7
7
  generate_category_feeds site if File.exists? File.join(site.source, '_rss', 'category.xml')
8
+ generate_tag_feeds site if File.exists? File.join(site.source, '_rss', 'tag.xml')
8
9
  end
9
10
 
10
11
  def generate_blog_feed(site)
@@ -22,6 +23,15 @@ module Jekyll
22
23
  site.pages << feed
23
24
  end
24
25
  end
26
+
27
+ def generate_tag_feeds(site)
28
+ path = File.join site.source, '_rss', 'tag.xml'
29
+ site.tags.each do |tag, posts|
30
+ feed = TagFeed.new site, path, tag
31
+ paginate_tag(site, feed, tag, posts) if site.config['rss'].is_a? Hash and site.config['rss']['paginate']
32
+ site.pages << feed
33
+ end
34
+ end
25
35
 
26
36
  def paginate_blog(site, feed)
27
37
  Pagination.paginate site, feed, site.posts do |pager|
@@ -37,6 +47,15 @@ module Jekyll
37
47
  category
38
48
  end
39
49
  end
50
+
51
+ def paginate_tag(site, feed, tag_name, tag_posts)
52
+ Pagination.paginate site, feed, tag_posts do |pager|
53
+ tag = TagFeed.new feed.site, feed.source, tag_name
54
+ tag.data['tag'] = tag_name
55
+ tag.data['posts'] = tag_posts
56
+ tag
57
+ end
58
+ end
40
59
  end
41
60
  end
42
61
  end
@@ -7,7 +7,7 @@ paginated_permalink: /rss/:num/:category.xml
7
7
  <channel>
8
8
  <title>{{ site.name | xml_escape }}</title>
9
9
  <description>{% if site.description %}{{ site.description | xml_escape }}{% endif %}</description>
10
- <link>{{ site.site_url }}/{{ page.category }}</link>
10
+ <link>{{ site.site_url }}/{{ page.category_slug }}</link>
11
11
  <atom:link href="{{ site.site_url }}{{ page.url }}" rel="self" type="application/rss+xml" />
12
12
  {% if paginator.next_page %}
13
13
  <atom:link href="{{ site.site_url }}{{ paginator.next_page_path }}" rel="next" type="application/rss+xml" />
@@ -0,0 +1,35 @@
1
+ ---
2
+ permalink: /rss/:category.xml
3
+ paginated_permalink: /rss/:num/:category.xml
4
+ ---
5
+ <?xml version="1.0" encoding="UTF-8"?>
6
+ <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
7
+ <channel>
8
+ <title>{{ site.name | xml_escape }}</title>
9
+ <description>{% if site.description %}{{ site.description | xml_escape }}{% endif %}</description>
10
+ <link>{{ site.site_url }}/{{ page.tag_slug }}</link>
11
+ <atom:link href="{{ site.site_url }}{{ page.url }}" rel="self" type="application/rss+xml" />
12
+ {% if paginator.next_page %}
13
+ <atom:link href="{{ site.site_url }}{{ paginator.next_page_path }}" rel="next" type="application/rss+xml" />
14
+ {% endif %}
15
+ {% if paginator.previous_page %}
16
+ <atom:link href="{{ site.site_url }}{{ paginator.previous_page_path }}" rel="previous" type="application/rss+xml" />
17
+ {% endif %}
18
+ {% for post in paginator.posts %}
19
+ <item>
20
+ <title>{{ post.title | xml_escape }}</title>
21
+ {% if post.author.name %}
22
+ <dc:creator>{{ post.author | xml_escape }}</dc:creator>
23
+ {% endif %}
24
+ {% if post.excerpt %}
25
+ <description>{{ post.excerpt | xml_escape }}</description>
26
+ {% else %}
27
+ <description>{{ post.content | xml_escape }}</description>
28
+ {% endif %}
29
+ <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
30
+ <link>{{ site.site_url }}{{ post.url }}</link>
31
+ <guid isPermaLink="true">{{ site.site_url }}{{ post.url }}</guid>
32
+ </item>
33
+ {% endfor %}
34
+ </channel>
35
+ </rss>
@@ -8,6 +8,7 @@ module Jekyll
8
8
  c.description 'Create the template files you need to format your RSS/Atom feeds.'
9
9
  c.option 'blog', '-B', '--blog', 'Generate the blog RSS/Atom feed template'
10
10
  c.option 'category', '-C', '--category', 'Generate the category RSS/Atom feed template'
11
+ c.option 'tag', '-T', '--tag', 'Generate the tag RSS/Atom feed template'
11
12
 
12
13
  c.action do |args, options|
13
14
  process options
@@ -17,7 +18,7 @@ module Jekyll
17
18
 
18
19
  def process(options)
19
20
  config = configuration_from_options(options)
20
- %w(blog category).each do |template|
21
+ %w(blog category tag).each do |template|
21
22
  create_template(config, template) if config[template]
22
23
  end
23
24
  end
@@ -0,0 +1,23 @@
1
+
2
+ module Jekyll
3
+ module RSS
4
+ class TagFeed < RSSFeed
5
+
6
+ NON_SLUG_REGEX = /[^a-z0-9\-_]/
7
+
8
+ def initialize(site, path, tag)
9
+ @tag = tag
10
+ @tag_slug = tag.strip.gsub(' ', '-').gsub(NON_SLUG_REGEX, '')
11
+ super site, path
12
+ self.data['tag'] = tag.split(' ').map(&:capitalize).join(' ')
13
+ self.data['tag_slug'] = @tag_slug
14
+ end
15
+
16
+ def url_placeholders
17
+ placeholders = super
18
+ placeholders[:tag] = @tag_slug
19
+ placeholders
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module RSS
3
- VERSION = "1.0.0alpha2"
3
+ VERSION = "1.0.0alpha3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-rss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0alpha2
4
+ version: 1.0.0alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bez Hermoso
@@ -82,7 +82,9 @@ files:
82
82
  - lib/jekyll-rss/rss_feed.rb
83
83
  - lib/jekyll-rss/rss_templates/blog.xml
84
84
  - lib/jekyll-rss/rss_templates/category.xml
85
+ - lib/jekyll-rss/rss_templates/tag.xml
85
86
  - lib/jekyll-rss/rss_templates_command.rb
87
+ - lib/jekyll-rss/tag_feed.rb
86
88
  - lib/jekyll-rss/version.rb
87
89
  homepage: https://github.com/bezhermoso/jekyll-rss
88
90
  licenses: