gettalong-webgen 0.5.7.20090227 → 0.5.8.20090507

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. data/Rakefile +37 -36
  2. data/data/webgen/resources.yaml +2 -2
  3. data/data/webgen/webgui/app.rb +11 -0
  4. data/data/webgen/webgui/controller/main.rb +30 -26
  5. data/data/webgen/webgui/{view/page.xhtml → layout/default.xhtml} +8 -8
  6. data/data/webgen/webgui/start.rb +9 -0
  7. data/data/webgen/webgui/view/create_website.xhtml +6 -14
  8. data/data/webgen/webgui/view/manage_website.xhtml +2 -2
  9. data/data/webgen/website_bundles/default/README +6 -0
  10. data/data/webgen/website_bundles/default/src/index.page +15 -0
  11. data/data/webgen/{website_styles → website_bundles/style}/1024px/README +0 -0
  12. data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.css +0 -0
  13. data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.template +0 -0
  14. data/data/webgen/{website_styles → website_bundles/style}/1024px/src/images/background.gif +0 -0
  15. data/data/webgen/{website_styles → website_bundles/style}/andreas00/README +0 -0
  16. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.css +0 -0
  17. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.template +0 -0
  18. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/bg.gif +0 -0
  19. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/front.jpg +0 -0
  20. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg.gif +0 -0
  21. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg2.gif +0 -0
  22. data/data/webgen/{website_styles → website_bundles/style}/andreas01/README +0 -0
  23. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.css +0 -0
  24. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.template +0 -0
  25. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/bg.gif +0 -0
  26. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/front.jpg +0 -0
  27. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/print.css +0 -0
  28. data/data/webgen/{website_styles → website_bundles/style}/andreas03/README +0 -0
  29. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.css +0 -0
  30. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.template +0 -0
  31. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/bodybg.png +0 -0
  32. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/contbg.png +0 -0
  33. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/footerbg.png +0 -0
  34. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient1.png +0 -0
  35. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient2.png +0 -0
  36. data/data/webgen/{website_styles → website_bundles/style}/andreas04/README +0 -0
  37. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.css +0 -0
  38. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.template +0 -0
  39. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/blinkarrow.gif +0 -0
  40. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/bodybg.png +0 -0
  41. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/contentbg.png +0 -0
  42. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/entrybg.png +0 -0
  43. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash.gif +0 -0
  44. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash2.gif +0 -0
  45. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globe.gif +0 -0
  46. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globebottom.gif +0 -0
  47. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/linkarrow.gif +0 -0
  48. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/menuhover.png +0 -0
  49. data/data/webgen/{website_styles → website_bundles/style}/andreas05/README +0 -0
  50. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.css +0 -0
  51. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.template +0 -0
  52. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/bodybg.gif +0 -0
  53. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/front.png +0 -0
  54. data/data/webgen/{website_styles → website_bundles/style}/andreas06/README +0 -0
  55. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.css +6 -4
  56. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.template +2 -2
  57. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/bodybg.gif +0 -0
  58. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/boxbg.gif +0 -0
  59. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/greypx.gif +0 -0
  60. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/header.jpg +0 -0
  61. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/innerbg.gif +0 -0
  62. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/leaves.jpg +0 -0
  63. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/tabs.gif +0 -0
  64. data/data/webgen/{website_styles → website_bundles/style}/andreas07/README +0 -0
  65. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/browserfix.css +0 -0
  66. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.css +0 -0
  67. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.template +0 -0
  68. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/bodybg.gif +0 -0
  69. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/sidebarbg.gif +0 -0
  70. data/data/webgen/{website_styles → website_bundles/style}/andreas08/README +0 -0
  71. data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.css +0 -0
  72. data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.template +0 -0
  73. data/data/webgen/{website_styles → website_bundles/style}/andreas09/README +0 -0
  74. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.css +0 -0
  75. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.template +0 -0
  76. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-black.jpg +0 -0
  77. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-green.jpg +0 -0
  78. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-orange.jpg +0 -0
  79. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-purple.jpg +0 -0
  80. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-red.jpg +0 -0
  81. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg.jpg +0 -0
  82. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/footerbg.jpg +0 -0
  83. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-black.jpg +0 -0
  84. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-green.jpg +0 -0
  85. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-orange.jpg +0 -0
  86. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-purple.jpg +0 -0
  87. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-red.jpg +0 -0
  88. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover.jpg +0 -0
  89. data/data/webgen/{website_styles → website_bundles/style}/simple/README +0 -0
  90. data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.css +0 -0
  91. data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.template +0 -0
  92. data/data/webgen/website_skeleton/README +1 -1
  93. data/data/webgen/website_skeleton/config.yaml +5 -4
  94. data/doc/contentprocessor/blocks.page +43 -10
  95. data/doc/contentprocessor/builder.page +1 -1
  96. data/doc/contentprocessor/erb.page +12 -11
  97. data/doc/contentprocessor/redcloth.page +3 -1
  98. data/doc/extensions.page +3 -3
  99. data/doc/faq.page +13 -10
  100. data/doc/getting_started.page +12 -15
  101. data/doc/index.page +7 -1
  102. data/doc/manual.page +78 -27
  103. data/doc/reference_configuration.page +166 -3
  104. data/doc/reference_website_styles.page +28 -0
  105. data/doc/source/filesystem.page +39 -0
  106. data/doc/source/tararchive.page +40 -0
  107. data/doc/tag/tikz.page +2 -1
  108. data/doc/webgen_page_format.page +13 -12
  109. data/doc/website_styles.metainfo +8 -0
  110. data/lib/webgen/blackboard.rb +2 -2
  111. data/lib/webgen/cache.rb +4 -4
  112. data/lib/webgen/cli.rb +29 -16
  113. data/lib/webgen/cli/apply_command.rb +66 -0
  114. data/lib/webgen/cli/create_command.rb +22 -16
  115. data/lib/webgen/cli/utils.rb +23 -0
  116. data/lib/webgen/cli/webgui_command.rb +31 -16
  117. data/lib/webgen/configuration.rb +8 -6
  118. data/lib/webgen/contentprocessor.rb +4 -5
  119. data/lib/webgen/contentprocessor/blocks.rb +2 -0
  120. data/lib/webgen/contentprocessor/builder.rb +6 -3
  121. data/lib/webgen/contentprocessor/erb.rb +6 -3
  122. data/lib/webgen/contentprocessor/erubis.rb +7 -6
  123. data/lib/webgen/contentprocessor/haml.rb +6 -3
  124. data/lib/webgen/contentprocessor/rdoc.rb +0 -1
  125. data/lib/webgen/contentprocessor/redcloth.rb +3 -1
  126. data/lib/webgen/context.rb +73 -0
  127. data/lib/webgen/context/nodes.rb +36 -0
  128. data/lib/webgen/coreext.rb +3 -2
  129. data/lib/webgen/default_config.rb +3 -1
  130. data/lib/webgen/deprecated.rb +53 -0
  131. data/lib/webgen/node.rb +24 -19
  132. data/lib/webgen/output.rb +50 -7
  133. data/lib/webgen/page.rb +45 -36
  134. data/lib/webgen/path.rb +1 -1
  135. data/lib/webgen/source.rb +32 -4
  136. data/lib/webgen/source/resource.rb +3 -3
  137. data/lib/webgen/source/stacked.rb +1 -1
  138. data/lib/webgen/source/tararchive.rb +73 -0
  139. data/lib/webgen/sourcehandler.rb +4 -4
  140. data/lib/webgen/sourcehandler/base.rb +36 -24
  141. data/lib/webgen/sourcehandler/copy.rb +1 -1
  142. data/lib/webgen/sourcehandler/feed.rb +2 -2
  143. data/lib/webgen/sourcehandler/fragment.rb +1 -1
  144. data/lib/webgen/sourcehandler/metainfo.rb +15 -6
  145. data/lib/webgen/sourcehandler/page.rb +9 -5
  146. data/lib/webgen/sourcehandler/virtual.rb +44 -7
  147. data/lib/webgen/tag/base.rb +19 -13
  148. data/lib/webgen/tag/link.rb +1 -0
  149. data/lib/webgen/version.rb +1 -1
  150. data/lib/webgen/webgentask.rb +15 -13
  151. data/lib/webgen/website.rb +42 -11
  152. data/lib/webgen/websiteaccess.rb +1 -1
  153. data/lib/webgen/websitemanager.rb +61 -66
  154. data/man/man1/webgen.1 +4 -0
  155. data/misc/default.css +13 -0
  156. data/misc/default.template +1 -1
  157. data/misc/htmldoc.metainfo +2 -1
  158. data/misc/style.page +33 -0
  159. data/test/test_cli.rb +1 -7
  160. data/test/test_common_sitemap.rb +2 -2
  161. data/test/test_contentprocessor_blocks.rb +14 -1
  162. data/test/test_contentprocessor_builder.rb +3 -1
  163. data/test/test_contentprocessor_erb.rb +3 -2
  164. data/test/test_contentprocessor_erubis.rb +3 -3
  165. data/test/test_contentprocessor_fragments.rb +3 -3
  166. data/test/test_contentprocessor_haml.rb +3 -2
  167. data/test/test_contentprocessor_maruku.rb +3 -3
  168. data/test/test_contentprocessor_rdiscount.rb +1 -1
  169. data/test/test_contentprocessor_rdoc.rb +1 -1
  170. data/test/test_contentprocessor_redcloth.rb +9 -2
  171. data/test/test_contentprocessor_sass.rb +1 -1
  172. data/test/test_contentprocessor_tags.rb +1 -1
  173. data/test/{test_contentprocessor_context.rb → test_context.rb} +9 -7
  174. data/test/test_node.rb +27 -21
  175. data/test/test_page.rb +4 -4
  176. data/test/test_source_tararchive.rb +65 -0
  177. data/test/test_sourcehandler_fragment.rb +1 -1
  178. data/test/test_sourcehandler_memory.rb +6 -6
  179. data/test/test_sourcehandler_metainfo.rb +34 -13
  180. data/test/test_sourcehandler_page.rb +8 -0
  181. data/test/test_sourcehandler_virtual.rb +51 -12
  182. data/test/test_tag_breadcrumbtrail.rb +4 -4
  183. data/test/test_tag_coderay.rb +1 -1
  184. data/test/test_tag_date.rb +1 -1
  185. data/test/test_tag_executecommand.rb +1 -1
  186. data/test/test_tag_includefile.rb +3 -3
  187. data/test/test_tag_langbar.rb +6 -6
  188. data/test/test_tag_link.rb +8 -2
  189. data/test/test_tag_menu.rb +9 -9
  190. data/test/test_tag_metainfo.rb +1 -1
  191. data/test/test_tag_relocatable.rb +1 -1
  192. data/test/test_tag_sitemap.rb +1 -1
  193. data/test/test_tag_tikz.rb +2 -2
  194. data/test/test_website.rb +17 -0
  195. data/test/test_websitemanager.rb +16 -21
  196. metadata +181 -171
  197. data/data/webgen/website_templates/default/README +0 -6
  198. data/data/webgen/website_templates/default/src/index.page +0 -8
  199. data/data/webgen/website_templates/project/README +0 -5
  200. data/data/webgen/website_templates/project/src/about.page +0 -12
  201. data/data/webgen/website_templates/project/src/download.page +0 -15
  202. data/data/webgen/website_templates/project/src/features.page +0 -8
  203. data/data/webgen/website_templates/project/src/index.page +0 -9
  204. data/data/webgen/website_templates/project/src/screenshots.page +0 -18
  205. data/lib/webgen/contentprocessor/context.rb +0 -89
