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,20 @@
1
+ require 'test/unit'
2
+ require 'webgen/tree'
3
+ require 'webgen/contentprocessor'
4
+
5
+ class TestContentProcessorHaml < Test::Unit::TestCase
6
+
7
+ def test_call
8
+ obj = Webgen::ContentProcessor::Haml.new
9
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
10
+ node = Webgen::Node.new(root, 'test', 'test')
11
+ context = Webgen::ContentProcessor::Context.new(:content => "#content\n %h1 Hallo\n = node.absolute_lcn",
12
+ :chain => [node])
13
+ obj.call(context)
14
+ assert_equal("<div id='content'>\n <h1>Hallo</h1>\n /test\n</div>\n", context.content)
15
+
16
+ context.content = "#cont\n = unknown"
17
+ assert_raise(RuntimeError) { obj.call(context) }
18
+ end
19
+
20
+ end
@@ -0,0 +1,27 @@
1
+ require 'test/unit'
2
+ require 'webgen/node'
3
+ require 'webgen/tree'
4
+ require 'webgen/contentprocessor'
5
+
6
+ class TestContentProcessorMaruku < Test::Unit::TestCase
7
+
8
+ def test_call
9
+ @obj = Webgen::ContentProcessor::Maruku.new
10
+ node = Webgen::Node.new(Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/'), 'test', 'test')
11
+ context = Webgen::ContentProcessor::Context.new(:content => '# header', :chain => [node])
12
+ assert_equal('<h1 id=\'header\'>header</h1>', @obj.call(context).content)
13
+
14
+ context.content = "# head*d* {#das .dsaf "
15
+ assert_raise(RuntimeError) { @obj.call(context)}
16
+ end
17
+
18
+ def test_call_fix_for_invalid_id
19
+ @obj = Webgen::ContentProcessor::Maruku.new
20
+ context = Webgen::ContentProcessor::Context.new(:content => '# `test`')
21
+ assert_equal('<h1 id=\'id1\'><code>test</code></h1>', @obj.call(context).content)
22
+
23
+ context = Webgen::ContentProcessor::Context.new(:content => '# `test`')
24
+ assert_equal('<h1 id=\'id1\'><code>test</code></h1>', @obj.call(context).content)
25
+ end
26
+
27
+ end
@@ -0,0 +1,15 @@
1
+ require 'test/unit'
2
+ require 'webgen/node'
3
+ require 'webgen/tree'
4
+ require 'webgen/contentprocessor'
5
+
6
+ class TestContentProcessorRDiscount < Test::Unit::TestCase
7
+
8
+ def test_call
9
+ @obj = Webgen::ContentProcessor::RDiscount.new
10
+ node = Webgen::Node.new(Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/'), 'test', 'test')
11
+ context = Webgen::ContentProcessor::Context.new(:content => '# header', :chain => [node])
12
+ assert_equal("<h1>header</h1>\n", @obj.call(context).content)
13
+ end
14
+
15
+ end
@@ -0,0 +1,16 @@
1
+ require 'test/unit'
2
+ require 'webgen/tree'
3
+ require 'webgen/contentprocessor'
4
+
5
+ class TestContentProcessorRDoc < Test::Unit::TestCase
6
+
7
+ def test_call
8
+ obj = Webgen::ContentProcessor::RDoc.new
9
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
10
+ node = Webgen::Node.new(root, 'test', 'test')
11
+ context = Webgen::ContentProcessor::Context.new(:content => "* hello",
12
+ :chain => [node])
13
+ assert_equal("<ul>\n<li>hello\n\n</li>\n</ul>\n", obj.call(context).content)
14
+ end
15
+
16
+ end
@@ -0,0 +1,12 @@
1
+ require 'test/unit'
2
+ require 'webgen/contentprocessor'
3
+
4
+ class TestContentProcessorRedCloth < Test::Unit::TestCase
5
+
6
+ def test_call
7
+ @obj = Webgen::ContentProcessor::RedCloth.new
8
+ context = Webgen::ContentProcessor::Context.new(:content => 'h1. header')
9
+ assert_equal('<h1>header</h1>', @obj.call(context).content)
10
+ end
11
+
12
+ end
@@ -0,0 +1,20 @@
1
+ require 'test/unit'
2
+ require 'webgen/tree'
3
+ require 'webgen/contentprocessor'
4
+
5
+ class TestContentProcessorSass < Test::Unit::TestCase
6
+
7
+ def test_call
8
+ obj = Webgen::ContentProcessor::Sass.new
9
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
10
+ node = Webgen::Node.new(root, 'test', 'test')
11
+ context = Webgen::ContentProcessor::Context.new(:content => "#main\n :background-color #000",
12
+ :chain => [node])
13
+ obj.call(context)
14
+ assert_equal("#main {\n background-color: #000; }\n", context.content)
15
+
16
+ context.content = "#cont \n = unknown"
17
+ assert_raise(RuntimeError) { obj.call(context) }
18
+ end
19
+
20
+ end
@@ -0,0 +1,97 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'webgen/tree'
4
+ require 'webgen/contentprocessor/tags'
5
+
6
+ class TestContentProcessorTags < Test::Unit::TestCase
7
+
8
+ include Test::WebsiteHelper
9
+
10
+ class TestTag
11
+
12
+ def set_params(*args); end
13
+
14
+ def create_tag_params(*args); end
15
+
16
+ def call(tag, body, context)
17
+ case tag
18
+ when 'body'
19
+ body
20
+ when 'bodyproc'
21
+ [body, true]
22
+ else
23
+ tag
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ def setup
30
+ super
31
+ @obj = Webgen::ContentProcessor::Tags.new
32
+ @website.config['contentprocessor.tags.map'].delete(:default)
33
+ end
34
+
35
+ def test_call
36
+ context = Webgen::ContentProcessor::Context.new(:chain => [Webgen::Tree.new.dummy_root])
37
+ context.content = "{test: }"
38
+ assert_equal('', @obj.call(context).content)
39
+
40
+ add_test_tag
41
+ assert_equal('test', @obj.call(context.clone(:content => "{test: }")).content)
42
+ assert_equal('thebody', @obj.call(context.clone(:content => "{body::}thebody{body}")).content)
43
+ assert_equal('test {other:}other test',
44
+ @obj.call(context.clone(:content => "test{bodyproc::} \\{other:}{other:} {bodyproc}test")).content)
45
+ end
46
+
47
+ def test_replace_tags
48
+ check_returned_tags('sdfsdf{asd', [])
49
+ check_returned_tags('sdfsdf}asd', [])
50
+ check_returned_tags('sdfsdf{asd}', [])
51
+ check_returned_tags('sdfsdf{asd: {}as', [])
52
+ check_returned_tags('sdfsdf{test: {test1: }}', [['test', ' {test1: }', '']], 'sdfsdftest1')
53
+ check_returned_tags('sdfsdf{test: {test1: {}}', [['test', '', '']], 'sdfsdf{test: {test1: {}}')
54
+ check_returned_tags('sdfsdf{test:}{test1: }', [['test', '', ''], ['test1', ' ', '']], 'sdfsdftest1test2')
55
+ check_returned_tags('sdfsdf{test:}\\{test1: }', [['test', '', '']], "sdfsdftest1{test1: }")
56
+ check_returned_tags('sdfsdf\\{test:}{test1:}', [['test1', '', '']], "sdfsdf{test:}test1")
57
+ check_returned_tags('sdfsdf{test: asdf}', [['test', ' asdf', '']], "sdfsdftest1")
58
+ check_returned_tags('sdfsdf\\{test: asdf}', [], "sdfsdf{test: asdf}")
59
+ check_returned_tags('sdfsdf\\\\{test: asdf}', [['test', ' asdf', '']], "sdfsdf\\test1")
60
+ check_returned_tags('sdfsdf\\\\\\{test: asdf}sdf', [['test', ' asdf', '']], "sdfsdf\\{test: asdf}sdf")
61
+
62
+ check_returned_tags('before{test::}body{test}', [['test', '', 'body']], "beforetest1")
63
+ check_returned_tags('before{test::}body{testno}', [], "before{test::}body{testno}")
64
+ check_returned_tags('before{test::}body\\{test}other{test}', [['test', '', 'body{test}other']], "beforetest1")
65
+ check_returned_tags('before{test::}body\\{test}{test}', [['test', '', 'body{test}']], "beforetest1")
66
+ check_returned_tags('before{test::}body\\{test}\\\\{test}after', [['test', '', 'body{test}\\']], "beforetest1after")
67
+ check_returned_tags('before\\{test::}body{test}', [['test', '', 'body']], "before{test::}body{test}")
68
+ check_returned_tags('before\\\\{test:: asdf}body{test}after', [['test', ' asdf', 'body']], "before\\test1after")
69
+ end
70
+
71
+ def test_processor_for_tag
72
+ assert_nil(@obj.instance_eval { processor_for_tag('test') })
73
+ assert_nil(@obj.instance_eval { processor_for_tag(:default) })
74
+ add_test_tag
75
+ assert_not_nil(@obj.instance_eval { processor_for_tag(:default) })
76
+ end
77
+
78
+ private
79
+
80
+ def add_test_tag
81
+ @website.config['contentprocessor.tags.map'].update(:default => 'TestContentProcessorTags::TestTag')
82
+ end
83
+
84
+ def check_returned_tags(content, data, result = content)
85
+ i = 0
86
+ check_proc = proc do |tag, params, body|
87
+ assert_equal(data[i][0], tag, 'tag: ' + content)
88
+ assert_equal(data[i][1], params, 'params: ' + content)
89
+ assert_equal(data[i][2], body, 'body: ' + content)
90
+ i += 1
91
+ 'test' + i.to_s
92
+ end
93
+ assert_equal(result, @obj.instance_eval { replace_tags(content, Webgen::Tree.new.dummy_root, &check_proc) })
94
+ assert(i, data.length)
95
+ end
96
+
97
+ end
@@ -0,0 +1,53 @@
1
+ require 'test/unit'
2
+ require 'webgen/languages'
3
+
4
+ class TestLanguages < Test::Unit::TestCase
5
+
6
+ def test_get_language
7
+ assert_nil(Webgen::LanguageManager.language_for_code(nil))
8
+
9
+ lang1 = Webgen::LanguageManager.language_for_code('ger')
10
+ lang2 = Webgen::LanguageManager.language_for_code('deu')
11
+ lang3 = Webgen::LanguageManager.language_for_code('de')
12
+ lang4 = Webgen::LanguageManager.language_for_code('en')
13
+
14
+ [lang1, lang2, lang3, lang4].each {|lang| assert_kind_of(Webgen::Language, lang)}
15
+ assert_equal(lang1, lang2)
16
+ assert_equal(lang3, lang2)
17
+ assert_not_equal(lang4, lang2)
18
+ end
19
+
20
+ def test_find_language
21
+ langs = Webgen::LanguageManager.find_language('greek')
22
+ assert_equal(2, langs.length)
23
+ assert_equal('gre', langs[0].code3chars)
24
+ assert_equal('grc', langs[1].code3chars)
25
+ end
26
+
27
+ def test_language_accessors
28
+ lang = Webgen::LanguageManager.language_for_code('ger')
29
+ assert_equal('ger', lang.code3chars)
30
+ assert_equal('deu', lang.code3chars_alternative)
31
+ assert_equal('de', lang.code2chars)
32
+ end
33
+
34
+ def test_other_methods
35
+ de = Webgen::LanguageManager.language_for_code('ger')
36
+ assert_equal('de', de)
37
+ assert_equal(de, 'de')
38
+ assert_equal("de", de.to_s)
39
+ assert_equal("Implicitly de", "Implicitly " + de)
40
+ assert_kind_of(String, de.inspect)
41
+ end
42
+
43
+ def test_sort_method
44
+ ger = Webgen::LanguageManager.language_for_code('ger')
45
+ eng = Webgen::LanguageManager.language_for_code('en')
46
+ ace = Webgen::LanguageManager.language_for_code('ace')
47
+
48
+ assert_equal(-1, ger <=> eng)
49
+ assert_equal(-1, ace <=> ger)
50
+ assert_equal(-1, ace <=> eng)
51
+ end
52
+
53
+ end
@@ -0,0 +1,30 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'webgen/loggable'
4
+ require 'webgen/logger'
5
+ require 'stringio'
6
+
7
+ class TestLoggable < Test::Unit::TestCase
8
+
9
+ include Test::WebsiteHelper
10
+
11
+ def setup
12
+ super
13
+ @website.logger = Webgen::Logger.new(@io = StringIO.new, true)
14
+ @obj = Object.new
15
+ @obj.extend(Webgen::Loggable)
16
+ end
17
+
18
+ def test_log
19
+ @obj.log(:error) { 'hallo' }
20
+ assert_equal("ERROR -- hallo\n", @io.string)
21
+ end
22
+
23
+ def test_puts
24
+ @obj.puts 'test'
25
+ assert_equal("test\n", @io.string)
26
+ @obj.puts 'test', :verbose
27
+ assert_equal("test\n", @io.string)
28
+ end
29
+
30
+ end
@@ -0,0 +1,73 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'webgen/logger'
4
+
5
+ class TestLogger < Test::Unit::TestCase
6
+
7
+ def test_initialize
8
+ l = Webgen::Logger.new(io = StringIO.new)
9
+ assert_equal(:normal, l.verbosity)
10
+ assert_equal(::Logger::WARN, l.level)
11
+ assert_equal(false, l.sync)
12
+ end
13
+
14
+ def test_setters
15
+ l = Webgen::Logger.new(io = StringIO.new)
16
+ l.verbosity = :quiet
17
+ l.level = ::Logger::DEBUG
18
+ assert_equal(::Logger::DEBUG, l.level)
19
+ assert_equal(:quiet, l.verbosity)
20
+ end
21
+
22
+ def test_log_sync
23
+ l = Webgen::Logger.new(io = StringIO.new, true)
24
+ l.error { 'error' }
25
+ l.stdout { 'hallo' }
26
+ l.warn { 'warn' }
27
+ l.info { 'info' }
28
+ l.debug { 'debug' }
29
+ assert_equal("ERROR -- error\nhallo\n WARN -- warn\n", io.string)
30
+ end
31
+
32
+ def test_log_async
33
+ l = Webgen::Logger.new(io = StringIO.new, false)
34
+ l.error { 'error' }
35
+ l.stdout { 'hallo' }
36
+ assert_equal("hallo\n", io.string)
37
+ end
38
+
39
+ def test_verbosity_levels
40
+ l = Webgen::Logger.new(io = StringIO.new)
41
+ l.verbose { 'vrb'}
42
+ l.stdout { 'std' }
43
+ assert_equal("std\n", io.string)
44
+
45
+ io.string = ''
46
+ l.verbosity = :verbose
47
+ l.verbose { 'vrb' }
48
+ assert_equal("vrb\n", io.string)
49
+
50
+ io.string = ''
51
+ l.verbosity = :quiet
52
+ l.stdout { 'vrb' }
53
+ assert_equal("", io.string)
54
+ end
55
+
56
+ def test_debug_format
57
+ l = Webgen::Logger.new(io = StringIO.new, true)
58
+ l.level = ::Logger::DEBUG
59
+ l.info('source') { 'hallo' }
60
+ assert_equal(" INFO -- source: hallo\n", io.string)
61
+ end
62
+
63
+ def test_log_output
64
+ l = Webgen::Logger.new(io = StringIO.new, true)
65
+ l.error { 'hallo' }
66
+ assert_equal('', l.log_output)
67
+
68
+ l = Webgen::Logger.new(io = StringIO.new, false)
69
+ l.error { 'hallo' }
70
+ assert_equal("ERROR -- hallo\n", l.log_output)
71
+ end
72
+
73
+ end
data/test/test_node.rb ADDED
@@ -0,0 +1,339 @@
1
+ require 'test/unit'
2
+ require 'helper'
3
+ require 'webgen/node'
4
+ require 'webgen/tree'
5
+
6
+ class TestNode < Test::Unit::TestCase
7
+
8
+ include Test::WebsiteHelper
9
+
10
+ def setup
11
+ super
12
+ @tree = Webgen::Tree.new
13
+ end
14
+
15
+ def create_default_nodes
16
+ {
17
+ :root => node = Webgen::Node.new(@tree.dummy_root, '/', '/'),
18
+ :somename_en => child_en = Webgen::Node.new(node, '/somename.en.html', 'somename.page', {'lang' => 'en', 'title' => 'somename'}),
19
+ :somename_de => child_de = Webgen::Node.new(node, '/somename.de.html', 'somename.page', {'lang' => 'de'}),
20
+ :other => Webgen::Node.new(node, '/other.html', 'other.page', {}),
21
+ :other_en => Webgen::Node.new(node, '/other1.html', 'other.page', {'lang' => 'en'}),
22
+ :somename_en_frag => frag_en = Webgen::Node.new(child_en, '/somename.en.html#frag', '#othertest', {'title' => 'frag'}),
23
+ :somename_de_frag => Webgen::Node.new(child_de, '/somename.de.html#frag', '#othertest'),
24
+ :somename_en_fragnest => Webgen::Node.new(frag_en, '/somename.en.html#fragnest', '#nestedpath'),
25
+ :dir => dir = Webgen::Node.new(node, '/dir/', 'dir/'),
26
+ :dir_file => dir_file = Webgen::Node.new(dir, '/dir/file.html', 'file.html'),
27
+ :dir_file_frag => Webgen::Node.new(dir_file, '/dir/file.html#frag', '#frag'),
28
+ :dir2 => dir2 = Webgen::Node.new(node, '/dir2/', 'dir2/', {'index_path' => 'index.html', 'title' => 'dir2'}),
29
+ :dir2_index_en => Webgen::Node.new(dir2, '/dir2/index.html', 'index.html', {'lang' => 'en', 'routed_title' => 'routed', 'title' => 'index'}),
30
+ :dir2_index_de => Webgen::Node.new(dir2, '/dir2/index.de.html', 'index.html', {'lang' => 'de', 'routed_title' => 'routed_de', 'title' => 'index'}),
31
+ }
32
+ end
33
+
34
+ def test_initialize
35
+ check_proc = proc do |node, parent, path, cn, lcn, alcn, lang, mi|
36
+ assert_equal(parent, node.parent)
37
+ assert_equal(path, node.path)
38
+ assert_equal(cn, node.cn)
39
+ assert_equal(lcn, node.lcn)
40
+ assert_equal(alcn, node.absolute_lcn)
41
+ assert_equal(lang, node.lang)
42
+ assert(node.dirty)
43
+ assert(node.created)
44
+ assert_equal(mi, node.meta_info)
45
+ assert_equal({:used_nodes => Set.new, :used_meta_info_nodes => Set.new}, node.node_info)
46
+ mi.each {|k,v| assert_equal(v, node[k])}
47
+ end
48
+
49
+ node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
50
+ check_proc.call(node, @tree.dummy_root, 'test/', 'test', 'test', '/test', nil, {:test => :value})
51
+
52
+ child = Webgen::Node.new(node, 'somename.html', 'somename.page', {'lang' => 'de'})
53
+ check_proc.call(child, node, 'somename.html', 'somename.page', 'somename.de.page',
54
+ '/test/somename.de.page', 'de', {})
55
+
56
+ ['http://webgen.rubyforge.org', 'c:\\test'].each_with_index do |abspath, index|
57
+ cn = 'test' + index.to_s + '.html'
58
+ child = Webgen::Node.new(node, abspath, cn)
59
+ check_proc.call(child, node, abspath, cn, cn, '/test/' + cn, nil, {})
60
+ end
61
+ end
62
+
63
+ def test_type_checkers
64
+ nodes = create_default_nodes
65
+ assert(nodes[:root].is_directory?)
66
+ assert(nodes[:somename_en].is_file?)
67
+ assert(nodes[:somename_en_frag].is_fragment?)
68
+ assert(nodes[:root].is_root?)
69
+ assert(!nodes[:somename_en].is_root?)
70
+ end
71
+
72
+ def test_meta_info_assignment
73
+ node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
74
+ node[:test] = :newvalue
75
+ node[:other] = :value
76
+ assert_equal(:newvalue, node[:test])
77
+ assert_equal(:value, node[:other])
78
+ end
79
+
80
+ def test_in_lang
81
+ nodes = create_default_nodes
82
+
83
+ assert_equal(nodes[:somename_de], nodes[:somename_en].in_lang('de'))
84
+ assert_equal(nodes[:somename_en], nodes[:somename_en].in_lang('en'))
85
+ assert_equal(nodes[:somename_en], nodes[:somename_de].in_lang('en'))
86
+ assert_equal(nil, nodes[:somename_de].in_lang('fr'))
87
+ assert_equal(nil, nodes[:somename_en].in_lang(nil))
88
+
89
+ assert_equal(nodes[:other_en], nodes[:other].in_lang('en'))
90
+ assert_equal(nodes[:other], nodes[:other].in_lang('de'))
91
+ assert_equal(nodes[:other], nodes[:other].in_lang(nil))
92
+ assert_equal(nodes[:other], nodes[:other_en].in_lang(nil))
93
+ assert_equal(nodes[:other], nodes[:other_en].in_lang('de'))
94
+
95
+ assert_equal(nil, nodes[:somename_en_frag].in_lang(nil))
96
+ assert_equal(nodes[:somename_en_frag], nodes[:somename_en_frag].in_lang('en'))
97
+ assert_equal(nodes[:somename_de_frag], nodes[:somename_en_frag].in_lang('de'))
98
+ end
99
+
100
+ def test_resolve
101
+ nodes = create_default_nodes
102
+
103
+ [nodes[:root], nodes[:somename_de], nodes[:somename_en], nodes[:other]].each do |n|
104
+ assert_equal(nil, n.resolve('somename.page', nil))
105
+ assert_equal(nodes[:somename_en], n.resolve('somename.page', 'en'))
106
+ assert_equal(nodes[:somename_de], n.resolve('somename.page', 'de'))
107
+ assert_equal(nil, n.resolve('somename.page', 'fr'))
108
+ assert_equal(nodes[:somename_en], n.resolve('somename.en.page', nil))
109
+ assert_equal(nodes[:somename_en], n.resolve('somename.en.page', 'en'))
110
+ assert_equal(nodes[:somename_en], n.resolve('somename.en.page', 'de'))
111
+ assert_equal(nil, n.resolve('somename.fr.page', 'de'))
112
+
113
+ assert_equal(nodes[:other], n.resolve('other.page', nil))
114
+ assert_equal(nodes[:other], n.resolve('other.page', 'fr'))
115
+ assert_equal(nodes[:other_en], n.resolve('other.page', 'en'))
116
+ assert_equal(nodes[:other_en], n.resolve('other.en.page', nil))
117
+ assert_equal(nodes[:other_en], n.resolve('other.en.page', 'de'))
118
+ assert_equal(nil, n.resolve('other.fr.page', nil))
119
+ assert_equal(nil, n.resolve('other.fr.page', 'en'))
120
+ end
121
+
122
+ assert_equal(nodes[:somename_en_frag], nodes[:somename_en].resolve('#othertest', 'de'))
123
+ assert_equal(nodes[:somename_en_frag], nodes[:somename_en].resolve('#othertest', nil))
124
+ assert_equal(nodes[:somename_en_fragnest], nodes[:somename_en].resolve('#nestedpath', nil))
125
+
126
+ assert_equal(nil, nodes[:root].resolve('/somename.page#othertest', nil))
127
+ assert_equal(nodes[:somename_en_frag], nodes[:root].resolve('/somename.page#othertest', 'en'))
128
+ assert_equal(nodes[:somename_de_frag], nodes[:root].resolve('/somename.page#othertest', 'de'))
129
+ assert_equal(nodes[:somename_en_frag], nodes[:root].resolve('/somename.en.page#othertest'))
130
+ assert_equal(nodes[:somename_de_frag], nodes[:root].resolve('/somename.de.page#othertest'))
131
+
132
+ assert_equal(nil, nodes[:dir2].resolve('index.html'))
133
+ assert_equal(nodes[:dir2_index_en], nodes[:dir2].resolve('index.html', 'en'))
134
+
135
+ assert_equal(nodes[:dir], nodes[:somename_en].resolve('/dir/'))
136
+ assert_equal(nodes[:root], nodes[:somename_en].resolve('/'))
137
+ end
138
+
139
+ def test_introspection
140
+ node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
141
+ assert(node.inspect =~ /alcn=\/test/)
142
+ end
143
+
144
+ def test_changed
145
+ node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
146
+ node.dirty = node.created = false
147
+
148
+ calls = 0
149
+ @website.blackboard.add_listener(:node_changed?) {|n| assert(node, n); node.dirty = true; calls += 1}
150
+ node.changed?
151
+ assert_equal(1, calls)
152
+ node.changed?
153
+ assert_equal(1, calls)
154
+
155
+ node.dirty = false
156
+ node.node_info[:used_nodes] << node.absolute_lcn
157
+ node.node_info[:used_nodes] << 'unknown alcn'
158
+ node.node_info[:used_nodes] << @tree.dummy_root.absolute_lcn
159
+ node.changed?
160
+ assert_equal(1, calls)
161
+
162
+ # Test circular depdendence
163
+ other_node = Webgen::Node.new(@tree.dummy_root, '/other', 'test.l', {'lang' => 'de', :test => :value})
164
+ other_node.dirty = node.created = false
165
+ node.dirty = false
166
+ other_node.node_info[:used_nodes] = [node.absolute_lcn]
167
+ node.node_info[:used_nodes] = [other_node.absolute_lcn]
168
+ node.changed?
169
+ end
170
+
171
+ def test_meta_info_changed
172
+ node = Webgen::Node.new(@tree.dummy_root, '/', '/')
173
+ node.dirty = node.created = false
174
+
175
+ calls = 0
176
+ @website.blackboard.add_listener(:node_meta_info_changed?) {|n| assert(node, n); node.dirty_meta_info = true; calls += 1}
177
+ assert(node.meta_info_changed?)
178
+ assert_equal(1, calls)
179
+ assert(node.meta_info_changed?)
180
+ assert_equal(1, calls)
181
+
182
+ node.dirty_meta_info = false
183
+ node.node_info[:used_meta_info_nodes] << node.absolute_lcn
184
+ node.node_info[:used_meta_info_nodes] << 'unknown alcn'
185
+ node.node_info[:used_meta_info_nodes] << @tree.dummy_root.absolute_lcn
186
+ assert(node.meta_info_changed?)
187
+ assert_equal(2, calls)
188
+ end
189
+
190
+ def test_method_missing
191
+ node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
192
+ assert_raise(NoMethodError) { node.unknown }
193
+ obj = @website.cache.instance('Object')
194
+ def obj.doit(node); :value; end
195
+ node.node_info[:processor] = 'Object'
196
+ assert_equal(:value, node.doit)
197
+ end
198
+
199
+ def test_matching
200
+ root = Webgen::Node.new(@tree.dummy_root, '/', '/')
201
+ node = Webgen::Node.new(root, 'somefile.de.html', 'somefile.html', {'lang' => 'de'})
202
+ assert(node =~ '**/*')
203
+ assert(node =~ '**/somefile.de.HTML')
204
+ assert(node =~ '/**/somefile.*.html')
205
+ assert(node !~ '/somefile.html')
206
+ assert(node !~ '**/*.test')
207
+ end
208
+
209
+ def test_absolute_name
210
+ root = Webgen::Node.new(@tree.dummy_root, '/', '/')
211
+ node = Webgen::Node.new(root, 'somepath', 'somefile.html', {'lang' => 'de'})
212
+ assert_equal('/somefile.de.html', node.absolute_lcn)
213
+ end
214
+
215
+ def test_route_to
216
+ nodes = create_default_nodes
217
+
218
+ #arg is Node
219
+ assert_equal('somename.en.html', nodes[:somename_en].route_to(nodes[:somename_en]))
220
+ assert_equal('somename.de.html', nodes[:somename_en_frag].route_to(nodes[:somename_de]))
221
+ assert_equal('file.html#frag', nodes[:dir].route_to(nodes[:dir_file_frag]))
222
+ assert_equal('#frag', nodes[:dir_file].route_to(nodes[:dir_file_frag]))
223
+ assert_equal('../dir2/index.html', nodes[:dir_file_frag].route_to(nodes[:dir2_index_en]))
224
+ assert_equal('../dir2/index.html', nodes[:dir_file].route_to(nodes[:dir2_index_en]))
225
+
226
+ assert_equal('./', nodes[:somename_en].route_to(nodes[:root]))
227
+ assert_equal('../', nodes[:dir].route_to(nodes[:root]))
228
+ assert_equal('dir/', nodes[:somename_en].route_to(nodes[:dir]))
229
+
230
+ #arg is String
231
+ assert_equal('somename.en.html', nodes[:somename_en].route_to('somename.en.html'))
232
+ assert_equal('../other.html', nodes[:dir_file].route_to('/other.html'))
233
+ assert_equal('../other', nodes[:dir_file].route_to('../other'))
234
+ assert_equal('document/file2', nodes[:dir_file_frag].route_to('document/file2'))
235
+ assert_equal('ftp://test', nodes[:dir].route_to('ftp://test'))
236
+
237
+ #test args with '..' and '.': either too many of them or absolute path given
238
+ assert_equal('../dir2', nodes[:dir_file].route_to('../../.././dir2'))
239
+ assert_equal('../file', nodes[:dir_file].route_to('/dir/../file'))
240
+ assert_equal('file', nodes[:dir_file].route_to('dir/../file'))
241
+
242
+ #arg is something else
243
+ assert_raise(ArgumentError) { nodes[:root].route_to(5) }
244
+ end
245
+
246
+ def test_routing_node
247
+ nodes = create_default_nodes
248
+
249
+ assert_equal(nodes[:somename_en], nodes[:somename_en].routing_node('en'))
250
+
251
+ assert_equal(nodes[:dir], nodes[:dir].routing_node('en'))
252
+ assert_equal(nodes[:dir2_index_en], nodes[:dir2].routing_node('en'))
253
+ assert_equal(nodes[:dir2_index_en], nodes[:dir2].routing_node('en'))
254
+ @website.cache.volatile.clear
255
+ nodes[:dir2].meta_info['index_path'] = 'unknown'
256
+ assert_equal(nodes[:dir2], nodes[:dir2].routing_node('en'))
257
+ end
258
+
259
+ def test_comparision_op
260
+ nodes = create_default_nodes
261
+ nodes[:somename_en]['title'] = 'somename'
262
+ nodes[:other_en]['title'] = 'other'
263
+
264
+ assert_equal(0, nodes[:somename_en] <=> nodes[:somename_en])
265
+ assert_equal(1, nodes[:somename_en] <=> nodes[:other_en])
266
+ assert_equal(-1, nodes[:other_en] <=> nodes[:somename_en])
267
+ nodes[:other_en]['sort_info'] = 1
268
+ assert_equal(1, nodes[:somename_en] <=> nodes[:other_en])
269
+ nodes[:other_en]['sort_info'] = '2008-06-28'
270
+ nodes[:somename_en]['sort_info'] = '2008-06-29'
271
+ assert_equal(1, nodes[:somename_en] <=> nodes[:other_en])
272
+ end
273
+
274
+ def test_level
275
+ nodes = create_default_nodes
276
+ assert_equal(0, nodes[:root].level)
277
+ assert_equal(1, nodes[:dir].level)
278
+ assert_equal(2, nodes[:dir_file].level)
279
+ assert_equal(3, nodes[:dir_file_frag].level)
280
+ end
281
+
282
+ def test_in_subtree_of
283
+ nodes = create_default_nodes
284
+
285
+ assert(nodes[:somename_en].in_subtree_of?(nodes[:root]))
286
+ assert(nodes[:dir].in_subtree_of?(nodes[:root]))
287
+
288
+ assert(nodes[:dir_file].in_subtree_of?(nodes[:dir]))
289
+
290
+ assert(nodes[:dir_file_frag].in_subtree_of?(nodes[:root]))
291
+ assert(nodes[:dir_file_frag].in_subtree_of?(nodes[:dir]))
292
+ assert(nodes[:dir_file_frag].in_subtree_of?(nodes[:dir_file]))
293
+
294
+ assert(!nodes[:dir2_index_en].in_subtree_of?(nodes[:dir]))
295
+ assert(!nodes[:somename_en].in_subtree_of?(nodes[:dir]))
296
+ assert(!nodes[:somename_en].in_subtree_of?(nodes[:dir_file]))
297
+ assert(!nodes[:dir_file].in_subtree_of?(nodes[:dir2_index_en]))
298
+ end
299
+
300
+ def test_link_to
301
+ nodes = create_default_nodes
302
+
303
+ # general tests
304
+ assert_equal('<a href="#frag">frag</a>',
305
+ nodes[:somename_en].link_to(nodes[:somename_en_frag]))
306
+ assert_equal('<a href="#frag">link_text</a>',
307
+ nodes[:somename_en].link_to(nodes[:somename_en_frag], :link_text => 'link_text'))
308
+ assert_equal('<a attr1="val1" href="#frag">frag</a>',
309
+ nodes[:somename_en].link_to(nodes[:somename_en_frag], 'attr1' => 'val1'))
310
+ assert_equal('<a href="#frag">frag</a>',
311
+ nodes[:somename_en].link_to(nodes[:somename_en_frag], :attr1 => 'val1'))
312
+ assert_equal('<a href="dir2/index.html">index</a>',
313
+ nodes[:somename_en].link_to(nodes[:dir2_index_en]))
314
+
315
+ nodes[:somename_en_frag]['link_attrs'] = {:link_text => 'Default Text', 'class'=>'help'}
316
+ assert_equal('<a attr1="val1" class="help" href="#frag">link_text</a>',
317
+ nodes[:somename_en].link_to(nodes[:somename_en_frag], :link_text => 'link_text', 'attr1' => 'val1'))
318
+
319
+ # links to directories
320
+ assert_equal('<a href="dir2/index.de.html">routed_de</a>',
321
+ nodes[:somename_de].link_to(nodes[:dir2]))
322
+ assert_equal('<a href="dir2/index.html">routed</a>',
323
+ nodes[:somename_en].link_to(nodes[:dir2]))
324
+ assert_equal('<a href="dir2/index.de.html">routed_de</a>',
325
+ nodes[:somename_en].link_to(nodes[:dir2], :lang => 'de'))
326
+ assert_equal('<span>routed</span>',
327
+ nodes[:dir2_index_en].link_to(nodes[:dir2]))
328
+
329
+ # varying the website.link_to_current_page option
330
+ @website.config['website.link_to_current_page'] = true
331
+ assert_equal('<a class="help" href="#frag">Default Text</a>',
332
+ nodes[:somename_en_frag].link_to(nodes[:somename_en_frag]))
333
+ @website.config['website.link_to_current_page'] = false
334
+ assert_equal('<span class="help">Default Text</span>',
335
+ nodes[:somename_en_frag].link_to(nodes[:somename_en_frag]))
336
+ end
337
+
338
+
339
+ end