middleman-blog-ymd 0.0.2 → 0.0.3
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 +4 -4
- data/lib/middleman-blog-ymd/version.rb +3 -0
- data/lib/middleman-blog-ymd/ymdtree.rb +42 -0
- data/lib/middleman-blog-ymd.rb +48 -0
- data/lib/middleman-extension.rb +1 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22ab466f43a9c4c9d062a75c02f5ee57f8865491
|
4
|
+
data.tar.gz: fd29f7c7dd01345c2bb08a603571ca795cb58064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f93ad4966af5ba0fc9cea6e4d1994f535666ae45a3ffabc2839d31d4cd9ba047f68ff85d8385ad899b670b761c26f8854bd72479c4e2337858370e7e49b332d5
|
7
|
+
data.tar.gz: e9a75018c27a4b9d349991eeb0762b4a364be5d1910cae63d21d62061433b1d25c61c0ab7eede799bef6d993e208c9e05d67423bff07d40ab7cb1ac888cfa306
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Ymdtree
|
2
|
+
@hash = Hash.new{|h, k| h[k] = Hash.new(&h.default_proc) }
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def hash
|
6
|
+
return @hash
|
7
|
+
end
|
8
|
+
def add(y , m , d)
|
9
|
+
@hash[y][m][d] = true
|
10
|
+
end
|
11
|
+
def years
|
12
|
+
@hash.keys
|
13
|
+
end
|
14
|
+
def months_of( y )
|
15
|
+
@hash[y].keys
|
16
|
+
end
|
17
|
+
def days_of( y, m )
|
18
|
+
@hash[y][m].keys
|
19
|
+
end
|
20
|
+
def next_month( y , m)
|
21
|
+
month_array = @hash[y].to_a
|
22
|
+
m_idx = month_array.index(m)
|
23
|
+
if m_idx == ( m_idx.length - 1 )
|
24
|
+
return false
|
25
|
+
else
|
26
|
+
return month_array[ m_idx + 1 ]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
def previous_month( y , m)
|
30
|
+
p @hash
|
31
|
+
p y
|
32
|
+
month_array = @hash[y].to_a
|
33
|
+
p month_array
|
34
|
+
m_idx = month_array.index(m)
|
35
|
+
if m_idx == 0
|
36
|
+
return false
|
37
|
+
else
|
38
|
+
return month_array[ m_idx - 1 ]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "middleman-blog"
|
2
|
+
require "middleman-blog-ymd/version"
|
3
|
+
require "middleman-blog-ymd/ymdtree"
|
4
|
+
|
5
|
+
def collect_articles_ymds
|
6
|
+
blog.articles.each{|article|
|
7
|
+
if article.path =~ /^(\d+)\/(\d+)\/(\d+)_/
|
8
|
+
year_value = $1
|
9
|
+
month_value = $2
|
10
|
+
day_value = $3.to_s[4..5].to_i
|
11
|
+
Ymdtree.add(year_value, month_value, day_value)
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
class YmdExtension < ::Middleman::Extension
|
16
|
+
def initialize(app, options_hash={}, &block)
|
17
|
+
# Call super to build options from the options_hash
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def manipulate_resource_list(resources)
|
22
|
+
p ::Middleman:BlogExtension.data
|
23
|
+
end
|
24
|
+
|
25
|
+
helpers do
|
26
|
+
def ymdtree
|
27
|
+
return YMDTree
|
28
|
+
end
|
29
|
+
|
30
|
+
def blog_years
|
31
|
+
return YMDTree.years
|
32
|
+
end
|
33
|
+
|
34
|
+
def blog_year_month_hash
|
35
|
+
ymhash = Hash.new
|
36
|
+
YMDTree.hash.each{ |k, v|
|
37
|
+
ymhash[k] = v.keys
|
38
|
+
}
|
39
|
+
return ymhash
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
::Middleman::Extensions.register(:ymd_extension, YmdExtension)
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require "middleman-blog-ymd"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-blog-ymd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- niceume
|
@@ -64,6 +64,10 @@ files:
|
|
64
64
|
- LICENSE.txt
|
65
65
|
- README.md
|
66
66
|
- Rakefile
|
67
|
+
- lib/middleman-blog-ymd.rb
|
68
|
+
- lib/middleman-blog-ymd/version.rb
|
69
|
+
- lib/middleman-blog-ymd/ymdtree.rb
|
70
|
+
- lib/middleman-extension.rb
|
67
71
|
- middleman-blog-ymd.gemspec
|
68
72
|
homepage: ''
|
69
73
|
licenses:
|