@@ -19,17 +19,17 @@ class TestSourceHandlerMemory < Test::Unit::TestCase
19
19
  node = obj.create_node(root, path_with_meta_info('/test.png'), '/', 'data')
20
20
  assert_equal('/', node.node_info[:memory_source_alcn])
21
21
  assert_equal('data', obj.content(node))
22
- assert(!node.flagged(:reinit))
22
+ assert(!node.flagged?(:reinit))
23
23
  root.tree.delete_node(node)
24
24
 
25
25
  node = obj.create_node(root, path_with_meta_info('/test.png'), '/') {|n| assert_equal(node, n); 'data'}
26
26
  assert_equal('/', node.node_info[:memory_source_alcn])
27
27
  assert_equal('data', obj.content(node))
28
- assert(!node.flagged(:reinit))
28
+ assert(!node.flagged?(:reinit))
29
29
 
30
- assert(!root.flagged(:dirty))
30
+ assert(!root.flagged?(:dirty))
31
31
  node.flag(:reinit)
32
- assert(root.flagged(:dirty))
32
+ assert(root.flagged?(:dirty))
33
33
  root.unflag(:dirty)
34
34
  root.tree.delete_node(node)
35
35
 
@@ -37,8 +37,8 @@ class TestSourceHandlerMemory < Test::Unit::TestCase
37
37
  assert_equal('/', node.node_info[:memory_source_alcn])
