webby 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +13 -0
- data/Manifest.txt +44 -33
- data/Rakefile +2 -2
- data/bin/webby +33 -0
- data/bin/webby-gen +33 -0
- data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
- data/examples/presentation/content/presentation/s5/print.css +25 -1
- data/examples/webby/content/release-notes/rel-0-9-3/index.txt +49 -0
- data/lib/webby.rb +3 -10
- data/lib/webby/apps/generator.rb +41 -48
- data/lib/webby/apps/main.rb +22 -0
- data/lib/webby/auto_builder.rb +78 -6
- data/lib/webby/builder.rb +9 -9
- data/lib/webby/core_ext/kernel.rb +5 -0
- data/lib/webby/filters/wiki_words.rb +14 -0
- data/lib/webby/helpers/url_helper.rb +6 -0
- data/lib/webby/journal.rb +126 -0
- data/lib/webby/renderer.rb +11 -6
- data/lib/webby/resources/meta_file.rb +8 -5
- data/lib/webby/stelan/paginator.rb +2 -2
- data/lib/webby/tasks/growl.rake +4 -3
- data/spec/data/outline/basic.out +81 -0
- data/spec/data/outline/basic.txt +25 -0
- data/spec/data/outline/no_clobber.out +86 -0
- data/spec/data/outline/numbering.out +81 -0
- data/spec/data/outline/numbering_only.out +21 -0
- data/spec/data/outline/toc_range_1.out +66 -0
- data/spec/data/outline/toc_range_2.out +55 -0
- data/spec/data/outline/toc_style.out +81 -0
- data/spec/data/{Sitefile → site/Sitefile} +0 -0
- data/spec/data/{content → site/content}/_partial.txt +0 -0
- data/spec/data/{content → site/content}/css/coderay.css +0 -0
- data/spec/data/{content → site/content}/css/site.css +0 -0
- data/spec/data/{content → site/content}/css/tumblog.css +0 -0
- data/spec/data/{content → site/content}/images/tumblog/permalink.gif +0 -0
- data/spec/data/{content → site/content}/images/tumblog/rss.gif +0 -0
- data/spec/data/{content → site/content}/index.txt +0 -0
- data/spec/data/{content → site/content}/photos.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200806/the-noble-chicken/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200807/mad-city-chickens/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200807/the-wisdom-of-the-dutch/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200807/up-a-tree/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/rss.txt +0 -0
- data/spec/data/{layouts → site/layouts}/default.txt +0 -0
- data/spec/data/{layouts → site/layouts}/tumblog/default.txt +0 -0
- data/spec/data/{layouts → site/layouts}/tumblog/post.txt +0 -0
- data/spec/data/{lib → site/lib}/breadcrumbs.rb +0 -0
- data/spec/data/{lib → site/lib}/tumblog_helper.rb +0 -0
- data/spec/data/{tasks → site/tasks}/tumblog.rake +0 -0
- data/spec/data/{templates → site/templates}/_partial.erb +0 -0
- data/spec/data/{templates → site/templates}/atom_feed.erb +0 -0
- data/spec/data/{templates → site/templates}/page.erb +0 -0
- data/{examples/website → spec/data/site}/templates/presentation.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/conversation.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/link.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/photo.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/post.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/quote.erb +0 -0
- data/spec/spec_helper.rb +4 -4
- data/spec/webby/apps/generator_spec.rb +3 -2
- data/spec/webby/filters/basepath_spec.rb +167 -0
- data/spec/webby/filters/outline_spec.rb +92 -0
- data/spec/webby/renderer_spec.rb +1 -1
- data/spec/webby/resources/db_spec.rb +1 -1
- data/spec/webby/resources/layout_spec.rb +1 -1
- data/spec/webby/resources/meta_file_spec.rb +27 -13
- data/spec/webby/resources/page_spec.rb +1 -1
- data/spec/webby/resources/resource_spec.rb +1 -1
- data/spec/webby/resources_spec.rb +1 -1
- data/tasks/gem.rake +93 -32
- data/tasks/manifest.rake +3 -4
- data/tasks/rubyforge.rake +2 -4
- metadata +67 -56
- data/lib/webby/tasks/heel.rake +0 -28
- data/spec/data/templates/presentation.erb +0 -40
@@ -0,0 +1,81 @@
|
|
1
|
+
<ul>
|
2
|
+
<li>
|
3
|
+
<a href="#h1">First Header</a>
|
4
|
+
<ul>
|
5
|
+
<li>
|
6
|
+
<a href="#h1_1">Second Header</a>
|
7
|
+
</li>
|
8
|
+
<li>
|
9
|
+
<a href="#h1_2">Third Header</a>
|
10
|
+
</li>
|
11
|
+
</ul>
|
12
|
+
</li>
|
13
|
+
<li>
|
14
|
+
<a href="#h2">Fourth Header</a>
|
15
|
+
</li>
|
16
|
+
<li>
|
17
|
+
<a href="#h3">Fifth Header</a>
|
18
|
+
<ul>
|
19
|
+
<li>
|
20
|
+
<a href="#h3_1">Sixth Header</a>
|
21
|
+
<ul>
|
22
|
+
<li>
|
23
|
+
<a href="#h3_1_1">Seventh Header</a>
|
24
|
+
<ul>
|
25
|
+
<li>
|
26
|
+
<a href="#h3_1_1_1">Eighth Header</a>
|
27
|
+
<ul>
|
28
|
+
<li>
|
29
|
+
<a href="#h3_1_1_1_1">Ninth Header</a>
|
30
|
+
<ul>
|
31
|
+
<li>
|
32
|
+
<a href="#h3_1_1_1_1_1">Tenth Header</a>
|
33
|
+
</li>
|
34
|
+
</ul>
|
35
|
+
</li>
|
36
|
+
</ul>
|
37
|
+
</li>
|
38
|
+
</ul>
|
39
|
+
</li>
|
40
|
+
</ul>
|
41
|
+
</li>
|
42
|
+
<li>
|
43
|
+
<a href="#h3_2">Eleventh Header</a>
|
44
|
+
<ul>
|
45
|
+
<li>
|
46
|
+
<a href="#h3_2_1">Twelfth Header</a>
|
47
|
+
</li>
|
48
|
+
<li>
|
49
|
+
<a href="#h3_2_2">Thirteenth Header</a>
|
50
|
+
</li>
|
51
|
+
</ul>
|
52
|
+
</li>
|
53
|
+
</ul>
|
54
|
+
</li>
|
55
|
+
<li>
|
56
|
+
<a href="#h4">Fourteenth Header</a>
|
57
|
+
<ul>
|
58
|
+
<li>
|
59
|
+
<a href="#h4_1">Fifteenth Header</a>
|
60
|
+
</li>
|
61
|
+
</ul></li></ul>
|
62
|
+
|
63
|
+
<h1 id="h1"><span class="heading-num">1</span>First Header</h1>
|
64
|
+
<h2 id="h1_1"><span class="heading-num">1.1</span>Second Header</h2>
|
65
|
+
<h2 id="h1_2"><span class="heading-num">1.2</span>Third Header</h2>
|
66
|
+
|
67
|
+
<h1 id="h2"><span class="heading-num">2</span>Fourth Header</h1>
|
68
|
+
|
69
|
+
<h1 id="h3"><span class="heading-num">3</span>Fifth Header</h1>
|
70
|
+
<h2 id="h3_1"><span class="heading-num">3.1</span>Sixth Header</h2>
|
71
|
+
<h3 id="h3_1_1"><span class="heading-num">3.1.1</span>Seventh Header</h3>
|
72
|
+
<h4 id="h3_1_1_1"><span class="heading-num">3.1.1.1</span>Eighth Header</h4>
|
73
|
+
<h5 id="h3_1_1_1_1"><span class="heading-num">3.1.1.1.1</span>Ninth Header</h5>
|
74
|
+
<h6 id="h3_1_1_1_1_1"><span class="heading-num">3.1.1.1.1.1</span>Tenth Header</h6>
|
75
|
+
|
76
|
+
<h2 id="h3_2"><span class="heading-num">3.2</span>Eleventh Header</h2>
|
77
|
+
<h3 id="h3_2_1"><span class="heading-num">3.2.1</span>Twelfth Header</h3>
|
78
|
+
<h3 id="h3_2_2"><span class="heading-num">3.2.2</span>Thirteenth Header</h3>
|
79
|
+
|
80
|
+
<h1 id="h4"><span class="heading-num">4</span>Fourteenth Header</h1>
|
81
|
+
<h2 id="h4_1"><span class="heading-num">4.1</span>Fifteenth Header</h2>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -13,13 +13,13 @@ require File.expand_path(
|
|
13
13
|
Spec::Runner.configure do |config|
|
14
14
|
config.before :all do
|
15
15
|
@pwd = Dir.pwd
|
16
|
-
Dir.chdir Webby.datapath
|
17
|
-
FileUtils.mkdir_p Webby.datapath(::Webby.site.output_dir)
|
16
|
+
Dir.chdir Webby.datapath('site')
|
17
|
+
FileUtils.mkdir_p Webby.datapath('site', ::Webby.site.output_dir)
|
18
18
|
end
|
19
19
|
|
20
20
|
config.after :all do
|
21
|
-
FileUtils.rm_rf(Webby.datapath(::Webby.cairn))
|
22
|
-
FileUtils.rm_rf(Dir.glob(Webby.datapath
|
21
|
+
FileUtils.rm_rf(Webby.datapath('site', ::Webby.cairn))
|
22
|
+
FileUtils.rm_rf(Dir.glob(Webby.datapath(%w[site output *])))
|
23
23
|
Dir.chdir @pwd
|
24
24
|
end
|
25
25
|
|
@@ -55,8 +55,9 @@ describe Webby::Apps::Generator do
|
|
55
55
|
|
56
56
|
before :each do
|
57
57
|
@strio = StringIO.new
|
58
|
-
|
59
|
-
|
58
|
+
::Logging::Logger['Webby::Journal'].appenders =
|
59
|
+
::Logging::Appenders::IO.new('test', @strio)
|
60
|
+
@generator = Webby::Apps::Generator.new(@strio)
|
60
61
|
|
61
62
|
class << @strio
|
62
63
|
def to_s
|
@@ -0,0 +1,167 @@
|
|
1
|
+
|
2
|
+
require ::File.expand_path(
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper]))
|
4
|
+
|
5
|
+
# ---------------------------------------------------------------------------
|
6
|
+
describe Webby::Filters::BasePath do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@input = <<-HTML
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
%s
|
13
|
+
</head>
|
14
|
+
<body>
|
15
|
+
%s
|
16
|
+
</body>
|
17
|
+
</html>
|
18
|
+
HTML
|
19
|
+
end
|
20
|
+
|
21
|
+
before :each do
|
22
|
+
Webby.site.base = nil
|
23
|
+
@xpaths = Webby.site.xpaths.dup
|
24
|
+
end
|
25
|
+
|
26
|
+
after :each do
|
27
|
+
Webby.site.xpaths = @xpaths
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'raises an exception if a new base has not been specified' do
|
31
|
+
input = @input % ['', '<img src="/foo/picture.jpg" />']
|
32
|
+
bp = Webby::Filters::BasePath.new(input, 'html')
|
33
|
+
|
34
|
+
lambda {bp.filter}.
|
35
|
+
should raise_error(TypeError, "can't convert nil into String")
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'changes nothing with an empty base path' do
|
39
|
+
Webby.site.base = ''
|
40
|
+
input = @input % ['', '<img src="/foo/picture.jpg" />']
|
41
|
+
|
42
|
+
bp = Webby::Filters::BasePath.new(input, 'html')
|
43
|
+
bp.filter.should == <<-HTML
|
44
|
+
<html>
|
45
|
+
<head>
|
46
|
+
|
47
|
+
</head>
|
48
|
+
<body>
|
49
|
+
<img src="/foo/picture.jpg" />
|
50
|
+
</body>
|
51
|
+
</html>
|
52
|
+
HTML
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'substitutes the base path for xpath values that have a leading slash' do
|
56
|
+
Webby.site.base = 'http://example.com'
|
57
|
+
input = @input % ['', '<img src="/foo/picture.jpg" />']
|
58
|
+
|
59
|
+
bp = Webby::Filters::BasePath.new(input, 'html')
|
60
|
+
bp.filter.should == <<-HTML
|
61
|
+
<html>
|
62
|
+
<head>
|
63
|
+
|
64
|
+
</head>
|
65
|
+
<body>
|
66
|
+
<img src="http://example.com/foo/picture.jpg" />
|
67
|
+
</body>
|
68
|
+
</html>
|
69
|
+
HTML
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'operates on all entities in the input string' do
|
73
|
+
Webby.site.base = 'http://webby.rubyforge.org'
|
74
|
+
input = @input % ['', %Q(<img src="/foo/picture.jpg" />\n<a href="/page.html">Page Title</a>)]
|
75
|
+
|
76
|
+
bp = Webby::Filters::BasePath.new(input, 'html')
|
77
|
+
bp.filter.should == <<-HTML
|
78
|
+
<html>
|
79
|
+
<head>
|
80
|
+
|
81
|
+
</head>
|
82
|
+
<body>
|
83
|
+
<img src="http://webby.rubyforge.org/foo/picture.jpg" />
|
84
|
+
<a href="http://webby.rubyforge.org/page.html">Page Title</a>
|
85
|
+
</body>
|
86
|
+
</html>
|
87
|
+
HTML
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'only operates on entities defined in the xpaths configuration' do
|
91
|
+
Webby.site.xpaths.delete '/html/body//a[@href]'
|
92
|
+
Webby.site.base = 'http://webby.rubyforge.org'
|
93
|
+
input = @input % ['', %Q(<img src="/foo/picture.jpg" />\n<a href="/page.html">Page Title</a>)]
|
94
|
+
|
95
|
+
bp = Webby::Filters::BasePath.new(input, 'html')
|
96
|
+
bp.filter.should == <<-HTML
|
97
|
+
<html>
|
98
|
+
<head>
|
99
|
+
|
100
|
+
</head>
|
101
|
+
<body>
|
102
|
+
<img src="http://webby.rubyforge.org/foo/picture.jpg" />
|
103
|
+
<a href="/page.html">Page Title</a>
|
104
|
+
</body>
|
105
|
+
</html>
|
106
|
+
HTML
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'is restrictive to the configured xpaths' do
|
110
|
+
Webby.site.base = 'not a real site'
|
111
|
+
input = @input % ['<img src="/foo/picture.jpg" />', '<a href="/page.html">Page Title</a>']
|
112
|
+
|
113
|
+
bp = Webby::Filters::BasePath.new(input, 'html')
|
114
|
+
bp.filter.should == <<-HTML
|
115
|
+
<html>
|
116
|
+
<head>
|
117
|
+
<img src="/foo/picture.jpg" />
|
118
|
+
</head>
|
119
|
+
<body>
|
120
|
+
<a href="not a real site/page.html">Page Title</a>
|
121
|
+
</body>
|
122
|
+
</html>
|
123
|
+
HTML
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'registers a "basepath" filter in the filters module' do
|
127
|
+
handler = Webby::Filters._handlers['basepath']
|
128
|
+
handler.should_not be_nil
|
129
|
+
handler.arity.should == 2
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'leaves the input text unchanged if a base path is not configured' do
|
133
|
+
cursor = mock("Cursor")
|
134
|
+
page = mock("Page")
|
135
|
+
cursor.stub!(:page).and_return(page)
|
136
|
+
page.stub!(:extension).and_return('html')
|
137
|
+
input = @input % ['', '<img src="/foo/picture.jpg" />']
|
138
|
+
|
139
|
+
handler = Webby::Filters._handlers['basepath']
|
140
|
+
output = handler.call(input, cursor)
|
141
|
+
|
142
|
+
output.should equal(input)
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'modifies text when a base path is configured' do
|
146
|
+
cursor = mock("Cursor")
|
147
|
+
page = mock("Page")
|
148
|
+
cursor.stub!(:page).and_return(page)
|
149
|
+
page.stub!(:extension).and_return('html')
|
150
|
+
Webby.site.base = 'http://example.com'
|
151
|
+
input = @input % ['', '<img src="/foo/picture.jpg" />']
|
152
|
+
|
153
|
+
handler = Webby::Filters._handlers['basepath']
|
154
|
+
handler.call(input, cursor).should == <<-HTML
|
155
|
+
<html>
|
156
|
+
<head>
|
157
|
+
|
158
|
+
</head>
|
159
|
+
<body>
|
160
|
+
<img src="http://example.com/foo/picture.jpg" />
|
161
|
+
</body>
|
162
|
+
</html>
|
163
|
+
HTML
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# EOF
|
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
require ::File.expand_path(
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper]))
|
4
|
+
|
5
|
+
# ---------------------------------------------------------------------------
|
6
|
+
describe Webby::Filters::Outline do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@input = Webby::Resources::MetaFile.read(
|
10
|
+
Webby.datapath(%w[outline basic.txt]))
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should regsiter the outline filter handler' do
|
14
|
+
Webby::Filters._handlers['outline'].should_not be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'generates outline formatting for HTML heading tags' do
|
18
|
+
output = File.read(Webby.datapath(%w[outline basic.out]))
|
19
|
+
|
20
|
+
outline = Webby::Filters::Outline.new(@input)
|
21
|
+
outline.filter.should == output
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'starts numbering at an arbitrary value' do
|
25
|
+
input = @input.sub(%r/<toc \/>/, '<toc numbering_start="3" />')
|
26
|
+
output = File.read(Webby.datapath(%w[outline numbering.out]))
|
27
|
+
|
28
|
+
outline = Webby::Filters::Outline.new(input)
|
29
|
+
outline.filter.should == output
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'limits the range of headers the table of contents covers' do
|
33
|
+
input = @input.sub(%r/<toc \/>/, '<toc toc_range="h1-h3" />')
|
34
|
+
output = File.read(Webby.datapath(%w[outline toc_range_1.out]))
|
35
|
+
|
36
|
+
outline = Webby::Filters::Outline.new(input)
|
37
|
+
outline.filter.should == output
|
38
|
+
|
39
|
+
input = @input.sub(%r/<toc \/>/, '<toc toc_range="h2-h4" />')
|
40
|
+
output = File.read(Webby.datapath(%w[outline toc_range_2.out]))
|
41
|
+
|
42
|
+
outline = Webby::Filters::Outline.new(input)
|
43
|
+
outline.filter.should == output
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'uses different list styling for the table of contents' do
|
47
|
+
input = @input.sub(%r/<toc \/>/, '<toc toc_style="ul" />')
|
48
|
+
output = File.read(Webby.datapath(%w[outline toc_style.out]))
|
49
|
+
|
50
|
+
outline = Webby::Filters::Outline.new(input)
|
51
|
+
outline.filter.should == output
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'performs outline numbering without creatng a table of contents' do
|
55
|
+
input = @input.sub(%r/<toc \/>/, '')
|
56
|
+
output = File.read(Webby.datapath(%w[outline numbering_only.out]))
|
57
|
+
|
58
|
+
outline = Webby::Filters::Outline.new(input)
|
59
|
+
outline.filter.should == output
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'detects mis-ordered heading tags' do
|
63
|
+
input = <<-HTML
|
64
|
+
<h2>Heading Three</h2>
|
65
|
+
<h3>Heading Two</h3>
|
66
|
+
<h1>Heading One</h1>
|
67
|
+
HTML
|
68
|
+
outline = Webby::Filters::Outline.new(input)
|
69
|
+
|
70
|
+
lambda {outline.filter}.should raise_error(
|
71
|
+
Webby::Error, "heading tags are not in order, cannot outline"
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'does not clobber other HTML tags' do
|
76
|
+
html = <<-HTML
|
77
|
+
<div>
|
78
|
+
<p>This is the title</p>
|
79
|
+
<toc />
|
80
|
+
<p>And some sampler text</p>
|
81
|
+
</div>
|
82
|
+
HTML
|
83
|
+
input = @input.sub(%r/<toc \/>/, html)
|
84
|
+
output = File.read(Webby.datapath(%w[outline no_clobber.out]))
|
85
|
+
|
86
|
+
outline = Webby::Filters::Outline.new(input)
|
87
|
+
outline.filter.should == output
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
# EOF
|
data/spec/webby/renderer_spec.rb
CHANGED
@@ -6,7 +6,7 @@ require File.expand_path(
|
|
6
6
|
describe Webby::Renderer do
|
7
7
|
before :each do
|
8
8
|
layout = Webby::Resources::Layout.
|
9
|
-
new(Webby.datapath
|
9
|
+
new(Webby.datapath(%w[site layouts tumblog default.txt]))
|
10
10
|
Webby::Resources.stub!(:find_layout).and_return(layout)
|
11
11
|
|
12
12
|
@filename = File.join %w[content tumblog index.txt]
|