webby 0.9.3-x86-mswin32

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.
Files changed (229) hide show
  1. data/History.txt +206 -0
  2. data/Manifest.txt +228 -0
  3. data/README.txt +92 -0
  4. data/Rakefile +49 -0
  5. data/bin/webby +41 -0
  6. data/bin/webby-gen +41 -0
  7. data/examples/blog/Sitefile +7 -0
  8. data/examples/blog/tasks/blog.rake +72 -0
  9. data/examples/blog/templates/atom_feed.erb +40 -0
  10. data/examples/blog/templates/blog/month.erb +22 -0
  11. data/examples/blog/templates/blog/post.erb +16 -0
  12. data/examples/blog/templates/blog/year.erb +22 -0
  13. data/examples/presentation/Sitefile +10 -0
  14. data/examples/presentation/content/css/uv/twilight.css +137 -0
  15. data/examples/presentation/content/presentation/_sample_code.txt +10 -0
  16. data/examples/presentation/content/presentation/index.txt +63 -0
  17. data/examples/presentation/content/presentation/s5/blank.gif +0 -0
  18. data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
  19. data/examples/presentation/content/presentation/s5/framing.css +23 -0
  20. data/examples/presentation/content/presentation/s5/iepngfix.htc +42 -0
  21. data/examples/presentation/content/presentation/s5/opera.css +7 -0
  22. data/examples/presentation/content/presentation/s5/outline.css +15 -0
  23. data/examples/presentation/content/presentation/s5/pretty.css +86 -0
  24. data/examples/presentation/content/presentation/s5/print.css +25 -0
  25. data/examples/presentation/content/presentation/s5/s5-core.css +9 -0
  26. data/examples/presentation/content/presentation/s5/slides.css +3 -0
  27. data/examples/presentation/content/presentation/s5/slides.js +553 -0
  28. data/examples/presentation/layouts/presentation.txt +43 -0
  29. data/examples/presentation/templates/_code_partial.erb +13 -0
  30. data/examples/presentation/templates/presentation.erb +40 -0
  31. data/examples/tumblog/Sitefile +9 -0
  32. data/examples/tumblog/content/css/tumblog.css +308 -0
  33. data/examples/tumblog/content/images/tumblog/permalink.gif +0 -0
  34. data/examples/tumblog/content/images/tumblog/rss.gif +0 -0
  35. data/examples/tumblog/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  36. data/examples/tumblog/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  37. data/examples/tumblog/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  38. data/examples/tumblog/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  39. data/examples/tumblog/content/tumblog/200807/up-a-tree/index.txt +13 -0
  40. data/examples/tumblog/content/tumblog/index.txt +37 -0
  41. data/examples/tumblog/content/tumblog/rss.txt +37 -0
  42. data/examples/tumblog/layouts/tumblog/default.txt +44 -0
  43. data/examples/tumblog/layouts/tumblog/post.txt +15 -0
  44. data/examples/tumblog/lib/tumblog_helper.rb +32 -0
  45. data/examples/tumblog/tasks/tumblog.rake +30 -0
  46. data/examples/tumblog/templates/atom_feed.erb +40 -0
  47. data/examples/tumblog/templates/tumblog/conversation.erb +12 -0
  48. data/examples/tumblog/templates/tumblog/link.erb +10 -0
  49. data/examples/tumblog/templates/tumblog/photo.erb +13 -0
  50. data/examples/tumblog/templates/tumblog/post.erb +12 -0
  51. data/examples/tumblog/templates/tumblog/quote.erb +11 -0
  52. data/examples/webby/Sitefile +19 -0
  53. data/examples/webby/content/communicate/index.txt +28 -0
  54. data/examples/webby/content/css/background.gif +0 -0
  55. data/examples/webby/content/css/blueprint/print.css +76 -0
  56. data/examples/webby/content/css/blueprint/screen.css +696 -0
  57. data/examples/webby/content/css/coderay.css +96 -0
  58. data/examples/webby/content/css/site.css +196 -0
  59. data/examples/webby/content/css/uv/twilight.css +137 -0
  60. data/examples/webby/content/index.txt +37 -0
  61. data/examples/webby/content/learn/index.txt +28 -0
  62. data/examples/webby/content/reference/index.txt +204 -0
  63. data/examples/webby/content/release-notes/index.txt +21 -0
  64. data/examples/webby/content/release-notes/rel-0-9-0/index.txt +74 -0
  65. data/examples/webby/content/release-notes/rel-0-9-1/index.txt +93 -0
  66. data/examples/webby/content/release-notes/rel-0-9-2/index.txt +14 -0
  67. data/examples/webby/content/release-notes/rel-0-9-3/index.txt +49 -0
  68. data/examples/webby/content/robots.txt +6 -0
  69. data/examples/webby/content/script/jquery.corner.js +152 -0
  70. data/examples/webby/content/script/jquery.js +31 -0
  71. data/examples/webby/content/sitemap.txt +31 -0
  72. data/examples/webby/content/tips_and_tricks/index.txt +97 -0
  73. data/examples/webby/content/tutorial/index.txt +135 -0
  74. data/examples/webby/content/user-manual/index.txt +419 -0
  75. data/examples/webby/layouts/default.txt +49 -0
  76. data/examples/webby/templates/page.erb +10 -0
  77. data/examples/website/Sitefile +7 -0
  78. data/examples/website/content/css/blueprint/License.txt +21 -0
  79. data/examples/website/content/css/blueprint/Readme.txt +100 -0
  80. data/examples/website/content/css/blueprint/compressed/print.css +76 -0
  81. data/examples/website/content/css/blueprint/compressed/screen.css +696 -0
  82. data/examples/website/content/css/blueprint/lib/forms.css +45 -0
  83. data/examples/website/content/css/blueprint/lib/grid.css +193 -0
  84. data/examples/website/content/css/blueprint/lib/grid.png +0 -0
  85. data/examples/website/content/css/blueprint/lib/ie.css +30 -0
  86. data/examples/website/content/css/blueprint/lib/reset.css +39 -0
  87. data/examples/website/content/css/blueprint/lib/typography.css +116 -0
  88. data/examples/website/content/css/blueprint/plugins/buttons/Readme +31 -0
  89. data/examples/website/content/css/blueprint/plugins/buttons/buttons.css +97 -0
  90. data/examples/website/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  91. data/examples/website/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
  92. data/examples/website/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  93. data/examples/website/content/css/blueprint/plugins/css-classes/Readme +14 -0
  94. data/examples/website/content/css/blueprint/plugins/css-classes/css-classes.css +24 -0
  95. data/examples/website/content/css/blueprint/plugins/fancy-type/Readme +22 -0
  96. data/examples/website/content/css/blueprint/plugins/fancy-type/fancy-type-compressed.css +5 -0
  97. data/examples/website/content/css/blueprint/plugins/fancy-type/fancy-type.css +74 -0
  98. data/examples/website/content/css/blueprint/print.css +68 -0
  99. data/examples/website/content/css/blueprint/screen.css +22 -0
  100. data/examples/website/content/css/coderay.css +111 -0
  101. data/examples/website/content/css/site.css +67 -0
  102. data/examples/website/content/index.txt +19 -0
  103. data/examples/website/layouts/default.txt +58 -0
  104. data/examples/website/lib/breadcrumbs.rb +28 -0
  105. data/examples/website/templates/_partial.erb +10 -0
  106. data/examples/website/templates/page.erb +18 -0
  107. data/lib/webby.rb +221 -0
  108. data/lib/webby/apps.rb +12 -0
  109. data/lib/webby/apps/generator.rb +276 -0
  110. data/lib/webby/apps/main.rb +255 -0
  111. data/lib/webby/auto_builder.rb +157 -0
  112. data/lib/webby/builder.rb +180 -0
  113. data/lib/webby/core_ext/enumerable.rb +11 -0
  114. data/lib/webby/core_ext/hash.rb +28 -0
  115. data/lib/webby/core_ext/kernel.rb +26 -0
  116. data/lib/webby/core_ext/string.rb +163 -0
  117. data/lib/webby/core_ext/time.rb +9 -0
  118. data/lib/webby/filters.rb +83 -0
  119. data/lib/webby/filters/basepath.rb +97 -0
  120. data/lib/webby/filters/erb.rb +9 -0
  121. data/lib/webby/filters/haml.rb +18 -0
  122. data/lib/webby/filters/markdown.rb +16 -0
  123. data/lib/webby/filters/outline.rb +309 -0
  124. data/lib/webby/filters/sass.rb +17 -0
  125. data/lib/webby/filters/slides.rb +56 -0
  126. data/lib/webby/filters/textile.rb +16 -0
  127. data/lib/webby/filters/tidy.rb +76 -0
  128. data/lib/webby/filters/wiki_words.rb +14 -0
  129. data/lib/webby/helpers.rb +30 -0
  130. data/lib/webby/helpers/capture_helper.rb +141 -0
  131. data/lib/webby/helpers/coderay_helper.rb +69 -0
  132. data/lib/webby/helpers/graphviz_helper.rb +136 -0
  133. data/lib/webby/helpers/tag_helper.rb +65 -0
  134. data/lib/webby/helpers/tex_img_helper.rb +133 -0
  135. data/lib/webby/helpers/ultraviolet_helper.rb +63 -0
  136. data/lib/webby/helpers/url_helper.rb +241 -0
  137. data/lib/webby/journal.rb +126 -0
  138. data/lib/webby/link_validator.rb +152 -0
  139. data/lib/webby/renderer.rb +386 -0
  140. data/lib/webby/resources.rb +136 -0
  141. data/lib/webby/resources/db.rb +251 -0
  142. data/lib/webby/resources/layout.rb +54 -0
  143. data/lib/webby/resources/meta_file.rb +211 -0
  144. data/lib/webby/resources/page.rb +81 -0
  145. data/lib/webby/resources/partial.rb +85 -0
  146. data/lib/webby/resources/resource.rb +201 -0
  147. data/lib/webby/resources/static.rb +36 -0
  148. data/lib/webby/stelan/mktemp.rb +135 -0
  149. data/lib/webby/stelan/paginator.rb +165 -0
  150. data/lib/webby/stelan/spawner.rb +339 -0
  151. data/lib/webby/tasks/build.rake +27 -0
  152. data/lib/webby/tasks/create.rake +22 -0
  153. data/lib/webby/tasks/deploy.rake +22 -0
  154. data/lib/webby/tasks/growl.rake +16 -0
  155. data/lib/webby/tasks/validate.rake +19 -0
  156. data/spec/core_ext/hash_spec.rb +47 -0
  157. data/spec/core_ext/string_spec.rb +110 -0
  158. data/spec/core_ext/time_spec.rb +19 -0
  159. data/spec/data/hooligans/bad_meta_data_1.txt +34 -0
  160. data/spec/data/hooligans/bad_meta_data_2.txt +34 -0
  161. data/spec/data/outline/basic.out +81 -0
  162. data/spec/data/outline/basic.txt +25 -0
  163. data/spec/data/outline/no_clobber.out +86 -0
  164. data/spec/data/outline/numbering.out +81 -0
  165. data/spec/data/outline/numbering_only.out +21 -0
  166. data/spec/data/outline/toc_range_1.out +66 -0
  167. data/spec/data/outline/toc_range_2.out +55 -0
  168. data/spec/data/outline/toc_style.out +81 -0
  169. data/spec/data/site/Sitefile +9 -0
  170. data/spec/data/site/content/_partial.txt +10 -0
  171. data/spec/data/site/content/css/coderay.css +111 -0
  172. data/spec/data/site/content/css/site.css +67 -0
  173. data/spec/data/site/content/css/tumblog.css +308 -0
  174. data/spec/data/site/content/images/tumblog/permalink.gif +0 -0
  175. data/spec/data/site/content/images/tumblog/rss.gif +0 -0
  176. data/spec/data/site/content/index.txt +19 -0
  177. data/spec/data/site/content/photos.txt +21 -0
  178. data/spec/data/site/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  179. data/spec/data/site/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  180. data/spec/data/site/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  181. data/spec/data/site/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  182. data/spec/data/site/content/tumblog/200807/up-a-tree/index.txt +13 -0
  183. data/spec/data/site/content/tumblog/index.txt +37 -0
  184. data/spec/data/site/content/tumblog/rss.txt +37 -0
  185. data/spec/data/site/layouts/default.txt +58 -0
  186. data/spec/data/site/layouts/tumblog/default.txt +44 -0
  187. data/spec/data/site/layouts/tumblog/post.txt +15 -0
  188. data/spec/data/site/lib/breadcrumbs.rb +28 -0
  189. data/spec/data/site/lib/tumblog_helper.rb +32 -0
  190. data/spec/data/site/tasks/tumblog.rake +30 -0
  191. data/spec/data/site/templates/_partial.erb +10 -0
  192. data/spec/data/site/templates/atom_feed.erb +40 -0
  193. data/spec/data/site/templates/page.erb +18 -0
  194. data/spec/data/site/templates/presentation.erb +40 -0
  195. data/spec/data/site/templates/tumblog/conversation.erb +12 -0
  196. data/spec/data/site/templates/tumblog/link.erb +10 -0
  197. data/spec/data/site/templates/tumblog/photo.erb +13 -0
  198. data/spec/data/site/templates/tumblog/post.erb +12 -0
  199. data/spec/data/site/templates/tumblog/quote.erb +11 -0
  200. data/spec/spec.opts +1 -0
  201. data/spec/spec_helper.rb +51 -0
  202. data/spec/webby/apps/generator_spec.rb +116 -0
  203. data/spec/webby/apps/main_spec.rb +88 -0
  204. data/spec/webby/filters/basepath_spec.rb +167 -0
  205. data/spec/webby/filters/outline_spec.rb +92 -0
  206. data/spec/webby/filters/textile_spec.rb +20 -0
  207. data/spec/webby/helpers/capture_helper_spec.rb +56 -0
  208. data/spec/webby/renderer_spec.rb +139 -0
  209. data/spec/webby/resources/db_spec.rb +250 -0
  210. data/spec/webby/resources/layout_spec.rb +83 -0
  211. data/spec/webby/resources/meta_file_spec.rb +171 -0
  212. data/spec/webby/resources/page_spec.rb +111 -0
  213. data/spec/webby/resources/partial_spec.rb +58 -0
  214. data/spec/webby/resources/resource_spec.rb +219 -0
  215. data/spec/webby/resources/static_spec.rb +49 -0
  216. data/spec/webby/resources_spec.rb +69 -0
  217. data/tasks/ann.rake +81 -0
  218. data/tasks/bones.rake +21 -0
  219. data/tasks/gem.rake +187 -0
  220. data/tasks/git.rake +41 -0
  221. data/tasks/manifest.rake +48 -0
  222. data/tasks/notes.rake +28 -0
  223. data/tasks/post_load.rake +39 -0
  224. data/tasks/rdoc.rake +51 -0
  225. data/tasks/rubyforge.rake +55 -0
  226. data/tasks/setup.rb +268 -0
  227. data/tasks/spec.rake +55 -0
  228. data/tasks/website.rake +38 -0
  229. metadata +365 -0