38
38
  obj.instance_eval { @data = nil }
39
39
  assert_nil(obj.content(node))
40
- assert(node.flagged(:reinit))
41
- assert(root.flagged(:dirty))
40
+ assert(node.flagged?(:reinit))
41
+ assert(root.flagged?(:dirty))
42
42
  end
43
43
 
44
44
  end
@@ -12,29 +12,40 @@ class TestSourceHandlerMetainfo < Test::Unit::TestCase
12
12
  class TestSH; include Webgen::SourceHandler::Base; end
13
13
 
14
14
  CONTENT=<<EOF
15
- **/*:
15
+ /default.*:
16
16
  title: new title
17
17
  before: valbef
18
18
  ---
19
- **/*/:
19
+ /default.css:
20
20
  after: valaft
21
+
22
+ /other.page:
23
+ title: Not Other
21
24
  EOF
22
25
 
23
26
  def setup
24
27
  super
25
28
  @website.blackboard.add_service(:source_paths) do
26
- {'/default.css' => path_with_meta_info('/default.css') {StringIO.new('# header')}}
29
+ {'/default.css' => path_with_meta_info('/default.css') {StringIO.new('# header')},
30
+ '/other.page' => path_with_meta_info('/other.page') {StringIO.new('other page')},
31
+ }
27
32
  end
