octopress-ink 1.0.0.rc.49 → 1.0.0.rc.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4858b7de639dfc2e080960481b60d2e3b35c809
4
- data.tar.gz: 748629f2f8af0d24a45fe78025106eb9c6cd4b57
3
+ metadata.gz: ce4c7acfb6d35fa4fbef2bd55517ea7afe07c152
4
+ data.tar.gz: 11699fa14d7a02824d0d19dd06ba50d0e202195a
5
5
  SHA512:
6
- metadata.gz: 71f5e690c1ca468c8e14f8ab3770cc53b0fb2cfecf7379ca4be5ca11106de7a61acc46172571e69bfcc9bdc5e14b98427f236e198d91f19d92355b69f84c360b
7
- data.tar.gz: 329f7932850c832ced252c2fd5103c45c9965c78528d4aee906bb303f919b9858b58c350c53407bc2c86375bc9328160fa0b5e500f6ca448dc7ba10011ac1acf
6
+ metadata.gz: f1799a7689945f7ca5f44474c7ab83261c267826bfcbee3078fa6ab9cbac01255acecd68b52dc766e8b616a57ac4c89512d9b2a7696ab1e01fc5f58ba27d95ea
7
+ data.tar.gz: 370063e56a406ef072e2e9032ebef830930529c2384fd0523d1a55ed803bc1f75d734476fe881c9c5550df31a0b79f31663143fb16ddf841e7f20a494883b115
data/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # Changelog
2
2
 
3
- ### 1.0.0 RC49 - 2015-03-02
3
+ ### 1.0.0 RC50 - 2015-03-04
4
+ - Improved information about disabled or overridden assets on `ink list plugin` commands
5
+ - Reworked plugin bootstrap to use templates instead of pages
6
+ - Removed page clone method (templates should be used for this)
4
7
 
8
+ ### 1.0.0 RC49 - 2015-03-02
5
9
  - New: Plugin bootstrap allows plugins to work with templates for post indexes and RSS feeds. Each with automatic support for multilingual sites.
6
10
 
7
11
  Plugins can add pages and templates for:
@@ -2,11 +2,10 @@ module Octopress
2
2
  module Ink
3
3
  module Assets
4
4
  class Asset
5
- attr_reader :plugin, :dir, :base, :root, :file, :overridden
5
+ attr_reader :plugin, :dir, :base, :root, :file, :replacement
6
6
  attr_accessor :exists
7
7
 
8
8
  FRONT_MATTER = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
9
- @overridden = false
10
9
 
11
10
  def initialize(plugin, base, file)
12
11
  @file = file
@@ -19,16 +18,22 @@ module Octopress
19
18
  end
20
19
 
21
20
  def info
21
+ " - #{asset_info}"
22
+ end
23
+
24
+ def asset_info
22
25
  message = filename.ljust(35)
23
- if @overridden
24
- message += "-overridden by #{@overridden}-"
26
+
27
+ if replaced?
28
+ message += "Replaced by #{@replacement} plugin"
25
29
  elsif disabled?
26
- message += "-disabled-"
30
+ message += "Disabled by configuration"
27
31
  elsif path.to_s != plugin_path
28
32
  shortpath = File.join(Plugins.custom_dir.sub(Dir.pwd,''), dir).sub('/','')
29
- message += "from: #{File.join(shortpath,filename).sub('/./', '/')}"
33
+ message += "From: #{File.join(shortpath,filename)}"
30
34
  end
31
- " - #{message}"
35
+
36
+ message
32
37
  end
33
38
 
34
39
  def filename
@@ -36,7 +41,15 @@ module Octopress
36
41
  end
37
42
 
38
43
  def disabled?
39
- is_disabled(base, filename) || @overridden
44
+ @disabled || is_disabled(base, filename) || replaced?
45
+ end
46
+
47
+ def replaced?
48
+ !@replacement.nil?
49
+ end
50
+
51
+ def disable
52
+ @disabled = true
40
53
  end
41
54
 
42
55
  def is_disabled(base, file)
@@ -44,10 +57,6 @@ module Octopress
44
57
  config.include?(base) || config.include?(File.join(base, filename))
45
58
  end
46
59
 
47
- def override(plugin)
48
- @overridden = plugin.name
49
- end
50
-
51
60
  def path
52
61
  if @found_file
53
62
  @found_file
@@ -6,7 +6,7 @@ module Octopress
6
6
  module Assets
7
7
  class PageAsset < Asset
8
8
  attr_reader :filename
