francois-webby 0.9.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. data/History.txt +218 -0
  2. data/README.rdoc +92 -0
  3. data/Rakefile +62 -0
  4. data/bin/webby +41 -0
  5. data/bin/webby-gen +41 -0
  6. data/examples/blog/Sitefile +7 -0
  7. data/examples/blog/tasks/blog.rake +72 -0
  8. data/examples/blog/templates/atom_feed.erb +40 -0
  9. data/examples/blog/templates/blog/month.erb +22 -0
  10. data/examples/blog/templates/blog/post.erb +16 -0
  11. data/examples/blog/templates/blog/year.erb +22 -0
  12. data/examples/presentation/Sitefile +10 -0
  13. data/examples/presentation/content/css/uv/twilight.css +137 -0
  14. data/examples/presentation/content/presentation/_sample_code.txt +10 -0
  15. data/examples/presentation/content/presentation/index.txt +63 -0
  16. data/examples/presentation/content/presentation/s5/blank.gif +0 -0
  17. data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
  18. data/examples/presentation/content/presentation/s5/framing.css +23 -0
  19. data/examples/presentation/content/presentation/s5/iepngfix.htc +42 -0
  20. data/examples/presentation/content/presentation/s5/opera.css +7 -0
  21. data/examples/presentation/content/presentation/s5/outline.css +15 -0
  22. data/examples/presentation/content/presentation/s5/pretty.css +86 -0
  23. data/examples/presentation/content/presentation/s5/print.css +25 -0
  24. data/examples/presentation/content/presentation/s5/s5-core.css +9 -0
  25. data/examples/presentation/content/presentation/s5/slides.css +3 -0
  26. data/examples/presentation/content/presentation/s5/slides.js +553 -0
  27. data/examples/presentation/layouts/presentation.txt +43 -0
  28. data/examples/presentation/templates/_code_partial.erb +13 -0
  29. data/examples/presentation/templates/presentation.erb +40 -0
  30. data/examples/tumblog/Sitefile +9 -0
  31. data/examples/tumblog/content/css/tumblog.css +308 -0
  32. data/examples/tumblog/content/images/tumblog/permalink.gif +0 -0
  33. data/examples/tumblog/content/images/tumblog/rss.gif +0 -0
  34. data/examples/tumblog/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  35. data/examples/tumblog/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  36. data/examples/tumblog/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  37. data/examples/tumblog/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  38. data/examples/tumblog/content/tumblog/200807/up-a-tree/index.txt +13 -0
  39. data/examples/tumblog/content/tumblog/index.txt +37 -0
  40. data/examples/tumblog/content/tumblog/rss.txt +37 -0
  41. data/examples/tumblog/layouts/tumblog/default.txt +44 -0
  42. data/examples/tumblog/layouts/tumblog/post.txt +15 -0
  43. data/examples/tumblog/lib/tumblog_helper.rb +32 -0
  44. data/examples/tumblog/tasks/tumblog.rake +30 -0
  45. data/examples/tumblog/templates/atom_feed.erb +40 -0
  46. data/examples/tumblog/templates/tumblog/conversation.erb +12 -0
  47. data/examples/tumblog/templates/tumblog/link.erb +10 -0
  48. data/examples/tumblog/templates/tumblog/photo.erb +13 -0
  49. data/examples/tumblog/templates/tumblog/post.erb +12 -0
  50. data/examples/tumblog/templates/tumblog/quote.erb +11 -0
  51. data/examples/webby/Sitefile +19 -0
  52. data/examples/webby/content/communicate/index.txt +28 -0
  53. data/examples/webby/content/css/background.gif +0 -0
  54. data/examples/webby/content/css/blueprint/print.css +76 -0
  55. data/examples/webby/content/css/blueprint/screen.css +696 -0
  56. data/examples/webby/content/css/coderay.css +96 -0
  57. data/examples/webby/content/css/site.css +196 -0
  58. data/examples/webby/content/css/uv/twilight.css +137 -0
  59. data/examples/webby/content/index.txt +37 -0
  60. data/examples/webby/content/learn/index.txt +28 -0
  61. data/examples/webby/content/reference/index.txt +204 -0
  62. data/examples/webby/content/release-notes/index.txt +21 -0
  63. data/examples/webby/content/release-notes/rel-0-9-0/index.txt +74 -0
  64. data/examples/webby/content/release-notes/rel-0-9-1/index.txt +93 -0
  65. data/examples/webby/content/release-notes/rel-0-9-2/index.txt +14 -0
  66. data/examples/webby/content/release-notes/rel-0-9-3/index.txt +47 -0
  67. data/examples/webby/content/robots.txt +6 -0
  68. data/examples/webby/content/script/jquery.corner.js +152 -0
  69. data/examples/webby/content/script/jquery.js +31 -0
  70. data/examples/webby/content/sitemap.txt +31 -0
  71. data/examples/webby/content/tips_and_tricks/index.txt +97 -0
  72. data/examples/webby/content/tutorial/index.txt +135 -0
  73. data/examples/webby/content/user-manual/index.txt +419 -0
  74. data/examples/webby/layouts/default.txt +49 -0
  75. data/examples/webby/templates/page.erb +10 -0
  76. data/examples/website/Sitefile +7 -0
  77. data/examples/website/content/css/blueprint/ie.css +26 -0
  78. data/examples/website/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  79. data/examples/website/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
  80. data/examples/website/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  81. data/examples/website/content/css/blueprint/plugins/buttons/readme.txt +32 -0
  82. data/examples/website/content/css/blueprint/plugins/buttons/screen.css +97 -0
  83. data/examples/website/content/css/blueprint/plugins/fancy-type/readme.txt +14 -0
  84. data/examples/website/content/css/blueprint/plugins/fancy-type/screen.css +71 -0
  85. data/examples/website/content/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
  86. data/examples/website/content/css/blueprint/plugins/link-icons/icons/email.png +0 -0
  87. data/examples/website/content/css/blueprint/plugins/link-icons/icons/external.png +0 -0
  88. data/examples/website/content/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
  89. data/examples/website/content/css/blueprint/plugins/link-icons/icons/im.png +0 -0
  90. data/examples/website/content/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  91. data/examples/website/content/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
  92. data/examples/website/content/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
  93. data/examples/website/content/css/blueprint/plugins/link-icons/readme.txt +18 -0
  94. data/examples/website/content/css/blueprint/plugins/link-icons/screen.css +40 -0
  95. data/examples/website/content/css/blueprint/plugins/rtl/readme.txt +10 -0
  96. data/examples/website/content/css/blueprint/plugins/rtl/screen.css +109 -0
  97. data/examples/website/content/css/blueprint/print.css +30 -0
  98. data/examples/website/content/css/blueprint/screen.css +251 -0
  99. data/examples/website/content/css/blueprint/src/forms.css +49 -0
  100. data/examples/website/content/css/blueprint/src/grid.css +212 -0
  101. data/examples/website/content/css/blueprint/src/grid.png +0 -0
  102. data/examples/website/content/css/blueprint/src/ie.css +59 -0
  103. data/examples/website/content/css/blueprint/src/print.css +85 -0
  104. data/examples/website/content/css/blueprint/src/reset.css +38 -0
  105. data/examples/website/content/css/blueprint/src/typography.css +105 -0
  106. data/examples/website/content/css/coderay.css +111 -0
  107. data/examples/website/content/css/site.css +67 -0
  108. data/examples/website/content/index.txt +19 -0
  109. data/examples/website/layouts/default.txt +61 -0
  110. data/examples/website/lib/breadcrumbs.rb +28 -0
  111. data/examples/website/templates/_partial.erb +10 -0
  112. data/examples/website/templates/page.erb +18 -0
  113. data/lib/webby/apps/generator.rb +276 -0
  114. data/lib/webby/apps/main.rb +258 -0
  115. data/lib/webby/apps.rb +12 -0
  116. data/lib/webby/auto_builder.rb +157 -0
  117. data/lib/webby/builder.rb +172 -0
  118. data/lib/webby/core_ext/enumerable.rb +11 -0
  119. data/lib/webby/core_ext/hash.rb +28 -0
  120. data/lib/webby/core_ext/kernel.rb +26 -0
  121. data/lib/webby/core_ext/string.rb +163 -0
  122. data/lib/webby/core_ext/time.rb +9 -0
  123. data/lib/webby/filters/basepath.rb +97 -0
  124. data/lib/webby/filters/erb.rb +9 -0
  125. data/lib/webby/filters/haml.rb +18 -0
  126. data/lib/webby/filters/markdown.rb +16 -0
  127. data/lib/webby/filters/maruku.rb +16 -0
  128. data/lib/webby/filters/outline.rb +309 -0
  129. data/lib/webby/filters/sass.rb +17 -0
  130. data/lib/webby/filters/slides.rb +56 -0
  131. data/lib/webby/filters/textile.rb +16 -0
  132. data/lib/webby/filters/tidy.rb +76 -0
  133. data/lib/webby/filters/wiki_words.rb +14 -0
  134. data/lib/webby/filters.rb +85 -0
  135. data/lib/webby/helpers/capture_helper.rb +141 -0
  136. data/lib/webby/helpers/coderay_helper.rb +69 -0
  137. data/lib/webby/helpers/graphviz_helper.rb +136 -0
  138. data/lib/webby/helpers/tag_helper.rb +65 -0
  139. data/lib/webby/helpers/tex_img_helper.rb +133 -0
  140. data/lib/webby/helpers/ultraviolet_helper.rb +63 -0
  141. data/lib/webby/helpers/url_helper.rb +241 -0
  142. data/lib/webby/helpers.rb +30 -0
  143. data/lib/webby/journal.rb +126 -0
  144. data/lib/webby/link_validator.rb +160 -0
  145. data/lib/webby/renderer.rb +389 -0
  146. data/lib/webby/resources/db.rb +251 -0
  147. data/lib/webby/resources/layout.rb +54 -0
  148. data/lib/webby/resources/meta_file.rb +211 -0
  149. data/lib/webby/resources/page.rb +81 -0
  150. data/lib/webby/resources/partial.rb +85 -0
  151. data/lib/webby/resources/resource.rb +201 -0
  152. data/lib/webby/resources/static.rb +36 -0
  153. data/lib/webby/resources.rb +137 -0
  154. data/lib/webby/stelan/mktemp.rb +135 -0
  155. data/lib/webby/stelan/paginator.rb +165 -0
  156. data/lib/webby/tasks/build.rake +27 -0
  157. data/lib/webby/tasks/create.rake +25 -0
  158. data/lib/webby/tasks/deploy.rake +22 -0
  159. data/lib/webby/tasks/growl.rake +16 -0
  160. data/lib/webby/tasks/validate.rake +19 -0
  161. data/lib/webby.rb +232 -0
  162. data/spec/core_ext/hash_spec.rb +47 -0
  163. data/spec/core_ext/string_spec.rb +110 -0
  164. data/spec/core_ext/time_spec.rb +19 -0
  165. data/spec/data/hooligans/bad_meta_data_1.txt +34 -0
  166. data/spec/data/hooligans/bad_meta_data_2.txt +34 -0
  167. data/spec/data/html/anchor.html +11 -0
  168. data/spec/data/html/external.html +10 -0
  169. data/spec/data/html/invalid-relative.html +10 -0
  170. data/spec/data/html/relative-anchor.html +10 -0
  171. data/spec/data/html/relative-invalid-anchor.html +10 -0
  172. data/spec/data/html/relative.html +10 -0
  173. data/spec/data/outline/basic.out +81 -0
  174. data/spec/data/outline/basic.txt +25 -0
  175. data/spec/data/outline/no_clobber.out +86 -0
  176. data/spec/data/outline/numbering.out +81 -0
  177. data/spec/data/outline/numbering_only.out +21 -0
  178. data/spec/data/outline/toc_range_1.out +66 -0
  179. data/spec/data/outline/toc_range_2.out +55 -0
  180. data/spec/data/outline/toc_style.out +81 -0
  181. data/spec/data/site/Sitefile +9 -0
  182. data/spec/data/site/content/_partial.txt +10 -0
  183. data/spec/data/site/content/css/coderay.css +111 -0
  184. data/spec/data/site/content/css/site.css +67 -0
  185. data/spec/data/site/content/css/tumblog.css +308 -0
  186. data/spec/data/site/content/images/tumblog/permalink.gif +0 -0
  187. data/spec/data/site/content/images/tumblog/rss.gif +0 -0
  188. data/spec/data/site/content/index.txt +19 -0
  189. data/spec/data/site/content/photos.txt +21 -0
  190. data/spec/data/site/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  191. data/spec/data/site/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  192. data/spec/data/site/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  193. data/spec/data/site/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  194. data/spec/data/site/content/tumblog/200807/up-a-tree/index.txt +13 -0
  195. data/spec/data/site/content/tumblog/index.txt +37 -0
  196. data/spec/data/site/content/tumblog/rss.txt +37 -0
  197. data/spec/data/site/layouts/default.txt +58 -0
  198. data/spec/data/site/layouts/tumblog/default.txt +44 -0
  199. data/spec/data/site/layouts/tumblog/post.txt +15 -0
  200. data/spec/data/site/lib/breadcrumbs.rb +28 -0
  201. data/spec/data/site/lib/tumblog_helper.rb +32 -0
  202. data/spec/data/site/tasks/tumblog.rake +30 -0
  203. data/spec/data/site/templates/_partial.erb +10 -0
  204. data/spec/data/site/templates/atom_feed.erb +40 -0
  205. data/spec/data/site/templates/page.erb +18 -0
  206. data/spec/data/site/templates/presentation.erb +40 -0
  207. data/spec/data/site/templates/tumblog/conversation.erb +12 -0
  208. data/spec/data/site/templates/tumblog/link.erb +10 -0
  209. data/spec/data/site/templates/tumblog/photo.erb +13 -0
  210. data/spec/data/site/templates/tumblog/post.erb +12 -0
  211. data/spec/data/site/templates/tumblog/quote.erb +11 -0
  212. data/spec/spec.opts +1 -0
  213. data/spec/spec_helper.rb +58 -0
  214. data/spec/webby/apps/generator_spec.rb +117 -0
  215. data/spec/webby/apps/main_spec.rb +88 -0
  216. data/spec/webby/filters/basepath_spec.rb +167 -0
  217. data/spec/webby/filters/maruku_spec.rb +31 -0
  218. data/spec/webby/filters/outline_spec.rb +92 -0
  219. data/spec/webby/filters/textile_spec.rb +31 -0
  220. data/spec/webby/helpers/capture_helper_spec.rb +56 -0
  221. data/spec/webby/link_validator_spec.rb +154 -0
  222. data/spec/webby/renderer_spec.rb +139 -0
  223. data/spec/webby/resources/db_spec.rb +250 -0
  224. data/spec/webby/resources/layout_spec.rb +83 -0
  225. data/spec/webby/resources/meta_file_spec.rb +171 -0
  226. data/spec/webby/resources/page_spec.rb +111 -0
  227. data/spec/webby/resources/partial_spec.rb +58 -0
  228. data/spec/webby/resources/resource_spec.rb +219 -0
  229. data/spec/webby/resources/static_spec.rb +49 -0
  230. data/spec/webby/resources_spec.rb +69 -0
  231. data/tasks/mswin32.rake +38 -0
  232. data/tasks/website.rake +37 -0
  233. metadata +372 -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::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
@@ -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