thewoolleyman-webgen 0.5.8.20090419

Sign up to get free protection for your applications and to get access to all the features.
Files changed (309) hide show
  1. data/AUTHORS +8 -0
  2. data/COPYING +10 -0
  3. data/GPL +340 -0
  4. data/Rakefile +334 -0
  5. data/THANKS +18 -0
  6. data/bin/webgen +12 -0
  7. data/data/webgen/resources.yaml +3 -0
  8. data/data/webgen/webgui/controller/main.rb +135 -0
  9. data/data/webgen/webgui/overrides/win32console.rb +0 -0
  10. data/data/webgen/webgui/public/css/jquery.autocomplete.css +50 -0
  11. data/data/webgen/webgui/public/css/ramaze_error.css +90 -0
  12. data/data/webgen/webgui/public/css/style.css +55 -0
  13. data/data/webgen/webgui/public/img/headerbg.jpg +0 -0
  14. data/data/webgen/webgui/public/img/webgen_logo.png +0 -0
  15. data/data/webgen/webgui/public/js/jquery.autocomplete.js +15 -0
  16. data/data/webgen/webgui/public/js/jquery.js +32 -0
  17. data/data/webgen/webgui/view/create_website.xhtml +22 -0
  18. data/data/webgen/webgui/view/error.xhtml +64 -0
  19. data/data/webgen/webgui/view/index.xhtml +22 -0
  20. data/data/webgen/webgui/view/manage_website.xhtml +18 -0
  21. data/data/webgen/webgui/view/page.xhtml +40 -0
  22. data/data/webgen/website_skeleton/README +10 -0
  23. data/data/webgen/website_skeleton/Rakefile +40 -0
  24. data/data/webgen/website_skeleton/config.yaml +17 -0
  25. data/data/webgen/website_skeleton/ext/init.rb +10 -0
  26. data/data/webgen/website_styles/1024px/README +13 -0
  27. data/data/webgen/website_styles/1024px/src/default.css +188 -0
  28. data/data/webgen/website_styles/1024px/src/default.template +60 -0
  29. data/data/webgen/website_styles/1024px/src/images/background.gif +0 -0
  30. data/data/webgen/website_styles/andreas00/README +13 -0
  31. data/data/webgen/website_styles/andreas00/src/default.css +290 -0
  32. data/data/webgen/website_styles/andreas00/src/default.template +60 -0
  33. data/data/webgen/website_styles/andreas00/src/images/bg.gif +0 -0
  34. data/data/webgen/website_styles/andreas00/src/images/front.jpg +0 -0
  35. data/data/webgen/website_styles/andreas00/src/images/menubg.gif +0 -0
  36. data/data/webgen/website_styles/andreas00/src/images/menubg2.gif +0 -0
  37. data/data/webgen/website_styles/andreas01/README +14 -0
  38. data/data/webgen/website_styles/andreas01/src/default.css +310 -0
  39. data/data/webgen/website_styles/andreas01/src/default.template +62 -0
  40. data/data/webgen/website_styles/andreas01/src/images/bg.gif +0 -0
  41. data/data/webgen/website_styles/andreas01/src/images/front.jpg +0 -0
  42. data/data/webgen/website_styles/andreas01/src/print.css +35 -0
  43. data/data/webgen/website_styles/andreas03/README +14 -0
  44. data/data/webgen/website_styles/andreas03/src/default.css +223 -0
  45. data/data/webgen/website_styles/andreas03/src/default.template +58 -0
  46. data/data/webgen/website_styles/andreas03/src/images/bodybg.png +0 -0
  47. data/data/webgen/website_styles/andreas03/src/images/contbg.png +0 -0
  48. data/data/webgen/website_styles/andreas03/src/images/footerbg.png +0 -0
  49. data/data/webgen/website_styles/andreas03/src/images/gradient1.png +0 -0
  50. data/data/webgen/website_styles/andreas03/src/images/gradient2.png +0 -0
  51. data/data/webgen/website_styles/andreas04/README +15 -0
  52. data/data/webgen/website_styles/andreas04/src/default.css +290 -0
  53. data/data/webgen/website_styles/andreas04/src/default.template +81 -0
  54. data/data/webgen/website_styles/andreas04/src/images/blinkarrow.gif +0 -0
  55. data/data/webgen/website_styles/andreas04/src/images/bodybg.png +0 -0
  56. data/data/webgen/website_styles/andreas04/src/images/contentbg.png +0 -0
  57. data/data/webgen/website_styles/andreas04/src/images/entrybg.png +0 -0
  58. data/data/webgen/website_styles/andreas04/src/images/flash.gif +0 -0
  59. data/data/webgen/website_styles/andreas04/src/images/flash2.gif +0 -0
  60. data/data/webgen/website_styles/andreas04/src/images/globe.gif +0 -0
  61. data/data/webgen/website_styles/andreas04/src/images/globebottom.gif +0 -0
  62. data/data/webgen/website_styles/andreas04/src/images/linkarrow.gif +0 -0
  63. data/data/webgen/website_styles/andreas04/src/images/menuhover.png +0 -0
  64. data/data/webgen/website_styles/andreas05/README +14 -0
  65. data/data/webgen/website_styles/andreas05/src/default.css +33 -0
  66. data/data/webgen/website_styles/andreas05/src/default.template +40 -0
  67. data/data/webgen/website_styles/andreas05/src/images/bodybg.gif +0 -0
  68. data/data/webgen/website_styles/andreas05/src/images/front.png +0 -0
  69. data/data/webgen/website_styles/andreas06/README +14 -0
  70. data/data/webgen/website_styles/andreas06/src/default.css +354 -0
  71. data/data/webgen/website_styles/andreas06/src/default.template +70 -0
  72. data/data/webgen/website_styles/andreas06/src/images/bodybg.gif +0 -0
  73. data/data/webgen/website_styles/andreas06/src/images/boxbg.gif +0 -0
  74. data/data/webgen/website_styles/andreas06/src/images/greypx.gif +0 -0
  75. data/data/webgen/website_styles/andreas06/src/images/header.jpg +0 -0
  76. data/data/webgen/website_styles/andreas06/src/images/innerbg.gif +0 -0
  77. data/data/webgen/website_styles/andreas06/src/images/leaves.jpg +0 -0
  78. data/data/webgen/website_styles/andreas06/src/images/tabs.gif +0 -0
  79. data/data/webgen/website_styles/andreas07/README +15 -0
  80. data/data/webgen/website_styles/andreas07/src/browserfix.css +7 -0
  81. data/data/webgen/website_styles/andreas07/src/default.css +92 -0
  82. data/data/webgen/website_styles/andreas07/src/default.template +42 -0
  83. data/data/webgen/website_styles/andreas07/src/images/bodybg.gif +0 -0
  84. data/data/webgen/website_styles/andreas07/src/images/sidebarbg.gif +0 -0
  85. data/data/webgen/website_styles/andreas08/README +14 -0
  86. data/data/webgen/website_styles/andreas08/src/default.css +224 -0
  87. data/data/webgen/website_styles/andreas08/src/default.template +51 -0
  88. data/data/webgen/website_styles/andreas09/README +14 -0
  89. data/data/webgen/website_styles/andreas09/src/default.css +308 -0
  90. data/data/webgen/website_styles/andreas09/src/default.template +68 -0
  91. data/data/webgen/website_styles/andreas09/src/images/bodybg-black.jpg +0 -0
  92. data/data/webgen/website_styles/andreas09/src/images/bodybg-green.jpg +0 -0
  93. data/data/webgen/website_styles/andreas09/src/images/bodybg-orange.jpg +0 -0
  94. data/data/webgen/website_styles/andreas09/src/images/bodybg-purple.jpg +0 -0
  95. data/data/webgen/website_styles/andreas09/src/images/bodybg-red.jpg +0 -0
  96. data/data/webgen/website_styles/andreas09/src/images/bodybg.jpg +0 -0
  97. data/data/webgen/website_styles/andreas09/src/images/footerbg.jpg +0 -0
  98. data/data/webgen/website_styles/andreas09/src/images/menuhover-black.jpg +0 -0
  99. data/data/webgen/website_styles/andreas09/src/images/menuhover-green.jpg +0 -0
  100. data/data/webgen/website_styles/andreas09/src/images/menuhover-orange.jpg +0 -0
  101. data/data/webgen/website_styles/andreas09/src/images/menuhover-purple.jpg +0 -0
  102. data/data/webgen/website_styles/andreas09/src/images/menuhover-red.jpg +0 -0
  103. data/data/webgen/website_styles/andreas09/src/images/menuhover.jpg +0 -0
  104. data/data/webgen/website_styles/simple/README +6 -0
  105. data/data/webgen/website_styles/simple/src/default.css +84 -0
  106. data/data/webgen/website_styles/simple/src/default.template +36 -0
  107. data/data/webgen/website_templates/default/README +6 -0
  108. data/data/webgen/website_templates/default/src/index.page +8 -0
  109. data/data/webgen/website_templates/project/README +5 -0
  110. data/data/webgen/website_templates/project/src/about.page +12 -0
  111. data/data/webgen/website_templates/project/src/download.page +15 -0
  112. data/data/webgen/website_templates/project/src/features.page +8 -0
  113. data/data/webgen/website_templates/project/src/index.page +9 -0
  114. data/data/webgen/website_templates/project/src/screenshots.page +18 -0
  115. data/doc/contentprocessor.template +11 -0
  116. data/doc/contentprocessor/blocks.page +129 -0
  117. data/doc/contentprocessor/builder.page +80 -0
  118. data/doc/contentprocessor/erb.page +59 -0
  119. data/doc/contentprocessor/erubis.page +46 -0
  120. data/doc/contentprocessor/fragments.page +25 -0
  121. data/doc/contentprocessor/haml.page +47 -0
  122. data/doc/contentprocessor/maruku.page +41 -0
  123. data/doc/contentprocessor/rdiscount.page +37 -0
  124. data/doc/contentprocessor/rdoc.page +36 -0
  125. data/doc/contentprocessor/redcloth.page +39 -0
  126. data/doc/contentprocessor/sass.page +31 -0
  127. data/doc/contentprocessor/tags.page +73 -0
  128. data/doc/extensions.metainfo +29 -0
  129. data/doc/extensions.page +16 -0
  130. data/doc/extensions.template +17 -0
  131. data/doc/faq.page +219 -0
  132. data/doc/getting_started.page +135 -0
  133. data/doc/index.page +65 -0
  134. data/doc/manual.page +589 -0
  135. data/doc/reference_configuration.page +959 -0
  136. data/doc/reference_metainfo.page +222 -0
  137. data/doc/source/filesystem.page +39 -0
  138. data/doc/source/tararchive.page +40 -0
  139. data/doc/sourcehandler.template +21 -0
  140. data/doc/sourcehandler/copy.page +19 -0
  141. data/doc/sourcehandler/directory.page +27 -0
  142. data/doc/sourcehandler/feed.page +105 -0
  143. data/doc/sourcehandler/metainfo.page +41 -0
  144. data/doc/sourcehandler/page.page +14 -0
  145. data/doc/sourcehandler/sitemap.page +46 -0
  146. data/doc/sourcehandler/template.page +45 -0
  147. data/doc/sourcehandler/virtual.page +49 -0
  148. data/doc/tag.template +25 -0
  149. data/doc/tag/breadcrumbtrail.page +40 -0
  150. data/doc/tag/coderay.page +49 -0
  151. data/doc/tag/date.page +31 -0
  152. data/doc/tag/executecommand.page +26 -0
  153. data/doc/tag/includefile.page +32 -0
  154. data/doc/tag/langbar.page +44 -0
  155. data/doc/tag/link.page +44 -0
  156. data/doc/tag/menu.page +106 -0
  157. data/doc/tag/metainfo.page +29 -0
  158. data/doc/tag/relocatable.page +38 -0
  159. data/doc/tag/sitemap.page +31 -0
  160. data/doc/tag/tikz.page +158 -0
  161. data/doc/upgrading.page +139 -0
  162. data/doc/webgen_page_format.page +129 -0
  163. data/lib/webgen/blackboard.rb +78 -0
  164. data/lib/webgen/cache.rb +87 -0
  165. data/lib/webgen/cli.rb +124 -0
  166. data/lib/webgen/cli/apply_command.rb +64 -0
  167. data/lib/webgen/cli/create_command.rb +66 -0
  168. data/lib/webgen/cli/run_command.rb +22 -0
  169. data/lib/webgen/cli/utils.rb +88 -0
  170. data/lib/webgen/cli/webgui_command.rb +72 -0
  171. data/lib/webgen/common.rb +21 -0
  172. data/lib/webgen/common/sitemap.rb +83 -0
  173. data/lib/webgen/configuration.rb +153 -0
  174. data/lib/webgen/contentprocessor.rb +99 -0
  175. data/lib/webgen/contentprocessor/blocks.rb +60 -0
  176. data/lib/webgen/contentprocessor/builder.rb +30 -0
  177. data/lib/webgen/contentprocessor/context.rb +89 -0
  178. data/lib/webgen/contentprocessor/erb.rb +28 -0
  179. data/lib/webgen/contentprocessor/erubis.rb +40 -0
  180. data/lib/webgen/contentprocessor/fragments.rb +25 -0
  181. data/lib/webgen/contentprocessor/haml.rb +30 -0
  182. data/lib/webgen/contentprocessor/maruku.rb +20 -0
  183. data/lib/webgen/contentprocessor/rdiscount.rb +17 -0
  184. data/lib/webgen/contentprocessor/rdoc.rb +19 -0
  185. data/lib/webgen/contentprocessor/redcloth.rb +17 -0
  186. data/lib/webgen/contentprocessor/sass.rb +20 -0
  187. data/lib/webgen/contentprocessor/tags.rb +136 -0
  188. data/lib/webgen/coreext.rb +13 -0
  189. data/lib/webgen/default_config.rb +215 -0
  190. data/lib/webgen/languages.rb +589 -0
  191. data/lib/webgen/loggable.rb +25 -0
  192. data/lib/webgen/logger.rb +97 -0
  193. data/lib/webgen/node.rb +391 -0
  194. data/lib/webgen/output.rb +82 -0
  195. data/lib/webgen/output/filesystem.rb +69 -0
  196. data/lib/webgen/page.rb +153 -0
  197. data/lib/webgen/path.rb +194 -0
  198. data/lib/webgen/source.rb +54 -0
  199. data/lib/webgen/source/filesystem.rb +61 -0
  200. data/lib/webgen/source/resource.rb +44 -0
  201. data/lib/webgen/source/stacked.rb +55 -0
  202. data/lib/webgen/source/tararchive.rb +73 -0
  203. data/lib/webgen/sourcehandler.rb +226 -0
  204. data/lib/webgen/sourcehandler/base.rb +248 -0
  205. data/lib/webgen/sourcehandler/copy.rb +43 -0
  206. data/lib/webgen/sourcehandler/directory.rb +36 -0
  207. data/lib/webgen/sourcehandler/feed.rb +117 -0
  208. data/lib/webgen/sourcehandler/fragment.rb +68 -0
  209. data/lib/webgen/sourcehandler/memory.rb +43 -0
  210. data/lib/webgen/sourcehandler/metainfo.rb +128 -0
  211. data/lib/webgen/sourcehandler/page.rb +59 -0
  212. data/lib/webgen/sourcehandler/sitemap.rb +60 -0
  213. data/lib/webgen/sourcehandler/template.rb +66 -0
  214. data/lib/webgen/sourcehandler/virtual.rb +110 -0
  215. data/lib/webgen/tag.rb +27 -0
  216. data/lib/webgen/tag/base.rb +170 -0
  217. data/lib/webgen/tag/breadcrumbtrail.rb +70 -0
  218. data/lib/webgen/tag/coderay.rb +31 -0
  219. data/lib/webgen/tag/date.rb +18 -0
  220. data/lib/webgen/tag/executecommand.rb +30 -0
  221. data/lib/webgen/tag/includefile.rb +42 -0
  222. data/lib/webgen/tag/langbar.rb +52 -0
  223. data/lib/webgen/tag/link.rb +26 -0
  224. data/lib/webgen/tag/menu.rb +207 -0
  225. data/lib/webgen/tag/metainfo.rb +25 -0
  226. data/lib/webgen/tag/relocatable.rb +54 -0
  227. data/lib/webgen/tag/sitemap.rb +41 -0
  228. data/lib/webgen/tag/tikz.rb +119 -0
  229. data/lib/webgen/tree.rb +90 -0
  230. data/lib/webgen/version.rb +8 -0
  231. data/lib/webgen/webgentask.rb +152 -0
  232. data/lib/webgen/website.rb +342 -0
  233. data/lib/webgen/websiteaccess.rb +31 -0
  234. data/lib/webgen/websitemanager.rb +127 -0
  235. data/man/man1/webgen.1 +73 -0
  236. data/misc/default.css +384 -0
  237. data/misc/default.template +75 -0
  238. data/misc/htmldoc.metainfo +25 -0
  239. data/misc/htmldoc.virtual +5 -0
  240. data/misc/images/arrow.gif +0 -0
  241. data/misc/images/error.png +0 -0
  242. data/misc/images/headerbg.jpg +0 -0
  243. data/misc/images/important.png +0 -0
  244. data/misc/images/information.png +0 -0
  245. data/misc/images/quote.gif +0 -0
  246. data/misc/images/warning.png +0 -0
  247. data/setup.rb +1585 -0
  248. data/test/helper.rb +45 -0
  249. data/test/test_blackboard.rb +60 -0
  250. data/test/test_cache.rb +59 -0
  251. data/test/test_cli.rb +21 -0
  252. data/test/test_common.rb +18 -0
  253. data/test/test_common_sitemap.rb +58 -0
  254. data/test/test_configuration.rb +68 -0
  255. data/test/test_contentprocessor.rb +33 -0
  256. data/test/test_contentprocessor_blocks.rb +68 -0
  257. data/test/test_contentprocessor_builder.rb +23 -0
  258. data/test/test_contentprocessor_context.rb +40 -0
  259. data/test/test_contentprocessor_erb.rb +23 -0
  260. data/test/test_contentprocessor_erubis.rb +49 -0
  261. data/test/test_contentprocessor_fragments.rb +42 -0
  262. data/test/test_contentprocessor_haml.rb +23 -0
  263. data/test/test_contentprocessor_maruku.rb +29 -0
  264. data/test/test_contentprocessor_rdiscount.rb +17 -0
  265. data/test/test_contentprocessor_rdoc.rb +18 -0
  266. data/test/test_contentprocessor_redcloth.rb +15 -0
  267. data/test/test_contentprocessor_sass.rb +22 -0
  268. data/test/test_contentprocessor_tags.rb +99 -0
  269. data/test/test_languages.rb +67 -0
  270. data/test/test_loggable.rb +32 -0
  271. data/test/test_logger.rb +94 -0
  272. data/test/test_node.rb +367 -0
  273. data/test/test_output_filesystem.rb +60 -0
  274. data/test/test_page.rb +214 -0
  275. data/test/test_path.rb +165 -0
  276. data/test/test_source_filesystem.rb +76 -0
  277. data/test/test_source_resource.rb +28 -0
  278. data/test/test_source_stacked.rb +36 -0
  279. data/test/test_source_tararchive.rb +65 -0
  280. data/test/test_sourcehandler_base.rb +123 -0
  281. data/test/test_sourcehandler_copy.rb +47 -0
  282. data/test/test_sourcehandler_directory.rb +42 -0
  283. data/test/test_sourcehandler_feed.rb +77 -0
  284. data/test/test_sourcehandler_fragment.rb +69 -0
  285. data/test/test_sourcehandler_memory.rb +44 -0
  286. data/test/test_sourcehandler_metainfo.rb +118 -0
  287. data/test/test_sourcehandler_page.rb +65 -0
  288. data/test/test_sourcehandler_sitemap.rb +49 -0
  289. data/test/test_sourcehandler_template.rb +65 -0
  290. data/test/test_sourcehandler_virtual.rb +87 -0
  291. data/test/test_tag_base.rb +85 -0
  292. data/test/test_tag_breadcrumbtrail.rb +91 -0
  293. data/test/test_tag_coderay.rb +32 -0
  294. data/test/test_tag_date.rb +18 -0
  295. data/test/test_tag_executecommand.rb +41 -0
  296. data/test/test_tag_includefile.rb +50 -0
  297. data/test/test_tag_langbar.rb +72 -0
  298. data/test/test_tag_link.rb +69 -0
  299. data/test/test_tag_menu.rb +207 -0
  300. data/test/test_tag_metainfo.rb +19 -0
  301. data/test/test_tag_relocatable.rb +59 -0
  302. data/test/test_tag_sitemap.rb +47 -0
  303. data/test/test_tag_tikz.rb +69 -0
  304. data/test/test_tree.rb +70 -0
  305. data/test/test_webgentask.rb +23 -0
  306. data/test/test_website.rb +98 -0
  307. data/test/test_websiteaccess.rb +25 -0
  308. data/test/test_websitemanager.rb +70 -0
  309. metadata +613 -0
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/source'
6
+
7
+ class TestSourceResource < Test::Unit::TestCase
8
+
9
+ include Test::WebsiteHelper
10
+
11
+ def test_initialize
12
+ source = Webgen::Source::Resource.new('test-glob-*')
13
+ assert_equal('test-glob-*', source.glob)
14
+ end
15
+
16
+ def test_paths
17
+ @website.config['resources']['test-resource'] = ['Webgen::Source::FileSystem', '.', File.basename(__FILE__)]
18
+ @website.config['resources']['other-resource'] = ['Webgen::Source::FileSystem', '../lib']
19
+
20
+ source = Webgen::Source::Resource.new('test-*')
21
+ assert_equal(1, source.paths.length)
22
+ assert(source.paths.include?(Webgen::Path.new('/test_source_resource.rb')))
23
+
24
+ source = Webgen::Source::Resource.new('other-*', '/webgen/**/*', '/webgen/')
25
+ assert(source.paths.include?(Webgen::Path.new('/source/resource.rb')))
26
+ end
27
+
28
+ end
@@ -0,0 +1,36 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/source'
6
+
7
+ class TestSourceFileSystemStacked < Test::Unit::TestCase
8
+
9
+ class TestSource
10
+ def initialize(paths); @paths = paths; end
11
+ def paths; Set.new(@paths); end
12
+ end
13
+
14
+ def test_initialize
15
+ source = Webgen::Source::Stacked.new
16
+ assert_equal([], source.stack)
17
+ source = Webgen::Source::Stacked.new('/dir' => 6)
18
+ assert_equal([['/dir', 6]], source.stack)
19
+ end
20
+
21
+ def test_add
22
+ source = Webgen::Source::Stacked.new
23
+ assert_raise(RuntimeError) { source.add(['dir', 6])}
24
+ source.add('/temp' => :source)
25
+ assert_equal([['/temp', :source]], source.stack)
26
+ end
27
+
28
+ def test_paths
29
+ source = Webgen::Source::Stacked.new
30
+ source.add('/' => TestSource.new([Webgen::Path.new('/hallo/dir'), Webgen::Path.new('/other')]))
31
+ source.add('/hallo' => TestSource.new([Webgen::Path.new('/dir'), Webgen::Path.new('/other')]))
32
+ assert_equal(Set.new([Webgen::Path.new('/hallo/dir'), Webgen::Path.new('/other'),
33
+ Webgen::Path.new('/hallo/other')]), source.paths)
34
+ end
35
+
36
+ end
@@ -0,0 +1,65 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/source'
6
+
7
+ class TestSourceTarArchive < Test::Unit::TestCase
8
+
9
+ class FakeStream
10
+
11
+ def open
12
+ require 'stringio'
13
+ sio = StringIO.new
14
+ stream = Archive::Tar::Minitar::Writer.new(sio)
15
+ stream.mkdir('/test', :mtime => (Time.now - 5).to_i, :mode => 0100755)
16
+ stream.add_file('/test/hallo.page', :mtime => (Time.now - 4).to_i, :mode => 0100644) do |os, opts|
17
+ os.write('This is the contents!')
18
+ end
19
+ stream.add_file('/other.page', :mtime => (Time.now - 4).to_i, :mode => 0100644) do |os, opts|
20
+ os.write('This is other content!')
21
+ end
22
+ sio.rewind
23
+ sio
24
+ end
25
+
26
+ end
27
+
28
+ include Test::WebsiteHelper
29
+
30
+ def setup
31
+ super
32
+ @website = Webgen::Website.new(File.join(File.dirname(__FILE__), '..'), nil)
33
+ @website.init
34
+ Thread.current[:webgen_website] = @website
35
+ @stream = FakeStream.new
36
+ end
37
+
38
+ def test_initialize
39
+ source = Webgen::Source::TarArchive.new(@stream)
40
+ assert_equal(@stream, source.uri)
41
+ end
42
+
43
+ def test_paths
44
+ source = Webgen::Source::TarArchive.new(@stream)
45
+ assert_equal(3, source.paths.length)
46
+ assert(source.paths.include?(Webgen::Path.new('/test/')))
47
+ assert(source.paths.include?(Webgen::Path.new('/test/hallo.page')))
48
+ assert_equal('This is the contents!', source.paths.find {|p| p.path == '/test/hallo.page'}.io.data)
49
+
50
+ source = Webgen::Source::TarArchive.new(@stream, '/test/*')
51
+ assert_equal(1, source.paths.length)
52
+ assert(source.paths.include?(Webgen::Path.new('/test/hallo.page')))
53
+ end
54
+
55
+ def test_path_changed?
56
+ stream = @stream
57
+ source = Webgen::Source::TarArchive.new(stream)
58
+ source.paths.each do |path|
59
+ assert(!path.changed?)
60
+ @website.cache.instance_eval { @old_data[[:tararchive_path, stream, path.path]] = Time.now - 60 }
61
+ assert(path.changed?)
62
+ end
63
+ end
64
+
65
+ end
@@ -0,0 +1,123 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/tree'
6
+ require 'webgen/node'
7
+ require 'webgen/path'
8
+ require 'webgen/sourcehandler'
9
+ require 'time'
10
+
11
+ class TestSourceHandlerBase < Test::Unit::TestCase
12
+
13
+ class TestSH; include Webgen::SourceHandler::Base; end
14
+
15
+ include Test::WebsiteHelper
16
+
17
+ def setup
18
+ super
19
+ @obj = Object.new
20
+ @obj.extend(Webgen::SourceHandler::Base)
21
+ end
22
+
23
+ def test_create_node
24
+ tree = Webgen::Tree.new
25
+ path = path_with_meta_info('/path.html')
26
+ count = 0
27
+
28
+ path.instance_eval { @source_path = '/path'}
29
+ node = @obj.create_node(tree.dummy_root, path) {|n| count +=1 }
30
+ assert_equal('/path', node.node_info[:src])
31
+ assert_equal('Object', node.node_info[:processor])
32
+ assert_kind_of(Time, node['modified_at'])
33
+ assert_equal(1, count)
34
+
35
+ other_node = @obj.create_node(tree.dummy_root, path) {|n| count +=1 }
36
+ assert_equal(node, other_node)
37
+ assert_equal(1, count)
38
+
39
+ node.flag(:reinit)
40
+ other_node = @obj.create_node(tree.dummy_root, path) {|n| count +=1 }
41
+ assert_equal(node, other_node)
42
+ assert_equal(2, count)
43
+
44
+ path.instance_eval { @source_path = '/other' }
45
+ other_node = @obj.create_node(tree.dummy_root, path) {|n| count +=1 }
46
+ assert_equal(node, other_node)
47
+ assert_equal(2, count)
48
+ end
49
+
50
+ def test_node_exists
51
+ @tree = Webgen::Tree.new
52
+ node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
53
+ child_de = Webgen::Node.new(node, 'test/somename.html', 'somename.page', {'lang' => 'de'})
54
+ frag_de = Webgen::Node.new(child_de, '#data1', '#othertest')
55
+
56
+ assert_equal(child_de, @obj.node_exists?(node, path_with_meta_info('somename.de.page')))
57
+ assert_equal(child_de, @obj.node_exists?(node, path_with_meta_info('other.page'), @obj.output_path(node, path_with_meta_info('somename.html'))))
58
+ assert_equal(false, @obj.node_exists?(node, path_with_meta_info('somename.en.page', {'no_output' => true}),
59
+ @obj.output_path(node, path_with_meta_info('somename.html'))))
60
+ assert_equal(frag_de, @obj.node_exists?(child_de, path_with_meta_info('#othertest')))
61
+ assert_equal(nil, @obj.node_exists?(node, path_with_meta_info('unknown')))
62
+ end
63
+
64
+ def test_output_path
65
+ node = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
66
+ assert_raise(RuntimeError) { @obj.output_path(node, path_with_meta_info('test.page', 'output_path' => 'non'))}
67
+ end
68
+
69
+ def test_standard_output_path
70
+ @tree = Webgen::Tree.new
71
+ node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
72
+
73
+ path = path_with_meta_info('path.html')
74
+ assert_equal('test/path.html', @obj.output_path(node, path))
75
+ path = path_with_meta_info('path.en.html')
76
+ assert_equal('test/path.html', @obj.output_path(node, path))
77
+ path = path_with_meta_info('path.eo.html')
78
+ assert_equal('test/path.eo.html', @obj.output_path(node, path))
79
+ path = path_with_meta_info('dir/')
80
+ assert_equal('test/dir/', @obj.output_path(node, path))
81
+
82
+ other = Webgen::Node.new(node, 'test/path.html', 'other.page')
83
+ path = path_with_meta_info('path.html')
84
+ assert_equal('test/path.html', @obj.output_path(node, path))
85
+ path = path_with_meta_info('path.en.html')
86
+ assert_equal('test/path.en.html', @obj.output_path(node, path))
87
+
88
+ path = path_with_meta_info('#frag')
89
+ assert_equal('test/path.html#frag', @obj.output_path(other, path))
90
+ frag = Webgen::Node.new(other, 'test/path.html#frag', '#frag')
91
+ path = path_with_meta_info('#frag1')
92
+ assert_equal('test/path.html#frag1', @obj.output_path(frag, path))
93
+
94
+ path = path_with_meta_info('/')
95
+ assert_equal('/', @obj.output_path(@tree.dummy_root, path))
96
+ path = path_with_meta_info('/', 'output_path_style' => [:parent, 'hallo', 56])
97
+ assert_equal('hallo/', @obj.output_path(@tree.dummy_root, path))
98
+
99
+ assert_raise(RuntimeError) do
100
+ path = path_with_meta_info('path.html', 'output_path_style' => [:parent, :year, '/', :month, '/', :cnbase, :ext])
101
+ @obj.output_path(node, path)
102
+ end
103
+ time = Time.parse('2008-09-04 08:15')
104
+ path = path_with_meta_info('path.html', 'output_path_style' => [:parent, :year, '/', :month, '/', :day, '-', :cnbase, :ext],
105
+ 'created_at' => time)
106
+ assert_equal('test/2008/09/04-path.html', @obj.output_path(node, path))
107
+ end
108
+
109
+ def test_content
110
+ assert_nil(@obj.content(nil))
111
+ end
112
+
113
+ def test_page_from_path
114
+ path = path_with_meta_info('/other.page', {'key' => 'value'}) { StringIO.new("---\nkey: value1\n---\ncontent")}
115
+ page = @obj.page_from_path(path)
116
+ assert_equal('content', page.blocks['content'].content)
117
+ assert_equal('value1', path.meta_info['key'])
118
+
119
+ path = path_with_meta_info('/other.page') { StringIO.new("---\:dfk")}
120
+ assert_raise(RuntimeError) { @obj.page_from_path(path) }
121
+ end
122
+
123
+ end
@@ -0,0 +1,47 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/sourcehandler'
6
+ require 'stringio'
7
+
8
+ class TestSourceHandlerCopy < Test::Unit::TestCase
9
+
10
+ include Test::WebsiteHelper
11
+
12
+ class TestCP
13
+ def call(context); context.content = context.content.reverse; end
14
+ end
15
+
16
+ def setup
17
+ super
18
+ @website.config['contentprocessor.map']['test'] = 'TestSourceHandlerCopy::TestCP'
19
+ @obj = Webgen::SourceHandler::Copy.new
20
+ @root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
21
+ @without = @obj.create_node(@root, path_with_meta_info('/default.css') {StringIO.new('# header')})
22
+ @with = @obj.create_node(@root, path_with_meta_info('/other.test.css') {StringIO.new('# header')})
23
+ end
24
+
25
+ def test_create_node
26
+ assert_not_nil(@without)
27
+ assert_equal(nil, @without.node_info[:preprocessor])
28
+ assert_equal('test/default.css', @without.path)
29
+
30
+ assert_not_nil(@with)
31
+ assert_equal('test', @with.node_info[:preprocessor])
32
+ assert_equal('test/other.css', @with.path)
33
+
34
+ node = @obj.create_node(@root, path_with_meta_info('/other.unknown.css') {StringIO.new('# header')})
35
+ assert_equal(nil, node.node_info[:preprocessor])
36
+ end
37
+
38
+ def test_content
39
+ @website.blackboard.add_service(:source_paths) do
40
+ {'/default.css' => path_with_meta_info('/default.css') {StringIO.new('# header')}}
41
+ end
42
+ @without.node_info[:src] = @with.node_info[:src] = '/default.css'
43
+ assert_kind_of(Webgen::Path::SourceIO, @without.content)
44
+ assert_equal('# header'.reverse, @with.content)
45
+ end
46
+
47
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/sourcehandler'
6
+ require 'stringio'
7
+
8
+ class TestSourceHandlerDirectory < Test::Unit::TestCase
9
+
10
+ include Test::WebsiteHelper
11
+
12
+ def test_create_node
13
+ @obj = Webgen::SourceHandler::Directory.new
14
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
15
+ node = @obj.create_node(root, path_with_meta_info('/dir/', {:key => :value}) {StringIO.new('')})
16
+ assert_not_nil(node)
17
+ assert_equal(:value, node[:key])
18
+
19
+ node.flag(:reinit)
20
+ assert_equal(node, @obj.create_node(root, path_with_meta_info('/dir/', {:key => :other}) {StringIO.new('')}))
21
+ assert_equal(:other, node[:key])
22
+ end
23
+
24
+ def test_create_directories
25
+ @obj = Webgen::SourceHandler::Directory.new
26
+ shm = Webgen::SourceHandler::Main.new # for using service :create_nodes
27
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
28
+ dir = @obj.create_node(root, path_with_meta_info('/dir/'))
29
+
30
+ assert_equal(dir, @obj.create_directories(root, '/dir/', path_with_meta_info('/test')))
31
+ assert_equal(dir, @obj.create_directories(root, 'dir/', path_with_meta_info('/test')))
32
+ assert_equal(dir, @obj.create_directories(root, 'dir', path_with_meta_info('/test')))
33
+
34
+ which = @obj.create_directories(root, 'dir/under/which', path_with_meta_info('/test'))
35
+ assert_equal(which, @obj.create_directories(root, 'dir/under/which', path_with_meta_info('/test')))
36
+ end
37
+
38
+ def test_content
39
+ assert_equal('', Webgen::SourceHandler::Directory.new.content(nil))
40
+ end
41
+
42
+ end
@@ -0,0 +1,77 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/sourcehandler'
6
+ require 'stringio'
7
+
8
+ class TestSourceHandlerFeed < Test::Unit::TestCase
9
+
10
+ include Test::WebsiteHelper
11
+
12
+ FEED_CONTENT = <<EOF
13
+ ---
14
+ site_url: http://example.com
15
+ entries: *.html
16
+ author: Thomas Leitner
17
+ content_block_name: abstract
18
+ --- name:rss_template
19
+ hallo
20
+ EOF
21
+ def setup
22
+ super
23
+ @nodes = {
24
+ :root => root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/', {'index_path' => 'index.html'}),
25
+ :file1_en => Webgen::Node.new(root, '/file1.en.html', 'file1.html', {'lang' => 'en', 'in_menu' => true, 'modified_at' => Time.now}),
26
+ :index_en => Webgen::Node.new(root, '/index.en.html', 'index.html', {'lang' => 'en', 'modified_at' => Time.now - 1, 'author' => 'test'}),
27
+ }
28
+ @nodes[:index_en].node_info[:page] = Webgen::Page.from_data("--- name:content\nMyContent\n--- name:abstract\nRealContent")
29
+ @obj = Webgen::SourceHandler::Feed.new
30
+ @path = path_with_meta_info('/test.feed', {}, @obj.class.name) {StringIO.new(FEED_CONTENT)}
31
+ end
32
+
33
+ def test_create_node
34
+ atom_node, rss_node = @obj.create_node(@nodes[:root], @path)
35
+
36
+ assert_not_nil(atom_node)
37
+ assert_not_nil(rss_node)
38
+ assert_kind_of(Webgen::Page, atom_node.node_info[:feed])
39
+ assert_equal('atom', atom_node.node_info[:feed_type])
40
+ assert_equal('rss', rss_node.node_info[:feed_type])
41
+
42
+ assert_equal([atom_node, rss_node], @obj.create_node(@nodes[:root], @path))
43
+ end
44
+
45
+ def test_content
46
+ atom_node, rss_node = @obj.create_node(@nodes[:root], @path)
47
+ assert_equal('hallo', rss_node.content)
48
+ assert(atom_node.content =~ /Thomas Leitner/)
49
+ assert(atom_node.content =~ /RealContent/)
50
+ end
51
+
52
+ def test_feed_entries
53
+ atom_node, rss_node = @obj.create_node(@nodes[:root], @path)
54
+ assert_equal([@nodes[:index_en]], atom_node.feed_entries)
55
+ assert_equal([@nodes[:index_en]], rss_node.feed_entries)
56
+ end
57
+
58
+ def test_node_changed
59
+ atom_node, rss_node = @obj.create_node(@nodes[:root], @path)
60
+ assert(atom_node.changed?)
61
+
62
+ atom_node.content # populate cache
63
+ @website.cache.old_data.update(@website.cache.new_data)
64
+
65
+ atom_node.unflag(:dirty)
66
+ assert(atom_node.changed?)
67
+
68
+ atom_node.unflag(:dirty)
69
+ @nodes[:file1_en].unflag(:dirty)
70
+ @nodes[:index_en].unflag(:dirty)
71
+ assert(!atom_node.changed?)
72
+
73
+ atom_node['entries'] = 'file.*.html'
74
+ assert(atom_node.changed?)
75
+ end
76
+
77
+ end
@@ -0,0 +1,69 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/sourcehandler'
6
+ require 'stringio'
7
+
8
+ class TestSourceHandlerFragment < Test::Unit::TestCase
9
+
10
+ include Test::WebsiteHelper
11
+
12
+ TEST_CONTENT=<<EOF
13
+ - data: |
14
+ <h1 id="test">Test</h1>
15
+ <h2 id="other">test</h2>
16
+ <h1>nothing</h1>
17
+ <h1 id="third">test</h1>
18
+ sections:
19
+ - [1, test, Test]
20
+ - [2, other, test]
21
+ - [1, third, test]
22
+
23
+ - data: |
24
+ <h1 id="test">Test</h1>
25
+ <h2 id="other">test</h2>
26
+ <h3 id='non'>other</h3>
27
+ <h1 id="third">test</h1>
28
+ <h3 id='four'>fourth</h3>
29
+ sections:
30
+ - [1, test, Test]
31
+ - [2, other, test]
32
+ - [3, non, other]
33
+ - [1, third, test]
34
+ - [3, four, fourth]
35
+ EOF
36
+
37
+ def test_parse_html_headers
38
+ @obj = Webgen::SourceHandler::Fragment.new
39
+ YAML::load(TEST_CONTENT).each do |data|
40
+ sections = @obj.parse_html_headers(data['data'])
41
+ check_sections(sections, data['sections'])
42
+ end
43
+ end
44
+
45
+ def test_create_fragment_nodes
46
+ @obj = Webgen::SourceHandler::Fragment.new
47
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
48
+ path = path_with_meta_info('hallo.html') {StringIO.new('')}
49
+ node = @obj.create_node(root, path)
50
+ @website.blackboard.add_service(:create_nodes, method(:create_nodes_service))
51
+
52
+ sections = @obj.parse_html_headers(YAML::load(TEST_CONTENT).first['data'])
53
+ @obj.create_fragment_nodes(sections, node, path, 'true')
54
+ assert_equal(node, node.resolve('#test').parent)
55
+ assert_equal(node.resolve('#test'), node.resolve('#other').parent)
56
+ end
57
+
58
+ def create_nodes_service(tree, alcn, path, sh)
59
+ [yield(tree[alcn], path_with_meta_info(path.path))]
60
+ end
61
+
62
+ def check_sections(sections, valid)
63
+ sections.each do |level, id, title, subsecs|
64
+ assert_equal(valid.shift, [level, id, title])
65
+ check_sections(subsecs, valid)
66
+ end
67
+ end
68
+
69
+ end