9
- attr_accessor :data, :permalink_name, :cloned, :clone_of
9
+ attr_accessor :data, :permalink_name
10
10
 
11
11
  def initialize(plugin, base, file)
12
12
  @root = plugin.assets_path
@@ -31,14 +31,6 @@ module Octopress
31
31
  end
32
32
  end
33
33
 
34
- def clone(data={})
35
- self.cloned = true
36
- p = PageAsset.new(plugin, base, file)
37
- p.clone_of = self
38
- p.data = data
39
- p
40
- end
41
-
42
34
  def merge_data(data={})
43
35
  page.data.merge!(data)
44
36
  end
@@ -68,26 +60,12 @@ module Octopress
68
60
  end
69
61
 
70
62
  page.data.merge!(@data)
63
+ page.plugin = plugin
71
64
 
72
65
  page
73
66
  end
74
67
  end
75
68
 
76
- def info
77
- message = super
78
- return message if disabled?
79
-
80
- if clone_of
81
- " #{permalink}"
82
- elsif cloned
83
- message << "\n #{permalink}"
84
- else
85
- name = permalink_name << page.ext
86
- message.sub!(/#{filename}\s*/, name.ljust(35))
87
- message.ljust(25) << permalink
88
- end
89
- end
90
-
91
69
  def permalink
92
70
  page.url
93
71
  end
@@ -7,25 +7,24 @@ module Octopress
7
7
  def initialize(*args)
8
8
  super(*args)
9
9
  @pages = []
10
+ @existing_pages = {}
10
11
  end
11
12
 
12
13
  def add; end
13
14
 
14
15
  def info
15
- message = filename.ljust(35)
16
-
17
- if disabled?
18
- message += "-disabled-"
19
- elsif path.to_s != plugin_path
20
- shortpath = File.join(Plugins.custom_dir.sub(Dir.pwd,''), dir).sub('/','')
21
- message += "from: #{shortpath}/#{filename}"
16
+ message = " - #{asset_info}\n"
17
+
18
+ unless disabled?
19
+ self.pages.each do |page|
20
+ if existing_page = @existing_pages[page.url]
21
+ message << " #{page.url.ljust(33)} Disabled: /#{existing_page.path} already exists\n"
22
+ else
23
+ message << " #{page.url}\n"
24
+ end
25
+ end
22
26
  end
23
27
 
24
- message = " - #{message}\n"
25
-
26
- self.pages.each do |page|
27
- message << " #{page.url}\n"
28
- end
29
28
  message
30
29
  end
31
30
 
@@ -33,10 +32,23 @@ module Octopress
33
32
  return if disabled?
34
33
  page = Ink::Page.new(Octopress.site, File.dirname(self.path), '.', File.basename(self.path))
35
34
  page.data.merge!(data)
36
-
35
+ page.plugin = plugin
37
36
  self.pages << page
38
37
 
39
- page
38
+ if existing_page = page_exists?(page)
39
+ if existing_page.respond_to?(:plugin)
40
+ @replacement = existing_page.plugin.name
41
+ else
42
+ @existing_pages[existing_page.url] = existing_page
43
+ end
44
+ false
45
+ else
46
+ page
47
+ end
48
+ end
49
+
50
+ def page_exists?(page)
51
+ Octopress.site.pages.find {|p| p.url == page.url}
40
52
  end
41
53
  end
42
54
  end
@@ -2,7 +2,7 @@ module Octopress
2
2
  module Ink
3
3
  class Page < Jekyll::Page
4
4
  include Ink::Convertible
5
- attr_accessor :dir, :name
5
+ attr_accessor :dir, :name, :plugin
6
6
 
7
7
  def relative_asset_path
8
8
  site_source = Pathname.new Octopress.site.source
@@ -8,61 +8,49 @@ module Octopress
8
8
  # All with multilingual support.
9
9
  #
10
10
 
11
- def self.reset
12
- @pages = {}
13
- @categories = {}
14
- @tags = {}
15
- @feeds = {}
16
- end
17
-
18
- def self.pages
19
- @pages
20
- end
21
-
22
- def self.categories
23
- @categories
24
- end
25
-
26
- def self.tags
27
- @tags
28
- end
29
-
30
- def self.feeds
31
- @feeds
32
- end
11
+ class << self
12
+ attr_reader :pages, :categories, :tags, :feeds
13
+
14
+ def reset
15
+ @pages = {}
16
+ @categories = {}
17
+ @tags = {}
18
+ @feeds = {}
19
+ end
33
20
 
34
- def self.page(lang, type, key)
35
- @pages[type][key]
36
- end
21
+ def page(lang, type, key)
22
+ @pages[type][key]
23
+ end
37
24
 
38
- def self.category(category, lang)
39
- category = "#{category}_#{page.lang}" if Octopress.multilingual? && page.lang
40
- @categories[category]
41
- end
25
+ def category(category, lang)
26
+ category = "#{category}_#{page.lang}" if Octopress.multilingual? && page.lang
27
+ @categories[category]
28
+ end
42
29
 
43
- def self.tag(category, lang)
44
- tag = "#{tag}_#{page.lang}" if Octopress.multilingual? && page.lang
45
- @tags[tag]
46
- end
30
+ def tag(category, lang)
31
+ tag = "#{tag}_#{page.lang}" if Octopress.multilingual? && page.lang
32
+ @tags[tag]
33
+ end
47
34
 
48
- def self.add_page(page, key=nil)
49
- if @pages[page.url].nil?
50
- @pages[page.url] = page
51
-
52
- url = page.url.sub(/index.(xml|html)/, '')
53
-
54
- if key == 'feeds'
55
- @feeds[url] = page.data['title']
56
- elsif key == 'tag'
57
- tag = page.data[key]
58
- tag = "#{tag}_#{page.lang}" if Octopress.multilingual? && page.lang
59
- @tags[tag] = url
60
- elsif key == 'category'
61
- category = page.data[key]
62
- category = "#{category}_#{page.lang}" if Octopress.multilingual? && page.lang
63
- @categories[category] = url
35
+ def add_page(page, key=nil)
36
+ if @pages[page.url].nil?
37
+ @pages[page.url] = page
38
+
39
+ url = page.url.sub(/index.(xml|html)/, '')
40
+
41
+ if key == 'feeds'
42
+ @feeds[url] = page.data['title']
43
+ elsif key == 'tag'
44
+ tag = page.data[key]
45
+ tag = "#{tag}_#{page.lang}" if Octopress.multilingual? && page.lang
46
+ @tags[tag] = url
47
+ elsif key == 'category'
48
+ category = page.data[key]
49
+ category = "#{category}_#{page.lang}" if Octopress.multilingual? && page.lang
50
+ @categories[category] = url
51
+ end
52
+ page
64
53
  end
65
- page
66
54
  end
67
55
  end
68
56
 
@@ -71,7 +59,6 @@ module Octopress
71
59
  def bootstrap_plugin
72
60
  register_templates
73
61
  inject_configs
74
- add_page_metadata
75
62
 
76
63
  # Add pages for other languages
77
64
  if Octopress.multilingual?
@@ -84,8 +71,8 @@ module Octopress
84
71
  def register_templates
85
72
  # Find pages and templates
86
73
 
87
- @post_index = pages.find { |p| p.filename == 'post_index.html' }
88
- @post_archive = pages.find { |p| p.filename == 'post_archive.html' }
74
+ @post_index = templates.find { |p| p.filename == 'post_index.html' }
75
+ @post_archive = templates.find { |p| p.filename == 'post_archive.html' }
89
76
  @main_feed = templates.find { |p| p.filename == 'main_feed.xml' }
90
77
  @articles_feed = templates.find { |p| p.filename == 'articles_feed.xml' }
91
78
  @links_feed = templates.find { |p| p.filename == 'links_feed.xml' }
@@ -132,19 +119,6 @@ module Octopress
132
119
  opt_config
133
120
  end
134
121
 
135
- def add_page_metadata
136
- [post_index, post_archive].compact.each do |page|
137
- page.page.data['title'] ||= page_title(page.page, config)
138
- if Octopress.multilingual?
139
- page.page.data['lang'] = Octopress.site.config['lang']
140
- end
141
-
142
- unless Bootstrap.add_page(page)
143
- page.override Bootstrap.pages[page.url].plugin
144
- end
145
- end
146
- end
147
-
148
122
  # Automatically clone pages or generate templates
149
123
  #
150
124
  # This will only occur if:
@@ -161,10 +135,8 @@ module Octopress
161
135
 
162
136
  # Only clone these pages for additional languages
163
137
  #
164
- if Octopress.multilingual? && Octopress.site.config['lang'] != lang
165
- add_indexes(config, lang, post_index)
166
- add_indexes(config, lang, post_archive)
167
- end
138
+ add_indexes(config, lang, post_index)
139
+ add_indexes(config, lang, post_archive)
168
140
 
169
141
  add_feeds(config, lang, main_feed)
170
142
 
@@ -177,33 +149,42 @@ module Octopress
177
149
  add_meta_indexes(config, lang, 'tag', 'tags')
178
150
  end
179
151
 
180
- def add_indexes(config, lang, page)
181
- if new_page = clone_page(page, lang)
182
- if Bootstrap.add_page(new_page)
183
- @pages << new_page
184
- end
152
+ def add_indexes(config, lang, template)
153
+ return if template.nil?
154
+
155
+ permalink = page_permalink(template, lang)
156
+ title = page_title(template, config, lang)
157
+
158
+ if page = template.new_page({
159
+ 'lang' => lang,
160
+ 'title' => title,
161
+ 'permalink' => permalink
162
+ })
163
+
164
+ Bootstrap.add_page(page)
165
+ Octopress.site.pages << page
185
166
  end
186
167
  end
187
168
 
188
- def add_feeds(config, lang, feed_template)
189
- if feed_template
190
- type = feed_type(feed_template)
191
- if page = feed_template.new_page({
192
- 'lang' => lang,
193
- 'feed_type' => type,
194
- 'permalink' => lang_permalink(lang, config['permalinks']["#{type}_feed"]),
195
- 'plugin' => self
196
- })
169
+ def add_feeds(config, lang, template)
170
+ return if template.nil?
197
171
 
198
- page.data['title'] = page_title(page, config)
172
+ permalink = page_permalink(template, lang)
199
173
 
200
- if Bootstrap.add_page(page, "feeds")
201
- Octopress.site.pages << page
202
- else
203
- feed_template.pages.delete(page)
204
- end
205
- end
174
+ if page = template.new_page({
175
+ 'lang' => lang,
176
+ 'permalink' => permalink,
177
+ 'title' => page_title(template, config, lang),
178
+ 'feed_type' => feed_type(template),
179
+ 'plugin' => self
180
+ })
181
+
182
+
183
+ Bootstrap.add_page(page, "feeds")
184
+ Octopress.site.pages << page
206
185
  end
186
+
187
+ page
207
188
  end
208
189
 
209
190
  # Generates tag or category index or feed pages for each category and language
@@ -234,88 +215,83 @@ module Octopress
234
215
 
235
216
  collection.each do |item|
236
217
  item = item.downcase
218
+ item_label = tag_or_category_display_label(item, config)
237
219
 
238
220
  # Only add pages if plugin has a feed template for this item
239
221
  # and it hasn't been disabled in the configuration
240
222
  #
241
- if page_template && config["#{type}_indexes"] != false
242
- permalink = lang_permalink(lang, config['permalinks']["#{type}_index"]).sub(":#{type}", item)
243
-
244
- page = page_template.new_page({
245
- 'lang' => lang,
246
- "#{type}" => item,
247
- 'permalink' => permalink,
248
- 'plugin' => self
249
- })
250
-
251
- page.data['title'] = page_title(page, config)
252
- if Bootstrap.add_page(page, type)
253
- Octopress.site.pages << page
223
+ if page_template
224
+ if config["#{type}_indexes"] == false
225
+ page_template.disable
254
226
  else
255
- page_template.pages.delete(page)
227
+ permalink = page_permalink(page_template, lang).sub(":#{type}", item)
228
+
229
+ if page = page_template.new_page({
230
+ 'lang' => lang,
231
+ "#{type}" => item,
232
+ 'title' => page_title(page_template, config, lang).sub(":#{type}", item_label),
233
+ 'permalink' => permalink,
234
+ 'plugin' => self
235
+ })
236
+
237
+ Bootstrap.add_page(page, type)
238
+ Octopress.site.pages << page
239
+ end
256
240
  end
257
241
  end
258
242
 
259
243
  # Only add feeds if plugin has a feed template for this item
260
244
  # and it hasn't been disabled in the configuration
261
245
  #
262
- if feed_template && config["#{type}_feeds"] != false
263
- permalink = lang_permalink(lang, config['permalinks']["#{type}_feed"]).sub(":#{type}", item)
264
-
265
- page = feed_template.new_page({
266
- 'lang' => lang,
267
- "#{type}" => item,
268
- 'feed_type' => type,
269
- 'permalink' => permalink,
270
- 'plugin' => self
271
- })
272
-
273
- page.data['title'] = page_title(page, config)
274
- if Bootstrap.add_page(page, 'feeds')
275
- Octopress.site.pages << page
246
+ if feed_template
247
+
248
+ if config["#{type}_feeds"] == false
249
+ feed_template.disable
276
250
  else
277
- feed_template.delete(page)
251
+ permalink = page_permalink(feed_template, lang).sub(":#{type}", item)
252
+
253
+ if page = feed_template.new_page({
254
+ 'lang' => lang,
255
+ "#{type}" => item,
256
+ 'title' => page_title(feed_template, config, lang).sub(":#{type}", item_label),
257
+ 'permalink' => permalink,
258
+ 'feed_type' => type,
259
+ 'plugin' => self
260
+ })
261
+
262
+ Bootstrap.add_page(page, 'feeds')
263
+ Octopress.site.pages << page
264
+ end
278
265
  end
279
266
  end
280
267
  end
281
268
  end
282
269
 
283
- # Creates a copy of an Ink Page asset
284
- # configuring lang and permalink accordingly
285
- #
286
- def clone_page(page, lang)
287
- return if page.nil?
288
- new_page = page.clone({
289
- 'lang' => lang,
290
- 'permalink' => page_permalink(page, lang)
291
- })
292
-
293
- new_page.page.data['title'] = page_title(new_page.page, config(lang))
294
- new_page.permalink_name = nil
295
- new_page
296
- end
297
-
298
- # Ensure cloned pages have language in their permalinks
299
- # Since pages are only cloned for multilingual sites
270
+ # Ensure pages have language in their permalinks except the primary language pages
271
+ # Unless the user has specified /:lang/ in their permalink config
300
272
  #
301
273
  def page_permalink(page, lang)
302
- permalink = config(lang)['permalinks'][page.permalink_name]
274
+ permalink = config(lang)['permalinks'][page_type(page)]
303
275
 
304
- if permalink.include?(":lang")
276
+ # Obey the permalink configuration
277
+ permalink = if lang && permalink.include?(":lang")
305
278
  permalink.sub(":lang", lang)
306
- else
279
+
280
+ # Otherwise only add lang for secondary languages
281
+ elsif lang && lang != Octopress.site.config['lang']
307
282
  File.join("/#{lang}", permalink)
308
- end
309
- end
310
283
 
311
- # Ensure language is set in permalink if language is defined
312
- #
313
- def lang_permalink(lang, permalink)
314
- if lang
315
- permalink.sub(":lang", lang)
284
+ # Finally strip language from url if primary language or no language defined
316
285
  else
317
286
  permalink.sub("/:lang/", '/')
318
287
  end
288
+
289
+ if permalink.end_with?('/')
290
+ ext = File.extname(page.path).match('xml') ? 'xml' : 'html'
291
+ permalink += "index.#{ext}"
292
+ end
293
+
294
+ permalink
319
295
  end
320
296
 
321
297
 
@@ -349,7 +325,8 @@ module Octopress
349
325
  end
350
326
  end
351
327
 
352
- def generic_title(type, config, lang=nil)
328
+ def page_title(page, config, lang)
329
+ type = page_type(page)
353
330
  title = config['titles'][type]
354
331
  title = title.sub(':site_name', Octopress.site.config['name'] || '')
355
332
  if lang && Octopress.multilingual?
@@ -358,21 +335,8 @@ module Octopress
358
335
  title
359
336
  end
360
337
 
361
- def page_title(page, config)
362
- type = page_type(page)
363
- title = generic_title(type, config, page.lang)
364
-
365
- if type.match(/(category|tag)/)
366
- key = type.sub(/_index|_feed/, '')
367
- label = tag_or_category_label(page, key, config)
368
- title = title.sub(":#{key}", label)
369
- end
370
-
371
- title
372
- end
373
-
374
- def tag_or_category_label(page, type, config)
375
- label = page.data[type].capitalize
338
+ def tag_or_category_display_label(label, config)
339
+ label = label.capitalize
376
340
 
377
341
  if labels = config["#{type}_labels"]
378
342
  label = labels[type] || label
@@ -11,7 +11,7 @@ module Octopress
11
11
  end
12
12
 
13
13
  def tag(url, title)
14
- "<link href='#{url.sub('index.xml', '')}' title='#{title}' rel='alternate' type='application/atom+xml'>"
14
+ "<link href='#{File.join('/', Octopress.site.config['baseurl'], url).sub('index.xml', '')}' title='#{title}' rel='alternate' type='application/atom+xml'>"
15
15
  end
16
16
  end
17
17
  end
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Ink
3
- VERSION = "1.0.0.rc.49"
3
+ VERSION = "1.0.0.rc.50"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-ink
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc.49
4
+ version: 1.0.0.rc.50
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-03-03 00:00:00.000000000 Z
11
+ date: 2015-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll