webgen 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/ChangeLog +3662 -0
  2. data/Rakefile +8 -1
  3. data/VERSION +1 -1
  4. data/data/webgen/website_styles/1024px/src/default.template +1 -1
  5. data/data/webgen/website_styles/andreas00/src/default.template +1 -1
  6. data/data/webgen/website_styles/andreas01/src/default.template +2 -1
  7. data/data/webgen/website_styles/andreas03/src/default.template +1 -1
  8. data/data/webgen/website_styles/andreas04/src/default.template +1 -1
  9. data/data/webgen/website_styles/andreas05/src/default.template +1 -1
  10. data/data/webgen/website_styles/andreas06/src/default.template +1 -1
  11. data/data/webgen/website_styles/andreas07/src/default.template +1 -1
  12. data/data/webgen/website_styles/andreas08/src/default.template +1 -1
  13. data/data/webgen/website_styles/andreas09/src/default.template +1 -1
  14. data/data/webgen/website_styles/simple/src/default.template +1 -1
  15. data/doc/contentprocessor/fragments.page +25 -0
  16. data/doc/extensions.page +1 -1
  17. data/doc/manual.page +33 -15
  18. data/doc/reference_configuration.page +339 -62
  19. data/doc/reference_metainfo.page +11 -2
  20. data/doc/sourcehandler/feed.page +19 -4
  21. data/doc/sourcehandler/page.page +0 -16
  22. data/doc/tag/langbar.page +8 -1
  23. data/doc/tag/link.page +44 -0
  24. data/doc/tag/tikz.page +158 -0
  25. data/lib/webgen/cli.rb +4 -4
  26. data/lib/webgen/common/sitemap.rb +2 -3
  27. data/lib/webgen/configuration.rb +3 -1
  28. data/lib/webgen/contentprocessor.rb +1 -0
  29. data/lib/webgen/contentprocessor/blocks.rb +0 -2
  30. data/lib/webgen/contentprocessor/context.rb +0 -3
  31. data/lib/webgen/contentprocessor/erubis.rb +0 -2
  32. data/lib/webgen/contentprocessor/fragments.rb +23 -0
  33. data/lib/webgen/default_config.rb +15 -2
  34. data/lib/webgen/languages.rb +9 -0
  35. data/lib/webgen/logger.rb +18 -1
  36. data/lib/webgen/node.rb +50 -25
  37. data/lib/webgen/page.rb +26 -16
  38. data/lib/webgen/path.rb +20 -10
  39. data/lib/webgen/sourcehandler.rb +85 -69
  40. data/lib/webgen/sourcehandler/base.rb +38 -15
  41. data/lib/webgen/sourcehandler/copy.rb +2 -2
  42. data/lib/webgen/sourcehandler/directory.rb +16 -13
  43. data/lib/webgen/sourcehandler/feed.rb +6 -12
  44. data/lib/webgen/sourcehandler/fragment.rb +6 -11
  45. data/lib/webgen/sourcehandler/memory.rb +41 -0
  46. data/lib/webgen/sourcehandler/metainfo.rb +21 -21
  47. data/lib/webgen/sourcehandler/page.rb +7 -27
  48. data/lib/webgen/sourcehandler/sitemap.rb +0 -2
  49. data/lib/webgen/sourcehandler/template.rb +0 -4
  50. data/lib/webgen/sourcehandler/virtual.rb +18 -18
  51. data/lib/webgen/tag.rb +2 -0
  52. data/lib/webgen/tag/breadcrumbtrail.rb +1 -4
  53. data/lib/webgen/tag/coderay.rb +0 -3
  54. data/lib/webgen/tag/date.rb +0 -2
  55. data/lib/webgen/tag/executecommand.rb +1 -2
  56. data/lib/webgen/tag/includefile.rb +1 -3
  57. data/lib/webgen/tag/langbar.rb +2 -5
  58. data/lib/webgen/tag/link.rb +23 -0
  59. data/lib/webgen/tag/menu.rb +1 -4
  60. data/lib/webgen/tag/metainfo.rb +0 -2
  61. data/lib/webgen/tag/relocatable.rb +2 -3
  62. data/lib/webgen/tag/sitemap.rb +0 -3
  63. data/lib/webgen/tag/tikz.rb +117 -0
  64. data/lib/webgen/tree.rb +11 -6
  65. data/lib/webgen/version.rb +1 -1
  66. data/lib/webgen/website.rb +2 -1
  67. data/test/test_cli.rb +14 -0
  68. data/test/test_common_sitemap.rb +4 -4
  69. data/test/test_contentprocessor_context.rb +1 -1
  70. data/test/test_contentprocessor_fragments.rb +40 -0
  71. data/test/test_contentprocessor_redcloth.rb +1 -0
  72. data/test/test_contentprocessor_tags.rb +1 -1
  73. data/test/test_languages.rb +12 -0
  74. data/test/test_logger.rb +19 -0
  75. data/test/test_node.rb +35 -15
  76. data/test/test_output_filesystem.rb +1 -1
  77. data/test/test_page.rb +15 -6
  78. data/test/test_path.rb +37 -5
  79. data/test/test_source_filesystem.rb +1 -1
  80. data/test/test_source_stacked.rb +1 -1
  81. data/test/test_sourcehandler_base.rb +30 -1
  82. data/test/test_sourcehandler_copy.rb +1 -1
  83. data/test/test_sourcehandler_directory.rb +16 -1
  84. data/test/test_sourcehandler_feed.rb +9 -8
  85. data/test/test_sourcehandler_fragment.rb +1 -1
  86. data/test/test_sourcehandler_memory.rb +42 -0
  87. data/test/test_sourcehandler_metainfo.rb +23 -21
  88. data/test/test_sourcehandler_page.rb +5 -12
  89. data/test/test_sourcehandler_template.rb +1 -1
  90. data/test/test_sourcehandler_virtual.rb +2 -2
  91. data/test/test_tag_base.rb +0 -1
  92. data/test/test_tag_breadcrumbtrail.rb +4 -4
  93. data/test/test_tag_includefile.rb +3 -3
  94. data/test/test_tag_langbar.rb +12 -7
  95. data/test/test_tag_link.rb +61 -0
  96. data/test/test_tag_menu.rb +7 -7
  97. data/test/test_tag_metainfo.rb +1 -1
  98. data/test/test_tag_relocatable.rb +1 -1
  99. data/test/test_tag_tikz.rb +66 -0
  100. data/test/test_tree.rb +8 -9
  101. metadata +15 -2
