webgen 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. data/ChangeLog +870 -0
  2. data/Rakefile +37 -36
  3. data/VERSION +1 -1
  4. data/data/webgen/resources.yaml +2 -2
  5. data/data/webgen/webgui/app.rb +11 -0
  6. data/data/webgen/webgui/controller/main.rb +30 -26
  7. data/data/webgen/webgui/{view/page.xhtml → layout/default.xhtml} +8 -8
  8. data/data/webgen/webgui/start.rb +9 -0
  9. data/data/webgen/webgui/view/create_website.xhtml +6 -14
  10. data/data/webgen/webgui/view/manage_website.xhtml +2 -2
  11. data/data/webgen/website_bundles/default/README +6 -0
  12. data/data/webgen/website_bundles/default/src/index.page +15 -0
  13. data/data/webgen/{website_styles → website_bundles/style}/1024px/README +0 -0
  14. data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.css +0 -0
  15. data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.template +0 -0
  16. data/data/webgen/{website_styles → website_bundles/style}/1024px/src/images/background.gif +0 -0
  17. data/data/webgen/{website_styles → website_bundles/style}/andreas00/README +0 -0
  18. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.css +0 -0
  19. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.template +0 -0
  20. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/bg.gif +0 -0
  21. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/front.jpg +0 -0
  22. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg.gif +0 -0
  23. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg2.gif +0 -0
  24. data/data/webgen/{website_styles → website_bundles/style}/andreas01/README +0 -0
  25. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.css +0 -0
  26. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.template +0 -0
  27. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/bg.gif +0 -0
  28. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/front.jpg +0 -0
  29. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/print.css +0 -0
  30. data/data/webgen/{website_styles → website_bundles/style}/andreas03/README +0 -0
  31. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.css +0 -0
  32. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.template +0 -0
  33. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/bodybg.png +0 -0
  34. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/contbg.png +0 -0
  35. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/footerbg.png +0 -0
  36. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient1.png +0 -0
  37. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient2.png +0 -0
  38. data/data/webgen/{website_styles → website_bundles/style}/andreas04/README +0 -0
  39. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.css +0 -0
  40. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.template +0 -0
  41. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/blinkarrow.gif +0 -0
  42. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/bodybg.png +0 -0
  43. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/contentbg.png +0 -0
  44. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/entrybg.png +0 -0
  45. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash.gif +0 -0
  46. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash2.gif +0 -0
  47. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globe.gif +0 -0
  48. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globebottom.gif +0 -0
  49. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/linkarrow.gif +0 -0
  50. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/menuhover.png +0 -0
  51. data/data/webgen/{website_styles → website_bundles/style}/andreas05/README +0 -0
  52. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.css +0 -0
  53. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.template +0 -0
  54. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/bodybg.gif +0 -0
  55. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/front.png +0 -0
  56. data/data/webgen/{website_styles → website_bundles/style}/andreas06/README +0 -0
  57. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.css +6 -4
  58. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.template +2 -2
  59. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/bodybg.gif +0 -0
  60. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/boxbg.gif +0 -0
  61. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/greypx.gif +0 -0
  62. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/header.jpg +0 -0
  63. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/innerbg.gif +0 -0
  64. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/leaves.jpg +0 -0
  65. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/tabs.gif +0 -0
  66. data/data/webgen/{website_styles → website_bundles/style}/andreas07/README +0 -0
  67. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/browserfix.css +0 -0
  68. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.css +0 -0
  69. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.template +0 -0
  70. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/bodybg.gif +0 -0
  71. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/sidebarbg.gif +0 -0
  72. data/data/webgen/{website_styles → website_bundles/style}/andreas08/README +0 -0
  73. data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.css +0 -0
  74. data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.template +0 -0
  75. data/data/webgen/{website_styles → website_bundles/style}/andreas09/README +0 -0
  76. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.css +0 -0
  77. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.template +0 -0
  78. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-black.jpg +0 -0
  79. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-green.jpg +0 -0
  80. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-orange.jpg +0 -0
  81. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-purple.jpg +0 -0
  82. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-red.jpg +0 -0
  83. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg.jpg +0 -0
  84. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/footerbg.jpg +0 -0
  85. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-black.jpg +0 -0
  86. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-green.jpg +0 -0
  87. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-orange.jpg +0 -0
  88. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-purple.jpg +0 -0
  89. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-red.jpg +0 -0
  90. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover.jpg +0 -0
  91. data/data/webgen/{website_styles → website_bundles/style}/simple/README +0 -0
  92. data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.css +0 -0
  93. data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.template +0 -0
  94. data/data/webgen/website_skeleton/README +1 -1
  95. data/data/webgen/website_skeleton/config.yaml +5 -4
  96. data/doc/contentprocessor/blocks.page +43 -10
  97. data/doc/contentprocessor/builder.page +1 -1
  98. data/doc/contentprocessor/erb.page +12 -11
  99. data/doc/contentprocessor/redcloth.page +3 -1
  100. data/doc/extensions.page +3 -3
  101. data/doc/faq.page +13 -10
  102. data/doc/getting_started.page +12 -15
  103. data/doc/index.page +7 -1
  104. data/doc/manual.page +78 -27
  105. data/doc/reference_configuration.page +166 -3
  106. data/doc/reference_website_styles.page +28 -0
  107. data/doc/source/filesystem.page +39 -0
  108. data/doc/source/tararchive.page +40 -0
  109. data/doc/tag/tikz.page +2 -1
  110. data/doc/webgen_page_format.page +13 -12
  111. data/doc/website_styles.metainfo +8 -0
  112. data/lib/webgen/blackboard.rb +2 -2
  113. data/lib/webgen/cache.rb +4 -4
  114. data/lib/webgen/cli.rb +29 -16
  115. data/lib/webgen/cli/apply_command.rb +66 -0
  116. data/lib/webgen/cli/create_command.rb +22 -16
  117. data/lib/webgen/cli/utils.rb +23 -0
  118. data/lib/webgen/cli/webgui_command.rb +31 -16
  119. data/lib/webgen/configuration.rb +8 -6
  120. data/lib/webgen/contentprocessor.rb +4 -5
  121. data/lib/webgen/contentprocessor/blocks.rb +2 -0
  122. data/lib/webgen/contentprocessor/builder.rb +6 -3
  123. data/lib/webgen/contentprocessor/erb.rb +6 -3
  124. data/lib/webgen/contentprocessor/erubis.rb +7 -6
  125. data/lib/webgen/contentprocessor/haml.rb +6 -3
  126. data/lib/webgen/contentprocessor/rdoc.rb +0 -1
  127. data/lib/webgen/contentprocessor/redcloth.rb +3 -1
  128. data/lib/webgen/context.rb +73 -0
  129. data/lib/webgen/context/nodes.rb +36 -0
  130. data/lib/webgen/coreext.rb +3 -2
  131. data/lib/webgen/default_config.rb +3 -1
  132. data/lib/webgen/deprecated.rb +53 -0
  133. data/lib/webgen/node.rb +24 -19
  134. data/lib/webgen/output.rb +50 -7
  135. data/lib/webgen/page.rb +45 -36
  136. data/lib/webgen/path.rb +1 -1
  137. data/lib/webgen/source.rb +32 -4
  138. data/lib/webgen/source/resource.rb +3 -3
  139. data/lib/webgen/source/stacked.rb +1 -1
  140. data/lib/webgen/source/tararchive.rb +73 -0
  141. data/lib/webgen/sourcehandler.rb +4 -4
  142. data/lib/webgen/sourcehandler/base.rb +36 -24
  143. data/lib/webgen/sourcehandler/copy.rb +1 -1
  144. data/lib/webgen/sourcehandler/feed.rb +2 -2
  145. data/lib/webgen/sourcehandler/fragment.rb +1 -1
  146. data/lib/webgen/sourcehandler/metainfo.rb +15 -6
  147. data/lib/webgen/sourcehandler/page.rb +9 -5
  148. data/lib/webgen/sourcehandler/virtual.rb +44 -7
  149. data/lib/webgen/tag/base.rb +19 -13
  150. data/lib/webgen/tag/link.rb +1 -0
  151. data/lib/webgen/version.rb +1 -1
  152. data/lib/webgen/webgentask.rb +15 -13
  153. data/lib/webgen/website.rb +42 -11
  154. data/lib/webgen/websiteaccess.rb +1 -1
  155. data/lib/webgen/websitemanager.rb +61 -66
  156. data/man/man1/webgen.1 +4 -0
  157. data/misc/default.css +13 -0
  158. data/misc/default.template +1 -1
  159. data/misc/htmldoc.metainfo +2 -1
  160. data/misc/style.page +33 -0
  161. data/test/test_cli.rb +1 -7
  162. data/test/test_common_sitemap.rb +2 -2
  163. data/test/test_contentprocessor_blocks.rb +14 -1
  164. data/test/test_contentprocessor_builder.rb +3 -1
  165. data/test/test_contentprocessor_erb.rb +3 -2
  166. data/test/test_contentprocessor_erubis.rb +3 -3
  167. data/test/test_contentprocessor_fragments.rb +3 -3
  168. data/test/test_contentprocessor_haml.rb +3 -2
  169. data/test/test_contentprocessor_maruku.rb +3 -3
  170. data/test/test_contentprocessor_rdiscount.rb +1 -1
  171. data/test/test_contentprocessor_rdoc.rb +1 -1
  172. data/test/test_contentprocessor_redcloth.rb +9 -2
  173. data/test/test_contentprocessor_sass.rb +1 -1
  174. data/test/test_contentprocessor_tags.rb +1 -1
  175. data/test/{test_contentprocessor_context.rb → test_context.rb} +9 -7
  176. data/test/test_node.rb +27 -21
  177. data/test/test_page.rb +4 -4
  178. data/test/test_source_tararchive.rb +65 -0
  179. data/test/test_sourcehandler_fragment.rb +1 -1
  180. data/test/test_sourcehandler_memory.rb +6 -6
  181. data/test/test_sourcehandler_metainfo.rb +34 -13
  182. data/test/test_sourcehandler_page.rb +8 -0
  183. data/test/test_sourcehandler_virtual.rb +51 -12
  184. data/test/test_tag_breadcrumbtrail.rb +4 -4
  185. data/test/test_tag_coderay.rb +1 -1
  186. data/test/test_tag_date.rb +1 -1
  187. data/test/test_tag_executecommand.rb +1 -1
  188. data/test/test_tag_includefile.rb +3 -3
  189. data/test/test_tag_langbar.rb +6 -6
  190. data/test/test_tag_link.rb +8 -2
  191. data/test/test_tag_menu.rb +9 -9
  192. data/test/test_tag_metainfo.rb +1 -1
  193. data/test/test_tag_relocatable.rb +1 -1
  194. data/test/test_tag_sitemap.rb +1 -1
  195. data/test/test_tag_tikz.rb +2 -2
  196. data/test/test_website.rb +17 -0
  197. data/test/test_websitemanager.rb +16 -21
  198. metadata +146 -187
  199. data/data/webgen/website_templates/default/README +0 -6
  200. data/data/webgen/website_templates/default/src/index.page +0 -8
  201. data/data/webgen/website_templates/project/README +0 -5
  202. data/data/webgen/website_templates/project/src/about.page +0 -12
  203. data/data/webgen/website_templates/project/src/download.page +0 -15
  204. data/data/webgen/website_templates/project/src/features.page +0 -8
  205. data/data/webgen/website_templates/project/src/index.page +0 -9
  206. data/data/webgen/website_templates/project/src/screenshots.page +0 -18
  207. data/lib/webgen/contentprocessor/context.rb +0 -89
