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,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'webgen/tree'
5
+ require 'webgen/contentprocessor'
6
+ require 'webgen/tag'
7
+
8
+ class TestTagMetainfo < Test::Unit::TestCase
9
+
10
+ def test_call
11
+ @obj = Webgen::Tag::Metainfo.new
12
+ node = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'hallo.page', 'hallo.page', 'test' => 10, 'lang' => 'en')
13
+ c = Webgen::ContentProcessor::Context.new(:chain => [node])
14
+ assert_equal('', @obj.call('invalid', '', c))
15
+ assert_equal('10', @obj.call('test', '', c))
16
+ assert_equal('en', @obj.call('lang', '', c))
17
+ end
18
+
19
+ end
@@ -0,0 +1,59 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/tree'
6
+ require 'webgen/contentprocessor'
7
+ require 'webgen/tag'
8
+
9
+ class TestTagRelocatable < Test::Unit::TestCase
10
+
11
+ include Test::WebsiteHelper
12
+
13
+ def setup
14
+ super
15
+ @obj = Webgen::Tag::Relocatable.new
16
+ end
17
+
18
+ def call(context)
19
+ @obj.call('relocatable', '', context)
20
+ end
21
+
22
+ def test_call
23
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
24
+ node = Webgen::Node.new(root, '/file.html', 'file.html', {'lang' => 'en'})
25
+ dir = Webgen::Node.new(root, '/dir/', 'dir/', 'index_path' => "index.html")
26
+ file = Webgen::Node.new(dir, '/dir/file.html', 'file.html', {'lang' => 'en'})
27
+ Webgen::Node.new(dir, '/dir/other.de.html', 'other.html', {'lang' => 'de'})
28
+ Webgen::Node.new(file, '/dir/file.html#fragment', '#fragment')
29
+ dir2 = Webgen::Node.new(root, '/dir2/', 'dir2/', 'index_path' => "index.html")
30
+ Webgen::Node.new(dir2, '/dir2/index.html', 'index.html')
31
+
32
+ context = Webgen::ContentProcessor::Context.new(:chain => [node])
33
+
34
+ # basic node resolving
35
+ @obj.set_params('tag.relocatable.path' => 'dir/file.html')
36
+ assert_equal('dir/file.html', call(context))
37
+ @obj.set_params('tag.relocatable.path' => 'dir/other.html')
38
+ assert_equal('', call(context))
39
+
40
+ # non-existing fragments
41
+ @obj.set_params('tag.relocatable.path' => 'file.html#hallo')
42
+ assert_equal('', call(context))
43
+
44
+ # absolute paths
45
+ @obj.set_params('tag.relocatable.path' => 'http://test.com')
46
+ assert_equal('http://test.com', call(context))
47
+
48
+ # directory paths
49
+ @obj.set_params('tag.relocatable.path' => 'dir')
50
+ assert_equal('dir/', call(context))
51
+ @obj.set_params('tag.relocatable.path' => 'dir2')
52
+ assert_equal('dir2/index.html', call(context))
53
+
54
+ # invalid paths
55
+ @obj.set_params('tag.relocatable.path' => ':/asdf=-)')
56
+ assert_equal('', call(context))
57
+ end
58
+
59
+ end
@@ -0,0 +1,47 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/tree'
6
+ require 'webgen/contentprocessor'
7
+ require 'webgen/tag'
8
+
9
+ class TestTagSitemap < Test::Unit::TestCase
10
+
11
+ include Test::WebsiteHelper
12
+
13
+ def setup
14
+ super
15
+ @obj = Webgen::Tag::Sitemap.new
16
+ end
17
+
18
+ def call(context, honor_in_menu, any_lang, used_kinds)
19
+ @obj.set_params({'common.sitemap.honor_in_menu' => honor_in_menu,
20
+ 'common.sitemap.any_lang' => any_lang,
21
+ 'common.sitemap.used_kinds' => used_kinds})
22
+ result = @obj.call('sitemap', '', context)
23
+ @obj.set_params({})
24
+ result
25
+ end
26
+
27
+ def test_call
28
+ nodes = create_sitemap_nodes
29
+ context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]])
30
+
31
+ assert_equal("<ul><li><a href=\"./\"></a>" +
32
+ "<ul><li><span></span>"+
33
+ "<ul><li><a href=\"#f1\"></a></li></ul></li></ul></li>" +
34
+ "<li><a href=\"../dir2/\"></a>" +
35
+ "<ul><li><a href=\"../dir2/file21.en.html\"></a></li></ul></li>"+
36
+ "<li><a href=\"../index.en.html\"></a></li>" +
37
+ "<li><a href=\"../dir3/index.en.html\"></a></li></ul>",
38
+ call(context, false, false, []))
39
+ assert_equal("",
40
+ call(context, false, false, ['noone']))
41
+ end
42
+
43
+ def test_tag_config_base
44
+ assert_equal('common.sitemap', @obj.send(:tag_config_base))
45
+ end
46
+
47
+ end
@@ -0,0 +1,69 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/tag'
6
+
7
+ class TestTagTikZ < Test::Unit::TestCase
8
+
9
+ include Test::WebsiteHelper
10
+
11
+ def setup
12
+ super
13
+ @obj = Webgen::Tag::TikZ.new
14
+ Webgen::SourceHandler::Main.new # service create_nodes
15
+ Webgen::SourceHandler::Directory.new # service create_directories
16
+ end
17
+
18
+ def call(context, body, path, libs, opts, res, trans, imgattr)
19
+ @obj.set_params({'tag.tikz.path' => path, 'tag.tikz.libraries' => libs,
20
+ 'tag.tikz.opts' => opts, 'tag.tikz.resolution' => res,
21
+ 'tag.tikz.transparent' => trans, 'tag.tikz.img_attr' => imgattr})
22
+ result = @obj.call('tikz', body, context)
23
+ @obj.set_params({})
24
+ result
25
+ end
26
+
27
+ def test_call
28
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
29
+ node = Webgen::Node.new(root, '/file.html', 'file.page')
30
+ context = Webgen::ContentProcessor::Context.new(:chain => [node])
31
+
32
+ output = call(context, '\tikz \draw (0,0) -- (0,1);', 'test.png', [], '', '72 72', false, {})
33
+ assert_equal('<img src="test.png" />', output)
34
+ assert(root.tree['/test.png'])
35
+ assert_not_nil(root.tree['/test.png'].content)
36
+ root.tree.delete_node('/test.png')
37
+
38
+ output = call(context, '\tikz \asdfasdfasf', 'test.png', [], '', '72 72', false, {})
39
+ assert_equal('<img src="test.png" />', output)
40
+ assert(root.tree['/test.png'])
41
+ assert_nil(root.tree['/test.png'].content)
42
+ root.tree.delete_node('/test.png')
43
+
44
+ output = call(context, '\tikz \draw (0,0) -- (0,1);', '/images/test.gif', ['arrows'], '->', '72 72', true, {'alt' => 'title'})
45
+ assert_equal('<img src="images/test.gif" alt="title" />', output)
46
+ assert(root.tree['/images/test.gif'])
47
+ assert_not_nil(root.tree['/images/test.gif'].content)
48
+ root.tree.delete_node('/images/test.gif')
49
+
50
+ output = call(context, '\tikz \draw (0,0) -- (0,1);', 'images/../img/test.png', [], '', '300 72', true, {})
51
+ assert_equal('<img src="img/test.png" />', output)
52
+ assert(root.tree['/img/test.png'])
53
+ assert_not_nil(root.tree['/img/test.png'].content)
54
+ root.tree.delete_node('/img/test.png')
55
+ end
56
+
57
+ def test_run_command
58
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
59
+ context = Webgen::ContentProcessor::Context.new(:chain => [root])
60
+ assert_equal("hallo\n", @obj.send(:run_command, echo_cmd('hallo'), context))
61
+ assert_nil(@obj.send(:run_command, 'unknown_command 2>&1', context))
62
+ end
63
+
64
+ def echo_cmd(data)
65
+ (Config::CONFIG['arch'].include?('mswin32') ? "echo #{data}" : "echo '#{data}'")
66
+ end
67
+
68
+
69
+ end
data/test/test_tree.rb ADDED
@@ -0,0 +1,70 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/tree'
6
+
7
+ class TestTree < Test::Unit::TestCase
8
+
9
+ include Test::WebsiteHelper
10
+
11
+ def setup
12
+ super
13
+ @tree = Webgen::Tree.new
14
+ end
15
+
16
+ def test_initialize
17
+ assert_not_nil(@tree.dummy_root)
18
+ assert_equal('', @tree.dummy_root.absolute_lcn)
19
+ end
20
+
21
+ def test_root
22
+ root = Webgen::Node.new(@tree.dummy_root, '/', '/')
23
+ assert_equal(root, @tree.root)
24
+ assert_equal('/', root.absolute_lcn)
25
+ end
26
+
27
+ def test_register_node_and_register_path
28
+ # Tree#register_node/_path is called when creating a node
29
+ node = Webgen::Node.new(@tree.dummy_root, 'dummy/', 'dummy')
30
+ assert_equal(node, @tree['/dummy', :alcn])
31
+ assert_equal(node, @tree['/dummy', :acn])
32
+ assert_equal(node, @tree['dummy/', :path])
33
+ assert_raise(RuntimeError) { Webgen::Node.new(@tree.dummy_root, '/', 'dummy') }
34
+ assert_raise(RuntimeError) { Webgen::Node.new(@tree.dummy_root, 'dummy/', 'other') }
35
+ assert_nothing_raised { Webgen::Node.new(@tree.dummy_root, 'dummy/', 'unknown', {'no_output' => true}) }
36
+ Webgen::Node.new(@tree.dummy_root, 'new', 'new', {'no_output' => true})
37
+ assert(!@tree['new', :path])
38
+ end
39
+
40
+ def test_delete_node
41
+ nrcalls = 0
42
+ @website.blackboard.add_listener(:before_node_deleted) { nrcalls += 1 }
43
+
44
+ root = Webgen::Node.new(@tree.dummy_root, '/', '/')
45
+ file = Webgen::Node.new(root, 'testfile', 'testfile')
46
+ dir = Webgen::Node.new(root, 'testdir/', 'testdir')
47
+
48
+ @tree.delete_node(@tree.dummy_root)
49
+ assert_not_nil(@tree[''])
50
+
51
+ assert_nothing_raised { @tree.delete_node('/unknown_path') }
52
+
53
+ @tree.delete_node(file)
54
+ assert_nil(@tree['/testfile'])
55
+ assert_nil(@tree['/testfile', :acn])
56
+ assert_nil(@tree.node_info['/testfile'])
57
+ assert_equal(1, root.children.size)
58
+ assert_equal(1, nrcalls)
59
+
60
+ @tree.delete_node('/')
61
+ assert_nil(@tree['/testdir'])
62
+ assert_nil(@tree['/testdir', :acn])
63
+ assert_nil(@tree.node_info['/testdir'])
64
+ assert_nil(@tree['/'])
65
+ assert_nil(@tree.node_info['/'])
66
+ assert_equal(3, nrcalls)
67
+ assert_equal([@tree.dummy_root], @tree.node_access[:alcn].values)
68
+ end
69
+
70
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'webgen/webgentask'
5
+
6
+ class TestWebgenTask < Test::Unit::TestCase
7
+
8
+ include Rake
9
+
10
+ def test_create
11
+ site = Webgen::WebgenTask.new('doit') do |s|
12
+ s.clobber_outdir = true
13
+ s.config_block = lambda {|c| c}
14
+ s.directory = 'website'
15
+ end
16
+ assert_equal('website', site.directory)
17
+ assert_equal(true, site.clobber_outdir)
18
+ assert_equal(5, site.config_block[5])
19
+ assert(Task['doit'])
20
+ assert(Task['clobber_doit'])
21
+ end
22
+
23
+ end
@@ -0,0 +1,98 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'webgen/website'
5
+ require 'tmpdir'
6
+ require 'fileutils'
7
+
8
+ class TestWebsite < Test::Unit::TestCase
9
+
10
+ def test_initialize
11
+ ws = Webgen::Website.new('dir') do
12
+ assert_equal(ws, Webgen::WebsiteAccess.website)
13
+ throw :called
14
+ end
15
+ assert_nil(ws.blackboard)
16
+ assert_nil(ws.cache)
17
+ assert_nil(ws.config)
18
+ assert_nil(ws.tree)
19
+ assert_equal('dir', ws.directory)
20
+ assert_throws(:called) { ws.init }
21
+ assert_nil(Thread.current[:webgen_website])
22
+ end
23
+
24
+ def test_autoload_service
25
+ ws = Webgen::Website.new('unknown', nil)
26
+ ws.init
27
+ ws.instance_eval { @cache = Webgen::Cache.new }
28
+ ws.autoload_service('[]', 'Hash')
29
+ assert_equal([], ws.cache.permanent[:classes])
30
+ ws.blackboard.invoke('[]', 5)
31
+ assert_equal(['Hash'], ws.cache.permanent[:classes])
32
+ end
33
+
34
+ def test_init
35
+ ws = Webgen::Website.new('hallo')
36
+ ws.init
37
+ assert_not_nil(ws.config)
38
+ assert_not_nil(ws.blackboard)
39
+ assert_not_nil(ws.cache)
40
+ assert_not_nil(ws.tree)
41
+ end
42
+
43
+ def test_render_of_non_webgen_website
44
+ ws = Webgen::Website.new(File.dirname(__FILE__), nil) do |config|
45
+ config['website.cache'] = [:string, '']
46
+ end
47
+ assert_nil(ws.render)
48
+ assert(ws.config['website.cache'][1].length == 0)
49
+ end
50
+
51
+ def test_execute_in_env
52
+ ws = Webgen::Website.new('hallo')
53
+ assert_nil(Webgen::WebsiteAccess.website)
54
+ ws.execute_in_env { assert_not_nil(Webgen::WebsiteAccess.website) }
55
+ end
56
+
57
+ def test_read_config_file
58
+ dir = File.join(Dir.tmpdir, 'webgen-' + Process.pid.to_s)
59
+ FileUtils.mkdir_p(dir)
60
+
61
+ ws = Webgen::Website.new(dir)
62
+ ws.init
63
+ assert_equal('', ws.logger.log_output)
64
+ FileUtils.touch(File.join(dir, 'config.yml'))
65
+ ws.init
66
+ assert_match(/spelling error/, ws.logger.log_output)
67
+
68
+ File.open(File.join(dir, 'config.yaml'), 'w+') {|f| f.write('- unknown')}
69
+ assert_raise(Webgen::Website::ConfigFileInvalid) { ws.init }
70
+
71
+ File.open(File.join(dir, 'config.yaml'), 'w+') {|f| f.write('webgen.unknown: doit')}
72
+ assert_raise(Webgen::Website::ConfigFileInvalid) { ws.init }
73
+
74
+ File.open(File.join(dir, 'config.yaml'), 'w+') {|f| f.write("website.lang: de\ndefault_meta_info: {:all: {hallo: du}}")}
75
+ ws.init
76
+ assert_equal('de', ws.config['website.lang'])
77
+ assert_equal('du', ws.config['sourcehandler.default_meta_info'][:all]['hallo'])
78
+ ensure
79
+ FileUtils.rm_rf(dir)
80
+ end
81
+
82
+ def test_clean
83
+ dir = File.join(Dir.tmpdir, 'webgen-' + Process.pid.to_s)
84
+ FileUtils.mkdir_p(dir)
85
+ FileUtils.mkdir_p(File.join(dir, 'src'))
86
+ FileUtils.touch(File.join(dir, 'src', 'test.jpg'))
87
+
88
+ ws = Webgen::Website.new(dir, nil)
89
+ assert_equal(:success, ws.render)
90
+ assert(File.exists?(File.join(dir, 'out', 'test.jpg')))
91
+ ws.clean
92
+ assert(!File.exists?(File.join(dir, 'out', 'test.jpg')))
93
+ assert(File.directory?(File.join(dir, 'out')))
94
+ ws.clean(true)
95
+ assert(!File.directory?(File.join(dir, 'out')))
96
+ end
97
+
98
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'webgen/websiteaccess'
5
+
6
+
7
+ class TestWebsiteaccess < Test::Unit::TestCase
8
+
9
+ class WSAccessSubClass
10
+ include Webgen::WebsiteAccess
11
+
12
+ def get_private_website
13
+ website
14
+ end
15
+ end
16
+
17
+ def test_accessors
18
+ Thread.current[:webgen_website] = :value
19
+ assert_equal(:value, Webgen::WebsiteAccess.website)
20
+ assert_equal(:value, WSAccessSubClass.website)
21
+ assert_equal(:value, WSAccessSubClass.new.get_private_website)
22
+ Thread.current[:webgen_website] = nil
23
+ end
24
+
25
+ end
@@ -0,0 +1,70 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'fileutils'
4
+ require 'tmpdir'
5
+ require 'helper'
6
+ require 'test/unit'
7
+ require 'webgen/websitemanager'
8
+
9
+ class TestWebsiteManager < Test::Unit::TestCase
10
+
11
+ def test_initialize
12
+ wm = Webgen::WebsiteManager.new('.')
13
+ t = wm.templates['default']
14
+ assert_equal('Thomas Leitner', t.author)
15
+ assert(t.paths.length > 0)
16
+
17
+ s = wm.styles['1024px']
18
+ assert(s.paths.length > 0)
19
+ end
20
+
21
+ def test_create_website
22
+ with_tmpdir do |dir|
23
+ wm = Webgen::WebsiteManager.new(dir)
24
+ wm.create_website
25
+ assert(File.directory?(File.join(dir, 'ext')))
26
+ assert(File.directory?(File.join(dir, 'src')))
27
+ assert(File.file?(File.join(dir, 'README')))
28
+ assert(File.file?(File.join(dir, 'config.yaml')))
29
+ end
30
+ end
31
+
32
+ def test_apply_template
33
+ with_tmpdir do |dir|
34
+ wm = Webgen::WebsiteManager.new(dir)
35
+ assert_raise(RuntimeError) { wm.apply_template('default') }
36
+
37
+ Dir.mkdir(dir)
38
+ wm.apply_template('default')
39
+ assert(File.directory?(File.join(dir, 'src')))
40
+ assert(File.file?(File.join(dir, 'src', 'index.page')))
41
+
42
+ assert_raise(ArgumentError) { wm.apply_template('unknown-template') }
43
+ end
44
+ end
45
+
46
+ def test_apply_style
47
+ dir = with_tmpdir
48
+ wm = Webgen::WebsiteManager.new(dir)
49
+ assert_raise(RuntimeError) { wm.apply_style('simple') }
50
+
51
+ wm.styles.each do |name, infos|
52
+ Dir.mkdir(dir)
53
+ wm.apply_style(name)
54
+ assert(File.directory?(File.join(dir, 'src')))
55
+ assert(File.file?(File.join(dir, 'src', 'default.template')))
56
+ assert(File.file?(File.join(dir, 'src', 'default.css')))
57
+ FileUtils.rm_rf(dir)
58
+ end
59
+ assert_raise(ArgumentError) { wm.apply_style('unknown-style') }
60
+ end
61
+
62
+ def with_tmpdir
63
+ dir = File.join(Dir.tmpdir, 'webgen-' + Process.pid.to_s)
64
+ yield(dir) if block_given?
65
+ dir
66
+ ensure
67
+ FileUtils.rm_rf(dir)
68
+ end
69
+
70
+ end