@@ -1,3 +1,4 @@
1
+ require 'facets/symbol/to_proc'
1
2
  require 'webgen/websiteaccess'
2
3
  require 'webgen/loggable'
3
4
  require 'webgen/page'
@@ -42,9 +43,18 @@ module Webgen::SourceHandler
42
43
  # <tt>node_info[:processor]</tt>:: Has to be set to the class name of the source handler. This is
43
44
  # used by the Node class: all unknown method calls are forwarded
44
45
  # to the node processor.
45
- # <tt>node_info[:src]</tt>:: Has to be set to the string version of the source path.
46
+ # <tt>node_info[:src]</tt>:: Has to be set to the string version of the path that lead to the
47
+ # creation of the node.
48
+ # <tt>node_info[:creation_path]</tt>:: Has to be set to the string version of the path that is
49
+ # used to create the path.
46
50
  # <tt>meta_info['no_output']</tt>:: Has to be set to +true+ on nodes that are used during a
47
51
  # webgen run but do not produce an output file.
52
+ # <tt>meta_info['modified_at']</tt>:: Is automatically set to the current time if not already set
53
+ # correctly (ie. if not a Time object).
54
+ #
55
+ # Note: The difference between +:src+ and +:creation_path+ is that a creation path need not have
56
+ # an existing source path representation. For example, fragments created from a page source path
57
+ # have a different +:creation_path+ which includes the fragment part.
48
58
  #
49
59
  # Additional information that is used only for processing purposes should be stored in the
50
60
  # #node_info hash of a node as the #meta_info hash is reserved for real node meta information and
@@ -55,7 +65,8 @@ module Webgen::SourceHandler
55
65
  # Path patterns define which paths are handled by a specific source handler. These patterns are
56
66
  # specified in the <tt>sourcehandler.patterns</tt> configuration hash as a mapping from the source
57
67
  # handler class name to an array of path patterns. The patterns need to have a format that
58
- # <tt>Dir.glob</tt> can handle.
68
+ # <tt>Dir.glob</tt> can handle. You can use the configuration helper +patterns+ to set this (is
69
+ # shown in the example below).
59
70
  #
60
71
  # Specifying a path pattern does not mean that webgen uses the source handler. One also needs to
