jamesgolick-webby 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +219 -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 +233 -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 +18 -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 +17 -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 +435 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
|
4
|
+
|
5
|
+
# -------------------------------------------------------------------------
|
6
|
+
describe Webby::Resources::Page do
|
7
|
+
before :each do
|
8
|
+
layout = Webby::Resources::Layout.
|
9
|
+
new(Webby.datapath %w[site layouts default.txt])
|
10
|
+
Webby::Resources.stub!(:find_layout).and_return(layout)
|
11
|
+
|
12
|
+
@filename = File.join %w[content index.txt]
|
13
|
+
@page = Webby::Resources::Page.new(@filename)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'parses meta-data on initialization' do
|
17
|
+
h = @page._meta_data
|
18
|
+
|
19
|
+
h.should_not be_empty
|
20
|
+
h['title'].should == 'Home Page'
|
21
|
+
h['filter'].should == ['erb', 'textile']
|
22
|
+
h['layout'].should == 'default'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can be given a hash of meta-data on initialization' do
|
26
|
+
page = Webby::Resources::Page.new(
|
27
|
+
@filename,
|
28
|
+
'title' => 'Not Your Average Title'
|
29
|
+
)
|
30
|
+
|
31
|
+
h = page._meta_data
|
32
|
+
h.should_not be_empty
|
33
|
+
h['title'].should == 'Not Your Average Title'
|
34
|
+
h['layout'].should == 'default'
|
35
|
+
h['created_at'].should be_nil
|
36
|
+
h['filter'].should be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'reads the contents of the file' do
|
40
|
+
str = @page._read
|
41
|
+
str.split($/).first.should == "p(title). <%= @page.title %>"
|
42
|
+
end
|
43
|
+
|
44
|
+
# -----------------------------------------------------------------------
|
45
|
+
describe '.url' do
|
46
|
+
before :each do
|
47
|
+
@filename = File.join %w[content tumblog rss.txt]
|
48
|
+
@page = Webby::Resources::Page.new(@filename)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'computes the url from the destination' do
|
52
|
+
@page.url.should == '/tumblog/rss.xml'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "uses only the directory name for 'index' files" do
|
56
|
+
filename = File.join %w[content tumblog index.txt]
|
57
|
+
resource = Webby::Resources::Page.new(filename)
|
58
|
+
resource.url.should == '/tumblog'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# -----------------------------------------------------------------------
|
63
|
+
describe '.extension' do
|
64
|
+
it 'uses the extension from the meta-data if present' do
|
65
|
+
@page['extension'] = 'foo'
|
66
|
+
@page.extension.should == 'foo'
|
67
|
+
end
|
68
|
+
|
69
|
+
it "uses the layout's extension if a layout is present" do
|
70
|
+
@page.extension.should == 'html'
|
71
|
+
end
|
72
|
+
|
73
|
+
it "uses the file's extension as a last ditch effort" do
|
74
|
+
@page._meta_data.delete('layout')
|
75
|
+
@page.extension.should == 'txt'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# -----------------------------------------------------------------------
|
80
|
+
describe '.dirty?' do
|
81
|
+
it 'overrides the dirty state based on the meta-data value' do
|
82
|
+
@page['dirty'] = true
|
83
|
+
@page.dirty?.should == true
|
84
|
+
|
85
|
+
@page['dirty'] = false
|
86
|
+
@page.dirty?.should == false
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'returns true if the output file is missing' do
|
90
|
+
@page.dirty?.should == true
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'returns true if the layout is dirty' do
|
94
|
+
dest = @page.destination
|
95
|
+
FileUtils.touch dest
|
96
|
+
|
97
|
+
@page.dirty?.should == true
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns false if everything is up to date' do
|
101
|
+
dest = @page.destination
|
102
|
+
FileUtils.touch dest
|
103
|
+
FileUtils.touch ::Webby.cairn
|
104
|
+
|
105
|
+
@page.dirty?.should == false
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end # describe Webby::Resources::Page
|
110
|
+
|
111
|
+
# EOF
|
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
|
4
|
+
|
5
|
+
# -------------------------------------------------------------------------
|
6
|
+
describe Webby::Resources::Partial do
|
7
|
+
before :each do
|
8
|
+
@filename = File.join %w[content _partial.txt]
|
9
|
+
@partial = Webby::Resources::Partial.new(@filename)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'parses meta-data on initialization' do
|
13
|
+
h = @partial._meta_data
|
14
|
+
|
15
|
+
h.should_not be_empty
|
16
|
+
h.should == {'filter' => 'erb'}
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'uses the cairn file as the destination' do
|
20
|
+
@partial.destination.should == ::Webby.cairn
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'always returns nil as the url' do
|
24
|
+
@partial.url.should be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'reads the contents of the file' do
|
28
|
+
str = @partial._read
|
29
|
+
str.split($/).first.should == 'A partial has access to the page from which it was called. The title below will be the title of the page in which this partial is rendered.'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'uses the files extension as the extension' do
|
33
|
+
@partial.extension.should equal(@partial.ext)
|
34
|
+
end
|
35
|
+
|
36
|
+
# -----------------------------------------------------------------------
|
37
|
+
describe '.dirty?' do
|
38
|
+
it 'overrides the dirty state based on the meta-data value' do
|
39
|
+
@partial['dirty'] = true
|
40
|
+
@partial.dirty?.should == true
|
41
|
+
|
42
|
+
@partial['dirty'] = false
|
43
|
+
@partial.dirty?.should == false
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'returns true if the cairn file is missing' do
|
47
|
+
@partial.dirty?.should == true
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'returns false if the cairn file is present' do
|
51
|
+
FileUtils.touch Webby.cairn
|
52
|
+
@partial.dirty?.should == false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end # describe Webby::Resources::Partial
|
57
|
+
|
58
|
+
# EOF
|
@@ -0,0 +1,219 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
|
4
|
+
|
5
|
+
# -------------------------------------------------------------------------
|
6
|
+
describe Webby::Resources::Resource do
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
layout = Webby::Resources::Layout.
|
10
|
+
new(Webby.datapath %w[site layouts default.txt])
|
11
|
+
Webby::Resources.stub!(:find_layout).and_return(layout)
|
12
|
+
|
13
|
+
@filename = File.join %w[content index.txt]
|
14
|
+
@resource = Webby::Resources::Resource.new(@filename)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'does not parse meta-data by default' do
|
18
|
+
@resource._meta_data.should be_empty
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'provides the path to the file' do
|
22
|
+
@resource.path.should == @filename
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns the bare filename' do
|
26
|
+
@resource.name.should == 'index'
|
27
|
+
|
28
|
+
resource = Webby::Resources::Resource.
|
29
|
+
new(File.join(%w[content tumblog rss.txt]))
|
30
|
+
resource.name.should == 'rss'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns the path-based extension' do
|
34
|
+
@resource.ext.should == 'txt'
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'computes the directory of the file with the content folder removed' do
|
38
|
+
@resource.dir.should == ''
|
39
|
+
|
40
|
+
resource = Webby::Resources::Resource.
|
41
|
+
new(File.join(%w[content tumblog index.txt]))
|
42
|
+
resource.dir.should == 'tumblog'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns the modification time of the file' do
|
46
|
+
@resource.mtime.should be_instance_of(Time)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'determines equality from the full path' do
|
50
|
+
a = Webby::Resources::Resource.new(File.join(%w[content tumblog index.txt]))
|
51
|
+
b = Webby::Resources::Resource.new(File.join(%w[content tumblog rss.txt]))
|
52
|
+
c = Webby::Resources::Resource.new(File.join(%w[content tumblog index.txt]))
|
53
|
+
|
54
|
+
(a == b).should == false
|
55
|
+
(a == c).should == true
|
56
|
+
(b == c).should == false
|
57
|
+
(a == nil).should == false
|
58
|
+
(a == a.path).should == false
|
59
|
+
|
60
|
+
b['filename'] = 'index'
|
61
|
+
b._reset
|
62
|
+
b.destination.should == a.destination
|
63
|
+
(a == b).should == false
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'compares two resources by path' do
|
67
|
+
a = Webby::Resources::Resource.new(File.join(%w[content tumblog index.txt]))
|
68
|
+
b = Webby::Resources::Resource.new(File.join(%w[content tumblog rss.txt]))
|
69
|
+
c = Webby::Resources::Resource.new(File.join(%w[content tumblog index.txt]))
|
70
|
+
|
71
|
+
(a <=> b).should == -1
|
72
|
+
(b <=> a).should == 1
|
73
|
+
(a <=> c).should == 0
|
74
|
+
(a <=> a).should == 0
|
75
|
+
(a <=> nil).should be_nil
|
76
|
+
(a <=> a.path).should be_nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'can alter meta-data' do
|
80
|
+
@resource['title'].should be_nil
|
81
|
+
@resource[:title] = 'Home Page'
|
82
|
+
|
83
|
+
@resource['title'].should == 'Home Page'
|
84
|
+
@resource[:title].should == 'Home Page'
|
85
|
+
@resource[:title].should equal(@resource['title'])
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'overrides the dirty state based on the meta-data value' do
|
89
|
+
@resource['dirty'] = true
|
90
|
+
@resource.dirty?.should == true
|
91
|
+
|
92
|
+
@resource['dirty'] = false
|
93
|
+
@resource.dirty?.should == false
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'reads the contents of the file' do
|
97
|
+
str = @resource._read
|
98
|
+
str.split($/).first.should == "p(title). <%= @page.title %>"
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'repleces the meta-data hash when reset' do
|
102
|
+
@resource._meta_data.should be_empty
|
103
|
+
oid = @resource._meta_data.object_id
|
104
|
+
|
105
|
+
@resource._reset('foo' => 'bar')
|
106
|
+
@resource._meta_data.should_not be_empty
|
107
|
+
@resource._meta_data.object_id.should == oid
|
108
|
+
@resource._meta_data['foo'].should == 'bar'
|
109
|
+
end
|
110
|
+
|
111
|
+
# -----------------------------------------------------------------------
|
112
|
+
describe '.filename' do
|
113
|
+
it 'uses the filename from the meta-data if present' do
|
114
|
+
@resource['filename'] = 'bozo'
|
115
|
+
@resource.filename.should == 'bozo'
|
116
|
+
end
|
117
|
+
|
118
|
+
it "uses the file's filename as a last ditch effort" do
|
119
|
+
@resource.filename.should == 'index'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# -----------------------------------------------------------------------
|
124
|
+
describe '.extension' do
|
125
|
+
it 'uses the extension from the meta-data if present' do
|
126
|
+
@resource['extension'] = 'foo'
|
127
|
+
@resource.extension.should == 'foo'
|
128
|
+
end
|
129
|
+
|
130
|
+
it "uses the file's extension as a last ditch effort" do
|
131
|
+
@resource.extension.should == 'txt'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# -----------------------------------------------------------------------
|
136
|
+
describe '.directory' do
|
137
|
+
it 'uses the directory from the meta-data if present' do
|
138
|
+
@resource['directory'] = 'foo'
|
139
|
+
@resource.directory.should == 'foo'
|
140
|
+
end
|
141
|
+
|
142
|
+
it "uses the file's directory as a last ditch effort" do
|
143
|
+
@resource.directory.should == ''
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# -----------------------------------------------------------------------
|
148
|
+
describe '.url' do
|
149
|
+
it 'computes the url from the filename and directory' do
|
150
|
+
@resource.url.should == '/index.txt'
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'caches the url' do
|
154
|
+
@resource.url.should == '/index.txt'
|
155
|
+
|
156
|
+
@resource['directory'] = 'foo/bar/baz'
|
157
|
+
@resource.url.should == '/index.txt'
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'clears the cached url on reset' do
|
161
|
+
@resource.url.should == '/index.txt'
|
162
|
+
|
163
|
+
@resource['directory'] = 'foo/bar/baz'
|
164
|
+
@resource.url.should == '/index.txt'
|
165
|
+
|
166
|
+
@resource._reset
|
167
|
+
@resource.url.should == '/foo/bar/baz/index.txt'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# -----------------------------------------------------------------------
|
172
|
+
describe '.destination' do
|
173
|
+
it 'computes the destination from the filename and directory' do
|
174
|
+
@resource.destination.should == 'output/index.txt'
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'caches the destination' do
|
178
|
+
@resource.destination.should == 'output/index.txt'
|
179
|
+
|
180
|
+
@resource['directory'] = 'foo/bar/baz'
|
181
|
+
@resource.destination.should == 'output/index.txt'
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'clears the cached destination on reset' do
|
185
|
+
@resource.destination.should == 'output/index.txt'
|
186
|
+
|
187
|
+
@resource['directory'] = 'foo/bar/baz'
|
188
|
+
@resource.destination.should == 'output/index.txt'
|
189
|
+
|
190
|
+
@resource._reset
|
191
|
+
@resource.destination.should == 'output/foo/bar/baz/index.txt'
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# -----------------------------------------------------------------------
|
196
|
+
describe '.dirty?' do
|
197
|
+
it 'overrides the dirty state based on the meta-data value' do
|
198
|
+
@resource['dirty'] = true
|
199
|
+
@resource.dirty?.should == true
|
200
|
+
|
201
|
+
@resource['dirty'] = false
|
202
|
+
@resource.dirty?.should == false
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'returns true if the output file is missing' do
|
206
|
+
@resource.dirty?.should == true
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'returns false if everything is up to date' do
|
210
|
+
dest = @resource.destination
|
211
|
+
FileUtils.touch dest
|
212
|
+
|
213
|
+
@resource.dirty?.should == false
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
end # describe Webby::Resources::Resource
|
218
|
+
|
219
|
+
# EOF
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
|
4
|
+
|
5
|
+
# -------------------------------------------------------------------------
|
6
|
+
describe Webby::Resources::Static do
|
7
|
+
before :all do
|
8
|
+
@filename = File.join %w[content css coderay.css]
|
9
|
+
@static = Webby::Resources::Static.new(@filename)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'contains no meta-data' do
|
13
|
+
@static._meta_data.should be_empty
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'uses the path remounted to the output directory as the destination' do
|
17
|
+
@static.destination.should == 'output/css/coderay.css'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns destination without the output directory as the url' do
|
21
|
+
@static.url.should == '/css/coderay.css'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'reads the contents of the file' do
|
25
|
+
str = @static._read
|
26
|
+
str.split($/).first.should == '.CodeRay {'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'uses the file extension as the extension' do
|
30
|
+
@static.extension.should equal(@static.ext)
|
31
|
+
end
|
32
|
+
|
33
|
+
# -----------------------------------------------------------------------
|
34
|
+
describe '.dirty?' do
|
35
|
+
it 'returns true if the output file is missing' do
|
36
|
+
@static.dirty?.should == true
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns false if the output file is present' do
|
40
|
+
dest = @static.destination
|
41
|
+
FileUtils.mkdir_p File.dirname(dest)
|
42
|
+
FileUtils.touch dest
|
43
|
+
@static.dirty?.should == false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end # describe Webby::Resources::Static
|
48
|
+
|
49
|
+
# EOF
|
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require File.expand_path(
|
4
|
+
File.join(File.dirname(__FILE__), %w[.. spec_helper]))
|
5
|
+
|
6
|
+
# --------------------------------------------------------------------------
|
7
|
+
describe Webby::Resources do
|
8
|
+
before :each do
|
9
|
+
Webby::Resources.clear
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should raise a useful error if there are no layouts" do
|
13
|
+
layouts = mock("Layouts")
|
14
|
+
Webby::Resources.stub!(:layouts).and_return(layouts)
|
15
|
+
layouts.should_receive(:find).and_raise RuntimeError
|
16
|
+
|
17
|
+
lambda do
|
18
|
+
Webby::Resources.find_layout("default")
|
19
|
+
end.should raise_error(Webby::Error, 'could not find layout "default"')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return the directory name for a file" do
|
23
|
+
Webby::Resources.dirname('content').should == './'
|
24
|
+
Webby::Resources.dirname('layouts').should == './'
|
25
|
+
|
26
|
+
Webby::Resources.dirname('content/index.txt').should == ''
|
27
|
+
Webby::Resources.dirname('layouts/default.txt').should == ''
|
28
|
+
|
29
|
+
Webby::Resources.dirname('content/tumblog/index.txt').should == 'tumblog'
|
30
|
+
Webby::Resources.dirname('layouts/tumblog/post.txt').should == 'tumblog'
|
31
|
+
|
32
|
+
Webby::Resources.dirname('output/tumblog/index.html').should == 'output/tumblog'
|
33
|
+
Webby::Resources.dirname('templates/tumblog/post.erb').should == 'templates/tumblog'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should normalize the path for a filename" do
|
37
|
+
Webby::Resources.path('content').should == 'content'
|
38
|
+
Webby::Resources.path('/content').should == 'content'
|
39
|
+
Webby::Resources.path('./content').should == 'content'
|
40
|
+
|
41
|
+
Webby::Resources.path('./').should == ''
|
42
|
+
Webby::Resources.path('/').should == ''
|
43
|
+
Webby::Resources.path('').should == ''
|
44
|
+
end
|
45
|
+
|
46
|
+
# ------------------------------------------------------------------------
|
47
|
+
describe "#new" do
|
48
|
+
before :each do
|
49
|
+
layout = Webby::Resources::Layout.
|
50
|
+
new(Webby.datapath %w[site layouts default.txt])
|
51
|
+
Webby::Resources.stub!(:find_layout).and_return(layout)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "creates multiple pages for files with multiple YAML sections" do
|
55
|
+
pages = Webby::Resources.pages
|
56
|
+
|
57
|
+
fn = File.join %w[content photos.txt]
|
58
|
+
Webby::Resources.new(fn)
|
59
|
+
|
60
|
+
ary = pages.find(:all, :in_directory => 'photos')
|
61
|
+
ary.map {|page| page.title}.should == [
|
62
|
+
'First Photo', 'Second Photo', 'Third Photo'
|
63
|
+
]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
# EOF
|