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 +4 -4
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/features/cli.feature +1 -1
- data/jekyll-shorts.gemspec +1 -1
- data/lib/jekyll-shorts/generator.rb +9 -3
- data/lib/jekyll-shorts/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f5bac761a44799decc825865e2358b45fece80d82d5b42d42f5e0afd86e48d9
|
4
|
+
data.tar.gz: 31c24b5d3621b716cfb9963eb27c90e0c761c45c122db3342f81755dcab9fcf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
data/jekyll-shorts.gemspec
CHANGED
@@ -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.
|
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
|
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("
|
101
|
+
Jekyll.logger.debug("Short URL created from #{path.inspect} to #{@long.inspect}")
|
96
102
|
end
|
97
103
|
true
|
98
104
|
end
|