tomafro-jekyll 0.5.3.2 → 0.5.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,19 +28,6 @@ module Jekyll
28
28
  def number_of_words(input)
29
29
  input.split.length
30
30
  end
31
-
32
- def ordinalize(number)
33
- if (11..13).include?(number.to_i % 100)
34
- "#{number}th"
35
- else
36
- case number.to_i % 10
37
- when 1; "#{number}st"
38
- when 2; "#{number}nd"
39
- when 3; "#{number}rd"
40
- else "#{number}th"
41
- end
42
- end
43
- end
44
31
 
45
32
  def array_to_sentence_string(array)
46
33
  connector = "and"
@@ -55,6 +42,20 @@ module Jekyll
55
42
  "#{array[0...-1].join(', ')}, #{connector} #{array[-1]}"
56
43
  end
57
44
  end
58
-
45
+
46
+ # Stolen from ActiveSupport
47
+
48
+ def ordinalize(number)
49
+ if (11..13).include?(number.to_i % 100)
50
+ "#{number}th"
51
+ else
52
+ case number.to_i % 10
53
+ when 1; "#{number}st"
54
+ when 2; "#{number}nd"
55
+ when 3; "#{number}rd"
56
+ else "#{number}th"
57
+ end
58
+ end
59
+ end
59
60
  end
60
61
  end
data/lib/jekyll/page.rb CHANGED
@@ -87,15 +87,19 @@ module Jekyll
87
87
  def write(dest_prefix, dest_suffix = nil)
88
88
  dest = File.join(dest_prefix, @dir)
89
89
  dest = File.join(dest, dest_suffix) if dest_suffix
90
- FileUtils.mkdir_p(dest)
91
-
90
+
92
91
  # The url needs to be unescaped in order to preserve the correct filename
93
92
  path = File.join(dest, CGI.unescape(self.url))
94
93
  if self.ext == '.html' && self.url[/\.html$/].nil?
95
- FileUtils.mkdir_p(path)
96
- path = File.join(path, "index.html")
94
+ if site.pretty_style == :html_extension
95
+ path = path + ".html"
96
+ else
97
+ path = File.join(path, "index.html")
98
+ end
97
99
  end
98
100
 
101
+ FileUtils.mkdir_p(File.dirname(path))
102
+
99
103
  File.open(path, 'w') do |f|
100
104
  f.write(self.output)
101
105
  end
data/lib/jekyll/post.rb CHANGED
@@ -200,7 +200,8 @@ module Jekyll
200
200
  path = File.join(dest, CGI.unescape(self.url))
201
201
 
202
202
  if template[/\.html$/].nil?
203
- path = "#{path}.html"
203
+ FileUtils.mkdir_p(path)
204
+ path = File.join(path, "index.html")
204
205
  end
205
206
 
206
207
  File.open(path, 'w') do |f|
data/lib/jekyll/site.rb CHANGED
@@ -2,7 +2,7 @@ module Jekyll
2
2
 
3
3
  class Site
4
4
  attr_accessor :config, :layouts, :posts, :categories, :exclude,
5
- :source, :dest, :lsi, :pygments, :permalink_style, :tags
5
+ :source, :dest, :lsi, :pygments, :permalink_style, :pretty_style, :tags
6
6
 
7
7
  # Initialize the site
8
8
  # +config+ is a Hash containing site configurations details
@@ -17,7 +17,7 @@ module Jekyll
17
17
  self.pygments = config['pygments']
18
18
  self.permalink_style = config['permalink'].to_sym
19
19
  self.exclude = config['exclude'] || []
20
-
20
+ self.pretty_style = (config['pretty_style'] && config['pretty_style'].to_sym) || :index_page
21
21
  self.reset
22
22
  self.setup
23
23
  end
data/test/test_filters.rb CHANGED
@@ -45,11 +45,17 @@ class TestFilters < Test::Unit::TestCase
45
45
  should "escape special characters" do
46
46
  assert_equal "hey%21", @filter.cgi_escape("hey!")
47
47
  end
48
-
48
+
49
49
  should "ordinalize numbers" do
50
50
  assert_equal "1st", @filter.ordinalize(1)
51
- assert_equal "113th", @filter.ordinalize(113)
52
- assert_equal "502nd", @filter.ordinalize(502)
51
+ assert_equal "22nd", @filter.ordinalize(22)
52
+ assert_equal "423rd", @filter.ordinalize(423)
53
+ end
54
+
55
+ should "ordinalize numbers in strings" do
56
+ assert_equal "1st", @filter.ordinalize("1")
57
+ assert_equal "22nd", @filter.ordinalize("22")
58
+ assert_equal "423rd", @filter.ordinalize("423")
53
59
  end
54
60
  end
55
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomafro-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3.2
4
+ version: 0.5.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner