zzot-semi-static 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/semi-static/site.rb +19 -4
- data/lib/semi-static/tags.rb +16 -2
- data/test/source/indices/tag.erb +7 -0
- data/test/test_output.rb +10 -0
- metadata +26 -2
data/VERSION.yml
CHANGED
data/lib/semi-static/site.rb
CHANGED
@@ -41,17 +41,21 @@ module SemiStatic
|
|
41
41
|
attr_reader :tags
|
42
42
|
|
43
43
|
##
|
44
|
-
#
|
44
|
+
# Template used to generate the year indices in the output site.
|
45
45
|
attr_reader :year_index
|
46
46
|
|
47
47
|
##
|
48
|
-
#
|
48
|
+
# Template used to generate the month indices in the output site.
|
49
49
|
attr_reader :month_index
|
50
50
|
|
51
51
|
##
|
52
|
-
#
|
52
|
+
# Template used to generate the day indices in the output site.
|
53
53
|
attr_reader :day_index
|
54
54
|
|
55
|
+
##
|
56
|
+
# Template used to generate the tag indices in the output site.
|
57
|
+
attr_reader :tag_index
|
58
|
+
|
55
59
|
##
|
56
60
|
# Site configuration.
|
57
61
|
attr_reader :metadata
|
@@ -178,6 +182,15 @@ module SemiStatic
|
|
178
182
|
end
|
179
183
|
end
|
180
184
|
end
|
185
|
+
|
186
|
+
unless tag_index.nil?
|
187
|
+
tags.each do |tag|
|
188
|
+
tag_index.context = tag.name
|
189
|
+
tag_index.posts = tag
|
190
|
+
FileUtils.mkdir_p tag.output_dir
|
191
|
+
File.open(tag.output_path, 'w') { |f| f.write tag_index.render }
|
192
|
+
end
|
193
|
+
end
|
181
194
|
end
|
182
195
|
end
|
183
196
|
|
@@ -275,7 +288,7 @@ module SemiStatic
|
|
275
288
|
def load_indices
|
276
289
|
return unless File.directory?(File.join(source_dir, 'indices'))
|
277
290
|
|
278
|
-
with_source_files('indices', '{year,month,day}.{haml,erb}') do |path|
|
291
|
+
with_source_files('indices', '{year,month,day,tag}.{haml,erb}') do |path|
|
279
292
|
# puts path
|
280
293
|
next unless File.file?(path)
|
281
294
|
|
@@ -288,6 +301,8 @@ module SemiStatic
|
|
288
301
|
@month_index = Index.new self, path
|
289
302
|
when 'day'
|
290
303
|
@day_index = Index.new self, path
|
304
|
+
when 'tag'
|
305
|
+
@tag_index = Index.new self, path
|
291
306
|
else
|
292
307
|
raise ArgumentError, "Unexpected index file: #{path}"
|
293
308
|
end
|
data/lib/semi-static/tags.rb
CHANGED
@@ -15,6 +15,14 @@ module SemiStatic
|
|
15
15
|
# URI for the tag's index page.
|
16
16
|
attr_reader :uri
|
17
17
|
|
18
|
+
##
|
19
|
+
# Directory path for the tag index
|
20
|
+
attr_reader :output_dir
|
21
|
+
|
22
|
+
##
|
23
|
+
# Path for the tag index
|
24
|
+
attr_reader :output_path
|
25
|
+
|
18
26
|
##
|
19
27
|
# Initializes a new Tag
|
20
28
|
def initialize(owner, name)
|
@@ -22,6 +30,8 @@ module SemiStatic
|
|
22
30
|
@name = name
|
23
31
|
@slug = Tags.slugize name
|
24
32
|
@uri = "#{owner.uri}#{slug}/"
|
33
|
+
@output_dir = "#{owner.output_dir}/#{slug}"
|
34
|
+
@output_path = "#{output_dir}/index.html"
|
25
35
|
end
|
26
36
|
end
|
27
37
|
|
@@ -32,6 +42,10 @@ module SemiStatic
|
|
32
42
|
# The URI for the collection's index page.
|
33
43
|
attr_reader :uri
|
34
44
|
|
45
|
+
##
|
46
|
+
# The output directory for the tag index pages.
|
47
|
+
attr_reader :output_dir
|
48
|
+
|
35
49
|
##
|
36
50
|
# Convert the given display name to a URL-ified one.
|
37
51
|
def self.slugize(name)
|
@@ -42,8 +56,8 @@ module SemiStatic
|
|
42
56
|
# Initializes a new collection with the given name
|
43
57
|
def initialize(slug)
|
44
58
|
super()
|
45
|
-
@
|
46
|
-
@uri = "/#{
|
59
|
+
@output_dir = slug.to_s
|
60
|
+
@uri = "/#{output_dir}/"
|
47
61
|
end
|
48
62
|
|
49
63
|
##
|
data/test/test_output.rb
CHANGED
@@ -2,6 +2,10 @@ require "#{File.dirname __FILE__}/helper"
|
|
2
2
|
require 'semi-static/cli'
|
3
3
|
|
4
4
|
class TestOutput < Test::Unit::TestCase
|
5
|
+
TAGS = [ :applescript, :'auto-show', :'catching-up', :'colbert-report',
|
6
|
+
:'comedy-central', :iphone, :raves, :rss, :travel, :typography,
|
7
|
+
:work ]
|
8
|
+
|
5
9
|
def test_output_files
|
6
10
|
with_test_cli do |cli|
|
7
11
|
cli.clean_first = true
|
@@ -26,6 +30,12 @@ class TestOutput < Test::Unit::TestCase
|
|
26
30
|
assert_directory '2008/12'
|
27
31
|
assert_directory '2008/12/04'
|
28
32
|
|
33
|
+
assert_directory 'tag'
|
34
|
+
for tag in TAGS
|
35
|
+
assert_directory "tag/#{tag}"
|
36
|
+
assert_file "tag/#{tag}/index.html"
|
37
|
+
end
|
38
|
+
|
29
39
|
assert_file '2005/index.html'
|
30
40
|
assert_file '2005/03/index.html'
|
31
41
|
assert_file '2005/03/27/index.html'''
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zzot-semi-static
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Dady
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-03 00:00:00 -08:00
|
13
13
|
default_executable: semi
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -97,6 +97,29 @@ files:
|
|
97
97
|
- test/output/scripts
|
98
98
|
- test/output/scripts/jquery-1.3.js
|
99
99
|
- test/output/scripts/jquery-1.3.min.js
|
100
|
+
- test/output/tag
|
101
|
+
- test/output/tag/applescript
|
102
|
+
- test/output/tag/applescript/index.html
|
103
|
+
- test/output/tag/auto-show
|
104
|
+
- test/output/tag/auto-show/index.html
|
105
|
+
- test/output/tag/catching-up
|
106
|
+
- test/output/tag/catching-up/index.html
|
107
|
+
- test/output/tag/colbert-report
|
108
|
+
- test/output/tag/colbert-report/index.html
|
109
|
+
- test/output/tag/comedy-central
|
110
|
+
- test/output/tag/comedy-central/index.html
|
111
|
+
- test/output/tag/iphone
|
112
|
+
- test/output/tag/iphone/index.html
|
113
|
+
- test/output/tag/raves
|
114
|
+
- test/output/tag/raves/index.html
|
115
|
+
- test/output/tag/rss
|
116
|
+
- test/output/tag/rss/index.html
|
117
|
+
- test/output/tag/travel
|
118
|
+
- test/output/tag/travel/index.html
|
119
|
+
- test/output/tag/typography
|
120
|
+
- test/output/tag/typography/index.html
|
121
|
+
- test/output/tag/work
|
122
|
+
- test/output/tag/work/index.html
|
100
123
|
- test/ref
|
101
124
|
- test/ref/test_layout
|
102
125
|
- test/ref/test_layout/default_layout.html
|
@@ -122,6 +145,7 @@ files:
|
|
122
145
|
- test/source/indices
|
123
146
|
- test/source/indices/day.erb
|
124
147
|
- test/source/indices/month.erb
|
148
|
+
- test/source/indices/tag.erb
|
125
149
|
- test/source/indices/year.erb
|
126
150
|
- test/source/layouts
|
127
151
|
- test/source/layouts/default.haml
|