jekyll-shorts 0.0.6 → 0.0.8

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
  SHA256:
3
- metadata.gz: b0865d5612007eb2f21897da52685a97e6555f305a34546f43541a7710349028
4
- data.tar.gz: e0555698b8f494dbd5f8f77bb1d6974aebac77ef91deef65db05ecf53877ea71
3
+ metadata.gz: 2f5bac761a44799decc825865e2358b45fece80d82d5b42d42f5e0afd86e48d9
4
+ data.tar.gz: 31c24b5d3621b716cfb9963eb27c90e0c761c45c122db3342f81755dcab9fcf4
5
5
  SHA512:
6
- metadata.gz: 99e93ff62eb54a5b88d7ce55dc94f662db5ea3956bd8fdf2d18990e4bb87f498e4a3ef991ab585a5aa08f55c89856d707013f0b2f24489ab5937250788db9116
7
- data.tar.gz: ee1717e2a2b55080afd0b6ffba8740bcb5d29aa12e4b5a731b57c59424f6fe356b611d980ba8b6c0de3e9d708d7cda15fd7076de152867a3eecb9fa152d0994a
6
+ metadata.gz: 7014fb51fdf53ac29797a39c785c88d4784fc911d82104f76d931a5d66b011f56bc54fa2d283ce6104c8b3925e06faf7fa93d62c30086f502382d34e19bffd53
7
+ data.tar.gz: cb2381f5f637fdbbc6f572e1ea72f277c94eb26344e8124ab03d4b92730e22c26f2adaa4ff98923a7f5afd1a053e6733f92db01c051e8b1ba1b060474ab2a15b
data/Gemfile CHANGED
@@ -28,6 +28,6 @@ gemspec
28
28
  gem 'cucumber', '9.1.0', require: false
29
29
  gem 'minitest', '5.22.1', require: false
30
30
  gem 'rake', '13.1.0', require: false
31
- gem 'rubocop', '1.59.0', require: false
31
+ gem 'rubocop', '1.60.2', require: false
32
32
  gem 'rubocop-rspec', '2.26.1', require: false
33
33
  gem 'simplecov', '0.22.0', require: false
data/README.md CHANGED
@@ -29,7 +29,7 @@ Here, every page in the site will get a sibling with the name
29
29
  * `:month` - the month of the post, like `01` or `12`
30
30
  * `:day` - the day of the post, like `07` or `29`
31
31
  * `:position` - the unique position of the post in the entire list of them, like `42` or `256`
32
- * `:letter` - one English letter inside a month
32
+ * `:letter` - one English letter inside a month (empty instead of `a`)
33
33
 
34
34
  Be careful with the `:position`, since it may change when you add a new post
35
35
  somewhere in the middle of existing flow of posts.
data/features/cli.feature CHANGED
@@ -96,5 +96,5 @@ Feature: Simple site building
96
96
  """
97
97
  And I build Jekyll site
98
98
  And Exit code is zero
99
- And File "_site/2301a.html" exists
99
+ And File "_site/2301.html" exists
100
100
  And File "_site/2301b.html" exists
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
29
29
  s.required_ruby_version = '>= 2.6'
30
30
  s.name = 'jekyll-shorts'
31
- s.version = '0.0.6'
31
+ s.version = '0.0.8'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Automatically generates short links for Jekyll website'
34
34
  s.description = [
@@ -50,13 +50,14 @@ class JekyllShorts::Generator < Jekyll::Generator
50
50
  long = doc.url
51
51
  month = doc.date.strftime('%Y%m')
52
52
  months[month] = 0 if months[month].nil?
53
+ raise 'Too many letters' if months[month] >= 26
53
54
  short = Jekyll::URL.new(
54
55
  template: permalink,
55
56
  placeholders: {
56
57
  'year' => doc.date.year.to_s[2..],
57
58
  'month' => doc.date.month.to_s.rjust(2, '0'),
58
59
  'day' => doc.date.day.to_s.rjust(2, '0'),
59
- 'letter' => (months[month] + 'a'.ord).chr,
60
+ 'letter' => months[month].zero? ? '' : (months[month] + 'a'.ord).chr,
60
61
  'position' => pos.to_s
61
62
  }
62
63
  ).to_s
@@ -76,11 +77,16 @@ class JekyllShorts::Generator < Jekyll::Generator
76
77
  @long = long
77
78
  end
78
79
 
80
+ def modified?
81
+ true
82
+ end
83
+
79
84
  def write(_dest)
80
85
  FileUtils.mkdir_p(File.dirname(path))
81
86
  html = "<html><head><meta charset='utf-8'/>\
82
87
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>\
83
- <meta http-equiv='refresh' content='#{@long}'/></head></html>"
88
+ <meta http-equiv='refresh' content='#{@long}'/></head>\
89
+ <body></body></html>"
84
90
  if File.exist?(path)
85
91
  before = File.read(path)
86
92
  if before != html
@@ -92,7 +98,7 @@ than before. Try to run 'jekyll clean', it will help, if you know what you are d
92
98
  end
93
99
  else
94
100
  File.write(path, html)
95
- Jekyll.logger.debug("HTML #{path.inspect} -> #{@long.inspect}")
101
+ Jekyll.logger.debug("Short URL created from #{path.inspect} to #{@long.inspect}")
96
102
  end
97
103
  true
98
104
  end
@@ -23,5 +23,5 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  module JekyllShorts
26
- VERSION = '0.0.6'
26
+ VERSION = '0.0.8'
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-shorts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko