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
@@ -62,7 +62,7 @@ module Webgen
62
62
  write_tree(tree)
63
63
  end
64
64
  puts "...done in " + ('%2.4f' % time.real) + ' seconds'
65
- end while tree.node_access[:alcn].any? {|name,node| node.flagged(:created) || node.flagged(:reinit)}
65
+ end while tree.node_access[:alcn].any? {|name,node| node.flagged?(:created) || node.flagged?(:reinit)}
66
66
  :success
67
67
  end
68
68
 
@@ -86,7 +86,7 @@ module Webgen
86
86
  if deleted
87
87
  nodes_to_delete << node
88
88
  #TODO: delete output path
89
- elsif (!node.flagged(:created) && find_all_source_paths[node.node_info[:src]].changed?) || node.meta_info_changed?
89
+ elsif (!node.flagged?(:created) && find_all_source_paths[node.node_info[:src]].changed?) || node.meta_info_changed?
90
90
  node.flag(:reinit)
91
91
  paths_to_use << node.node_info[:src]
92
92
  elsif node.changed?
@@ -98,7 +98,7 @@ module Webgen
98
98
  used_paths.merge(paths_to_use)
99
99
  paths = create_nodes_from_paths(tree, used_paths.to_a.sort)
100
100
  unused_paths.merge(used_paths - paths)
101
- tree.node_access[:alcn].each {|name, node| tree.delete_node(node) if node.flagged(:reinit)}
101
+ tree.node_access[:alcn].each {|name, node| tree.delete_node(node) if node.flagged?(:reinit)}
102
102
  website.cache.reset_volatile_cache
103
103
  end until used_paths.empty?
104
104
  end
@@ -108,7 +108,7 @@ module Webgen
108
108
  output = website.blackboard.invoke(:output_instance)
109
109
 
110
110
  tree.node_access[:alcn].select do |name, node|
111
- use_node = (node != tree.dummy_root && node.flagged(:dirty))
111
+ use_node = (node != tree.dummy_root && node.flagged?(:dirty))
112
112
  node.unflag(:dirty_meta_info)
113
113
  node.unflag(:created)
114
114
  node.unflag(:dirty)
@@ -10,7 +10,7 @@ module Webgen::SourceHandler
10
10
  # This module should be included in every source handler as it provides the default methods for
11
11
  # creating nodes.
12
12
  #
13
- # = Implementing Source Handlers
13
+ # == Implementing Source Handlers
14
14
  #
15
15
  # A source handler is a webgen extension that processes source paths to create nodes and that
16
16
  # provides the rendered content of these nodes. The nodes are later written to the output
@@ -27,42 +27,53 @@ module Webgen::SourceHandler
27
27
  # not need to reside under the Webgen::SourceHandler namespace but all shipped ones do.
28
28
  #
29
29
  # This base class provides useful default implementations of methods that are used by nearly all
30
- # source handler class:
30
+ # source handler classes:
31
31
  # * #create_node
32
+ # * #output_path
32
33
  # * #node_exists?
33
34
  #
34
35
  # It also provides other utility methods:
35
36
  # * #page_from_path
36
37
  # * #content
37
38
  #
38
- # = Nodes Created for Paths
39
+ # == Nodes Created for Paths
39
40
  #
40
41
  # The main functions of a source handler class are to create one or more nodes for a source path
41
42
  # and to provide the content of these nodes. To achieve this, certain information needs to be set
42
- # on a node. If you use the methods provided by this base class, you don't need to set them
43
- # explicitly because this is done by the provided methods.
43
+ # on a created node. If you use the +create_node+ method provided by this base class, you don't
44
+ # need to set them explicitly because this is done by the method:
44
45
  #
45
- # <tt>node_info[:processor]</tt>:: Has to be set to the class name of the source handler. This is
46
+ # [<tt>node_info[:processor]</tt>] Has to be set to the class name of the source handler. This is
46
47
  # used by the Node class: all unknown method calls are forwarded
47
48
  # to the node processor.
48
- # <tt>node_info[:src]</tt>:: Has to be set to the string version of the path that lead to the
49
+ # [<tt>node_info[:src]</tt>] Has to be set to the string version of the path that lead to the
49
50
  # creation of the node.
50
- # <tt>node_info[:creation_path]</tt>:: Has to be set to the string version of the path that is
51
+ # [<tt>node_info[:creation_path]</tt>] Has to be set to the string version of the path that is
51
52
  # used to create the path.