@@ -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,20 @@
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
+ it 'processes textile markup into HTML' do
13
+ input = "p(foo). this is a paragraph of text"
14
+ output = Webby::Filters._handlers['textile'].call(input)
15
+
16
+ output.should == %q{<p class="foo">this is a paragraph of text</p>}
17
+ end
18
+ end
19
+
20
+ # 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,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
@@ -0,0 +1,250 @@
1
+
2
+ require File.expand_path(
3
+ File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
4
+
5
+ # -------------------------------------------------------------------------
6
+ describe Webby::Resources::DB do
7
+
8
+ before :each do
9
+ layout = Webby::Resources::Layout.
10
+ new(Webby.datapath %w[site layouts tumblog default.txt])
11
+ Webby::Resources.stub!(:find_layout).and_return(layout)
12
+
13
+ @db = Webby::Resources::DB.new
14
+ Dir.glob('content/tumblog/**/*').each do |fn|
15
+ next unless test(?f, fn)
16
+ @db.add Webby::Resources::Page.new(fn)
17
+ end
18
+ @db_hash = @db.instance_variable_get(:@db)
19
+ end
20
+
21
+ it 'stores resources by directory' do
22
+ @db_hash.keys.sort.should == %w[
23
+ tumblog
24
+ tumblog/200806/the-noble-chicken
25
+ tumblog/200807/historical-perspectives-on-the-classic-chicken-joke
26
+ tumblog/200807/mad-city-chickens
27
+ tumblog/200807/the-wisdom-of-the-dutch
28
+ tumblog/200807/up-a-tree
29
+ ]
30
+ @db_hash['tumblog'].length.should == 2
31
+ @db_hash['tumblog/200807/up-a-tree'].length.should == 1
32
+ @db_hash['tumblog/200807/up-a-tree'].first.filename.should == 'index'
33
+ end
34
+
35
+ it 'replaces resources when adding' do
36
+ ary = @db_hash['tumblog/200806/the-noble-chicken']
37
+ page = ary.first
38
+
39
+ @db.add Webby::Resources::Page.
40
+ new('content/tumblog/200806/the-noble-chicken/index.txt')
41
+
42
+ ary.first.should_not equal(page)
43
+ ary.first.path.should == page.path
44
+ end
45
+
46
+ it 'clears the stored resources' do
47
+ @db_hash.should_not be_empty
48
+ @db.clear
49
+ @db_hash.should be_empty
50
+ end
51
+
52
+ it 'iterates over the resources in order' do
53
+ ary = []
54
+ @db.each {|page| ary << page.url}
55
+ ary.should == %w[
56
+ /tumblog
57
+ /tumblog/rss.xml
58
+ /tumblog/200806/the-noble-chicken
59
+ /tumblog/200807/historical-perspectives-on-the-classic-chicken-joke
60
+ /tumblog/200807/mad-city-chickens
61
+ /tumblog/200807/the-wisdom-of-the-dutch
62
+ /tumblog/200807/up-a-tree
63
+ ]
64
+ end
65
+
66
+ it 'returns the parent of a resource' do
67
+ page = Webby::Resources::Page.new('content/tumblog/index.txt')
68
+ parent = @db.parent_of(page)
69
+ (parent == nil).should == true
70
+
71
+ page = Webby::Resources::Page.new('content/tumblog/rss.txt')
72
+ parent = @db.parent_of(page)
73
+ parent.url.should == '/tumblog'
74
+
75
+ page = Webby::Resources::Page.new('content/tumblog/200807/up-a-tree/index.txt')
76
+ parent = @db.parent_of(page)
77
+ parent.url.should == '/tumblog'
78
+ end
79
+
80
+ it 'returns the siblings of a resource' do
81
+ page = Webby::Resources::Page.new('content/tumblog/index.txt')
82
+ siblings = @db.siblings(page)
83
+
84
+ siblings.length.should == 1
85
+ siblings.first.path.should == 'content/tumblog/rss.txt'
86
+
87
+ page = Webby::Resources::Page.new('content/tumblog/200806/the-noble-chicken/index.txt')
88
+ siblings = @db.siblings(page)
89
+ siblings.should be_empty
90
+ end
91
+
92
+ # -----------------------------------------------------------------------
93
+ describe '.children' do
94
+ it 'returns the children of a resource' do
95
+ page = Webby::Resources::Page.new('content/tumblog/index.txt')
96
+ children = @db.children(page)
97
+
98
+ children.length.should == 5
99
+ children.map {|page| page.url}.sort.should == %w[
100
+ /tumblog/200806/the-noble-chicken
101
+ /tumblog/200807/historical-perspectives-on-the-classic-chicken-joke
102
+ /tumblog/200807/mad-city-chickens
103
+ /tumblog/200807/the-wisdom-of-the-dutch
104
+ /tumblog/200807/up-a-tree
105
+ ]
106
+ end
107
+
108
+ it 'returns them in the specified sort order' do
109
+ page = Webby::Resources::Page.new('content/tumblog/index.txt')
110
+ children = @db.children(page, :sort_by => :url)
111
+
112
+ children.length.should == 5
113
+ children.map {|page| page.url}.should == %w[
114
+ /tumblog/200806/the-noble-chicken
115
+ /tumblog/200807/historical-perspectives-on-the-classic-chicken-joke
116
+ /tumblog/200807/mad-city-chickens
117
+ /tumblog/200807/the-wisdom-of-the-dutch
118
+ /tumblog/200807/up-a-tree
119
+ ]
120
+ end
121
+
122
+ it 'returns them in the reversed sort order' do
123
+ page = Webby::Resources::Page.new('content/tumblog/index.txt')
124
+ children = @db.children(page, :sort_by => :url, :reverse => true)
125
+
126
+ children.length.should == 5
127
+ children.map {|page| page.url}.should == %w[
128
+ /tumblog/200806/the-noble-chicken
129
+ /tumblog/200807/historical-perspectives-on-the-classic-chicken-joke
130
+ /tumblog/200807/mad-city-chickens
131
+ /tumblog/200807/the-wisdom-of-the-dutch
132
+ /tumblog/200807/up-a-tree
133
+ ].reverse
134
+ end
135
+ end
136
+
137
+ # -----------------------------------------------------------------------
138
+ describe '.find' do
139
+ it 'returns the first page if no options are given' do
140
+ page = @db.each {|p| break p}
141
+ @db.find.path.should == page.path
142
+ end
143
+
144
+ it 'returns all pages' do
145
+ ary = []
146
+ @db.each {|p| ary << p.path}
147
+
148
+ pages = @db.find(:all)
149
+ pages.map! {|p| p.path}
150
+ pages.should == ary
151
+
152
+ pages = @db.find(:limit => :all)
153
+ pages.map! {|p| p.path}
154
+ pages.should == ary
155
+
156
+ pages = @db.find('all')
157
+ pages.map! {|p| p.path}
158
+ pages.should == ary
159
+ end
160
+
161
+ it 'returns a limited number of pages' do
162
+ ary = []
163
+ @db.each {|p| ary << p.path}
164
+ ary = ary.slice(0,3)
165
+
166
+ pages = @db.find(3)
167
+ pages.map! {|p| p.path}
168
+ pages.should == ary
169
+
170
+ pages = @db.find(:limit => 3)
171
+ pages.map! {|p| p.path}
172
+ pages.should == ary
173
+ end
174
+
175
+ it 'can sorty by a given meta-data field' do
176
+ pages = @db.find(:all, :sort_by => 'title')
177
+ pages.map! {|p| p.title}
178
+ pages.should == [
179
+ 'A Mother Clucker',
180
+ 'A Mother Clucker',
181
+ 'Historical Perspectives on the Classic Chicken Joke',
182
+ 'Mad City Chickens',
183
+ 'The Noble Chicken',
184
+ 'The Wisdom of the Dutch',
185
+ 'Up a Tree'
186
+ ]
187
+
188
+ pages = @db.find(:all, :sort_by => 'tumblog_type')
189
+ pages.map! {|p| p.tumblog_type}
190
+ pages.should == %w[conversation link photo quote regular]
191
+ end
192
+
193
+ it 'can reverse the sort order' do
194
+ pages = @db.find(:all, :sort_by => 'tumblog_type', :reverse => true)
195
+ pages.map! {|p| p.tumblog_type}
196
+ pages.should == %w[conversation link photo quote regular].reverse
197
+
198
+ pages = @db.find(3, :sort_by => 'tumblog_type', :reverse => true)
199
+ pages.map! {|p| p.tumblog_type}
200
+ pages.should == %w[regular quote photo]
201
+ end
202
+
203
+ it 'can search is a specific directory' do
204
+ pages = @db.find('all', :in_directory => 'tumblog')
205
+ pages.map! {|p| p.path}
206
+ pages.should == %w[
207
+ content/tumblog/index.txt
208
+ content/tumblog/rss.txt
209
+ ]
210
+ end
211
+
212
+ it 'can recurse into directories' do
213
+ pages = @db.find('all', :in_directory => 'tumblog/200807', :recursive => true)
214
+ pages.map! {|p| p.title}
215
+ pages.should == [
216
+ 'The Wisdom of the Dutch',
217
+ 'Mad City Chickens',
218
+ 'Historical Perspectives on the Classic Chicken Joke',
219
+ 'Up a Tree'
220
+ ]
221
+ end
222
+
223
+ it 'can combine all these options' do
224
+ pages = @db.find(:limit => 2,
225
+ :in_directory => 'tumblog/200807', :recursive => true,
226
+ :sort_by => 'title', :reverse => true,
227
+ :author => 'Tim Pease')
228
+ pages.map! {|p| p.title}
229
+ pages.should == [
230
+ 'Up a Tree',
231
+ 'Mad City Chickens'
232
+ ]
233
+ end
234
+
235
+ it 'can find pages using a user supplied search block' do
236
+ pages = @db.find(:all, :sort_by => 'title') do |page|
237
+ %w[quote conversation photo].include? page.tumblog_type
238
+ end
239
+ pages.map! {|p| p.title}
240
+ pages.should == [
241
+ 'Historical Perspectives on the Classic Chicken Joke',
242
+ 'The Wisdom of the Dutch',
243
+ 'Up a Tree'
244
+ ]
245
+ end
246
+ end
247
+
248
+ end # describe Webby::Resources::DB
249
+
250
+ # EOF