@@ -60,6 +60,14 @@ class TestSourceHandlerPage < Test::Unit::TestCase
60
60
  @path.instance_eval { @io = Webgen::Path::SourceIO.new {StringIO.new("---\ntitle: test\n---\ncontent")} }
61
61
  @website.blackboard.dispatch_msg(:node_meta_info_changed?, node)
62
62
  assert(node.meta_info_changed?)
63
+
64
+ # Remove path from which node is created, meta info should naturally change
65
+ @root.tree.delete_node(node)
66
+ node = @obj.create_node(@root, @path)
67
+ @website.blackboard.del_service(:source_paths)
68
+ @website.blackboard.add_service(:source_paths) { {} }
69
+ @website.blackboard.dispatch_msg(:node_meta_info_changed?, node)
70
+ assert(node.meta_info_changed?)
63
71
  end
64
72
 
65
73
  end
@@ -27,32 +27,71 @@ class TestSourceHandlerVirtual < Test::Unit::TestCase
27
27
  title: Absolute
28
28
  EOF
29
29
 
30
- def test_create_node
31
- obj = Webgen::SourceHandler::Virtual.new
32
- root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
30
+ def setup
31
+ super
32
+ @obj = Webgen::SourceHandler::Virtual.new
33
+ @root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
33
34
  shm = Webgen::SourceHandler::Main.new # for using service :create_nodes
34
- time = Time.now
35
- nodes = obj.create_node(root, path_with_meta_info('/virtuals', {'modified_at' => time}, obj.class.name) {StringIO.new(CONTENT)})
35
+ @time = Time.now
36
+ @path = path_with_meta_info('/virtuals', {'modified_at' => @time}, @obj.class.name) {StringIO.new(CONTENT)}
37
+ @nodes = @obj.create_node(@root, @path)
38
+ @website.blackboard.del_service(:source_paths)
39
+ @website.blackboard.add_service(:source_paths) {{@path.path => @path}}
40
+ end
36
41
 
37
- nodes.each {|n| assert_equal('/virtuals', n.node_info[:src])}
42
+ def test_create_node
43
+ @nodes.each {|n| assert_equal('/virtuals', n.node_info[:src])}
38
44
 
39
- path_de = root.tree['/path.de.html']
40
- path_en = root.tree['/directory/path.en.html']
41
- dir = root.tree['/dir']
45
+ path_de = @root.tree['/path.de.html']
46
+ path_en = @root.tree['/directory/path.en.html']
47
+ dir = @root.tree['/dir']
42
48
  assert_not_nil(path_de)
43
49
  assert_not_nil(dir)
44
50
  assert_not_nil(path_en)
45
51
 
46
52
  assert_equal('new title', path_en['title'])
47
- assert_equal(time, path_en['modified_at'])
53
+ assert_equal(@time, path_en['modified_at'])
48
54
  assert(path_en['no_output'])
49
55
  assert_equal('My Dir', dir['title'])
50
56
  assert_equal('directory/other.html', path_de.route_to(path_en))
51
57
  assert_equal('../path.de.html', dir.route_to(path_de))
52
58
  assert_equal('../directory/other.html', dir.route_to(path_en))
53
59
 
54
- assert_equal('http://www.example.com', root.tree['/api.html'].path)
55
- assert_equal('http://www.example.com', root.tree['/path.de.html'].route_to(root.tree['/api.html']))
60
+ assert_equal('http://www.example.com', @root.tree['/api.html'].path)
61
+ assert_equal('http://www.example.com', @root.tree['/path.de.html'].route_to(@root.tree['/api.html']))
62
+ end
63
+
64
+ def test_meta_info_changed
65
+ # Nothing done, nothing should have changed
66
+ path_de = @root.tree['/path.de.html']
67
+ @obj.send(:node_meta_info_changed?, path_de)
68
+ assert(!path_de.flagged?(:dirty_meta_info))
69
+
70
+ # Change data, meta info should have changed
71
+ @path.instance_eval { @io = Webgen::Path::SourceIO.new {StringIO.new("path.de.html:\n title: hallo")} }
72
+ @obj.send(:node_meta_info_changed?, path_de)
73
+ assert(path_de.flagged?(:dirty_meta_info))
74
+
75
+ # Reinit node, meta info of path_de should not change, #create_node should only return one node
76
+ path_de.flag(:reinit)
77
+ assert(1, @obj.create_node(@root, @path).length)
78
+ @obj.send(:node_meta_info_changed?, path_de)
79
+ assert(!path_de.flagged?(:dirty_meta_info))
80
+
81
+ # Remove data, meta info should have changed
82
+ @path.instance_eval { @io = Webgen::Path::SourceIO.new {StringIO.new("patha.de.html:\n title: hallo")} }
83
+ @obj.send(:node_meta_info_changed?, path_de)
84
+ assert(path_de.flagged?(:dirty_meta_info))
85
+
86
+ # Remove path from which virtual node is created, meta info should naturally change
87
+ @root.tree.delete_node(path_de)
88
+ @path.instance_eval { @io = Webgen::Path::SourceIO.new {StringIO.new("path.de.html:\n title: hallo")} }
89
+ @obj.create_node(@root, @path)
90
+ path_de = @root.tree['/path.de.html']
91
+ @website.blackboard.del_service(:source_paths)
92
+ @website.blackboard.add_service(:source_paths) { {} }
93
+ @obj.send(:node_meta_info_changed?, path_de)
94
+ assert(path_de.meta_info_changed?)
56
95
  end
57
96
 
58
97
  end
@@ -40,7 +40,7 @@ class TestTagBreadcrumbTrail < Test::Unit::TestCase
40
40
 
41
41
  def test_call
42
42
  nodes = create_default_nodes
43
- context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]])
43
+ context = Webgen::Context.new(:chain => [nodes[:file11_en]])
44
44
 
45
45
  assert_equal('<a href="../../index.html"></a> / <a href="../">Dir1</a> / <a href="index.html">Dir11</a> / <span>File111</span>',
46
46
  call(context, ' / ', false, 0, -1))
@@ -76,16 +76,16 @@ class TestTagBreadcrumbTrail < Test::Unit::TestCase
76
76
 
77
77
  def test_node_changed
78
78
  nodes = create_default_nodes
79
- context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]])
79
+ context = Webgen::Context.new(:chain => [nodes[:file11_en]])
80
80
  call(context, ' / ', false, 0, -1)
81
81
 
82
82
  nodes[:file11_en].unflag(:dirty)
83
83
  @website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
84
- assert(!nodes[:file11_en].flagged(:dirty))
84
+ assert(!nodes[:file11_en].flagged?(:dirty))
85
85
 
86
86
  nodes[:index11_en].flag(:dirty_meta_info)
87
87
  @website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
88
- assert(nodes[:file11_en].flagged(:dirty))
88
+ assert(nodes[:file11_en].flagged?(:dirty))
89
89
  end
90
90
 
91
91
  end
@@ -23,7 +23,7 @@ class TestTagCoderay < Test::Unit::TestCase
23
23
 
24
24
  def test_call
25
25
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/', {'title' => 'Hallo'})
26
- context = Webgen::ContentProcessor::Context.new(:chain => [root])
26
+ context = Webgen::Context.new(:chain => [root])
27
27
 
28
28
  assert(call(context, 'TestData', 'html', false).include?('TestData'))
29
29
  assert(call(context, '{title:}', :ruby, true).include?('Hallo'))
@@ -12,7 +12,7 @@ class TestTagDate < Test::Unit::TestCase
12
12
 
13
13
  def test_call
14
14
  @obj = Webgen::Tag::Date.new
15
- assert_not_nil(Time.parse(@obj.call('date', '', Webgen::ContentProcessor::Context.new)))
15
+ assert_not_nil(Time.parse(@obj.call('date', '', Webgen::Context.new)))
16
16
  end
17
17
 
18
18
  end
@@ -24,7 +24,7 @@ class TestTagExecuteCommand < Test::Unit::TestCase
24
24
 
25
25
  def test_call
26
26
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
27
- context = Webgen::ContentProcessor::Context.new(:chain => [root])
27
+ context = Webgen::Context.new(:chain => [root])
28
28
 
29
29
  test_text = "a\"b\""
30
30
  assert_equal([test_text, false], call(context, echo_cmd(test_text), false, false))
@@ -26,7 +26,7 @@ class TestTagIncludeFile < Test::Unit::TestCase
26
26
 
27
27
  def test_call
28
28
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
29
- context = Webgen::ContentProcessor::Context.new(:chain => [root])
29
+ context = Webgen::Context.new(:chain => [root])
30
30
 
31
31
  content = "<a>This is 'a' Test</a>"
32
32
  file = Tempfile.new('webgen-test-file')
@@ -40,11 +40,11 @@ class TestTagIncludeFile < Test::Unit::TestCase
40
40
 
41
41
  root.unflag(:dirty)
42
42
  @website.blackboard.dispatch_msg(:node_changed?, root)
43
- assert(!root.flagged(:dirty))
43
+ assert(!root.flagged?(:dirty))
44
44
 
45
45
  File.utime(Time.now + 1, Time.now + 1, file.path)
46
46
  @website.blackboard.dispatch_msg(:node_changed?, root)
47
- assert(root.flagged(:dirty))
47
+ assert(root.flagged?(:dirty))
48
48
  end
49
49
 
50
50
  end
@@ -34,28 +34,28 @@ class TestTagLangbar < Test::Unit::TestCase
34
34
 
35
35
  @obj.set_params('tag.langbar.show_single_lang' => true, 'tag.langbar.show_own_lang' => true, 'tag.langbar.separator' => ' --- ')
36
36
  assert_equal(["#{de_link} --- #{en_link}", false],
37
- @obj.call('langbar', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index_en]])))
37
+ @obj.call('langbar', '', Webgen::Context.new(:chain => [nodes[:index_en]])))
38
38
 
39
39
  @obj.set_params('tag.langbar.show_single_lang' => true, 'tag.langbar.show_own_lang' => true,
40
40
  'tag.langbar.lang_names' => {'de' => 'Deutsch'})
41
41
  assert_equal(["<a href=\"index.de.html\">Deutsch</a> | #{en_link}", false],
42
- @obj.call('langbar', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index_en]])))
42
+ @obj.call('langbar', '', Webgen::Context.new(:chain => [nodes[:index_en]])))
43
43
 
44
44
  @obj.set_params('tag.langbar.show_single_lang' => true, 'tag.langbar.show_own_lang' => true,
45
45
  'tag.langbar.process_output' => true)
46
46
  assert_equal(["#{de_link} | #{en_link}", true],
47
- @obj.call('langbar', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index_en]])))
47
+ @obj.call('langbar', '', Webgen::Context.new(:chain => [nodes[:index_en]])))
48
48
 
49
49
  nodes[:index_en].unflag(:dirty)
50
50
  @website.blackboard.dispatch_msg(:node_changed?, nodes[:index_en])
51
- assert(!nodes[:index_en].flagged(:dirty))
51
+ assert(!nodes[:index_en].flagged?(:dirty))
52
52
  nodes[:index_en].tree.delete_node(nodes[:index_de])
53
53
  @website.blackboard.dispatch_msg(:node_changed?, nodes[:index_en])
54
- assert(nodes[:index_en].flagged(:dirty))
54
+ assert(nodes[:index_en].flagged?(:dirty))
55
55
  end
56
56
 
57
57
  def check_results(node, both_true, both_false, first_false, second_false)
58
- context = Webgen::ContentProcessor::Context.new(:chain => [node])
58
+ context = Webgen::Context.new(:chain => [node])
59
59
  @obj.set_params('tag.langbar.show_single_lang'=>true, 'tag.langbar.show_own_lang'=>true)
60
60
  assert_equal(both_true, @obj.call('langbar', '', context).first)
61
61
 
@@ -29,13 +29,13 @@ class TestTagLink < Test::Unit::TestCase
29
29
  dir2 = Webgen::Node.new(root, '/dir2/', 'dir2/', 'index_path' => "index.html")
30
30
  Webgen::Node.new(dir2, '/dir2/index.html', 'index.html')
31
31
 
32
- context = Webgen::ContentProcessor::Context.new(:chain => [node])
32
+ context = Webgen::Context.new(:chain => [node])
33
33
 
34
34
  # no path set
35
35
  node.unflag(:dirty)
36
36
  @obj.set_params('tag.link.path' => nil)
37
37
  assert_equal('', call(context))
38
- assert(node.flagged(:dirty))
38
+ assert(node.flagged?(:dirty))
39
39
 
40
40
  # invalid paths
41
41
  @obj.set_params('tag.link.path' => ':/asdf=-)')
@@ -58,6 +58,12 @@ class TestTagLink < Test::Unit::TestCase
58
58
  assert_equal('<a href="dir/"></a>', call(context))
59
59
  @obj.set_params('tag.link.path' => 'dir2')
60
60
  assert_equal('<a href="dir2/index.html"></a>', call(context))
61
+
62
+ # used node information correctly set
63
+ node.node_info[:used_meta_info_nodes] = Set.new
64
+ @obj.set_params('tag.link.path' => 'dir/file.html')
65
+ call(context)
66
+ assert(Set.new([file.absolute_lcn]), node.node_info[:used_meta_info_nodes])
61
67
  end
62
68
 
63
69
  end
@@ -52,14 +52,14 @@ class TestTagMenu < Test::Unit::TestCase
52
52
  def test_call
53
53
  nodes = create_default_nodes
54
54
 
55
- output = @obj.call('menu', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]]))
55
+ output = @obj.call('menu', '', Webgen::Context.new(:chain => [nodes[:file11_en]]))
56
56
  assert_equal("<ul><li class=\"webgen-menu-level1 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><a href=\"./\"></a>" +
57
57
  "<ul><li class=\"webgen-menu-level2 webgen-menu-submenu\"><a href=\"dir11/index.en.html\"></a></li>" +
58
58
  "<li class=\"webgen-menu-level2 webgen-menu-item-selected\"><span></span></li></ul></li>" +
59
59
  "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../dir2/\"></a></li>" +
60
60
  "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../dir3/\"></a></li></ul>", output)
61
61
 
62
- output = @obj.call('menu', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index11_en]]))
62
+ output = @obj.call('menu', '', Webgen::Context.new(:chain => [nodes[:index11_en]]))
63
63
  assert_equal("<ul><li class=\"webgen-menu-level1 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><a href=\"../\"></a>" +
64
64
  "<ul><li class=\"webgen-menu-level2 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><span></span>" +
65
65
  "<ul><li class=\"webgen-menu-level3\"><a href=\"file111.en.html\"></a></li>" +
@@ -69,7 +69,7 @@ class TestTagMenu < Test::Unit::TestCase
69
69
  "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../../dir3/\"></a></li></ul>", output)
70
70
 
71
71
  @obj.set_params('tag.menu.nested' => false)
72
- output = @obj.call('menu', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index11_en]]))
72
+ output = @obj.call('menu', '', Webgen::Context.new(:chain => [nodes[:index11_en]]))
73
73
  @obj.set_params({})
74
74
  assert_equal("<ul><li class=\"webgen-menu-level1 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><a href=\"../\"></a></li>" +
75
75
  "<li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"../../dir2/\"></a></li>" +
@@ -80,28 +80,28 @@ class TestTagMenu < Test::Unit::TestCase
80
80
  "<li class=\"webgen-menu-level3 webgen-menu-item-selected\"><span></span></li></ul>", output)
81
81
 
82
82
  @obj.set_params('tag.menu.used_nodes' => 'fragments')
83
- output = @obj.call('menu', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]]))
83
+ output = @obj.call('menu', '', Webgen::Context.new(:chain => [nodes[:file11_en]]))
84
84
  @obj.set_params({})
85
85
  assert_equal("<ul><li class=\"webgen-menu-level1 webgen-menu-submenu\"><a href=\"#f1\"></a></li>" +
86
86
  "<li class=\"webgen-menu-level1\"><a href=\"#f2\"></a></li></ul>", output)
87
87
 
88
88
  @obj.set_params('tag.menu.start_level' => 5)
89
- output = @obj.call('menu', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]]))
89
+ output = @obj.call('menu', '', Webgen::Context.new(:chain => [nodes[:file11_en]]))
90
90
  @obj.set_params({})
91
91
  assert_equal("", output)
92
92
 
93
93
  nodes.each {|k,v| v.unflag(:dirty)}
94
94
  @website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
95
- assert(!nodes[:file11_en].flagged(:dirty))
95
+ assert(!nodes[:file11_en].flagged?(:dirty))
96
96
 
97
97
  nodes[:index11_en].flag(:dirty_meta_info)
98
98
  @website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
99
- assert(nodes[:file11_en].flagged(:dirty))
99
+ assert(nodes[:file11_en].flagged?(:dirty))
100
100
 
101
101
  nodes.each {|k,v| v.unflag(:dirty)}
102
102
  nodes[:file11_en_f2]['in_menu'] = false
103
103
  @website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
104
- assert(nodes[:file11_en].flagged(:dirty))
104
+ assert(nodes[:file11_en].flagged?(:dirty))
105
105
  end
106
106
 
107
107
  def test_menu_tree_for_lang_and_create_menu_tree
@@ -191,7 +191,7 @@ class TestTagMenu < Test::Unit::TestCase
191
191
  def test_create_output_and_menu_item_details
192
192
  nodes = create_default_nodes
193
193
  tree = build_menu(nodes[:file111_en], [1, 2, 3, true])
194
- context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file111_en]])
194
+ context = Webgen::Context.new(:chain => [nodes[:file111_en]])
195
195
  assert_equal("<ul><li class=\"webgen-menu-level1 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><a href=\"../\"></a>" +
196
196
  "<ul><li class=\"webgen-menu-level2 webgen-menu-submenu webgen-menu-submenu-inhierarchy\"><a href=\"index.en.html\"></a>" +
197
197
  "<ul><li class=\"webgen-menu-level3 webgen-menu-item-selected\"><span></span></li>" +
@@ -10,7 +10,7 @@ class TestTagMetainfo < Test::Unit::TestCase
10
10
  def test_call
11
11
  @obj = Webgen::Tag::Metainfo.new
12
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])
13
+ c = Webgen::Context.new(:chain => [node])
14
14
  assert_equal('', @obj.call('invalid', '', c))
15
15
  assert_equal('10', @obj.call('test', '', c))
16
16
  assert_equal('en', @obj.call('lang', '', c))
@@ -29,7 +29,7 @@ class TestTagRelocatable < Test::Unit::TestCase
29
29
  dir2 = Webgen::Node.new(root, '/dir2/', 'dir2/', 'index_path' => "index.html")
30
30
  Webgen::Node.new(dir2, '/dir2/index.html', 'index.html')
31
31
 
32
- context = Webgen::ContentProcessor::Context.new(:chain => [node])
32
+ context = Webgen::Context.new(:chain => [node])
33
33
 
34
34
  # basic node resolving
35
35
  @obj.set_params('tag.relocatable.path' => 'dir/file.html')
@@ -26,7 +26,7 @@ class TestTagSitemap < Test::Unit::TestCase
26
26
 
27
27
  def test_call
28
28
  nodes = create_sitemap_nodes
29
- context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]])
29
+ context = Webgen::Context.new(:chain => [nodes[:file11_en]])
30
30
 
31
31
  assert_equal("<ul><li><a href=\"./\"></a>" +
32
32
  "<ul><li><span></span>"+
@@ -27,7 +27,7 @@ class TestTagTikZ < Test::Unit::TestCase
27
27
  def test_call
28
28
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
29
29
  node = Webgen::Node.new(root, '/file.html', 'file.page')
30
- context = Webgen::ContentProcessor::Context.new(:chain => [node])
30
+ context = Webgen::Context.new(:chain => [node])
31
31
 
32
32
  output = call(context, '\tikz \draw (0,0) -- (0,1);', 'test.png', [], '', '72 72', false, {})
33
33
  assert_equal('<img src="test.png" />', output)
@@ -56,7 +56,7 @@ class TestTagTikZ < Test::Unit::TestCase
56
56
 
57
57
  def test_run_command
58
58
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
59
- context = Webgen::ContentProcessor::Context.new(:chain => [root])
59
+ context = Webgen::Context.new(:chain => [root])
60
60
  assert_equal("hallo\n", @obj.send(:run_command, echo_cmd('hallo'), context))
61
61
  assert_nil(@obj.send(:run_command, 'unknown_command 2>&1', context))
62
62
  end
@@ -19,6 +19,15 @@ class TestWebsite < Test::Unit::TestCase
19
19
  assert_equal('dir', ws.directory)
20
20
  assert_throws(:called) { ws.init }
21
21
  assert_nil(Thread.current[:webgen_website])
22
+
23
+ ws = Webgen::Website.new
24
+ assert_equal(Dir.pwd, ws.directory)
25
+ ENV['WEBGEN_WEBSITE'] = 'hallo'
26
+ ws = Webgen::Website.new
27
+ assert_equal('hallo', ws.directory)
28
+ ENV['WEBGEN_WEBSITE'] = ''
29
+ ws = Webgen::Website.new
30
+ assert_equal(Dir.pwd, ws.directory)
22
31
  end
23
32
 
24
33
  def test_autoload_service
@@ -52,6 +61,14 @@ class TestWebsite < Test::Unit::TestCase
52
61
  ws = Webgen::Website.new('hallo')
53
62
  assert_nil(Webgen::WebsiteAccess.website)
54
63
  ws.execute_in_env { assert_not_nil(Webgen::WebsiteAccess.website) }
64
+ assert_nil(Webgen::WebsiteAccess.website)
65
+ ws.execute_in_env do
66
+ assert_equal(ws, Webgen::WebsiteAccess.website)
67
+ ws2 = Webgen::Website.new("hallo2")
68
+ ws2.execute_in_env { assert_equal(ws2, Webgen::WebsiteAccess.website) }
69
+ assert_equal(ws, Webgen::WebsiteAccess.website)
70
+ end
71
+ assert_equal(nil, Webgen::WebsiteAccess.website)
55
72
  end
56
73
 
57
74
  def test_read_config_file
@@ -10,12 +10,13 @@ class TestWebsiteManager < Test::Unit::TestCase
10
10
 
11
11
  def test_initialize
12
12
  wm = Webgen::WebsiteManager.new('.')
13
- t = wm.templates['default']
13
+ t = wm.bundles['default']
14
14
  assert_equal('Thomas Leitner', t.author)
15
15
  assert(t.paths.length > 0)
16
16
 
17
- s = wm.styles['1024px']
18
- assert(s.paths.length > 0)
17
+ ws = Webgen::Website.new('.')
18
+ wm = Webgen::WebsiteManager.new(ws)
19
+ assert_equal('Thomas Leitner', wm.bundles['default'].author)
19
20
  end
20
21
 
21
22
  def test_create_website
@@ -29,34 +30,28 @@ class TestWebsiteManager < Test::Unit::TestCase
29
30
  end
30
31
  end
31
32
 
32
- def test_apply_template
33
+ def test_apply_bundle
33
34
  with_tmpdir do |dir|
34
35
  wm = Webgen::WebsiteManager.new(dir)
35
- assert_raise(RuntimeError) { wm.apply_template('default') }
36
+ assert_raise(RuntimeError) { wm.apply_bundle('default') }
36
37
 
37
38
  Dir.mkdir(dir)
38
- wm.apply_template('default')
39
+ wm.apply_bundle('default')
39
40
  assert(File.directory?(File.join(dir, 'src')))
40
41
  assert(File.file?(File.join(dir, 'src', 'index.page')))
41
42
 
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') }
43
+ assert_raise(ArgumentError) { wm.apply_bundle('unknown-bundle') }
50
44
 
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
45
  FileUtils.rm_rf(dir)
46
+ wm.bundles.select {|n,i| n =~ /^style-/}.each do |name, infos|
47
+ Dir.mkdir(dir)
48
+ wm.apply_bundle(name)
49
+ assert(File.directory?(File.join(dir, 'src')))
50
+ assert(File.file?(File.join(dir, 'src', 'default.template')))
51
+ assert(File.file?(File.join(dir, 'src', 'default.css')))
52
+ FileUtils.rm_rf(dir)
53
+ end
58
54
  end
59
- assert_raise(ArgumentError) { wm.apply_style('unknown-style') }
60
55
  end
61
56
 
62
57
  def with_tmpdir