52
- # <tt>meta_info['no_output']</tt>:: Has to be set to +true+ on nodes that are used during a
53
+ # [<tt>meta_info['no_output']</tt>] Has to be set to +true+ on nodes that are used during a
53
54
  # webgen run but do not produce an output file.
54
- # <tt>meta_info['modified_at']</tt>:: Is automatically set to the current time if not already set
55
+ # [<tt>meta_info['modified_at']</tt>] Has to be set to the current time if not already set
55
56
  # correctly (ie. if not a Time object).
56
57
  #
57
- # Note: The difference between +:src+ and +:creation_path+ is that a creation path need not have
58
- # an existing source path representation. For example, fragments created from a page source path
59
- # have a different +:creation_path+ which includes the fragment part.
58
+ # If <tt>meta_info['draft']</tt> is set on a path, then no node should be created in +create_node+
59
+ # and +nil+ has to be returned.
60
+ #
61
+ # Note: The difference between +:src+ and +:creation_path+ is that a creation path
62
+ # need not have an existing source path representation. For example, fragments created from a page
63
+ # source path have a different +:creation_path+ which includes the fragment part.
60
64
  #
61
65
  # Additional information that is used only for processing purposes should be stored in the
62
66
  # #node_info hash of a node as the #meta_info hash is reserved for real node meta information and
63
67
  # should not be changed once the node is created.
64
68
  #
65
- # = Path Patterns and Invocation order
69
+ # == Output Path Names
70
+ #
71
+ # The method for creating an output path name for a source path is stored in the meta information
72
+ # +output_path+. If you don't use the provided method +output_path+, have a look at its
73
+ # implementation to see how to an output path gets created. Individual output path creation
74
+ # methods are stored as methods in the OutputPathHelpers module.
75
+ #
76
+ # == Path Patterns and Invocation order
66
77
  #
67
78
  # Path patterns define which paths are handled by a specific source handler. These patterns are
68
79
  # specified in the <tt>sourcehandler.patterns</tt> configuration hash as a mapping from the source
@@ -76,12 +87,12 @@ module Webgen::SourceHandler
76
87
  # invocation rank the earlier the specified source handlers are used.
77
88
  #
78
89
  # The default invocation ranks are:
79
- # 1:: Early. Normally there is no need to use this rank.
80
- # 5:: Standard. This is the rank the normal source handler should use.
81
- # 9:: Late. This rank should be used by source handlers that operate on/use already created nodes
90
+ # [1] Early. Normally there is no need to use this rank.
91
+ # [5] Standard. This is the rank the normal source handler should use.
92
+ # [9] Late. This rank should be used by source handlers that operate on/use already created nodes
82
93
  # and need to ensure that these nodes are available.
83
94
  #
84
- # = Default Meta Information
95
+ # == Default Meta Information
85
96
  #
86
97
  # Each source handler can define default meta information that gets automatically set on the
87
98
  # source paths that are passed to the #create_node method.
@@ -90,7 +101,7 @@ module Webgen::SourceHandler
90
101
  # configuration hash as a mapping from the source handler class name to the meta information
91
102
  # hash.
92
103
  #
93
- # = Sample Source Handler Class
104
+ # == Sample Source Handler Class
94
105
  #
95
106
  # Following is a simple source handler class example which copies paths from the source to
96
107
  # the output location modifying the extension:
@@ -119,9 +130,10 @@ module Webgen::SourceHandler
119
130
  #
120
131
  # All public methods of this module are considered to be output path creation methods and must
121
132
  # have the following parameters:
122
- # +parent+:: the parent node
123
- # +path+:: the path for which the output name should be created
124
- # +use_lang_part+:: controls whether the output path name has to include the language part
133
+ #
134
+ # [+parent+] the parent node
135
+ # [+path+] the path for which the output name should be created
136
+ # [+use_lang_part+] controls whether the output path name has to include the language part
125
137
  module OutputPathHelpers
126
138
 
127
139
  # Default method for creating an output path for +parent+ and source +path+.
@@ -201,7 +213,7 @@ module Webgen::SourceHandler
201
213
  return node
202
214
  elsif !node
203
215
  node = Webgen::Node.new(parent, output_path, path.cn, path.meta_info)
204
- elsif node.flagged(:reinit)
216
+ elsif node.flagged?(:reinit)
205
217
  node.reinit(output_path, path.meta_info)
206
218
  else
207
219
  return node
@@ -224,7 +236,7 @@ module Webgen::SourceHandler
224
236
  def page_from_path(path)
225
237
  begin
226
238
  page = Webgen::Page.from_data(path.io.data, path.meta_info)
227
- rescue Webgen::WebgenPageFormatError => e
239
+ rescue Webgen::Page::FormatError => e
228
240
  raise "Error reading source path <#{path}>: #{e.message}"
229
241
  end
230
242
  path.meta_info = page.meta_info
@@ -30,7 +30,7 @@ module Webgen::SourceHandler
30
30
  def content(node)
31
31
  io = website.blackboard.invoke(:source_paths)[node.node_info[:src]].io
32
32
  if node.node_info[:preprocessor]
33
- context = Webgen::ContentProcessor::Context.new(:content => io.data, :chain => [node])
33
+ context = Webgen::Context.new(:content => io.data, :chain => [node])
34
34
  website.blackboard.invoke(:content_processor, node.node_info[:preprocessor]).call(context)
35
35
  context.content
36
36
  else
@@ -45,7 +45,7 @@ module Webgen::SourceHandler
45
45
  block_name = node.node_info[:feed_type] + '_template'
46
46
  if node.node_info[:feed].blocks.has_key?(block_name)
47
47
  node.node_info[:feed].blocks[block_name].
48
- render(Webgen::ContentProcessor::Context.new(:chain => [node])).content
48
+ render(Webgen::Context.new(:chain => [node])).content
49
49
  else
50
50
  feed = (website.cache.volatile[:sourcehandler_feed] ||= {})[node.node_info[:src]] ||= build_feed_for(node)
51
51
  feed.build_xml(node.node_info[:feed_type], (node.node_info[:feed_type] == 'rss' ? node['rss_version'] || 2.0 : nil))
@@ -90,7 +90,7 @@ module Webgen::SourceHandler
90
90
  item = FeedTools::FeedItem.new
91
91
  item.title = entry['title']
92
92
  item.link = File.join(site_url, entry.path)
93
- item.content = entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::ContentProcessor::Context.new(:chain => [entry])).content
93
+ item.content = entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::Context.new(:chain => [entry])).content
94
94
  item.updated = entry['modified_at']
95
95
  item.published = entry['created_at'] if entry['created_at'].kind_of?(Time)
96
96
  if entry['author']
@@ -10,7 +10,7 @@ module Webgen::SourceHandler
10
10
  include Webgen::WebsiteAccess
11
11
 
12
12
  HTML_HEADER_REGEXP = /<h([123456])(?:>|\s([^>]*)>)(.*?)<\/h\1\s*>/i
13
- HTML_ATTR_REGEXP = /\s*(\w+)\s*=\s*('|")([^\2]+)\2\s*/
13
+ HTML_ATTR_REGEXP = /\s*(\w+)\s*=\s*('|")(.+?)\2\s*/
14
14
 
15
15
  # Parse the string +content+ for headers +h1+, ..., +h6+ and return the found, nested sections.
16
16
  #
@@ -28,10 +28,12 @@ module Webgen::SourceHandler
28
28
  super(parent, path) do |node|
29
29
  [[:mi_paths, 'paths'], [:mi_alcn, 'alcn']].each do |mi_key, block_name|
30
30
  node.node_info[mi_key] = {}
31
- YAML::load(page.blocks[block_name].content).each do |key, value|
32
- key = Webgen::Common.absolute_path(key, parent.absolute_lcn)
33
- node.node_info[mi_key][key] = value
34
- end if page.blocks.has_key?(block_name)
31
+ if page.blocks.has_key?(block_name) && (data = YAML::load(page.blocks[block_name].content))
32
+ data.each do |key, value|
33
+ key = Webgen::Common.absolute_path(key, parent.absolute_lcn)
34
+ node.node_info[mi_key][key] = value
35
+ end
36
+ end
35
37
  end
36
38
 
37
39
  mark_all_matched_dirty(node, :no_old_data)
@@ -66,7 +68,14 @@ module Webgen::SourceHandler
66
68
  (option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_paths][pattern])
67
69
  end || mi_node.node_info[:mi_alcn].any? do |pattern, mi|
68
70
  node =~ pattern && (option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_alcn][pattern])
69
- end)
71
+ end || (option == :no_old_data && cached &&
72
+ ((cached[:mi_paths].keys - mi_node.node_info[:mi_paths].keys).any? do |p|
73
+ Webgen::Path.match(node.node_info[:creation_path], p)
74
+ end || (cached[:mi_alcn].keys - mi_node.node_info[:mi_alcn].keys).any? do |p|
75
+ node =~ p
76
+ end)
77
+ )
78
+ )
70
79
  end
71
80
 
72
81
  # Mark all nodes that are matched by a path or an alcn specifcation in the meta info node +node+
@@ -99,7 +108,7 @@ module Webgen::SourceHandler
99
108
  # node in question has changed.
100
109
  def node_meta_info_changed?(node)
101
110
  self.nodes.each do |n|
102
- if n.flagged(:created) && meta_info_changed?(n, node)
111
+ if n.flagged?(:created) && meta_info_changed?(n, node)
103
112
  node.flag(:dirty_meta_info)
104
113
  return
105
114
  end
@@ -32,7 +32,7 @@ module Webgen::SourceHandler
32
32
 
33
33
  if chain.first.node_info[:page].blocks.has_key?(block_name)
34
34
  node.node_info[:used_nodes] << chain.first.absolute_lcn
35
- context = chain.first.node_info[:page].blocks[block_name].render(Webgen::ContentProcessor::Context.new(:chain => chain))
35
+ context = chain.first.node_info[:page].blocks[block_name].render(Webgen::Context.new(:chain => chain))
36
36
  context.content
37
37
  else
38
38
  raise "Error rendering <#{node.absolute_lcn}>: no block named '#{block_name}' in <#{chain.first.absolute_lcn}>"
@@ -47,11 +47,15 @@ module Webgen::SourceHandler
47
47
  # Checks if the meta information provided by the file in Webgen Page Format changed.
48
48
  def meta_info_changed?(node)
49
49
  path = website.blackboard.invoke(:source_paths)[node.node_info[:src]]
50
- return if node.node_info[:processor] != self.class.name || !path.changed?
50
+ return if node.node_info[:processor] != self.class.name || (path && !path.changed?)
51
51
 
52
- old_mi = node.node_info[:sh_page_node_mi]
53
- new_mi = Webgen::Page.meta_info_from_data(path.io.data)
54
- node.flag(:dirty_meta_info) if old_mi && old_mi != new_mi
52
+ if !path
53
+ node.flag(:dirty_meta_info)
54
+ else
55
+ old_mi = node.node_info[:sh_page_node_mi]
56
+ new_mi = Webgen::Page.meta_info_from_data(path.io.data)
57
+ node.flag(:dirty_meta_info) if old_mi && old_mi != new_mi
58
+ end
55
59
  end
56
60
 
57
61
  end
@@ -14,17 +14,20 @@ module Webgen::SourceHandler
14
14
  include Base
15
15
  include Webgen::WebsiteAccess
16
16
 
17
+ def initialize # :nodoc:
18
+ website.blackboard.add_listener(:node_meta_info_changed?, method(:node_meta_info_changed?))
19
+ @path_data = {}
20
+ end
21
+
17
22
  # Create all virtual nodes under +parent+ which are specified in +path+.
18
23
  def create_node(parent, path)
19
- page = page_from_path(path)
20
24
  nodes = []
21
- YAML::load(page.blocks['content'].content).each do |key, meta_info|
25
+ read_data(path).each do |key, meta_info|
26
+ cache_data = [key, meta_info.dup]
27
+
22
28
  key = Webgen::Common.absolute_path(key, parent.absolute_lcn) + (key =~ /\/$/ ? '/' : '')
23
29
  temp_parent = create_directories(parent.tree.root, File.dirname(key), path)
24
30
 
25
- meta_info ||= {}
26
- meta_info['modified_at'] = path.meta_info['modified_at']
27
- meta_info['no_output'] = true
28
31
  output_path = meta_info.delete('url') || key
29
32
  output_path = (URI::parse(output_path).absolute? || output_path =~ /^\// ?
30
33
  output_path : File.join(temp_parent.absolute_lcn, output_path))
@@ -35,10 +38,12 @@ module Webgen::SourceHandler
35
38
  nodes += website.blackboard.invoke(:create_nodes, parent.tree, temp_parent.absolute_lcn,
36
39
  Webgen::Path.new(key, path.source_path), self) do |cn_parent, cn_path|
37
40
  cn_path.meta_info.update(meta_info)
38
- super(cn_parent, cn_path, output_path)
41
+ super(cn_parent, cn_path, output_path) do |n|
42
+ n.node_info[:sh_virtual_cache_data] = cache_data
43
+ end
39
44
  end
40
45
  end
41
- end if page.blocks.has_key?('content')
46
+ end
42
47
  nodes.compact
43
48
  end
44
49
 
@@ -46,6 +51,23 @@ module Webgen::SourceHandler
46
51
  private
47
52
  #######
48
53
 
54
+ # Read the entries from the virtual file +data+ and yield the path, and the meta info hash for
55
+ # each entry. The +parent+ parameter is used for making absolute path values if relative ones
56
+ # are given.
57
+ def read_data(path)
58
+ if !@path_data.has_key?(path) || path.changed?
59
+ page = page_from_path(path)
60
+ @path_data[path] = YAML::load(page.blocks['content'].content).collect do |key, meta_info|
61
+ meta_info ||= {}
62
+ meta_info['modified_at'] = path.meta_info['modified_at']
63
+ meta_info['no_output'] = true
64
+ [key, meta_info]
65
+ end if page.blocks.has_key?('content')
66
+ @path_data[path] ||= []
67
+ end
68
+ @path_data[path]
69
+ end
70
+
49
71
  # Create the needed parent directories for a virtual node.
50
72
  def create_directories(parent, dirname, path)
51
73
  dirname.sub(/^\//, '').split('/').each do |dir|
@@ -72,6 +94,21 @@ module Webgen::SourceHandler
72
94
  parent
73
95
  end
74
96
 
97
+ # Check if the +node+ is virtual and if, if its meta information has changed. This can only be
98
+ # the case if the node has been recreated in this run.
99
+ def node_meta_info_changed?(node)
100
+ path = website.blackboard.invoke(:source_paths)[node.node_info[:src]]
101
+ return if node.node_info[:processor] != self.class.name || (path && !path.changed?)
102
+
103
+ if !path
104
+ node.flag(:dirty_meta_info)
105
+ else
106
+ old_data = node.node_info[:sh_virtual_cache_data]
107
+ new_data = read_data(path).find {|key, mi| key == old_data.first}
108
+ node.flag(:dirty_meta_info) if !new_data || old_data.last != new_data.last
109
+ end
110
+ end
111
+
75
112
  end
76
113
 
77
114
  end
@@ -7,7 +7,7 @@ require 'webgen/websiteaccess'
7
7
  # This module should be mixed into any class that wants to serve as a webgen tag class. Have a look
8
8
  # a the example below to see how a basic tag class looks like.
9
9
  #
10
- # = Tag classes
10
+ # == Tag classes
11
11
  #
12
12
  # A tag class is a webgen extension that handles specific webgen tags. webgen tags are used to add
13
13
  # dynamic content to page and template files and are made for ease of use.
@@ -23,18 +23,21 @@ require 'webgen/websiteaccess'
23
23
  # Tag classes *can* also choose to not use this module. If they don't use it they have to provide
24
24
  # the following methods: +set_params+, +create_tag_params+, +call+.
25
25
  #
26
- # = Tag parameters
26
+ # == Tag parameters
27
27
  #
28
28
  # webgen tags allow the specification of parameters in the tag definition. The method
29
29
  # +tag_params_list+ returns all configuration entries that can be set this way. And the method
30
- # +tag_config_base+ is used to resolve partially stated configuration entries. An additional
31
- # configuration entry option is also used: <tt>:mandatory</tt>. If this key is set to +true+ for a
32
- # configuration entry, the entry counts as mandatory and needs to be set in the tag definition. If
33
- # this key is set to +default+, this means that this entry should be the default mandatory parameter
34
- # (used when only a string is provided in the tag definition). There *should* be only one default
35
- # mandatory parameter.
30
+ # +tag_config_base+ is used to resolve partially stated configuration entries. The default method
31
+ # uses the full class name, strips a <tt>Webgen::</tt> part at the beginning away, substitutes
32
+ # <tt>.</tt> for <tt>::</tt> and makes everything lowercase.
36
33
  #
37
- # = Sample Tag Class
34
+ # An additional configuration entry option is also used: <tt>:mandatory</tt>. If this key is set to
35
+ # +true+ for a configuration entry, the entry counts as mandatory and needs to be set in the tag
36
+ # definition. If this key is set to +default+, this means that this entry should be the default
37
+ # mandatory parameter (used when only a string is provided in the tag definition). There *should* be
38
+ # only one default mandatory parameter.
39
+ #
40
+ # == Sample Tag Class
38
41
  #
39
42
  # Following is a simple tag class example which just reverses the body text and adds some
40
43
  # information about the context to the result. Note that the class does not reside in the
@@ -90,7 +93,7 @@ module Webgen::Tag::Base
90
93
  # The parameter +body+ holds the optional body value for the tag.
91
94
  #
92
95
  # The +context+ parameter holds all relevant information for processing. Have a look at the
93
- # Webgen::ContentProcessor::Context class to see what is available.
96
+ # Webgen::Context class to see what is available.
94
97
  #
95
98
  # The method has to return the result of the tag processing and, optionally, a boolean value
96
99
  # specifying if the result should further be processed (ie. webgen tags replaced).
@@ -104,13 +107,16 @@ module Webgen::Tag::Base
104
107
  private
105
108
  #######
106
109
 
107
- # The base part of the configuration name. This is normally the class name without the Webgen
108
- # module downcased and all "::" substituted with "." (e.g. Webgen::Tag::Menu -> tag.menu).
110
+ # The base part of the configuration name. This isthe class name without the Webgen module
111
+ # downcased and all "::" substituted with "." (e.g. Webgen::Tag::Menu -> tag.menu). By overriding
112
+ # this method one can provide a different way of specifying the base part of the configuration
113
+ # name.
109
114
  def tag_config_base
110
115
  self.class.name.gsub('::', '.').gsub(/^Webgen\./, '').downcase
111
116
  end
112
117
 
113
- # Return the list of all parameters for the tag class.
118
+ # Return the list of all parameters for the tag class. All configuration options starting with
119
+ # +tag_config_base+ are used.
114
120
  def tag_params_list
115
121
  regexp = /^#{tag_config_base}/
116
122
  website.config.data.keys.select {|key| key =~ regexp}
@@ -10,6 +10,7 @@ module Webgen::Tag
10
10
  # Return a HTML link to the given (A)LCN.
11
11
  def call(tag, body, context)
12
12
  if (dest_node = context.ref_node.resolve(param('tag.link.path'), context.dest_node.lang))
13
+ context.dest_node.node_info[:used_meta_info_nodes] << dest_node.absolute_lcn
13
14
  context.dest_node.link_to(dest_node, param('tag.link.attr').merge(:lang => context.content_node.lang))
14
15
  else
15
16
  raise ArgumentError, 'Resolving of path failed'
@@ -3,6 +3,6 @@
3
3
  module Webgen
4
4
 
5
5
  # The version of webgen.
6
- VERSION = '0.5.7'
6
+ VERSION = '0.5.8'
7
7
 
8
8
  end
@@ -41,30 +41,33 @@ module Webgen
41
41
  # It is assumed that you have already used the 'webgen' command to create the website directory
42
42
  # for the site.
43
43
  #
44
- # === Basics
44
+ # == Basics
45
45
  #
46
46
  # require 'webgen/webgentask'
47
47
  #
48
48
  # Webgen::WebgenTask.new
49
49
  #
50
- # === Attributes
50
+ # == Attributes
51
51
  #
52
52
  # The attributes available in the new block are:
53
53
  #
54
- # * directory - the root directory of the webgen site
55
- # (default Dir.pwd)
56
- # * config - the config block for setting additional configuration options
57
- # * clobber_outdir - remove webgens output directory on clobber
58
- # (default false)
54
+ # [directory]
55
+ # the root directory of the webgen site (default <tt>Dir.pwd</tt>)
56
+ # [config]
57
+ # the config block for setting additional configuration options
58
+ # [clobber_outdir]
59
+ # remove webgens output directory on clobber (default +false+)
59
60
  #
60
- # === Tasks Provided
61
+ # == Tasks Provided
61
62
  #
62
63
  # The tasks provided are :
63
64
  #
64
- # * webgen - render the webgen website
65
- # * clobber_webgen - remove all the files created during generation
65
+ # [webgen]
66
+ # render the webgen website
67
+ # [clobber_webgen]
68
+ # remove all the files created during generation
66
69
  #
67
- # === Integrate webgen in other project
70
+ # == Integrate webgen in other project
68
71
  #
69
72
  # To integrate webgen tasks in another project you can use rake namespaces. For example assuming
70
73
  # webgen's site directory is +webgen+ under the main project directory use the following code
@@ -96,8 +99,7 @@ module Webgen
96
99
  # The directory of the webgen website. This would be the directory of your <tt>config.yaml</tt>
97
100
  # file. Or the parent directory of the <tt>src/</tt> directory for webgen.
98
101
  #
99
- # The default for this is assumed to be
100
- # Dir.pwd
102
+ # The default for this is assumed to be <tt>Dir.pwd</tt>
101
103
  attr_accessor :directory
102
104
 
103
105
  # The configuration block that is invoked when the Webgen::Website object is initialized. This