61
72
  # provide an entry in the configuration value <tt>sourcehandler.invoke</tt>. This is a hash that
@@ -97,7 +108,7 @@ module Webgen::SourceHandler
97
108
  #
98
109
  # end
99
110
  #
100
- # WebsiteAccess.website.config.sourcehandler.patterns['SimpleCopy'] = ['**/*.jpg', '**/*.png']
111
+ # WebsiteAccess.website.config.patterns('SimpleCopy' => ['**/*.jpg', '**/*.png'])
101
112
  # WebsiteAccess.website.config.sourcehandler.invoke[5] << 'SimpleCopy'
102
113
  #
103
114
  module Base
@@ -153,10 +164,12 @@ module Webgen::SourceHandler
153
164
  Webgen::WebsiteAccess.website.config['sourcehandler.default_lang_in_output_path'] ||
154
165
  Webgen::WebsiteAccess.website.config['website.lang'] != path.meta_info['lang']
155
166
  end
156
- if OutputPathHelpers.public_instance_methods(false).include?(method)
167
+ if OutputPathHelpers.public_instance_methods(false).map(&:to_s).include?(method)
157
168
  name = send(method, parent, path, use_lang_part)
158
169
  name += '/' if path.path =~ /\/$/ && name !~ /\/$/
159
- if node_exists?(parent, path, name)
170
+ if (node = node_exists?(parent, path, name)) && node.lang == path.meta_info['lang']
171
+ name = node.path
172
+ elsif node
160
173
  name = send(method, parent, path, (path.meta_info['lang'].nil? ? false : true))
161
174
  name += '/' if path.path =~ /\/$/ && name !~ /\/$/
162
175
  end
@@ -172,21 +185,31 @@ module Webgen::SourceHandler
172
185
  parent.tree[Webgen::Node.absolute_name(parent, path.lcn, :alcn)] || (!path.meta_info['no_output'] && parent.tree[output_path, :path])
173
186
  end
174
187
 
175
- # Create and return a node under +parent+ from +path+ if it does not already exists. Some
188
+ # Create a node under +parent+ from +path+ if it does not already exists or needs to be
189
+ # re-initialized. The found node or the newly created node is returned afterwards. +nil+ is
190
+ # returned if no node can be created (e.g. when <tt>path.meta_info['draft']</tt> is set). Some
176
191
  # additional node information like <tt>:src</tt> and <tt>:processor</tt> is set and the meta
177
- # information is checked for validness. The created node is yielded if a block is given.
192
+ # information is checked for validness. The created/re-initialized node is yielded if a block is
193
+ # given.
178
194
  def create_node(parent, path, output_path = self.output_path(parent, path))
179
- return if path.meta_info['draft']
180
- if !node_exists?(parent, path, output_path)
195
+ return nil if path.meta_info['draft']
196
+ node = node_exists?(parent, path, output_path)
197
+ if node && (node.node_info[:src] != path.source_path || node.node_info[:processor] != self.class.name)
198
+ log(:warn) { "Node already exists: source = #{path.source_path} | path = #{node.path} | alcn = #{node.absolute_lcn}"}
199
+ return node
200
+ elsif !node
181
201
  node = Webgen::Node.new(parent, output_path, path.cn, path.meta_info)
182
- node['modified_at'] = Time.now unless node['modified_at'].kind_of?(Time)
183
- node.node_info[:src] = path.path
184
- node.node_info[:processor] = self.class.name
185
- yield(node) if block_given?
186
- node
202
+ elsif node.flagged(:reinit)
203
+ node.reinit(output_path, path.meta_info)
187
204
  else
188
- log(:warn) { "Node already exists: output path = #{output_path} | alcn = #{Webgen::Node.absolute_name(parent, path.lcn, :alcn)}"}
205
+ return node
189
206
  end
207
+ node['modified_at'] = Time.now unless node['modified_at'].kind_of?(Time)
208
+ node.node_info[:src] = path.source_path
209
+ node.node_info[:creation_path] = path.path
210
+ node.node_info[:processor] = self.class.name
211
+ yield(node) if block_given?
212
+ node
190
213
  end
191
214
 
192
215
  # Return the content of the given +node+. This default +content+ method just returns +nil+.
@@ -7,8 +7,8 @@ module Webgen::SourceHandler
7
7
  include Webgen::WebsiteAccess
8
8
  include Base
9
9
 
