gettalong-webgen 0.5.4.20080929

Sign up to get free protection for your applications and to get access to all the features.
Files changed (290) hide show
  1. data/AUTHORS +5 -0
  2. data/COPYING +10 -0
  3. data/GPL +340 -0
  4. data/Rakefile +324 -0
  5. data/THANKS +17 -0
  6. data/bin/webgen +10 -0
  7. data/data/webgen/resources.yaml +3 -0
  8. data/data/webgen/webgui/controller/main.rb +129 -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 +6 -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 +61 -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 +66 -0
  117. data/doc/contentprocessor/builder.page +80 -0
  118. data/doc/contentprocessor/erb.page +56 -0
  119. data/doc/contentprocessor/erubis.page +46 -0
  120. data/doc/contentprocessor/haml.page +47 -0
  121. data/doc/contentprocessor/maruku.page +41 -0
  122. data/doc/contentprocessor/rdiscount.page +37 -0
  123. data/doc/contentprocessor/rdoc.page +36 -0
  124. data/doc/contentprocessor/redcloth.page +39 -0
  125. data/doc/contentprocessor/sass.page +31 -0
  126. data/doc/contentprocessor/tags.page +73 -0
  127. data/doc/extensions.metainfo +29 -0
  128. data/doc/extensions.page +16 -0
  129. data/doc/extensions.template +17 -0
  130. data/doc/faq.page +214 -0
  131. data/doc/getting_started.page +134 -0
  132. data/doc/index.page +65 -0
  133. data/doc/manual.page +532 -0
  134. data/doc/reference_configuration.page +646 -0
  135. data/doc/reference_metainfo.page +213 -0
  136. data/doc/sourcehandler.template +21 -0
  137. data/doc/sourcehandler/copy.page +19 -0
  138. data/doc/sourcehandler/directory.page +27 -0
  139. data/doc/sourcehandler/feed.page +82 -0
  140. data/doc/sourcehandler/metainfo.page +41 -0
  141. data/doc/sourcehandler/page.page +30 -0
  142. data/doc/sourcehandler/sitemap.page +46 -0
  143. data/doc/sourcehandler/template.page +45 -0
  144. data/doc/sourcehandler/virtual.page +49 -0
  145. data/doc/tag.template +25 -0
  146. data/doc/tag/breadcrumbtrail.page +40 -0
  147. data/doc/tag/coderay.page +49 -0
  148. data/doc/tag/date.page +31 -0
  149. data/doc/tag/executecommand.page +26 -0
  150. data/doc/tag/includefile.page +32 -0
  151. data/doc/tag/langbar.page +22 -0
  152. data/doc/tag/menu.page +92 -0
  153. data/doc/tag/metainfo.page +29 -0
  154. data/doc/tag/relocatable.page +38 -0
  155. data/doc/tag/sitemap.page +31 -0
  156. data/doc/upgrading.page +139 -0
  157. data/doc/webgen_page_format.page +128 -0
  158. data/lib/webgen/blackboard.rb +73 -0
  159. data/lib/webgen/cache.rb +85 -0
  160. data/lib/webgen/cli.rb +118 -0
  161. data/lib/webgen/cli/create_command.rb +64 -0
  162. data/lib/webgen/cli/run_command.rb +20 -0
  163. data/lib/webgen/cli/utils.rb +86 -0
  164. data/lib/webgen/cli/webgui_command.rb +49 -0
  165. data/lib/webgen/common.rb +10 -0
  166. data/lib/webgen/common/sitemap.rb +76 -0
  167. data/lib/webgen/configuration.rb +147 -0
  168. data/lib/webgen/contentprocessor.rb +96 -0
  169. data/lib/webgen/contentprocessor/blocks.rb +46 -0
  170. data/lib/webgen/contentprocessor/builder.rb +26 -0
  171. data/lib/webgen/contentprocessor/context.rb +90 -0
  172. data/lib/webgen/contentprocessor/erb.rb +24 -0
  173. data/lib/webgen/contentprocessor/erubis.rb +40 -0
  174. data/lib/webgen/contentprocessor/haml.rb +25 -0
  175. data/lib/webgen/contentprocessor/maruku.rb +18 -0
  176. data/lib/webgen/contentprocessor/rdiscount.rb +15 -0
  177. data/lib/webgen/contentprocessor/rdoc.rb +17 -0
  178. data/lib/webgen/contentprocessor/redcloth.rb +15 -0
  179. data/lib/webgen/contentprocessor/sass.rb +18 -0
  180. data/lib/webgen/contentprocessor/tags.rb +134 -0
  181. data/lib/webgen/coreext.rb +10 -0
  182. data/lib/webgen/default_config.rb +198 -0
  183. data/lib/webgen/languages.rb +578 -0
  184. data/lib/webgen/loggable.rb +23 -0
  185. data/lib/webgen/logger.rb +78 -0
  186. data/lib/webgen/node.rb +347 -0
  187. data/lib/webgen/output.rb +37 -0
  188. data/lib/webgen/output/filesystem.rb +67 -0
  189. data/lib/webgen/page.rb +133 -0
  190. data/lib/webgen/path.rb +182 -0
  191. data/lib/webgen/source.rb +24 -0
  192. data/lib/webgen/source/filesystem.rb +58 -0
  193. data/lib/webgen/source/resource.rb +42 -0
  194. data/lib/webgen/source/stacked.rb +53 -0
  195. data/lib/webgen/sourcehandler.rb +202 -0
  196. data/lib/webgen/sourcehandler/base.rb +211 -0
  197. data/lib/webgen/sourcehandler/copy.rb +41 -0
  198. data/lib/webgen/sourcehandler/directory.rb +31 -0
  199. data/lib/webgen/sourcehandler/feed.rb +121 -0
  200. data/lib/webgen/sourcehandler/fragment.rb +71 -0
  201. data/lib/webgen/sourcehandler/metainfo.rb +117 -0
  202. data/lib/webgen/sourcehandler/page.rb +77 -0
  203. data/lib/webgen/sourcehandler/sitemap.rb +60 -0
  204. data/lib/webgen/sourcehandler/template.rb +68 -0
  205. data/lib/webgen/sourcehandler/virtual.rb +75 -0
  206. data/lib/webgen/tag.rb +23 -0
  207. data/lib/webgen/tag/base.rb +162 -0
  208. data/lib/webgen/tag/breadcrumbtrail.rb +71 -0
  209. data/lib/webgen/tag/coderay.rb +32 -0
  210. data/lib/webgen/tag/date.rb +18 -0
  211. data/lib/webgen/tag/executecommand.rb +29 -0
  212. data/lib/webgen/tag/includefile.rb +42 -0
  213. data/lib/webgen/tag/langbar.rb +52 -0
  214. data/lib/webgen/tag/menu.rb +186 -0
  215. data/lib/webgen/tag/metainfo.rb +25 -0
  216. data/lib/webgen/tag/relocatable.rb +53 -0
  217. data/lib/webgen/tag/sitemap.rb +42 -0
  218. data/lib/webgen/tree.rb +80 -0
  219. data/lib/webgen/version.rb +6 -0
  220. data/lib/webgen/webgentask.rb +148 -0
  221. data/lib/webgen/website.rb +214 -0
  222. data/lib/webgen/websiteaccess.rb +29 -0
  223. data/lib/webgen/websitemanager.rb +125 -0
  224. data/man/man1/webgen.1 +67 -0
  225. data/misc/default.css +360 -0
  226. data/misc/default.template +75 -0
  227. data/misc/htmldoc.metainfo +25 -0
  228. data/misc/htmldoc.virtual +5 -0
  229. data/misc/images/arrow.gif +0 -0
  230. data/misc/images/error.gif +0 -0
  231. data/misc/images/exclamation.gif +0 -0
  232. data/misc/images/headerbg.jpg +0 -0
  233. data/misc/images/information.gif +0 -0
  234. data/misc/images/quote.gif +0 -0
  235. data/setup.rb +1585 -0
  236. data/test/helper.rb +41 -0
  237. data/test/test_blackboard.rb +58 -0
  238. data/test/test_cache.rb +57 -0
  239. data/test/test_common_sitemap.rb +56 -0
  240. data/test/test_configuration.rb +66 -0
  241. data/test/test_contentprocessor.rb +31 -0
  242. data/test/test_contentprocessor_blocks.rb +34 -0
  243. data/test/test_contentprocessor_builder.rb +19 -0
  244. data/test/test_contentprocessor_context.rb +38 -0
  245. data/test/test_contentprocessor_erb.rb +20 -0
  246. data/test/test_contentprocessor_erubis.rb +47 -0
  247. data/test/test_contentprocessor_haml.rb +20 -0
  248. data/test/test_contentprocessor_maruku.rb +27 -0
  249. data/test/test_contentprocessor_rdiscount.rb +15 -0
  250. data/test/test_contentprocessor_rdoc.rb +16 -0
  251. data/test/test_contentprocessor_redcloth.rb +12 -0
  252. data/test/test_contentprocessor_sass.rb +20 -0
  253. data/test/test_contentprocessor_tags.rb +97 -0
  254. data/test/test_languages.rb +53 -0
  255. data/test/test_loggable.rb +30 -0
  256. data/test/test_logger.rb +73 -0
  257. data/test/test_node.rb +339 -0
  258. data/test/test_output_filesystem.rb +58 -0
  259. data/test/test_page.rb +203 -0
  260. data/test/test_path.rb +131 -0
  261. data/test/test_source_filesystem.rb +59 -0
  262. data/test/test_source_resource.rb +26 -0
  263. data/test/test_source_stacked.rb +34 -0
  264. data/test/test_sourcehandler_base.rb +92 -0
  265. data/test/test_sourcehandler_copy.rb +45 -0
  266. data/test/test_sourcehandler_directory.rb +25 -0
  267. data/test/test_sourcehandler_feed.rb +74 -0
  268. data/test/test_sourcehandler_fragment.rb +67 -0
  269. data/test/test_sourcehandler_metainfo.rb +93 -0
  270. data/test/test_sourcehandler_page.rb +70 -0
  271. data/test/test_sourcehandler_sitemap.rb +47 -0
  272. data/test/test_sourcehandler_template.rb +63 -0
  273. data/test/test_sourcehandler_virtual.rb +56 -0
  274. data/test/test_tag_base.rb +82 -0
  275. data/test/test_tag_breadcrumbtrail.rb +89 -0
  276. data/test/test_tag_coderay.rb +30 -0
  277. data/test/test_tag_date.rb +16 -0
  278. data/test/test_tag_executecommand.rb +39 -0
  279. data/test/test_tag_includefile.rb +48 -0
  280. data/test/test_tag_langbar.rb +60 -0
  281. data/test/test_tag_menu.rb +195 -0
  282. data/test/test_tag_metainfo.rb +17 -0
  283. data/test/test_tag_relocatable.rb +57 -0
  284. data/test/test_tag_sitemap.rb +44 -0
  285. data/test/test_tree.rb +69 -0
  286. data/test/test_webgentask.rb +21 -0
  287. data/test/test_website.rb +96 -0
  288. data/test/test_websiteaccess.rb +23 -0
  289. data/test/test_websitemanager.rb +68 -0
  290. metadata +575 -0
