genit 1.0.1 → 2.0
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.
- data/NEWS +12 -28
- data/README.markdown +6 -2
- data/Rakefile +1 -1
- data/TODO +177 -12
- data/VERSION +1 -1
- data/bin/genit +18 -20
- data/data/styles/screen.css +5 -9
- data/data/templates/main.html +0 -1
- data/lib/genit.rb +9 -4
- data/lib/genit/builders/body_link_builder.rb +8 -8
- data/lib/genit/builders/builder_base.rb +11 -11
- data/lib/genit/builders/head_link_builder.rb +8 -8
- data/lib/genit/builders/relativizer.rb +12 -12
- data/lib/genit/builders/script_builder.rb +7 -7
- data/lib/genit/documents/document_writer.rb +14 -14
- data/lib/genit/documents/fragment.rb +23 -22
- data/lib/genit/documents/xml_document.rb +5 -1
- data/lib/genit/project.rb +1 -0
- data/lib/genit/project/compiler.rb +54 -73
- data/lib/genit/project/page_compiler.rb +41 -41
- data/lib/genit/project/pages_finder.rb +6 -6
- data/lib/genit/project/project_creator.rb +116 -111
- data/lib/genit/project/root_cleaner.rb +31 -0
- data/lib/genit/project/rss_feed.rb +14 -14
- data/lib/genit/server.rb +2 -0
- data/lib/genit/server/server.rb +33 -0
- data/lib/genit/tags/class_fragment_tag.rb +2 -2
- data/lib/genit/tags/class_menu_tag.rb +2 -1
- data/lib/genit/tags/class_news_tag.rb +24 -24
- data/lib/genit/tags/class_pages_tag.rb +1 -1
- data/lib/genit/tags/here_tag.rb +22 -18
- data/lib/genit/utils/news_utils.rb +3 -3
- data/spec/class_news_tag_spec.rb +5 -5
- data/spec/compiler_spec.rb +51 -60
- data/spec/fragment_spec.rb +19 -19
- data/spec/html_document_spec.rb +10 -10
- data/spec/page_compiler_spec.rb +13 -9
- data/spec/pages_finder_spec.rb +11 -11
- data/spec/project_creator_spec.rb +53 -102
- data/spec/test-files/malformed.html +5 -0
- data/spec/xml_document_spec.rb +5 -0
- metadata +6 -9
- data/data/styles/alsa/all.css +0 -130
- data/data/styles/yui/all.css +0 -3
- data/data/styles/yui/base.css +0 -80
- data/data/styles/yui/fonts.css +0 -47
- data/data/styles/yui/reset.css +0 -126
- data/data/templates/xhtml_1.0_strict +0 -5
- data/data/templates/xhtml_1.0_transitional +0 -5
data/spec/fragment_spec.rb
CHANGED
@@ -4,28 +4,28 @@ require './spec/helper'
|
|
4
4
|
|
5
5
|
describe Fragment do
|
6
6
|
|
7
|
-
it "should replace one fragment tag" do
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
# it "should replace one fragment tag" do
|
8
|
+
# fragment = Fragment.new("spec/test-files/fragment.html", 'spec/test-files')
|
9
|
+
# fragment.to_html.start_with?('<h1>title</h1>').should be_true
|
10
|
+
# end
|
11
11
|
|
12
|
-
it "should replace one fragment tag among other tags" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
12
|
+
# it "should replace one fragment tag among other tags" do
|
13
|
+
# fragment = Fragment.new("spec/test-files/fragment4.html", 'spec/test-files')
|
14
|
+
# result = fragment.to_html
|
15
|
+
# result.gsub!("\n", '')
|
16
|
+
# result.should == '<h1>title</h1><p>para</p><p>footer</p>'
|
17
|
+
# end
|
18
18
|
|
19
|
-
it "should replace one fragment tag in markdown" do
|
20
|
-
|
21
|
-
|
22
|
-
end
|
19
|
+
# it "should replace one fragment tag in markdown" do
|
20
|
+
# fragment = Fragment.new("spec/test-files/fragment3.html", 'spec/test-files')
|
21
|
+
# fragment.to_html.start_with?('<h1>title</h1>').should be_true
|
22
|
+
# end
|
23
23
|
|
24
|
-
it "should replace some fragment tags" do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
24
|
+
# it "should replace some fragment tags" do
|
25
|
+
# fragment = Fragment.new("spec/test-files/fragment2.html", 'spec/test-files')
|
26
|
+
# result = fragment.to_html.gsub("\n", '')
|
27
|
+
# result.should == ("<p>abcde</p>")
|
28
|
+
# end
|
29
29
|
|
30
30
|
it "should not change a file without fragment tag" do
|
31
31
|
fragment = Fragment.new("spec/test-files/nothing.html", 'spec/test-files')
|
data/spec/html_document_spec.rb
CHANGED
@@ -8,32 +8,32 @@ describe HtmlDocument do
|
|
8
8
|
doc = HtmlDocument.open("data/templates/main.html")
|
9
9
|
doc.css("body genit").size.should >= 1
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should load html as a string" do
|
13
13
|
content = HtmlDocument.open_as_string("data/pages/index.html")
|
14
14
|
content.class.should == String
|
15
15
|
content.size.should > 0
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should load markdown as a string" do
|
19
19
|
content = HtmlDocument.open_as_string("spec/test-files/test.markdown")
|
20
20
|
content.should == '<h1>title</h1>'
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should extract the list of genit tags" do
|
24
24
|
doc = HtmlDocument.open("data/templates/main.html")
|
25
25
|
tags = HtmlDocument.genit_tags_from doc
|
26
26
|
tags.size.should == 2
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should build a page content from markdown" do
|
30
30
|
content = HtmlDocument.build_page_content("spec/test-files/test.markdown", 'spec/test-files')
|
31
31
|
content.should == '<h1>title</h1>'
|
32
32
|
end
|
33
|
-
|
34
|
-
it "should build page content from html" do
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
|
33
|
+
|
34
|
+
# it "should build page content from html" do
|
35
|
+
# content = HtmlDocument.build_page_content("spec/test-files/fragment.html", 'spec/test-files')
|
36
|
+
# content.start_with?('<h1>title</h1>').should be_true
|
37
|
+
# end
|
38
|
+
|
39
39
|
end
|
data/spec/page_compiler_spec.rb
CHANGED
@@ -7,27 +7,31 @@ describe PageCompiler do
|
|
7
7
|
after :all do
|
8
8
|
clean_test_repository
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def create_sample_project
|
12
|
-
FileUtils.makedirs('spec/project-name/templates')
|
13
|
-
FileUtils.makedirs('spec/project-name/pages')
|
14
|
-
File.open('spec/project-name/templates/main.html', "w")
|
15
|
-
|
12
|
+
FileUtils.makedirs('spec/project-name/src/templates')
|
13
|
+
FileUtils.makedirs('spec/project-name/src/pages')
|
14
|
+
File.open('spec/project-name/src/templates/main.html', "w") do |out|
|
15
|
+
out.puts '<h1><genit here="title"/></h1>'
|
16
|
+
end
|
17
|
+
File.open('spec/project-name/src/pages/index.html', "w") do |out|
|
18
|
+
out.puts '<genit what="title">My Title</genit>'
|
19
|
+
end
|
16
20
|
end
|
17
|
-
|
21
|
+
|
18
22
|
it "should substitute a variable" do
|
19
23
|
create_sample_project
|
20
24
|
pc = PageCompiler.new 'spec/project-name/', 'index.html'
|
21
25
|
doc = pc.compile
|
22
26
|
doc.at_css('h1').inner_html.should == 'My Title'
|
23
27
|
end
|
24
|
-
|
28
|
+
|
25
29
|
it "should not delete the tag from page when a var is subsituted" do
|
26
30
|
create_sample_project
|
27
31
|
pc = PageCompiler.new 'spec/project-name/', 'index.html'
|
28
32
|
doc = pc.compile
|
29
|
-
|
30
|
-
page = IO.read 'spec/project-name/pages/index.html'
|
33
|
+
|
34
|
+
page = IO.read 'spec/project-name/src/pages/index.html'
|
31
35
|
page.match('<genit what="title">My Title</genit>').should_not be_nil
|
32
36
|
end
|
33
37
|
|
data/spec/pages_finder_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require './spec/helper'
|
|
5
5
|
describe PagesFinder do
|
6
6
|
|
7
7
|
before :each do
|
8
|
-
@project = ProjectCreator.new('spec/project-name',
|
8
|
+
@project = ProjectCreator.new('spec/project-name', false)
|
9
9
|
@project.create
|
10
10
|
@finder = PagesFinder.new 'spec/project-name'
|
11
11
|
end
|
@@ -13,7 +13,7 @@ describe PagesFinder do
|
|
13
13
|
after :each do
|
14
14
|
clean_test_repository
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def write_file name, content
|
18
18
|
File.open(File.join('spec/project-name', name), "w") do |file|
|
19
19
|
file.puts content
|
@@ -21,30 +21,30 @@ describe PagesFinder do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should retrieve the right number of pages" do
|
24
|
-
write_file 'pages/a.html', '<h1>a</h1>'
|
25
|
-
write_file 'pages/b.html', '<h1>b</h1>'
|
24
|
+
write_file 'src/pages/a.html', '<h1>a</h1>'
|
25
|
+
write_file 'src/pages/b.html', '<h1>b</h1>'
|
26
26
|
@finder.find.size.should == 3
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should name the pages from the root" do
|
30
|
-
write_file 'pages/a.html', '<h1>a</h1>'
|
31
|
-
write_file 'pages/b.html', '<h1>b</h1>'
|
30
|
+
write_file 'src/pages/a.html', '<h1>a</h1>'
|
31
|
+
write_file 'src/pages/b.html', '<h1>b</h1>'
|
32
32
|
list = @finder.find
|
33
33
|
list.include?("index.html").should be_true
|
34
34
|
list.include?("a.html").should be_true
|
35
35
|
list.include?("b.html").should be_true
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "should take care of markdown files" do
|
39
|
-
write_file 'pages/a.markdown', '#a'
|
40
|
-
write_file 'pages/b.markdown', '#b'
|
39
|
+
write_file 'src/pages/a.markdown', '#a'
|
40
|
+
write_file 'src/pages/b.markdown', '#b'
|
41
41
|
list = @finder.find
|
42
42
|
list.size.should == 3
|
43
43
|
list.include?("index.html").should be_true
|
44
44
|
list.include?("a.html").should be_true
|
45
45
|
list.include?("b.html").should be_true
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it "should transform an array of pagenames into an array of URL strings" do
|
49
49
|
pagenames = ['a.html', 'b.html', 'c/d.html']
|
50
50
|
url = 'http://www.example.com'
|
@@ -5,212 +5,163 @@ require './spec/helper'
|
|
5
5
|
describe ProjectCreator do
|
6
6
|
|
7
7
|
before :all do
|
8
|
-
@project = ProjectCreator.new('spec/project-name',
|
8
|
+
@project = ProjectCreator.new('spec/project-name', false)
|
9
9
|
@project.create
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
after :all do
|
13
13
|
clean_test_repository
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
describe "Project folder" do
|
17
|
-
|
17
|
+
|
18
18
|
it "should create a project folder" do
|
19
19
|
File.exist?('spec/project-name').should == true
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should create a project folder with version number" do
|
23
23
|
a = File.read('VERSION').strip
|
24
24
|
b = File.read('spec/project-name/.genit').strip
|
25
25
|
b.should eql a
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should say it if it cannot create a project" do
|
29
|
-
project = ProjectCreator.new('/root/project',
|
29
|
+
project = ProjectCreator.new('/root/project', false)
|
30
30
|
$stdout.should_receive(:puts).with("Cannot create project...")
|
31
31
|
project.create
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
it "should create a project file" do
|
35
35
|
File.exist?('spec/project-name/.genit').should == true
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "should create a config file" do
|
39
|
-
File.exist?('spec/project-name
|
39
|
+
File.exist?('spec/project-name/config').should == true
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
describe "Config file" do
|
45
|
-
|
45
|
+
|
46
46
|
before :each do
|
47
|
-
@config_file = YAML.load_file('spec/project-name
|
47
|
+
@config_file = YAML.load_file('spec/project-name/config')
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
it "should have an address value of 'http://www.example.com'" do
|
51
51
|
@config_file[:address].should == 'http://www.example.com'
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it "should have an rss value at true" do
|
55
55
|
@config_file[:rss].should be_true
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
it "should have an rss_title value of 'RSS TITLE'" do
|
59
59
|
@config_file[:rss_title].should == 'RSS TITLE'
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
it "should have an rss_description value of 'RSS DESCRIPTION'" do
|
63
63
|
@config_file[:rss_description].should == 'RSS DESCRIPTION'
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
describe "Folder structure" do
|
69
69
|
|
70
70
|
it "should create a news folder" do
|
71
|
-
File.exist?('spec/project-name/news').should == true
|
71
|
+
File.exist?('spec/project-name/src/news').should == true
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it "should create a fragments folder" do
|
75
|
-
File.exist?('spec/project-name/fragments').should == true
|
75
|
+
File.exist?('spec/project-name/src/fragments').should == true
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
it "should create a pages folder" do
|
79
|
-
File.exist?('spec/project-name/pages').should == true
|
79
|
+
File.exist?('spec/project-name/src/pages').should == true
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
it "should create a scripts folder" do
|
83
83
|
File.exist?('spec/project-name/scripts').should == true
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
it "should create a styles folder" do
|
87
87
|
File.exist?('spec/project-name/styles').should == true
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
it "should create a templates folder" do
|
91
|
-
File.exist?('spec/project-name/templates').should == true
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should create a www folder" do
|
95
|
-
File.exist?('spec/project-name/www').should == true
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should create a alsa folder inside the styles" do
|
99
|
-
File.exist?('spec/project-name/styles/alsa').should == true
|
91
|
+
File.exist?('spec/project-name/src/templates').should == true
|
100
92
|
end
|
101
|
-
|
102
|
-
it "should create a
|
103
|
-
File.exist?('spec/project-name/
|
93
|
+
|
94
|
+
it "should not create a www folder" do
|
95
|
+
File.exist?('spec/project-name/www').should == false
|
104
96
|
end
|
105
|
-
|
97
|
+
|
106
98
|
it "should create a images folder inside the styles" do
|
107
99
|
File.exist?('spec/project-name/styles/images').should == true
|
108
100
|
end
|
109
|
-
|
101
|
+
|
110
102
|
it "should create a public folder" do
|
111
103
|
File.exist?('spec/project-name/public').should == true
|
112
104
|
end
|
113
|
-
|
105
|
+
|
114
106
|
end # "Folder structure"
|
115
|
-
|
116
107
|
|
117
|
-
|
108
|
+
|
118
109
|
describe "The templates folder" do
|
119
110
|
it "should have got templates/main.html" do
|
120
111
|
File.exist?('data/templates/main.html').should be_true
|
121
112
|
end
|
122
|
-
|
113
|
+
|
123
114
|
it "should copy templates/main.html" do
|
124
|
-
File.exist?('spec/project-name/templates/main.html').should be_true
|
115
|
+
File.exist?('spec/project-name/src/templates/main.html').should be_true
|
125
116
|
end
|
126
|
-
|
117
|
+
|
127
118
|
it "should have got templates/menu.html" do
|
128
119
|
File.exist?('data/templates/menu.html').should be_true
|
129
120
|
end
|
130
|
-
|
121
|
+
|
131
122
|
it "should copy templates/menu.html" do
|
132
|
-
File.exist?('spec/project-name/templates/menu.html').should be_true
|
123
|
+
File.exist?('spec/project-name/src/templates/menu.html').should be_true
|
133
124
|
end
|
134
|
-
|
125
|
+
|
135
126
|
end # "The templates folder"
|
136
127
|
|
137
128
|
describe "The pages folder" do
|
138
129
|
it "should have got pages/index.html" do
|
139
130
|
File.exist?('data/pages/index.html').should be_true
|
140
131
|
end
|
141
|
-
|
132
|
+
|
142
133
|
it "should copy pages/index.html" do
|
143
|
-
File.exist?('spec/project-name/pages/index.html').should be_true
|
134
|
+
File.exist?('spec/project-name/src/pages/index.html').should be_true
|
144
135
|
end
|
145
136
|
end # "The pages folder"
|
146
|
-
|
137
|
+
|
147
138
|
describe "The styles folder" do
|
148
139
|
it "should have got styles/handheld.css" do
|
149
140
|
File.exist?('data/styles/handheld.css').should be_true
|
150
141
|
end
|
151
|
-
|
142
|
+
|
152
143
|
it "should copy styles/handheld.css" do
|
153
144
|
File.exist?('spec/project-name/styles/handheld.css').should be_true
|
154
145
|
end
|
155
|
-
|
146
|
+
|
156
147
|
it "should have got styles/print.css" do
|
157
148
|
File.exist?('data/styles/print.css').should be_true
|
158
149
|
end
|
159
|
-
|
150
|
+
|
160
151
|
it "should copy styles/print.css" do
|
161
152
|
File.exist?('spec/project-name/styles/print.css').should be_true
|
162
153
|
end
|
163
|
-
|
154
|
+
|
164
155
|
it "should have got styles/screen.css" do
|
165
156
|
File.exist?('data/styles/screen.css').should be_true
|
166
157
|
end
|
167
|
-
|
158
|
+
|
168
159
|
it "should copy styles/screen.css" do
|
169
160
|
File.exist?('spec/project-name/styles/screen.css').should be_true
|
170
161
|
end
|
171
|
-
|
172
|
-
it "should have got styles/alsa/all.css" do
|
173
|
-
File.exist?('data/styles/alsa/all.css').should be_true
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should copy styles/alsa/all.css" do
|
177
|
-
File.exist?('spec/project-name/styles/alsa/all.css').should be_true
|
178
|
-
end
|
179
|
-
|
180
|
-
it "should have got styles/yui/all.css" do
|
181
|
-
File.exist?('data/styles/yui/all.css').should be_true
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should copy styles/yui/all.css" do
|
185
|
-
File.exist?('spec/project-name/styles/yui/all.css').should be_true
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should have got styles/yui/base.css" do
|
189
|
-
File.exist?('data/styles/yui/base.css').should be_true
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should copy styles/yui/base.css" do
|
193
|
-
File.exist?('spec/project-name/styles/yui/base.css').should be_true
|
194
|
-
end
|
195
|
-
|
196
|
-
it "should have got styles/yui/fonts.css" do
|
197
|
-
File.exist?('data/styles/yui/fonts.css').should be_true
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should copy styles/yui/fonts.css" do
|
201
|
-
File.exist?('spec/project-name/styles/yui/fonts.css').should be_true
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should have got styles/yui/reset.css" do
|
205
|
-
File.exist?('data/styles/yui/reset.css').should be_true
|
206
|
-
end
|
207
|
-
|
208
|
-
it "should copy styles/yui/reset.css" do
|
209
|
-
File.exist?('spec/project-name/styles/yui/reset.css').should be_true
|
210
|
-
end
|
211
|
-
|
162
|
+
|
212
163
|
end # "The styles folder"
|
213
|
-
|
214
164
|
|
215
|
-
|
165
|
+
|
166
|
+
|
216
167
|
end
|