octopress-feeds 1.3.4 → 1.4.0

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: 0fe46bf0122238ae29a7f72bbcc547c5fee9bf62
4
- data.tar.gz: 6c4c906d9b62c705ee14e1218083ea4e86ad2dbd
3
+ metadata.gz: 6f264c935532788b05d291d01c76a1a559c7e0af
4
+ data.tar.gz: c31b8664e1e0125eb2fdc0e1af7c901859e3f341
5
5
  SHA512:
6
- metadata.gz: 90f8609f0aa07406ad373ac2a24565f1aa091dcd68f6004a641f457debed0f8ead2d1c10dbecb7653406c8bf35bace8280f56ee1a230536043ef8a229cb46260
7
- data.tar.gz: a82ea0f399c9c32d50b8228d58e8434fb939c3c626b6448f92b5fd7a2ada0ac844557ae8208090c7bc3c974a14dacecfe69733bfdfc86069501246b6045da740
6
+ metadata.gz: 261edcab26afb5fe009409ac3a9fdc89fe255dc290354fd661b01e0095304c021839920be37e15cfbe1fa9df72c23b448faa339e6aeda37556784d0ccd11bd48
7
+ data.tar.gz: 81d03cff3a35358e3afdfcbc6e98b8bf48d67955e18630c02ffbfac693e700e25465ba9f67653b500999bc5930674155fc7ad5817f5405a6fa664bf51aa90404
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.4.0 (2015-02-20)
4
+ - New: Added category index feeds
5
+ - New: Better configuration management for titles and permalinks
6
+
3
7
  ### 1.3.4 (2015-02-14)
4
8
 
5
9
  - Only default feed language if a default site language is set.
data/README.md CHANGED
@@ -85,65 +85,9 @@ each language. Your feed urls will be organized by language. For example:
85
85
 
