dysinger-webby 0.9.4
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/History.txt +221 -0
- data/README.rdoc +92 -0
- data/Rakefile +62 -0
- data/bin/webby +41 -0
- data/bin/webby-gen +41 -0
- data/examples/blog/Sitefile +7 -0
- data/examples/blog/tasks/blog.rake +72 -0
- data/examples/blog/templates/atom_feed.erb +40 -0
- data/examples/blog/templates/blog/month.erb +22 -0
- data/examples/blog/templates/blog/post.erb +16 -0
- data/examples/blog/templates/blog/year.erb +22 -0
- data/examples/presentation/Sitefile +10 -0
- data/examples/presentation/content/css/uv/twilight.css +137 -0
- data/examples/presentation/content/presentation/_sample_code.txt +10 -0
- data/examples/presentation/content/presentation/index.txt +63 -0
- data/examples/presentation/content/presentation/s5/blank.gif +0 -0
- data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
- data/examples/presentation/content/presentation/s5/framing.css +23 -0
- data/examples/presentation/content/presentation/s5/iepngfix.htc +42 -0
- data/examples/presentation/content/presentation/s5/opera.css +7 -0
- data/examples/presentation/content/presentation/s5/outline.css +15 -0
- data/examples/presentation/content/presentation/s5/pretty.css +86 -0
- data/examples/presentation/content/presentation/s5/print.css +25 -0
- data/examples/presentation/content/presentation/s5/s5-core.css +9 -0
- data/examples/presentation/content/presentation/s5/slides.css +3 -0
- data/examples/presentation/content/presentation/s5/slides.js +553 -0
- data/examples/presentation/layouts/presentation.txt +43 -0
- data/examples/presentation/templates/_code_partial.erb +13 -0
- data/examples/presentation/templates/presentation.erb +40 -0
- data/examples/tumblog/Sitefile +9 -0
- data/examples/tumblog/content/css/tumblog.css +308 -0
- data/examples/tumblog/content/images/tumblog/permalink.gif +0 -0
- data/examples/tumblog/content/images/tumblog/rss.gif +0 -0
- data/examples/tumblog/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
- data/examples/tumblog/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
- data/examples/tumblog/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
- data/examples/tumblog/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
- data/examples/tumblog/content/tumblog/200807/up-a-tree/index.txt +13 -0
- data/examples/tumblog/content/tumblog/index.txt +37 -0
- data/examples/tumblog/content/tumblog/rss.txt +37 -0
- data/examples/tumblog/layouts/tumblog/default.txt +44 -0
- data/examples/tumblog/layouts/tumblog/post.txt +15 -0
- data/examples/tumblog/lib/tumblog_helper.rb +32 -0
- data/examples/tumblog/tasks/tumblog.rake +30 -0
- data/examples/tumblog/templates/atom_feed.erb +40 -0
- data/examples/tumblog/templates/tumblog/conversation.erb +12 -0
- data/examples/tumblog/templates/tumblog/link.erb +10 -0
- data/examples/tumblog/templates/tumblog/photo.erb +13 -0
- data/examples/tumblog/templates/tumblog/post.erb +12 -0
- data/examples/tumblog/templates/tumblog/quote.erb +11 -0
- data/examples/webby/Sitefile +19 -0
- data/examples/webby/content/communicate/index.txt +28 -0
- data/examples/webby/content/css/background.gif +0 -0
- data/examples/webby/content/css/blueprint/print.css +76 -0
- data/examples/webby/content/css/blueprint/screen.css +696 -0
- data/examples/webby/content/css/coderay.css +96 -0
- data/examples/webby/content/css/site.css +196 -0
- data/examples/webby/content/css/uv/twilight.css +137 -0
- data/examples/webby/content/index.txt +37 -0
- data/examples/webby/content/learn/index.txt +28 -0
- data/examples/webby/content/reference/index.txt +204 -0
- data/examples/webby/content/release-notes/index.txt +21 -0
- data/examples/webby/content/release-notes/rel-0-9-0/index.txt +74 -0
- data/examples/webby/content/release-notes/rel-0-9-1/index.txt +93 -0
- data/examples/webby/content/release-notes/rel-0-9-2/index.txt +14 -0
- data/examples/webby/content/release-notes/rel-0-9-3/index.txt +47 -0
- data/examples/webby/content/robots.txt +6 -0
- data/examples/webby/content/script/jquery.corner.js +152 -0
- data/examples/webby/content/script/jquery.js +31 -0
- data/examples/webby/content/sitemap.txt +31 -0
- data/examples/webby/content/tips_and_tricks/index.txt +97 -0
- data/examples/webby/content/tutorial/index.txt +135 -0
- data/examples/webby/content/user-manual/index.txt +419 -0
- data/examples/webby/layouts/default.txt +49 -0
- data/examples/webby/templates/page.erb +10 -0
- data/examples/website/Sitefile +7 -0
- data/examples/website/content/css/blueprint/ie.css +26 -0
- data/examples/website/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/examples/website/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
- data/examples/website/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/examples/website/content/css/blueprint/plugins/buttons/readme.txt +32 -0
- data/examples/website/content/css/blueprint/plugins/buttons/screen.css +97 -0
- data/examples/website/content/css/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/examples/website/content/css/blueprint/plugins/fancy-type/screen.css +71 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/readme.txt +18 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/screen.css +40 -0
- data/examples/website/content/css/blueprint/plugins/rtl/readme.txt +10 -0
- data/examples/website/content/css/blueprint/plugins/rtl/screen.css +109 -0
- data/examples/website/content/css/blueprint/print.css +30 -0
- data/examples/website/content/css/blueprint/screen.css +251 -0
- data/examples/website/content/css/blueprint/src/forms.css +49 -0
- data/examples/website/content/css/blueprint/src/grid.css +212 -0
- data/examples/website/content/css/blueprint/src/grid.png +0 -0
- data/examples/website/content/css/blueprint/src/ie.css +59 -0
- data/examples/website/content/css/blueprint/src/print.css +85 -0
- data/examples/website/content/css/blueprint/src/reset.css +38 -0
- data/examples/website/content/css/blueprint/src/typography.css +105 -0
- data/examples/website/content/css/coderay.css +111 -0
- data/examples/website/content/css/site.css +67 -0
- data/examples/website/content/index.txt +19 -0
- data/examples/website/layouts/default.txt +61 -0
- data/examples/website/lib/breadcrumbs.rb +28 -0
- data/examples/website/templates/_partial.erb +10 -0
- data/examples/website/templates/page.erb +18 -0
- data/lib/webby.rb +232 -0
- data/lib/webby/apps.rb +12 -0
- data/lib/webby/apps/generator.rb +276 -0
- data/lib/webby/apps/main.rb +258 -0
- data/lib/webby/auto_builder.rb +157 -0
- data/lib/webby/builder.rb +172 -0
- data/lib/webby/core_ext/enumerable.rb +11 -0
- data/lib/webby/core_ext/hash.rb +28 -0
- data/lib/webby/core_ext/kernel.rb +26 -0
- data/lib/webby/core_ext/string.rb +163 -0
- data/lib/webby/core_ext/time.rb +9 -0
- data/lib/webby/filters.rb +85 -0
- data/lib/webby/filters/basepath.rb +97 -0
- data/lib/webby/filters/erb.rb +9 -0
- data/lib/webby/filters/haml.rb +19 -0
- data/lib/webby/filters/markdown.rb +16 -0
- data/lib/webby/filters/maruku.rb +16 -0
- data/lib/webby/filters/outline.rb +309 -0
- data/lib/webby/filters/sass.rb +19 -0
- data/lib/webby/filters/slides.rb +56 -0
- data/lib/webby/filters/textile.rb +16 -0
- data/lib/webby/filters/tidy.rb +76 -0
- data/lib/webby/filters/wiki_words.rb +14 -0
- data/lib/webby/helpers.rb +30 -0
- data/lib/webby/helpers/capture_helper.rb +141 -0
- data/lib/webby/helpers/coderay_helper.rb +69 -0
- data/lib/webby/helpers/graphviz_helper.rb +136 -0
- data/lib/webby/helpers/tag_helper.rb +65 -0
- data/lib/webby/helpers/tex_img_helper.rb +133 -0
- data/lib/webby/helpers/ultraviolet_helper.rb +63 -0
- data/lib/webby/helpers/url_helper.rb +241 -0
- data/lib/webby/journal.rb +126 -0
- data/lib/webby/link_validator.rb +160 -0
- data/lib/webby/renderer.rb +390 -0
- data/lib/webby/resources.rb +137 -0
- data/lib/webby/resources/db.rb +251 -0
- data/lib/webby/resources/layout.rb +54 -0
- data/lib/webby/resources/meta_file.rb +211 -0
- data/lib/webby/resources/page.rb +81 -0
- data/lib/webby/resources/partial.rb +85 -0
- data/lib/webby/resources/resource.rb +201 -0
- data/lib/webby/resources/static.rb +36 -0
- data/lib/webby/stelan/mktemp.rb +135 -0
- data/lib/webby/stelan/paginator.rb +165 -0
- data/lib/webby/tasks/build.rake +27 -0
- data/lib/webby/tasks/create.rake +25 -0
- data/lib/webby/tasks/deploy.rake +22 -0
- data/lib/webby/tasks/growl.rake +16 -0
- data/lib/webby/tasks/validate.rake +19 -0
- data/spec/core_ext/hash_spec.rb +47 -0
- data/spec/core_ext/string_spec.rb +110 -0
- data/spec/core_ext/time_spec.rb +19 -0
- data/spec/data/hooligans/bad_meta_data_1.txt +34 -0
- data/spec/data/hooligans/bad_meta_data_2.txt +34 -0
- data/spec/data/html/anchor.html +11 -0
- data/spec/data/html/external.html +10 -0
- data/spec/data/html/invalid-relative.html +10 -0
- data/spec/data/html/relative-anchor.html +10 -0
- data/spec/data/html/relative-invalid-anchor.html +10 -0
- data/spec/data/html/relative.html +10 -0
- 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/site/Sitefile +9 -0
- data/spec/data/site/content/_partial.txt +10 -0
- data/spec/data/site/content/css/coderay.css +111 -0
- data/spec/data/site/content/css/site.css +67 -0
- data/spec/data/site/content/css/tumblog.css +308 -0
- data/spec/data/site/content/images/tumblog/permalink.gif +0 -0
- data/spec/data/site/content/images/tumblog/rss.gif +0 -0
- data/spec/data/site/content/index.txt +19 -0
- data/spec/data/site/content/photos.txt +21 -0
- data/spec/data/site/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
- data/spec/data/site/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
- data/spec/data/site/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
- data/spec/data/site/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
- data/spec/data/site/content/tumblog/200807/up-a-tree/index.txt +13 -0
- data/spec/data/site/content/tumblog/index.txt +37 -0
- data/spec/data/site/content/tumblog/rss.txt +37 -0
- data/spec/data/site/layouts/default.txt +58 -0
- data/spec/data/site/layouts/tumblog/default.txt +44 -0
- data/spec/data/site/layouts/tumblog/post.txt +15 -0
- data/spec/data/site/lib/breadcrumbs.rb +28 -0
- data/spec/data/site/lib/tumblog_helper.rb +32 -0
- data/spec/data/site/tasks/tumblog.rake +30 -0
- data/spec/data/site/templates/_partial.erb +10 -0
- data/spec/data/site/templates/atom_feed.erb +40 -0
- data/spec/data/site/templates/page.erb +18 -0
- data/spec/data/site/templates/presentation.erb +40 -0
- data/spec/data/site/templates/tumblog/conversation.erb +12 -0
- data/spec/data/site/templates/tumblog/link.erb +10 -0
- data/spec/data/site/templates/tumblog/photo.erb +13 -0
- data/spec/data/site/templates/tumblog/post.erb +12 -0
- data/spec/data/site/templates/tumblog/quote.erb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +58 -0
- data/spec/webby/apps/generator_spec.rb +117 -0
- data/spec/webby/apps/main_spec.rb +88 -0
- data/spec/webby/filters/basepath_spec.rb +167 -0
- data/spec/webby/filters/maruku_spec.rb +31 -0
- data/spec/webby/filters/outline_spec.rb +92 -0
- data/spec/webby/filters/textile_spec.rb +31 -0
- data/spec/webby/helpers/capture_helper_spec.rb +56 -0
- data/spec/webby/link_validator_spec.rb +154 -0
- data/spec/webby/renderer_spec.rb +139 -0
- data/spec/webby/resources/db_spec.rb +250 -0
- data/spec/webby/resources/layout_spec.rb +83 -0
- data/spec/webby/resources/meta_file_spec.rb +171 -0
- data/spec/webby/resources/page_spec.rb +111 -0
- data/spec/webby/resources/partial_spec.rb +58 -0
- data/spec/webby/resources/resource_spec.rb +219 -0
- data/spec/webby/resources/static_spec.rb +49 -0
- data/spec/webby/resources_spec.rb +69 -0
- data/tasks/mswin32.rake +38 -0
- data/tasks/website.rake +37 -0
- metadata +379 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
require ::File.expand_path(
|
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper]))
|
|
4
|
+
|
|
5
|
+
# ---------------------------------------------------------------------------
|
|
6
|
+
describe 'Webby::Filters::Maruku' do
|
|
7
|
+
|
|
8
|
+
it 'should regsiter the maruku filter handler' do
|
|
9
|
+
Webby::Filters._handlers['maruku'].should_not be_nil
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
if try_require('maruku')
|
|
13
|
+
|
|
14
|
+
it 'processes maruku markup into HTML' do
|
|
15
|
+
input = "## Heading Two\n\nAnd some text about this heading."
|
|
16
|
+
output = Webby::Filters._handlers['maruku'].call(input)
|
|
17
|
+
|
|
18
|
+
output.should == %Q{<h2 id='heading_two'>Heading Two</h2>\n\n<p>And some text about this heading.</p>}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
else
|
|
22
|
+
|
|
23
|
+
it 'raises an error when maruku is used but not installed' do
|
|
24
|
+
input = "## Heading Two\n\nAnd some text about this heading."
|
|
25
|
+
lambda {Webby::Filters._handlers['maruku'].call(input)}.should raise_error(Webby::Error, "'maruku' must be installed to use the maruku filter")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# 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
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
require ::File.expand_path(
|
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper]))
|
|
4
|
+
|
|
5
|
+
# ---------------------------------------------------------------------------
|
|
6
|
+
describe 'Webby::Filters::Textile' do
|
|
7
|
+
|
|
8
|
+
it 'should regsiter the textile filter handler' do
|
|
9
|
+
Webby::Filters._handlers['textile'].should_not be_nil
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
if try_require('redcloth')
|
|
13
|
+
|
|
14
|
+
it 'processes textile markup into HTML' do
|
|
15
|
+
input = "p(foo). this is a paragraph of text"
|
|
16
|
+
output = Webby::Filters._handlers['textile'].call(input)
|
|
17
|
+
|
|
18
|
+
output.should == %q{<p class="foo">this is a paragraph of text</p>}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
else
|
|
22
|
+
|
|
23
|
+
it 'raises an error when RedCloth is used but not installed' do
|
|
24
|
+
input = "p(foo). this is a paragraph of text"
|
|
25
|
+
lambda {Webby::Filters._handlers['textile'].call(input)}.should raise_error(Webby::Error, "'RedCloth' must be installed to use the textile filter")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# EOF
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
require ::File.expand_path(
|
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper]))
|
|
4
|
+
|
|
5
|
+
# ---------------------------------------------------------------------------
|
|
6
|
+
describe Webby::Helpers::CaptureHelper do
|
|
7
|
+
CFN = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', 'capture_for_yaml.txt'))
|
|
8
|
+
CLINES = [
|
|
9
|
+
"--- ",
|
|
10
|
+
"filter: ",
|
|
11
|
+
" - erb ",
|
|
12
|
+
"--- ",
|
|
13
|
+
"Hello world!",
|
|
14
|
+
"<% content_for :sidebar do %>",
|
|
15
|
+
"I'm sidebar content.",
|
|
16
|
+
"<% end %>"
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
before :all do
|
|
20
|
+
::File.open(CFN,'w') {|fd| fd.write CLINES.join("\n") }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
before :each do
|
|
24
|
+
@renderman = Webby::Renderer.new(
|
|
25
|
+
Webby::Resources::Page.new(CFN))
|
|
26
|
+
@page_content = @renderman._render_page
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
after :all do
|
|
30
|
+
::FileUtils.rm_f(CFN)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should not "leak" any content to containing page' do
|
|
34
|
+
@page_content.should_not be_nil
|
|
35
|
+
@page_content.should eql("Hello world!\n")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should return the stored content for the given key" do
|
|
39
|
+
@renderman.content_for(:sidebar).should_not be_nil
|
|
40
|
+
@renderman.content_for(:sidebar).should eql("\nI'm sidebar content.\n") # Note: Leading newline
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should report if content is associated with a given key" do
|
|
44
|
+
@renderman.content_for?(:sidebar).should == true
|
|
45
|
+
@renderman.content_for?(:header).should == false
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should clear content associated with a given key" do
|
|
49
|
+
@renderman.content_for?(:sidebar).should == true
|
|
50
|
+
@renderman.delete_content_for(:sidebar)
|
|
51
|
+
@renderman.content_for?(:sidebar).should == false
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# EOF
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
require File.expand_path(
|
|
2
|
+
File.join(File.dirname(__FILE__), %w[.. spec_helper]))
|
|
3
|
+
|
|
4
|
+
# ---------------------------------------------------------------------------
|
|
5
|
+
describe Webby::LinkValidator do
|
|
6
|
+
before do
|
|
7
|
+
@validator = Webby::LinkValidator.new
|
|
8
|
+
@@old = Webby.site.output_dir
|
|
9
|
+
Webby.site.output_dir = Webby.datapath('html')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
after do
|
|
13
|
+
Webby.site.output_dir = @@old
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe ".validate" do
|
|
17
|
+
it "passes options to a new validator" do
|
|
18
|
+
new_validator = stub('validator', :validate => true)
|
|
19
|
+
Webby::LinkValidator.should_receive(:new).with(:options).and_return(new_validator)
|
|
20
|
+
Webby::LinkValidator.validate(:options)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "checks each file" do
|
|
24
|
+
#TODO: test fake site
|
|
25
|
+
files = ["a file", "another file"]
|
|
26
|
+
Dir.stub!(:glob).and_return(files)
|
|
27
|
+
|
|
28
|
+
validator = Webby::LinkValidator.new
|
|
29
|
+
files.each do |file|
|
|
30
|
+
validator.should_receive(:check_file).with(file)
|
|
31
|
+
end
|
|
32
|
+
validator.validate
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe "checking a file" do
|
|
37
|
+
describe "with an anchor" do
|
|
38
|
+
before do
|
|
39
|
+
@filename = Webby.datapath('html', 'anchor.html')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "validates the anchor" do
|
|
43
|
+
@validator.should_receive(:validate_anchor)
|
|
44
|
+
@validator.check_file(@filename)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "does not add the file to the valid uri list" do
|
|
48
|
+
lambda { @validator.check_file(@filename) }.should_not change(@validator.instance_variable_get('@valid_uris'), :size)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "***CURRENTLY*** returns nil" do
|
|
52
|
+
@validator.check_file(@filename).should be_nil
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe "with a valid relative href" do
|
|
57
|
+
before do
|
|
58
|
+
@filename = Webby.datapath('html', 'relative.html')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "adds the file to the valid uri list" do
|
|
62
|
+
lambda { @validator.check_file(@filename) }.should change(@validator.instance_variable_get('@valid_uris'), :size).by(1)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "***CURRENTLY*** returns nil" do
|
|
66
|
+
@validator.check_file(@filename).should be_nil
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "with an invalid relative href" do
|
|
71
|
+
before do
|
|
72
|
+
@filename = Webby.datapath('html', 'invalid-relative.html')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "does not add the file to the invalid uri list" do
|
|
76
|
+
lambda { @validator.check_file(@filename) }.should_not change(@validator.instance_variable_get('@valid_uris'), :size)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "***CURRENTLY*** returns nil" do
|
|
80
|
+
@validator.check_file(@filename).should be_nil
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe "with a valid relative href that contains an anchor" do
|
|
85
|
+
before do
|
|
86
|
+
@filename = Webby.datapath('html', 'relative-anchor.html')
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "adds the file to the valid uri list" do
|
|
90
|
+
lambda { @validator.check_file(@filename) }.should change(@validator.instance_variable_get('@valid_uris'), :size).by(1)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "***CURRENTLY*** returns nil" do
|
|
94
|
+
@validator.check_file(@filename).should be_nil
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe "with a valid relative href that contains an invalid anchor" do
|
|
99
|
+
before do
|
|
100
|
+
@filename = Webby.datapath('html', 'relative-invalid-anchor.html')
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "does not the file to the valid uri list" do
|
|
104
|
+
lambda { @validator.check_file(@filename) }.should_not change(@validator.instance_variable_get('@valid_uris'), :size)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "***CURRENTLY*** returns nil" do
|
|
108
|
+
@validator.check_file(@filename).should be_nil
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
if $test_externals
|
|
113
|
+
describe "with a valid external href" do
|
|
114
|
+
before do
|
|
115
|
+
FakeWeb.register_uri('http://www.google.com/', :string => 'google')
|
|
116
|
+
@filename = Webby.datapath('html', 'external.html')
|
|
117
|
+
@validator.validate_externals = true
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "adds the file to the valid uri list" do
|
|
121
|
+
lambda { @validator.check_file(@filename) }.should change(@validator.instance_variable_get('@valid_uris'), :size).by(1)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "does not add the file to the invalid uri list" do
|
|
125
|
+
lambda { @validator.check_file(@filename) }.should_not change(@validator.instance_variable_get('@invalid_uris'), :size)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "***CURRENTLY*** returns nil" do
|
|
129
|
+
@validator.check_file(@filename).should be_nil
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe "with an invalid external href" do
|
|
134
|
+
before do
|
|
135
|
+
FakeWeb.register_uri('http://www.google.com/', :string => 'google', :status => [ 404, "Not Found" ])
|
|
136
|
+
@filename = Webby.datapath('html', 'external.html')
|
|
137
|
+
@validator.validate_externals = true
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "does not add the file to the valid uri list" do
|
|
141
|
+
lambda { @validator.check_file(@filename) }.should_not change(@validator.instance_variable_get('@valid_uris'), :size)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it "adds the file to the invalid uri list" do
|
|
145
|
+
lambda { @validator.check_file(@filename) }.should change(@validator.instance_variable_get('@invalid_uris'), :size).by(1)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it "***CURRENTLY*** returns nil" do
|
|
149
|
+
@validator.check_file(@filename).should be_nil
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
|
|
2
|
+
require File.expand_path(
|
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. spec_helper]))
|
|
4
|
+
|
|
5
|
+
# ---------------------------------------------------------------------------
|
|
6
|
+
describe Webby::Renderer do
|
|
7
|
+
before :each do
|
|
8
|
+
layout = Webby::Resources::Layout.
|
|
9
|
+
new(Webby.datapath(%w[site layouts tumblog default.txt]))
|
|
10
|
+
Webby::Resources.stub!(:find_layout).and_return(layout)
|
|
11
|
+
|
|
12
|
+
@filename = File.join %w[content tumblog index.txt]
|
|
13
|
+
@page = Webby::Resources::Page.new(@filename)
|
|
14
|
+
@renderer = Webby::Renderer.new(@page)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'needs some more specs'
|
|
18
|
+
|
|
19
|
+
# -------------------------------------------------------------------------
|
|
20
|
+
describe 'when paginating' do
|
|
21
|
+
after :each do
|
|
22
|
+
::Webby.site.create_mode = 'page'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'paginates a set of items' do
|
|
26
|
+
items = %w[one two three four five six seven eight]
|
|
27
|
+
output = []
|
|
28
|
+
|
|
29
|
+
@renderer.instance_variable_get(:@pager).should be_nil
|
|
30
|
+
|
|
31
|
+
# the first page of items
|
|
32
|
+
@renderer.paginate(items, 3) {|item| output << item}
|
|
33
|
+
pager = @renderer.instance_variable_get(:@pager)
|
|
34
|
+
|
|
35
|
+
pager.should_not be_nil
|
|
36
|
+
pager.number_of_pages.should == 3
|
|
37
|
+
pager.prev?.should == false
|
|
38
|
+
pager.next?.should == true
|
|
39
|
+
|
|
40
|
+
output.should == %w[one two three]
|
|
41
|
+
@page.destination.should == 'output/tumblog/index.html'
|
|
42
|
+
|
|
43
|
+
# go to the next page of items
|
|
44
|
+
@renderer._next_page.should == true
|
|
45
|
+
output.should == %w[one two three]
|
|
46
|
+
|
|
47
|
+
pager = @renderer.instance_variable_get(:@pager)
|
|
48
|
+
pager.should_not be_nil
|
|
49
|
+
pager.number_of_pages.should == 3
|
|
50
|
+
pager.prev?.should == true
|
|
51
|
+
pager.next?.should == true
|
|
52
|
+
|
|
53
|
+
@page.destination.should == 'output/tumblog/index2.html'
|
|
54
|
+
|
|
55
|
+
@renderer.paginate(items, 3) {|item| output << item}
|
|
56
|
+
output.should == %w[one two three four five six]
|
|
57
|
+
|
|
58
|
+
# go to the last page of items
|
|
59
|
+
@renderer._next_page.should == true
|
|
60
|
+
output.should == %w[one two three four five six]
|
|
61
|
+
|
|
62
|
+
pager = @renderer.instance_variable_get(:@pager)
|
|
63
|
+
pager.should_not be_nil
|
|
64
|
+
pager.number_of_pages.should == 3
|
|
65
|
+
pager.prev?.should == true
|
|
66
|
+
pager.next?.should == false
|
|
67
|
+
|
|
68
|
+
@page.destination.should == 'output/tumblog/index3.html'
|
|
69
|
+
|
|
70
|
+
@renderer.paginate(items, 3) {|item| output << item}
|
|
71
|
+
output.should == %w[one two three four five six seven eight]
|
|
72
|
+
|
|
73
|
+
# after the last page
|
|
74
|
+
@renderer._next_page.should == false
|
|
75
|
+
pager = @renderer.instance_variable_get(:@pager)
|
|
76
|
+
pager.should be_nil
|
|
77
|
+
@page.destination.should == 'output/tumblog/index.html'
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'obeys the create_mode of the site' do
|
|
81
|
+
::Webby.site.create_mode = 'directory'
|
|
82
|
+
items = %w[one two three four five six seven eight]
|
|
83
|
+
output = []
|
|
84
|
+
|
|
85
|
+
@renderer.instance_variable_get(:@pager).should be_nil
|
|
86
|
+
|
|
87
|
+
# the first page of items
|
|
88
|
+
@renderer.paginate(items, 3) {|item| output << item}
|
|
89
|
+
pager = @renderer.instance_variable_get(:@pager)
|
|
90
|
+
|
|
91
|
+
pager.should_not be_nil
|
|
92
|
+
pager.number_of_pages.should == 3
|
|
93
|
+
pager.prev?.should == false
|
|
94
|
+
pager.next?.should == true
|
|
95
|
+
|
|
96
|
+
output.should == %w[one two three]
|
|
97
|
+
@page.destination.should == 'output/tumblog/index.html'
|
|
98
|
+
|
|
99
|
+
# go to the next page of items
|
|
100
|
+
@renderer._next_page.should == true
|
|
101
|
+
output.should == %w[one two three]
|
|
102
|
+
|
|
103
|
+
pager = @renderer.instance_variable_get(:@pager)
|
|
104
|
+
pager.should_not be_nil
|
|
105
|
+
pager.number_of_pages.should == 3
|
|
106
|
+
pager.prev?.should == true
|
|
107
|
+
pager.next?.should == true
|
|
108
|
+
|
|
109
|
+
@page.destination.should == 'output/tumblog/2/index.html'
|
|
110
|
+
|
|
111
|
+
@renderer.paginate(items, 3) {|item| output << item}
|
|
112
|
+
output.should == %w[one two three four five six]
|
|
113
|
+
|
|
114
|
+
# go to the last page of items
|
|
115
|
+
@renderer._next_page.should == true
|
|
116
|
+
output.should == %w[one two three four five six]
|
|
117
|
+
|
|
118
|
+
pager = @renderer.instance_variable_get(:@pager)
|
|
119
|
+
pager.should_not be_nil
|
|
120
|
+
pager.number_of_pages.should == 3
|
|
121
|
+
pager.prev?.should == true
|
|
122
|
+
pager.next?.should == false
|
|
123
|
+
|
|
124
|
+
@page.destination.should == 'output/tumblog/3/index.html'
|
|
125
|
+
|
|
126
|
+
@renderer.paginate(items, 3) {|item| output << item}
|
|
127
|
+
output.should == %w[one two three four five six seven eight]
|
|
128
|
+
|
|
129
|
+
# after the last page
|
|
130
|
+
@renderer._next_page.should == false
|
|
131
|
+
pager = @renderer.instance_variable_get(:@pager)
|
|
132
|
+
pager.should be_nil
|
|
133
|
+
@page.destination.should == 'output/tumblog/index.html'
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
end # describe Webby::Renderer
|
|
138
|
+
|
|
139
|
+
# EOF
|