10
- # Create the node for +parent+ and +path+. If the +path+ has the name of a content processor in
11
- # the extension, it is preprocessed.
10
+ # Create the node for +parent+ and +path+. If the +path+ has the name of a content processor as
11
+ # the first part in the extension, it is preprocessed.
12
12
  def create_node(parent, path)
13
13
  if path.ext.index('.')
14
14
  processor, *rest = path.ext.split('.')
@@ -1,24 +1,27 @@
1
- require 'webgen/sourcehandler/base'
2
-
3
1
  module Webgen::SourceHandler
4
2
 
5
3
  # Handles directory source paths.
6
4
  class Directory
7
5
 
8
6
  include Base
7
+ include Webgen::WebsiteAccess
8
+
9
+ def initialize # :nodoc:
10
+ website.blackboard.add_service(:create_directories, method(:create_directories))
11
+ end
9
12
 
10
- # Creation of directory nodes is special because once they are created, they are only deleted
11
- # when the source path gets deleted. Otherwise, only the meta information of the node gets
12
- # updated.
13
- def create_node(parent, path)
14
- if node = node_exists?(parent, path)
15
- node.meta_info.clear
16
- node.meta_info.update(path.meta_info)
17
- node.dirty = true
18
- node
19
- else
20
- super(parent, path)
13
+ # Recursively create the directories specified in +dirname+ under +parent+ (a leading slash is
14
+ # ignored). The path +path+ is the path that lead to the creation of these directories.
15
+ def create_directories(parent, dirname, path)
16
+ dirname.sub(/^\//, '').split('/').each do |dir|
17
+ dir_path = Webgen::Path.new(File.join(parent.absolute_lcn, dir, '/'), path)
18
+ nodes = website.blackboard.invoke(:create_nodes, parent.tree, parent.absolute_lcn,
19
+ dir_path, self) do |dir_parent, dir_path|
20
+ node_exists?(dir_parent, dir_path) || create_node(dir_parent, dir_path)
21
+ end
22
+ parent = nodes.first
21
23
  end
24
+ parent
22
25
  end
23
26
 
24
27
  # Return an empty string to signal that the directory should be written to the output.
@@ -1,6 +1,3 @@
1
- require 'webgen/websiteaccess'
2
- require 'webgen/sourcehandler/base'
3
-
4
1
  module Webgen::SourceHandler
5
2
 
6
3
  # Source handler for creating atom and/or rss feeds.
@@ -49,8 +46,7 @@ module Webgen::SourceHandler
49
46
  render(Webgen::ContentProcessor::Context.new(:chain => [node])).content
50
47
  else
51
48
  feed = (website.cache.volatile[:sourcehandler_feed] ||= {})[node.node_info[:src]] ||= build_feed_for(node)
52
- feed.feed_type = node.node_info[:feed_type]
53
- feed.build_xml
49
+ feed.build_xml(node.node_info[:feed_type], (node.node_info[:feed_type] == 'rss' ? node['rss_version'] || 2.0 : nil))
54
50
  end
55
51
  end
56
52
 
@@ -61,8 +57,7 @@ module Webgen::SourceHandler
61
57
 
62
58
  node.tree.node_access[:alcn].values.
63
59
  select {|node| patterns.any? {|pat| node =~ pat} && node.node_info[:page]}.
64
- sort {|a,b| a['modified_at'] <=> b['modified_at']}.
65
- reverse[0, nr_items]
60
+ sort {|a,b| a['modified_at'] <=> b['modified_at']}[0, nr_items]
66
61
  end
67
62
 
68
63
  #######
@@ -88,13 +83,12 @@ module Webgen::SourceHandler
88
83
  feed.published = (node['created_at'].kind_of?(Time) ? node['created_at'] : Time.now)
89
84
  feed.updated = Time.now
90
85
  feed.generator = 'webgen - Webgen::SourceHandler::Feed'
91
- feed.icon = File.join(site_url, node.tree[node['icon']].path) if node['icon']
92
86
 
93
87
  node.feed_entries.each do |entry|
94
88
  item = FeedTools::FeedItem.new
95
89
  item.title = entry['title']
96
90
  item.link = File.join(site_url, entry.path)
97
- item.content = entry.node_info[:page].blocks['content'].render(Webgen::ContentProcessor::Context.new(:chain => [entry])).content
91
+ item.content = entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::ContentProcessor::Context.new(:chain => [entry])).content
98
92
  item.updated = entry['modified_at']
99
93
  item.published = entry['created_at'] if entry['created_at'].kind_of?(Time)
100
94
  if entry['author']
@@ -107,12 +101,12 @@ module Webgen::SourceHandler
107
101
  feed
108
102
  end
109
103
 
110
- # Check if the +node+ has meta information from any meta info node and if so, if the meta info
111
- # node in question has changed.
104
+ # Check if the any of the nodes used by this feed +node+ have changed and then mark the node as
105
+ # dirty.
112
106
  def node_changed?(node)
113
107
  return if node.node_info[:processor] != self.class.name
114
108
  entries = node.feed_entries
115
- node.dirty = true if entries.map {|n| n.absolute_lcn } != website.cache[[:sourcehandler_feed, node.node_info[:src]]] ||
109
+ node.flag(:dirty) if entries.map {|n| n.absolute_lcn } != website.cache[[:sourcehandler_feed, node.node_info[:src]]] ||
116
110
  entries.any? {|n| n.changed?}
117
111
  end
118
112
 
@@ -1,6 +1,3 @@
1
- require 'webgen/sourcehandler/base'
2
- require 'webgen/websiteaccess'
3
-
4
1
  module Webgen::SourceHandler
5
2
 
6
3
  # Handles page fragment nodes and provides utility methods for parsing HTML headers and generating
@@ -53,15 +50,13 @@ module Webgen::SourceHandler
53
50
  def create_fragment_nodes(sections, parent, path, in_menu, si = 1000 )
54
51
  sections.each do |level, id, title, sub_sections|
55
52
  node = website.blackboard.invoke(:create_nodes, parent.tree, parent.absolute_lcn,
56
- path, self) do |cn_parent, cn_path|
57
- ptemp = Webgen::Path.new('#' + id)
58
- ptemp.meta_info = cn_path.meta_info.merge(ptemp.meta_info)
59
- create_node(cn_parent, ptemp)
53
+ Webgen::Path.new('#' + id, path.source_path),
54
+ self) do |cn_parent, cn_path|
55
+ cn_path.meta_info['title'] = title
56
+ cn_path.meta_info['in_menu'] = in_menu
57
+ cn_path.meta_info['sort_info'] = si = si.succ
58
+ create_node(cn_parent, cn_path)
60
59
  end.first
61
- node['title'] = title
62
- node['in_menu'] = in_menu
63
- node['sort_info'] = si = si.succ
64
- node.node_info[:src] = path.path
65
60
  create_fragment_nodes(sub_sections, node, path, in_menu, si.succ)
66
61
  end
67
62
  end
@@ -0,0 +1,41 @@
1
+ module Webgen::SourceHandler
2
+
3
+ # This source handler should be used for handling nodes that are created during the write
4
+ # phase.
5
+ class Memory
6
+
7
+ include Webgen::WebsiteAccess
8
+ include Base
9
+
10
+ def initialize #:nodoc:
11
+ website.blackboard.add_listener(:node_flagged) do |node, *flags|
12
+ node.tree[node.node_info[:memory_source_alcn]].flag(:dirty) if node.node_info[:memory_source_alcn]
13
+ end
14
+ end
15
+
16
+ # Create a node under +parent+ for the +path+. The +source_alcn+ specified the node that creates
17
+ # this memory node when written. You have two options for providing the content for this node:
18
+ # either you set +data+ to a string (or a Webgen::Path::SourceIO object) or you provide a block
19
+ # which takes the created node as argument and return a string (or a Webgen::Path::SourceIO
20
+ # object).
21
+ def create_node(parent, path, source_alcn, data = nil)
22
+ super(parent, path) do |node|
23
+ node.node_info[:memory_source_alcn] = source_alcn
24
+ (@data ||= {})[node.absolute_lcn] = lambda { data || yield(node) }
25
+ end
26
+ end
27
+
28
+ # Return the content of the memory +node+. If the memory node was not created in this webgen
29
+ # run, it will be flagged for reinitialization (and therefore recreation).
30
+ def content(node)
31
+ if @data && @data[node.absolute_lcn]
32
+ @data[node.absolute_lcn].call
33
+ else
34
+ node.flag(:reinit)
35
+ nil
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -1,7 +1,5 @@
1
1
  require 'pathname'
2
2
  require 'yaml'