86
86
  To change the URL for these pages, read the [Feed Permalinks](#feed-permalinks) section below.
87
87
 
88
- ## Customize feeds
89
-
90
- To list detailed information about this plugin, run `$ octopress ink list feeds`. This will output something like this:
91
-
92
- ```
93
- Plugin: Octopress Feeds - v1.1.5
94
- Slug: feeds
95
- RSS feeds for Jekyll sites, featuring link-blogging and multilingual support.
96
- https://github.com/octopress/feeds
97
- =============================================================
98
- includes:
99
- - article-feed.xml
100
- - entry.xml
101
- - head.xml
102
- - link-feed.xml
103
- - main-feed.xml
104
-
105
- pages: urls:
106
- - main.xml /feed/
107
- - links.xml /feed/links/ # with octopress-linkblog
108
- - articles.xml /feed/articles/ # with octopress-linkblog
109
-
110
- config:
111
- count: 20
112
- excerpts: false # Feed excerpts post content
113
- external_links: true # Linkposts should direct visitors to the linked site
114
- titles:
115
- main-feed: "Posts Feed"
116
- article-feed: "Articles-only Feed"
117
- link-feed: "Links-only Feed"
118
- ```
119
-
120
- If you have posts written in English and German, and are using [octopress-multilingual](https://github.com/octopress/multilingual),
121
- your permalinks will automatically be name-spaced by language, like this:
122
-
123
- ```
124
- pages: urls:
125
- - main /en/feed/
126
- - links /en/feed/links/
127
- - articles /en/feed/articles/
128
- - main_de /de/feed/
129
- - links_de /de/feed/links/
130
- - articles_de /de/feed/articles/
131
- ```
132
-
133
- Octopress Ink can copy all of the plugin's assets to `_plugins/feeds/*` where you can override them with your own modifications. This is
134
- only necessary if you want to modify this plugin's behavior.
135
-
136
- ```
137
- octopress ink copy feeds
138
- ```
139
-
140
- This will copy the plugin's configuration, pages, and includes from the gem, to your local site. If, for example, you want to change the XML for an entry, you can simply edit the `_plugins/feeds/includes/entry.xml` file.
141
-
142
- If you want to revert to the defaults, simply delete any file you don't care to override from the `_plugins/feeds/` directory.
143
-
144
88
  ## Configuration
145
89
 
146
- To configure this plugin, first create a configuration file at `_plugins/feeds/config.yml`. If you like, you can have Octopress Ink add it for you.
90
+ To configure this plugin, first copy the plugin's configuration file to `_plugins/feeds/config.yml` buy running:
147
91
 
148
92
  ```
149
93
  $ octopress ink copy feeds --config-file
@@ -151,51 +95,45 @@ $ octopress ink copy feeds --config-file
151
95
 
152
96
  This will create a configuration file populated with the defaults for this plugin. Deleting this file will restore the default configuration.
153
97
 
98
+ ### Configuration defaults
154
99
 
155
- | Option | Description | Default |
156
- |:----------------------|:------------------------------------------------------------|:------------|
157
- | `count` | How many posts should appear in your feeds. | 20 |
158
- | `excerpts` | Feed entries will contain excerpts of post content. | false |
159
- | `external_linkposts` | Link posts should direct visitors to the linked site. | true |
160
- | `articles_feed` | Add an additional articles-only feed. | false |
161
- | `linkposts_feed` | Add an additional link-posts-only feed. | false |
162
- | `titles` | Set feed titles for main, article, and link feeds. | [see below] |
163
- | `permalinks` | Set the permalink for feed pages. | {} |
100
+ ```
101
+ count: 20 # Maximum number of posts in a feed
102
+ excerpts: false # Use post excerpts in feeds
103
+ external_links: true # Linkposts should direct visitors to the linked site
104
+ category_feeds: false # Add a feed for post categories
105
+ categories: [] # Only add feeds for these categories. (empty adds feeds for all categories)
164
106
 
107
+ titles:
108
+ main: site.name - Posts
109
+ links: site.name - Links-only
110
+ articles: site.name - Articles-only
111
+ category: site.name - Posts in category.name
112
+
113
+ permalinks:
114
+ main: /feed/
115
+ links: /feed/links/
116
+ articles: /feed/articles/
117
+ category: /feed/categories/category.name/
118
+ ```
165
119
 
166
120
  ### Feed titles
167
121
 
168
122
  The `titles` configuration allows you to control the title that RSS subscribers see for your feed.
169
123
 
170
- ```yaml
171
- titles:
172
- main-feed: Posts Feed
173
- article-feed: Articles-only Feed
174
- link-feed: Links-only Feed
175
- ```
124
+ As you'd expect, `site.name` is replaced with the value from your site configuration and `category.name` is replaced with the
125
+ category for that feed.
176
126
 
177
127
  If you want to change the title for other languages you can add a new language localized config file. For example if you have German
178
128
  feeds, you would add a config file at `_plugins/feeds/config_de.yml` and set titles for your German language feeds.
179
129
 
180
130
  ### Feed permalinks
181
131
 
182
- You can set the URL for the feed pages by configuring the `permalink` setting. Here's an example:
183
-
184
- ```yaml
185
- permalinks:
186
- main: /rss/
187
- links: /rss/links/
188
- articles: /rss/articles/
189
- ```
132
+ You can set the URL for the feed pages by configuring the `permalinks` setting.
190
133
 
191
- Now when you run `$ octopress ink list feeds` the pages section will look like this:
192
-
193
- ```
194
- pages: urls:
195
- - main /rss/
196
- - links /rss/links/
197
- - articles /rss/articles/
198
- ```
134
+ If you are running a multilingual site with [octopress-multilingual](https://github.com/octopress/multilingual) permalinks will be
135
+ prepended with the lanugage code that corresponds with the posts in that feed. So `/feeds/` will become `/en/feeds/` and `/de/feeds/`
136
+ and so on.
199
137
 
200
138
  ### Excerpted feeds
201
139
 
@@ -205,6 +143,34 @@ posts, You can change that to something like `<!--more-->` and place that commen
205
143
  split the content there.
206
144
 
207
145
 
146
+ ### Customizing feed templates
147
+
148
+ When you run `$ octopress ink list feeds` the includes and templates section might like this:
149
+
150
+ ```
151
+ includes:
152
+ - entry.xml
153
+ - head.xml
154
+
155
+ templates:
156
+ - articles.xml # template file
157
+ /feed/articles/index.xml # page generated from template
158
+ - category.xml
159
+ - links.xml
160
+ /feed/links/index.xml
161
+ - main.xml
162
+ /feed/index.xml
163
+ ```
164
+
165
+ To customize feed templates and inlcudes, Copy all of the plugin's assets to `_plugins/feeds/` by running this command:
166
+
167
+ ```
168
+ octopress ink copy feeds --templates --includes
169
+ ```
170
+
171
+ Any changes you make to these templates will override the templates in the plugin. If you want to revert to the defaults, simply delete any file you don't care to override from the `_plugins/feeds/` directory.
172
+
173
+
208
174
  ## Contributing
209
175
 
210
176
  1. Fork it ( https://github.com/octopress/feeds/fork )
data/assets/config.yml CHANGED
@@ -1,8 +1,17 @@
1
- count: 20
2
- excerpts: false # Feed excerpts post content
1
+ count: 20 # Maximum number of posts in a feed
2
+ excerpts: false # Use post excerpts in feeds
3
3
  external_links: true # Linkposts should direct visitors to the linked site
4
+ category_feeds: false # Add a feed for categories
5
+ categories: [] # Only add feeds for these categories. (empty adds feeds for all categories)
4
6
 
5
7
  titles:
6
- main-feed: Posts Feed
7
- article-feed: Articles-only Feed
8
- link-feed: Links-only Feed
8
+ main: site.name - Posts
9
+ links: site.name - Links-only
10
+ articles: site.name - Articles-only
11
+ category: site.name - Posts in category.name
12
+
13
+ permalinks:
14
+ main: /feed/
15
+ links: /feed/links/
16
+ articles: /feed/articles/
17
+ category: /feed/categories/category.name/
@@ -1,4 +1,6 @@
1
- {% assign feed_type = 'articles' %}{% include feeds:head.xml %}
1
+ ---
2
+ ---
3
+ {% include feeds:head.xml %}
2
4
  {% for post in site.articles limit:plugins.feeds.count %}
3
5
  <entry>
4
6
  {% include feeds:entry.xml %}
@@ -0,0 +1,9 @@
1
+ ---
2
+ ---
3
+ {% include feeds:head.xml %}
4
+ {% for post in site.categories[page.category] limit:plugins.feeds.count %}
5
+ <entry>
6
+ {% include feeds:entry.xml %}
7
+ </entry>
8
+ {% endfor %}
9
+ </feed>
@@ -1,4 +1,6 @@
1
- {% assign feed_type = 'linkposts' %}{% include feeds:head.xml %}
1
+ ---
2
+ ---
3
+ {% include feeds:head.xml %}
2
4
  {% for post in site.linkposts limit:plugins.feeds.count %}
3
5
  <entry>
4
6
  {% include feeds:entry.xml %}
@@ -1,4 +1,6 @@
1
- {% assign feed_type = 'posts' %}{% include feeds:head.xml %}
1
+ ---
2
+ ---
3
+ {% include feeds:head.xml %}
2
4
  {% for post in site.posts limit:plugins.feeds.count %}
3
5
  <entry>
4
6
  {% include feeds:entry.xml %}
@@ -2,8 +2,10 @@ module Octopress
2
2
  module Feeds
3
3
  class FeedTag < Liquid::Tag
4
4
  def render(context)
5
- Octopress::Ink.plugin('feeds').pages.dup
6
- .map { |p| tag(p.page) }
5
+ Octopress::Ink.plugin('feeds').templates
6
+ .sort_by { |template| template.file.size }
7
+ .map { |template| template.pages }
8
+ .flatten.map {|page| tag(page) }
7
9
  .join("\n")
8
10
  end
9
11
 
@@ -14,9 +16,7 @@ module Octopress
14
16
  end
15
17
 
16
18
  def page_title(page)
17
- title = page.site.config['name'].dup || ''
18
- title << ': ' unless title.empty?
19
- title << page_title_config(page)
19
+ title = page_title_config(page)
20
20
 
21
21
  if defined?(Octopress::Multilingual) && page.lang
22
22
  title << " (#{Octopress::Multilingual.language_name(page.lang)})"
@@ -26,29 +26,36 @@ module Octopress
26
26
  end
27
27
 
28
28
  def page_title_config(page)
29
- plugin = page.plugin
30
- config = plugin.config(page.lang)
29
+ plugin = Octopress::Ink.plugin('feeds')
30
+ config = plugin.config(page.lang)['titles']
31
31
 
32
- case plugin.feed_type(page.asset)
33
- when 'article'; config['titles']['article-feed']
34
- when 'link'; config['titles']['link-feed']
35
- else config['titles']['main-feed']
32
+ site_name = page.site.config['name'] || ''
33
+ type = page.data['feed_type']
34
+ title = config[type]
35
+
36
+ if type == 'category'
37
+ category = page.data['category'].capitalize
38
+
39
+ if labels = Octopress.site.config['category_labels']
40
+ category = labels[category.downcase] || category
41
+ end
42
+
43
+ title = title.sub(/category\.name/, category)
36
44
  end
45
+
46
+ title.sub(/site\.name/, site_name)
37
47
  end
38
48
  end
39
49
 
40
50
  class FeedUpdatedTag < Liquid::Tag
41
51
  def render(context)
42
- feed = context['feed_type'] || 'posts'
52
+ feed = context['page.feed_type']
43
53
  site = context['site']
44
54
 
45
- case feed
46
- when 'articles'
47
- posts = site['articles']
48
- when 'linkposts'
49
- posts = site['linkposts']
55
+ if feed == 'category'
56
+ posts = site['categories'][context['page.category']]
50
57
  else
51
- posts = site['posts']
58
+ posts = site[feed] || site['posts']
52
59
  end
53
60
 
54
61
  if posts && !posts.empty?
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Feeds
3
- VERSION = "1.3.4"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
@@ -4,88 +4,92 @@ require 'octopress-include-tag'
4
4
  require 'octopress-return-tag'
5
5
  require 'octopress-date-format'
6
6
  require 'octopress-feeds/tags'
7
- require 'octopress-feeds/config-asset'
8
7
 
9
8
 
10
9
  module Octopress
11
10
  module Feeds
12
11
  class Plugin < Ink::Plugin
13
12
 
14
- def config_defaults
15
- @config ||= Feeds::Config.new(self, @config_file)
13
+ def multilingual?
14
+ (defined?(Octopress::Multilingual) && !Octopress.site.config['lang'].nil?)
16
15
  end
17
16
 
18
- def add_pages
19
- super
20
-
17
+ def add_template_pages
21
18
  # Remove linkblog pages if the octopress-linkblog plugin isn't installed
22
-
23
- unless defined? Octopress::Linkblog
24
- @pages.reject! do |p|
25
- p.file =~ /(article|link)/
19
+ if multilingual?
20
+ # Add pages for other languages
21
+ Octopress::Multilingual.languages.each do |lang|
22
+ add_feeds(lang)
26
23
  end
24
+ else
25
+ add_feeds
27
26
  end
27
+ end
28
28
 
29
- @pages.sort_by! {|p| p.path.size }
29
+ def add_feeds(lang=nil)
30
30
 
31
- if defined?(Octopress::Multilingual) && Octopress.site.config['lang']
31
+ lang = nil unless multilingual?
32
32
 
33
- # Add default language to main feeds
34
- @pages.each do |page|
35
- lang = Octopress.site.config['lang']
36
- page.data.merge!({'lang' => lang})
37
- page.permalink ||= lang_permalink(page, lang)
38
- end
33
+ config = self.config(lang)
34
+ files = ['main.xml']
39
35
 
40
- # Ensure multilingual pages are set up for `ink list` view
41
- Octopress.site.read if Octopress.site.posts.empty?
36
+ if defined? Octopress::Linkblog
37
+ files.concat %w{links.xml articles.xml}
38
+ end
42
39
 
43
- # Add pages for other languages
44
- Octopress::Multilingual.languages.each do |lang|
45
- next if lang == Octopress::Multilingual.main_language
46
- @pages.concat add_lang_pages(lang)
47
- end
40
+ files.each do |file|
41
+ add_template_page(file, permalink(file, lang), {
42
+ 'lang' => lang,
43
+ 'feed_type' => feed_type(file)
44
+ })
48
45
  end
49
- end
50
46
 
51
- def lang_permalink(page, lang)
52
- File.join("/#{lang}", "feed", feed_url(page), '/')
47
+ if config['category_feeds']
48
+ add_category_feeds(config, lang)
49
+ end
53
50
  end
54
51
 
55
- def add_lang_pages(lang)
56
- lang_pages = []
57
-
58
- # For each page template, create a new page, and configure its permalink defaults
59
- #
60
- @pages.each do |page|
61
- # New name for permalink settings in plugin config.yml
62
- permalink_name = "#{page.permalink_name}_#{lang}"
52
+ def add_category_feeds(config, lang)
53
+ categories = Array(config['categories'])
63
54
 
64
- # Set the permalink default to /[lang]/feed/[type]
65
- permalink = File.join("/#{lang}", "feed", feed_url(page), '/')
66
-
67
- # Create a copy of the page
68
- lang_pages << begin
69
- p = page.clone(permalink, permalink_name).merge_data({'lang'=>lang})
55
+ if categories.empty?
56
+ if lang
57
+ categories = Octopres::Multilingual.categories_by_language(lang).keys
58
+ else
59
+ categories = Octopress.site.categories.keys
70
60
  end
71
61
  end
72
62
 
73
- lang_pages.sort_by {|p| p.path.size }
63
+ categories.each do |category|
64
+ category = category.downcase
65
+ dir = config['permalinks']['category'].sub('category.name', category)
66
+ permalink = File.join(lang || '', dir, 'index.xml')
67
+ add_template_page('category.xml', permalink, {
68
+ 'lang' => lang,
69
+ 'category' => category,
70
+ 'feed_type' => 'category'
71
+ })
72
+ end
74
73
  end
75
74
 
76
- def feed_url(page)
77
- case feed_type(page)
78
- when 'article'; 'articles'
79
- when 'link'; 'links'
80
- else ''
75
+ def permalink(template, lang)
76
+ type = feed_type(template)
77
+ url = File.join(lang || '', config(lang)['permalinks'][type])
78
+
79
+ # Allow permalinks to specify a filename (ugh, if you must…)
80
+ unless File.extname(url) == '.xml'
81
+ url = File.join(url, 'index.xml')
81
82
  end
83
+
84
+ url
82
85
  end
83
86
 
84
- def feed_type(page)
85
- if page.file =~ /article/
86
- 'article'
87
- elsif page.file =~ /link/
88
- 'link'
87
+ # Discern feed type based on filename
88
+ def feed_type(template)
89
+ if template =~ /articles/
90
+ 'articles'
91
+ elsif template =~ /links/
92
+ 'links'
89
93
  else
90
94
  'main'
91
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-feeds
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-15 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octopress-ink
@@ -161,16 +161,13 @@ files:
161
161
  - LICENSE.txt
162
162
  - README.md
163
163
  - assets/config.yml
164
- - assets/includes/article-feed.xml
165
164
  - assets/includes/entry.xml
166
165
  - assets/includes/head.xml
167
- - assets/includes/link-feed.xml
168
- - assets/includes/main-feed.xml
169
- - assets/pages/articles.xml
170
- - assets/pages/links.xml
171
- - assets/pages/main.xml
166
+ - assets/templates/articles.xml
167
+ - assets/templates/category.xml
168
+ - assets/templates/links.xml
169
+ - assets/templates/main.xml
172
170
  - lib/octopress-feeds.rb
173
- - lib/octopress-feeds/config-asset.rb
174
171
  - lib/octopress-feeds/tags.rb
175
172
  - lib/octopress-feeds/version.rb
176
173
  homepage: https://github.com/octopress/feeds
@@ -1,5 +0,0 @@
1
- ---
2
- permalink: /feed/articles/
3
- feed: true
4
- ---
5
- {% include feeds:article-feed.xml %}
@@ -1,5 +0,0 @@
1
- ---
2
- permalink: /feed/links/
3
- feed: true
4
- ---
5
- {% include feeds:link-feed.xml %}
@@ -1,5 +0,0 @@
1
- ---
2
- permalink: /feed/
3
- feed: true
4
- ---
5
- {% include feeds:main-feed.xml %}
@@ -1,25 +0,0 @@
1
- module Octopress
2
- module Feeds
3
- class Config < Ink::Assets::Config
4
- def read
5
- config = super
6
- if defined? Octopress::Multilingual
7
- config = Jekyll::Utils.deep_merge_hashes(multilingual_permalinks, config)
8
- end
9
- config
10
- end
11
-
12
- def multilingual_permalinks
13
- if lang = Octopress.site.config['lang']
14
- { "permalinks" => {
15
- "main" => "/#{lang}/feed/",
16
- "links" => "/#{lang}/feed/links/",
17
- "articles" => "/#{lang}/feed/articles/"
18
- }}
19
- else
20
- {}
21
- end
22
- end
23
- end
24
- end
25
- end