28
33
 
29
34
  @obj = Webgen::SourceHandler::Metainfo.new
30
- @root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', '/')
35
+ @root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
31
36
  @node = @obj.create_node(@root, path_with_meta_info('/metainfo', {}, @obj.class.name) {StringIO.new(CONTENT)})
32
37
  end
33
38
 
34
39
  def test_create_node
35
- assert(@node.flagged(:dirty_meta_info))
36
- assert_equal({'/**/*' => {'title' => 'new title', 'before' => 'valbef'}}, @node.node_info[:mi_paths])
37
- assert_equal({'/**/*' => {'after' => 'valaft'}}, @node.node_info[:mi_alcn])
40
+ assert_equal({'/default.*' => {'title' => 'new title', 'before' => 'valbef'}}, @node.node_info[:mi_paths])
41
+ assert_equal({'/default.css' => {'after' => 'valaft'},
42
+ '/other.page' => {'title' => 'Not Other'}}, @node.node_info[:mi_alcn])
43
+ end
44
+
45
+ def test_empty_metainfo_file
46
+ node = @obj.create_node(@root, path_with_meta_info('/test', {}, @obj.class.name) {StringIO.new('')})
47
+ assert_equal({}, node.node_info[:mi_paths])
48
+ assert_equal({}, node.node_info[:mi_alcn])
38
49
  end
39
50
 
40
51
  def test_meta_info_changed
@@ -49,15 +60,15 @@ EOF
49
60
 
50
61
  other.unflag(:dirty_meta_info)
51
62
  @obj.send(:mark_all_matched_dirty, @node)
52
- assert(!other.flagged(:dirty_meta_info))
63
+ assert(!other.flagged?(:dirty_meta_info))
53
64
 
54
65
  other.unflag(:dirty_meta_info)
55
66
  @obj.send(:mark_all_matched_dirty, @node, :force)
56
- assert(other.flagged(:dirty_meta_info))
67
+ assert(other.flagged?(:dirty_meta_info))
57
68
 
58
69
  other.unflag(:dirty_meta_info)
59
70
  @obj.send(:mark_all_matched_dirty, @node, :no_old_data)
60
- assert(!other.flagged(:dirty_meta_info))
71
+ assert(!other.flagged?(:dirty_meta_info))
61
72
  end
62
73
 
63
74
  def test_before_node_created
@@ -75,23 +86,33 @@ EOF
75
86
  def test_before_node_deleted
76
87
  other = TestSH.new.create_node(@root, path_with_meta_info('/default.css'))
77
88
  @website.blackboard.dispatch_msg(:before_node_deleted, @node)
78
- assert(other.flagged(:dirty_meta_info))
89
+ assert(other.flagged?(:dirty_meta_info))
79
90
  assert(@obj.nodes.empty?)
80
91
  end
81
92
 
82
93
  def test_node_meta_info_changed
83
94
  @node.unflag(:dirty_meta_info)
84
95
  @website.blackboard.dispatch_msg(:node_meta_info_changed?, @node)
85
- assert(!@node.flagged(:dirty_meta_info))
96
+ assert(!@node.flagged?(:dirty_meta_info))
86
97
 
87
98
  @node.node_info[:mi_alcn] = @node.node_info[:mi_alcn].dup
88
99
  @node.node_info[:mi_alcn]['/*metainfo'] = {'other' => 'doit'}
89
100
  @website.blackboard.dispatch_msg(:node_meta_info_changed?, @node)
90
- assert(@node.flagged(:dirty_meta_info))
101
+ assert(@node.flagged?(:dirty_meta_info))
91
102
  end
92
103
 
93
104
  def test_content
94
105
  assert_nil(@obj.content(nil))
95
106
  end
96
107
 
108
+ def test_deletion_of_metainfo
109
+ other = TestSH.new.create_node(@root, path_with_meta_info('/other.page'))
110
+ @website.blackboard.dispatch_msg(:after_node_created, other)
111
+ assert_equal('Not Other', other['title'])
112
+
113
+ @node.flag(:reinit)
114
+ @node = @obj.create_node(@root, path_with_meta_info('/metainfo', {}, @obj.class.name) {StringIO.new("")})
115
+ assert(other.flagged?(:dirty_meta_info))
116
+ end
117
+
97
118
  end
@@ -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>" +