3
- require 'webgen/sourcehandler/base'
4
- require 'webgen/websiteaccess'
5
3
 
6
4
  module Webgen::SourceHandler
7
5
 
@@ -19,7 +17,7 @@ module Webgen::SourceHandler
19
17
  website.blackboard.add_listener(:before_node_created, method(:before_node_created))
20
18
  website.blackboard.add_listener(:before_node_deleted, method(:before_node_deleted))
21
19
  website.blackboard.add_listener(:after_node_created, method(:after_node_created))
22
- self.nodes ||= Set.new
20
+ self.nodes ||= []
23
21
  end
24
22
 
25
23
  # Create a meta info node from +parent+ and +path+.
@@ -30,18 +28,18 @@ module Webgen::SourceHandler
30
28
  node.node_info[mi_key] = {}
31
29
  YAML::load(page.blocks[block_name].content).each do |key, value|
32
30
  key = Pathname.new(key =~ /^\// ? key : File.join(parent.absolute_lcn, key)).cleanpath.to_s
33
- key.chomp('/') unless key == '/'
34
31
  node.node_info[mi_key][key] = value
35
32
  end if page.blocks.has_key?(block_name)
36
33
  end
37
- website.cache[[:sh_metainfo_node_mi, node.absolute_lcn]] = {
34
+
35
+ mark_all_matched_dirty(node, :no_old_data)
36
+
37
+ website.cache.permanent[[:sh_metainfo_node_mi, node.absolute_lcn]] = {
38
38
  :mi_paths => node.node_info[:mi_paths],
39
39
  :mi_alcn => node.node_info[:mi_alcn]
40
40
  }
41
41
 
42
- mark_all_matched_dirty(node)
43
-
44
- self.nodes << node
42
+ self.nodes << node unless self.nodes.include?(node)
45
43
  self.nodes = self.nodes.sort_by {|n| n.absolute_lcn}
46
44
  end
47
45
  end
@@ -59,19 +57,21 @@ module Webgen::SourceHandler
59
57
  #######
60
58
 
61
59
  # Return +true+ if any meta information for +node+ provided by +mi_node+ has changed.
62
- def meta_info_changed?(mi_node, node, use_cache = true)
63
- use_cache = false if !website.cache.old_data[[:sh_metainfo_node_mi, mi_node.absolute_lcn]]
64
- cached = website.cache[[:sh_metainfo_node_mi, mi_node.absolute_lcn]]
65
- path = website.blackboard.invoke(:source_paths)[node.node_info[:src]]
66
- (mi_node.node_info[:mi_paths].any? {|pattern, mi| path =~ pattern && (!use_cache || mi != cached[:mi_paths][pattern])} ||
67
- mi_node.node_info[:mi_alcn].any? {|pattern, mi| node =~ pattern && (!use_cache || mi != cached[:mi_alcn][pattern])})
60
+ def meta_info_changed?(mi_node, node, option = nil)
61
+ cached = website.cache.permanent[[:sh_metainfo_node_mi, mi_node.absolute_lcn]]
62
+ (mi_node.node_info[:mi_paths].any? do |pattern, mi|
63
+ Webgen::Path.match(node.node_info[:creation_path], pattern) &&
64
+ (option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_paths][pattern])
65
+ end || mi_node.node_info[:mi_alcn].any? do |pattern, mi|
66
+ node =~ pattern && (option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_alcn][pattern])
67
+ end)
68
68
  end
69
69
 
70
70
  # Mark all nodes that are matched by a path or an alcn specifcation in the meta info node +node+
71
71
  # as dirty.
72
- def mark_all_matched_dirty(node, use_cache = true)
72
+ def mark_all_matched_dirty(node, option = nil)
73
73
  node.tree.node_access[:alcn].each do |path, n|
74
- n.dirty_meta_info = true if meta_info_changed?(node, n, use_cache)
74
+ n.flag(:dirty_meta_info) if meta_info_changed?(node, n, option)
75
75
  end
76
76
  end
77
77
 
@@ -79,7 +79,7 @@ module Webgen::SourceHandler
79
79
  def before_node_created(parent, path)
80
80
  self.nodes.each do |node|
81
81
  node.node_info[:mi_paths].each do |pattern, mi|
82
- path.meta_info.update(mi) if path =~ pattern
82
+ path.meta_info.update(mi) if Webgen::Path.match(path, pattern)
83
83
  end
84
84
  end
85
85
  end
@@ -96,10 +96,9 @@ module Webgen::SourceHandler
96
96
  # Check if the +node+ has meta information from any meta info node and if so, if the meta info
97
97
  # node in question has changed.
98
98
  def node_meta_info_changed?(node)
99
- return if self.nodes.include?(node)
100
99
  self.nodes.each do |n|
101
- if n.created && meta_info_changed?(n, node)
102
- node.dirty_meta_info = true
100
+ if n.flagged(:created) && meta_info_changed?(n, node)
101
+ node.flag(:dirty_meta_info)
103
102
  return
104
103
  end
105
104
  end
@@ -108,7 +107,8 @@ module Webgen::SourceHandler
108
107
  # Delete the meta info node +node+ from the internal array.
109
108
  def before_node_deleted(node)
110
109
  return unless node.node_info[:processor] == self.class.name
111
- mark_all_matched_dirty(node, false) if !website.blackboard.invoke(:source_paths).include?(node.node_info[:src])
110
+ mark_all_matched_dirty(node, :force)
111
+ website.cache.permanent.delete([:sh_metainfo_node_mi, node.absolute_lcn])
112
112
  self.nodes.delete(node)
113
113
  end
114
114
 
@@ -1,6 +1,3 @@
1
- require 'webgen/websiteaccess'
2
- require 'webgen/sourcehandler/base'
3
-
4
1
  module Webgen::SourceHandler
5
2
 
6
3
  # Source handler for handling content files in Webgen Page Format.
@@ -20,24 +17,8 @@ module Webgen::SourceHandler
20
17
  path.ext = 'html' if path.ext == 'page'
21
18
 
22
19
  super(parent, path) do |node|
23
- website.cache[[:sh_page_node_mi, node.absolute_lcn]] = node.meta_info.dup
24
-
20
+ node.node_info[:sh_page_node_mi] = Webgen::Page.meta_info_from_data(path.io.data)
25
21
  node.node_info[:page] = page
26
- tmp_logger = website.logger
27
- website.logger = nil # disabling logging whiling creating fragment nodes
28
-
29
- website.cache.permanent[:page_sections] ||= {}
30
- sections = if path.changed? || !website.cache.permanent[:page_sections][node.absolute_lcn]
31
- website.blackboard.invoke(:parse_html_headers, render_node(node, 'content', []))
32
- else
33
- website.cache.permanent[:page_sections][node.absolute_lcn]
34
- end
35
- website.cache.permanent[:page_sections][node.absolute_lcn] = sections
36
- website.blackboard.invoke(:create_fragment_nodes,
37
- sections,
38
- node, website.blackboard.invoke(:source_paths)[path.path],
39
- node.meta_info['fragments_in_menu'])
40
- website.logger = tmp_logger
41
22
  end
42
23
  end
43
24
 
@@ -63,13 +44,12 @@ module Webgen::SourceHandler
63
44
 
64
45
  # Checks if the meta information provided by the file in Webgen Page Format changed.
65
46
  def meta_info_changed?(node)
66
- return if !node.created || node.node_info[:processor] != self.class.name
67
- ckey = [:sh_page_node_mi, node.absolute_lcn]
68
- old_mi = website.cache.old_data[ckey]
69
- old_mi.delete('modified_at') if old_mi
70
- new_mi = website.cache.new_data[ckey]
71
- new_mi.delete('modified_at')
72
- node.dirty_meta_info = true if old_mi != new_mi
47
+ path = website.blackboard.invoke(:source_paths)[node.node_info[:src]]
48
+ return if node.node_info[:processor] != self.class.name || !path.changed?
49
+
50
+ old_mi = node.node_info[:sh_page_node_mi]
51
+ new_mi = Webgen::Page.meta_info_from_data(path.io.data)
52
+ node.flag(:dirty_meta_info) if old_mi && old_mi != new_mi
73
53
  end
74
54
 
75
55
  end
@@ -1,5 +1,3 @@
1
- require 'webgen/websiteaccess'
2
- require 'webgen/sourcehandler/base'
3
1
  require 'uri'
4
2
  require 'time'
5
3
 
@@ -1,7 +1,3 @@
1
- require 'webgen/websiteaccess'
2
- require 'webgen/loggable'
3
- require 'webgen/sourcehandler/base'
4
-
5
1
  module Webgen::SourceHandler
6
2
 
7
3
  # Source handler for handling template files in Webgen Page Format.