@@ -0,0 +1,39 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'webgen/tag'
4
+
5
+ class TestTagExecuteCommand < Test::Unit::TestCase
6
+
7
+ include Test::WebsiteHelper
8
+
9
+ def setup
10
+ super
11
+ @obj = Webgen::Tag::ExecuteCommand.new
12
+ end
13
+
14
+ def call(context, command, process, escape)
15
+ @obj.set_params({'tag.executecommand.command' => command,
16
+ 'tag.executecommand.process_output' => process,
17
+ 'tag.executecommand.escape_html' => escape})
18
+ result = @obj.call('execute_cmd', '', context)
19
+ @obj.set_params({})
20
+ [result.first.chomp.strip, result.last]
21
+ end
22
+
23
+ def test_call
24
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
25
+ context = Webgen::ContentProcessor::Context.new(:chain => [root])
26
+
27
+ test_text = "a\"b\""
28
+ assert_equal([test_text, false], call(context, echo_cmd(test_text), false, false))
29
+ assert_equal([test_text, true], call(context, echo_cmd(test_text), true, false))
30
+ assert_equal(['a&quot;b&quot;', true], call(context, echo_cmd(test_text), true, true))
31
+ assert_equal(['a&quot;b&quot;', true], call(context, echo_cmd(test_text), true, true))
32
+ assert_raise(RuntimeError) { call(context, 'invalid_echo_command', true, true) }
33
+ end
34
+
35
+ def echo_cmd(data)
36
+ (Config::CONFIG['arch'].include?('mswin32') ? "echo #{data}" : "echo '#{data}'")
37
+ end
38
+
39
+ end
@@ -0,0 +1,48 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'fileutils'
4
+ require 'tempfile'
5
+ require 'webgen/tag'
6
+
7
+ class TestTagIncludeFile < Test::Unit::TestCase
8
+
9
+ include Test::WebsiteHelper
10
+
11
+ def setup
12
+ super
13
+ @obj = Webgen::Tag::IncludeFile.new
14
+ end
15
+
16
+ def call(context, filename, process, escape)
17
+ @obj.set_params({'tag.includefile.filename' => filename,
18
+ 'tag.includefile.process_output' => process,
19
+ 'tag.includefile.escape_html' => escape})
20
+ result = @obj.call('include_file', '', context)
21
+ @obj.set_params({})
22
+ result
23
+ end
24
+
25
+ def test_call
26
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
27
+ context = Webgen::ContentProcessor::Context.new(:chain => [root])
28
+
29
+ content = "<a>This is 'a' Test</a>"
30
+ file = Tempfile.new('webgen-test-file')
31
+ file.write(content)
32
+ file.close
33
+
34
+ assert_equal([content, false], call(context, file.path, false, false))
35
+ assert_equal([content, true], call(context, file.path, true, false))
36
+ assert_equal([CGI::escapeHTML(content), true], call(context, file.path, true, true))
37
+ assert_raise(Errno::ENOENT) { call(context, 'invalidfile', true, true) }
38
+
39
+ root.dirty = false
40
+ @website.blackboard.dispatch_msg(:node_changed?, root)
41
+ assert(!root.dirty)
42
+
43
+ File.utime(Time.now + 1, Time.now + 1, file.path)
44
+ @website.blackboard.dispatch_msg(:node_changed?, root)
45
+ assert(root.dirty)
46
+ end
47
+
48
+ end
@@ -0,0 +1,60 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'webgen/tag'
4
+
5
+ class TestTagLangbar < Test::Unit::TestCase
6
+
7
+ include Test::WebsiteHelper
8
+
9
+ def setup
10
+ super
11
+ @obj = Webgen::Tag::Langbar.new
12
+ end
13
+
14
+ def create_default_nodes
15
+ {
16
+ :root => root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/', {'index_path' => 'index.html'}),
17
+ :file_en => Webgen::Node.new(root, '/file1.html', 'file1.html',
18
+ {'lang' => 'en', 'title' => 'File1'}),
19
+ :index_en => Webgen::Node.new(root, '/index.html', 'index.html', {'lang' => 'en'}),
20
+ :index_de => Webgen::Node.new(root, '/index.de.html', 'index.html', {'lang' => 'de'}),
21
+ }
22
+ end
23
+
24
+ def test_call
25
+ nodes = create_default_nodes
26
+
27
+ de_link = '<a href="index.de.html">de</a>'
28
+ en_link = '<span>en</span>'
29
+ check_results(nodes[:index_en], "#{de_link} | #{en_link}", de_link, "#{de_link} | #{en_link}", de_link)
30
+
31
+ link = '<span>en</span>'
32
+ check_results(nodes[:file_en], link, '', '', '')
33
+
34
+ @obj.set_params('tag.langbar.show_single_lang'=>true, 'tag.langbar.show_own_lang'=>true, 'tag.langbar.separator' => ' --- ')
35
+ assert_equal("#{de_link} --- #{en_link}", @obj.call('langbar', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index_en]])))
36
+
37
+ nodes[:index_en].dirty = false
38
+ @website.blackboard.dispatch_msg(:node_changed?, nodes[:index_en])
39
+ assert(!nodes[:index_en].dirty)
40
+ nodes[:index_en].tree.delete_node(nodes[:index_de])
41
+ @website.blackboard.dispatch_msg(:node_changed?, nodes[:index_en])
42
+ assert(nodes[:index_en].dirty)
43
+ end
44
+
45
+ def check_results(node, both_true, both_false, first_false, second_false)
46
+ context = Webgen::ContentProcessor::Context.new(:chain => [node])
47
+ @obj.set_params('tag.langbar.show_single_lang'=>true, 'tag.langbar.show_own_lang'=>true)
48
+ assert_equal(both_true, @obj.call('langbar', '', context))
49
+
50
+ @obj.set_params('tag.langbar.show_single_lang'=>false, 'tag.langbar.show_own_lang'=>false)
51
+ assert_equal(both_false, @obj.call('langbar', '', context))
52
+
53
+ @obj.set_params('tag.langbar.show_single_lang'=>false, 'tag.langbar.show_own_lang'=>true)
54
+ assert_equal(first_false, @obj.call('langbar', '', context))
55
+
56
+ @obj.set_params('tag.langbar.show_single_lang'=>true, 'tag.langbar.show_own_lang'=>false)
57
+ assert_equal(second_false, @obj.call('langbar', '', context))
58
+ end
59
+
60
+ end
@@ -0,0 +1,195 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'webgen/tree'
4
+ require 'webgen/contentprocessor'
5
+ require 'webgen/tag/menu'
6
+
7
+ class TestTagMenu < Test::Unit::TestCase
8
+
9
+ include Test::WebsiteHelper
10
+
11
+ def setup
12
+ super
13
+ @obj = Webgen::Tag::Menu.new
14
+ end
15
+
16
+ def create_default_nodes
17
+ {
18
+ :root => root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/', {'index_path' => 'index.html'}),
19
+ :dir1 => dir1 = Webgen::Node.new(root, '/dir1/', 'dir1/'),
20
+ :dir11 => dir11 = Webgen::Node.new(dir1, '/dir1/dir11/', 'dir11/', {'index_path' => 'index.html'}),
21
+ :file111_en => Webgen::Node.new(dir11, '/dir1/dir11/file111.en.html', 'file111.html', {'lang' => 'en', 'in_menu' => true}),
22
+ :file111_de => Webgen::Node.new(dir11, '/dir1/dir11/file111.de.html', 'file111.html', {'lang' => 'de', 'in_menu' => true}),
23
+ :index11_en => Webgen::Node.new(dir11, '/dir1/dir11/index.en.html', 'index.html', {'lang' => 'en', 'in_menu' => true}),
24
+ :file11_en => file11 = Webgen::Node.new(dir1, '/dir1/file11.en.html', 'file11.html', {'lang' => 'en', 'in_menu' => true}),
25
+ :file11_en_f1 => file11_f1 = Webgen::Node.new(file11, '/dir1/file11.en.html#f1', '#f1', {'in_menu' => true}),
26
+ :file11_en_f11 => Webgen::Node.new(file11_f1, '/dir1/file11.en.html#f11', '#f11', {'in_menu' => true}),
27
+ :file11_en_f2 => Webgen::Node.new(file11, '/dir1/file11.en.html#f2', '#f2', {'in_menu' => true}),
28
+ :dir2 => dir2 = Webgen::Node.new(root, '/dir2/', 'dir2/'),
29
+ :file21_en => Webgen::Node.new(dir2, '/dir2/file21.en.html', 'file21.html', {'lang' => 'en', 'in_menu' => true}),
30
+ :dir3 => dir3 = Webgen::Node.new(root, '/dir3/', 'dir3/'),
31
+ :file31_en => file31 = Webgen::Node.new(dir3, '/dir3/file31.en.html', 'file31.html', {'lang' => 'en', 'in_menu' => false}),
32
+ :file31_en_f1 => Webgen::Node.new(file31, '/dir3/file31.en.html#f1', '#f1', {'in_menu' => true}),
33
+ :file1_de => Webgen::Node.new(root, '/file1.de.html', 'file1.html', {'lang' => 'de', 'in_menu' => true}),
34
+ :index_en => Webgen::Node.new(root, '/index.en.html', 'index.html', {'lang' => 'en'}),
35
+ }
36
+ end
37
+
38
+ def build_menu(node, options)
39
+ @obj.set_params(options_hash(*options))
40
+ output = @obj.send(:specific_menu_tree_for, node)
41
+ @obj.set_params({})
42
+ output
43
+ end
44
+
45
+ def options_hash(start_level, min_levels, max_levels, subtree, used_nodes = 'all')
46
+ {'tag.menu.start_level' => start_level, 'tag.menu.min_levels' => min_levels, 'tag.menu.max_levels' => max_levels,
47
+ 'tag.menu.show_current_subtree_only' => subtree, 'tag.menu.used_nodes' => used_nodes }
48
+ end
49
+
50
+ def test_call
51
+ nodes = create_default_nodes
52
+
53
+ output = @obj.call('menu', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]]))
54
+ assert_equal("<ul><li class=\"webgen-menu-level1 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><a href=\"./\"></a>" +
55
+ "<ul><li class=\"webgen-menu-level2 webgen-menu-submenu\"><a href=\"dir11/index.en.html\"></a></li>" +
56
+ "<li class=\"webgen-menu-level2 webgen-menu-item-selected\"><span></span></li></ul></li>" +
57
+ "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../dir2/\"></a></li>" +
58
+ "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../dir3/\"></a></li></ul>", output)
59
+
60
+ output = @obj.call('menu', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index11_en]]))
61
+ assert_equal("<ul><li class=\"webgen-menu-level1 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><a href=\"../\"></a>" +
62
+ "<ul><li class=\"webgen-menu-level2 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><span></span>" +
63
+ "<ul><li class=\"webgen-menu-level3\"><a href=\"file111.en.html\"></a></li>" +
64
+ "<li class=\"webgen-menu-level3 webgen-menu-item-selected\"><span></span></li></ul></li>" +
65
+ "<li class=\"webgen-menu-level2\"><a href=\"../file11.en.html\"></a></li></ul></li>" +
66
+ "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../../dir2/\"></a></li>" +
67
+ "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../../dir3/\"></a></li></ul>", output)
68
+
69
+
70
+ @obj.set_params('tag.menu.used_nodes' => 'fragments')
71
+ output = @obj.call('menu', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]]))
72
+ @obj.set_params({})
73
+ assert_equal("<ul><li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"#f1\"></a></li>" +
74
+ "<li class=\"webgen-menu-level1\"><a href=\"#f2\"></a></li></ul>", output)
75
+
76
+ @obj.set_params('tag.menu.start_level' => 5)
77
+ output = @obj.call('menu', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]]))
78
+ @obj.set_params({})
79
+ assert_equal("", output)
80
+
81
+ nodes.each {|k,v| v.dirty = false}
82
+ @website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
83
+ assert(!nodes[:file11_en].dirty)
84
+
85
+ nodes[:index11_en].dirty_meta_info = true
86
+ @website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
87
+ assert(nodes[:file11_en].dirty)
88
+
89
+ nodes.each {|k,v| v.dirty = false}
90
+ nodes[:file11_en_f2]['in_menu'] = false
91
+ @website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
92
+ assert(nodes[:file11_en].dirty)
93
+ end
94
+
95
+ def test_menu_tree_for_lang_and_create_menu_tree
96
+ nodes = create_default_nodes
97
+
98
+ tree_en = @obj.send(:menu_tree_for_lang, 'en', nodes[:root])
99
+ expected = [nodes[:dir1], nodes[:dir11], nodes[:file111_en], nodes[:index11_en],
100
+ nodes[:file11_en], nodes[:file11_en_f1], nodes[:file11_en_f11], nodes[:file11_en_f2],
101
+ nodes[:dir2], nodes[:file21_en],
102
+ nodes[:dir3], nodes[:file31_en], nodes[:file31_en_f1]].collect {|n| n.absolute_lcn}
103
+
104
+ assert_equal(expected, tree_en.to_lcn_list.flatten)
105
+
106
+ tree_de = @obj.send(:menu_tree_for_lang, 'de', nodes[:root])
107
+ expected = [nodes[:dir1], nodes[:dir11], nodes[:file111_de], nodes[:file1_de]].collect {|n| n.absolute_lcn}
108
+
109
+ assert_equal(expected, tree_de.to_lcn_list.flatten)
110
+ end
111
+
112
+ def test_specific_menu_tree_for_and_build_specific_menu_tree
113
+ nodes = create_default_nodes
114
+
115
+ # testing min_levels and max_levels
116
+ output = build_menu(nodes[:index_en], [1, 1, 1, true])
117
+ expected = [nodes[:dir1], nodes[:dir2], nodes[:dir3]].collect {|n| n.absolute_lcn}
118
+ assert_equal(expected, output.to_lcn_list.flatten)
119
+
120
+ output = build_menu(nodes[:index_en], [1, 2, 1, true])
121
+ expected = [nodes[:dir1], nodes[:dir2], nodes[:dir3]].collect {|n| n.absolute_lcn}
122
+ assert_equal(expected, output.to_lcn_list.flatten)
123
+
124
+ output = build_menu(nodes[:index_en], [1, 2, 2, true])
125
+ expected = [nodes[:dir1], nodes[:dir11], nodes[:file11_en], nodes[:dir2], nodes[:file21_en],
126
+ nodes[:dir3], nodes[:file31_en]].collect {|n| n.absolute_lcn}
127
+ assert_equal(expected, output.to_lcn_list.flatten)
128
+
129
+ # testing show_current_subtree_only
130
+ output = build_menu(nodes[:file11_en], [1, 1, 2, true])
131
+ expected = [nodes[:dir1], nodes[:dir11], nodes[:file11_en], nodes[:dir2], nodes[:dir3]].collect {|n| n.absolute_lcn}
132
+ assert_equal(expected, output.to_lcn_list.flatten)
133
+
134
+ output = build_menu(nodes[:file11_en], [1, 1, 2, false])
135
+ expected = [nodes[:dir1], nodes[:dir11], nodes[:file11_en], nodes[:dir2], nodes[:file21_en],
136
+ nodes[:dir3], nodes[:file31_en]].collect {|n| n.absolute_lcn}
137
+ assert_equal(expected, output.to_lcn_list.flatten)
138
+
139
+ # testing start_level
140
+ output = build_menu(nodes[:index_en], [2, 1, 1, true])
141
+ assert_equal([], output.to_lcn_list.flatten)
142
+
143
+ output = build_menu(nodes[:file11_en], [2, 1, 2, true])
144
+ expected = [nodes[:dir11], nodes[:file11_en]].collect {|n| n.absolute_lcn}
145
+ assert_equal(expected, output.to_lcn_list.flatten)
146
+
147
+ output = build_menu(nodes[:file11_en], [2, 1, 2, false])
148
+ expected = [nodes[:dir11], nodes[:file11_en]].collect {|n| n.absolute_lcn}
149
+ assert_equal(expected, output.to_lcn_list.flatten)
150
+
151
+ output = build_menu(nodes[:file11_en], [2, 2, 2, false])
152
+ expected = [nodes[:dir11], nodes[:file111_en], nodes[:index11_en],
153
+ nodes[:file11_en], nodes[:file11_en_f1], nodes[:file11_en_f2]].collect {|n| n.absolute_lcn}
154
+ assert_equal(expected, output.to_lcn_list.flatten)
155
+
156
+ output = build_menu(nodes[:file111_en], [2, 1, 2, true])
157
+ expected = [nodes[:dir11], nodes[:file111_en], nodes[:index11_en], nodes[:file11_en]].collect {|n| n.absolute_lcn}
158
+ assert_equal(expected, output.to_lcn_list.flatten)
159
+
160
+ # testing used_nodes=files setting
161
+ output = build_menu(nodes[:file11_en], [2, 2, 2, false, 'files'])
162
+ expected = [nodes[:dir11], nodes[:file111_en], nodes[:index11_en], nodes[:file11_en]].collect {|n| n.absolute_lcn}
163
+ assert_equal(expected, output.to_lcn_list.flatten)
164
+
165
+ output = build_menu(nodes[:file11_en], [1, 1, 1, true, 'files'])
166
+ expected = [nodes[:dir1], nodes[:dir2]].collect {|n| n.absolute_lcn}
167
+ assert_equal(expected, output.to_lcn_list.flatten)
168
+
169
+ # testing used_nodes=fragments setting
170
+ output = build_menu(nodes[:file11_en], [1, 1, 2, false, 'fragments'])
171
+ expected = [nodes[:file11_en_f1], nodes[:file11_en_f2]].collect {|n| n.absolute_lcn}
172
+ assert_equal(expected, output.to_lcn_list.flatten)
173
+
174
+ output = build_menu(nodes[:file11_en], [1, 2, 2, false, 'fragments'])
175
+ expected = [nodes[:file11_en_f1], nodes[:file11_en_f11], nodes[:file11_en_f2]].collect {|n| n.absolute_lcn}
176
+ assert_equal(expected, output.to_lcn_list.flatten)
177
+ end
178
+
179
+ def test_create_output_and_menu_item_details
180
+ nodes = create_default_nodes
181
+ tree = build_menu(nodes[:file111_en], [1, 2, 3, true])
182
+ context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file111_en]])
183
+ assert_equal("<ul><li class=\"webgen-menu-level1 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><a href=\"../\"></a>" +
184
+ "<ul><li class=\"webgen-menu-level2 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><a href=\"index.en.html\"></a>" +
185
+ "<ul><li class=\"webgen-menu-level3 webgen-menu-item-selected\"><span></span></li>" +
186
+ "<li class=\"webgen-menu-level3\"><a href=\"index.en.html\"></a></li></ul></li>" +
187
+ "<li class=\"webgen-menu-level2\"><a href=\"../file11.en.html\"></a></li></ul></li>" +
188
+ "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../../dir2/\"></a>" +
189
+ "<ul><li class=\"webgen-menu-level2\"><a href=\"../../dir2/file21.en.html\"></a></li></ul></li>" +
190
+ "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../../dir3/\"></a>" +
191
+ "<ul><li class=\"webgen-menu-level2\"><a href=\"../../dir3/file31.en.html\"></a></li></ul></li></ul>",
192
+ @obj.send(:create_output, context, tree))
193
+ end
194
+
195
+ end
@@ -0,0 +1,17 @@
1
+ require 'test/unit'
2
+ require 'webgen/tree'
3
+ require 'webgen/contentprocessor'
4
+ require 'webgen/tag/metainfo'
5
+
6
+ class TestTagMetainfo < Test::Unit::TestCase
7
+
8
+ def test_call
9
+ @obj = Webgen::Tag::Metainfo.new
10
+ node = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'hallo.page', 'hallo.page', 'test' => 10, 'lang' => 'en')
11
+ c = Webgen::ContentProcessor::Context.new(:chain => [node])
12
+ assert_equal('', @obj.call('invalid', '', c))
13
+ assert_equal('10', @obj.call('test', '', c))
14
+ assert_equal('en', @obj.call('lang', '', c))
15
+ end
16
+
17
+ end
@@ -0,0 +1,57 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'webgen/tree'
4
+ require 'webgen/contentprocessor'
5
+ require 'webgen/tag/relocatable'
6
+
7
+ class TestTagRelocatable < Test::Unit::TestCase
8
+
9
+ include Test::WebsiteHelper
10
+
11
+ def setup
12
+ super
13
+ @obj = Webgen::Tag::Relocatable.new
14
+ end
15
+
16
+ def call(context)
17
+ @obj.call('relocatable', '', context)
18
+ end
19
+
20
+ def test_call
21
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
22
+ node = Webgen::Node.new(root, '/file.html', 'file.html', {'lang' => 'en'})
23
+ dir = Webgen::Node.new(root, '/dir/', 'dir/', 'index_path' => "index.html")
24
+ file = Webgen::Node.new(dir, '/dir/file.html', 'file.html', {'lang' => 'en'})
25
+ Webgen::Node.new(dir, '/dir/other.de.html', 'other.html', {'lang' => 'de'})
26
+ Webgen::Node.new(file, '/dir/file.html#fragment', '#fragment')
27
+ dir2 = Webgen::Node.new(root, '/dir2/', 'dir2/', 'index_path' => "index.html")
28
+ Webgen::Node.new(dir2, '/dir2/index.html', 'index.html')
29
+
30
+ context = Webgen::ContentProcessor::Context.new(:chain => [node])
31
+
32
+ # basic node resolving
33
+ @obj.set_params('tag.relocatable.path' => 'dir/file.html')
34
+ assert_equal('dir/file.html', call(context))
35
+ @obj.set_params('tag.relocatable.path' => 'dir/other.html')
36
+ assert_equal('', call(context))
37
+
38
+ # non-existing fragments
39
+ @obj.set_params('tag.relocatable.path' => 'file.html#hallo')
40
+ assert_equal('', call(context))
41
+
42
+ # absolute paths
43
+ @obj.set_params('tag.relocatable.path' => 'http://test.com')
44
+ assert_equal('http://test.com', call(context))
45
+
46
+ # directory paths
47
+ @obj.set_params('tag.relocatable.path' => 'dir')
48
+ assert_equal('dir/', call(context))
49
+ @obj.set_params('tag.relocatable.path' => 'dir2')
50
+ assert_equal('dir2/index.html', call(context))
51
+
52
+ # invalid paths
53
+ @obj.set_params('tag.relocatable.path' => ':/asdf=-)')
54
+ assert_equal('', call(context))
55
+ end
56
+
57
+ end
@@ -0,0 +1,44 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'webgen/tree'
4
+ require 'webgen/contentprocessor'
5
+ require 'webgen/tag'
6
+
7
+ class TestTagSitemap < Test::Unit::TestCase
8
+
9
+ include Test::WebsiteHelper
10
+
11
+ def setup
12
+ super
13
+ @obj = Webgen::Tag::Sitemap.new
14
+ end
15
+
16
+ def call(context, honor_in_menu, any_lang, used_kinds)
17
+ @obj.set_params({'common.sitemap.honor_in_menu' => honor_in_menu,
18
+ 'common.sitemap.any_lang' => any_lang,
19
+ 'common.sitemap.used_kinds' => used_kinds})
20
+ result = @obj.call('sitemap', '', context)
21
+ @obj.set_params({})
22
+ result
23
+ end
24
+
25
+ def test_call
26
+ nodes = create_sitemap_nodes
27
+ context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]])
28
+
29
+ assert_equal("<ul><li><a href=\"./\"></a>" +
30
+ "<ul><li><span></span>"+
31
+ "<ul><li><a href=\"#f1\"></a></li></ul></li></ul></li>" +
32
+ "<li><a href=\"../dir2/\"></a>" +
33
+ "<ul><li><a href=\"../dir2/file21.en.html\"></a></li></ul></li>"+
34
+ "<li><a href=\"../index.en.html\"></a></li></ul>",
35
+ call(context, false, false, []))
36
+ assert_equal("",
37
+ call(context, false, false, ['noone']))
38
+ end
39
+
40
+ def test_tag_config_base
41
+ assert_equal('common.sitemap', @obj.send(:tag_config_base))
42
+ end
43
+
44
+ end