gettalong-webgen 0.5.8.20090507 → 0.5.9.20090620

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/Rakefile +5 -6
  2. data/data/webgen/passive_sources/images/generated_by_webgen.png +0 -0
  3. data/data/webgen/passive_sources/images/webgen_logo.png +0 -0
  4. data/data/webgen/passive_sources/templates/atom_feed.template +38 -0
  5. data/data/webgen/passive_sources/templates/rss_feed.template +28 -0
  6. data/data/webgen/resources.yaml +2 -1
  7. data/doc/contentprocessor/builder.page +1 -1
  8. data/doc/contentprocessor/erb.page +5 -2
  9. data/doc/contentprocessor/erubis.page +2 -2
  10. data/doc/extensions.page +1 -1
  11. data/doc/manual.page +56 -26
  12. data/doc/reference_configuration.page +36 -1
  13. data/doc/reference_website_styles.page +1 -1
  14. data/doc/sourcehandler/feed.page +6 -11
  15. data/doc/tag/includefile.page +1 -1
  16. data/lib/webgen/cli/apply_command.rb +1 -1
  17. data/lib/webgen/cli/utils.rb +2 -2
  18. data/lib/webgen/common.rb +0 -9
  19. data/lib/webgen/contentprocessor/blocks.rb +60 -36
  20. data/lib/webgen/contentprocessor/builder.rb +2 -2
  21. data/lib/webgen/contentprocessor/erb.rb +3 -2
  22. data/lib/webgen/contentprocessor/erubis.rb +2 -2
  23. data/lib/webgen/contentprocessor/haml.rb +2 -2
  24. data/lib/webgen/contentprocessor/maruku.rb +1 -1
  25. data/lib/webgen/contentprocessor/sass.rb +2 -2
  26. data/lib/webgen/contentprocessor/tags.rb +25 -11
  27. data/lib/webgen/context.rb +4 -1
  28. data/lib/webgen/context/render.rb +32 -0
  29. data/lib/webgen/context/tags.rb +20 -0
  30. data/lib/webgen/default_config.rb +4 -1
  31. data/lib/webgen/deprecated.rb +37 -4
  32. data/lib/webgen/node.rb +37 -38
  33. data/lib/webgen/path.rb +151 -54
  34. data/lib/webgen/source.rb +6 -6
  35. data/lib/webgen/source/stacked.rb +13 -5
  36. data/lib/webgen/sourcehandler.rb +71 -45
  37. data/lib/webgen/sourcehandler/base.rb +51 -21
  38. data/lib/webgen/sourcehandler/copy.rb +4 -4
  39. data/lib/webgen/sourcehandler/directory.rb +3 -9
  40. data/lib/webgen/sourcehandler/feed.rb +23 -49
  41. data/lib/webgen/sourcehandler/fragment.rb +10 -8
  42. data/lib/webgen/sourcehandler/memory.rb +9 -10
  43. data/lib/webgen/sourcehandler/metainfo.rb +9 -9
  44. data/lib/webgen/sourcehandler/page.rb +5 -5
  45. data/lib/webgen/sourcehandler/sitemap.rb +3 -3
  46. data/lib/webgen/sourcehandler/template.rb +6 -6
  47. data/lib/webgen/sourcehandler/virtual.rb +19 -17
  48. data/lib/webgen/tag/base.rb +34 -26
  49. data/lib/webgen/tag/breadcrumbtrail.rb +3 -3
  50. data/lib/webgen/tag/executecommand.rb +3 -3
  51. data/lib/webgen/tag/langbar.rb +2 -2
  52. data/lib/webgen/tag/link.rb +3 -3
  53. data/lib/webgen/tag/menu.rb +2 -2
  54. data/lib/webgen/tag/metainfo.rb +1 -1
  55. data/lib/webgen/tag/relocatable.rb +17 -21
  56. data/lib/webgen/tag/tikz.rb +5 -6
  57. data/lib/webgen/tree.rb +7 -7
  58. data/lib/webgen/version.rb +1 -1
  59. data/lib/webgen/website.rb +4 -2
  60. data/misc/default.css +8 -2
  61. data/misc/default.template +2 -2
  62. data/misc/logo.svg +313 -0
  63. data/misc/style.page +1 -1
  64. data/test/helper.rb +2 -2
  65. data/test/test_common_sitemap.rb +1 -1
  66. data/test/test_contentprocessor_blocks.rb +12 -4
  67. data/test/test_contentprocessor_builder.rb +2 -1
  68. data/test/test_contentprocessor_erb.rb +2 -1
  69. data/test/test_contentprocessor_erubis.rb +1 -1
  70. data/test/test_contentprocessor_fragments.rb +12 -11
  71. data/test/test_contentprocessor_haml.rb +2 -1
  72. data/test/test_contentprocessor_maruku.rb +1 -0
  73. data/test/test_contentprocessor_rdiscount.rb +1 -0
  74. data/test/test_contentprocessor_rdoc.rb +1 -0
  75. data/test/test_contentprocessor_sass.rb +1 -0
  76. data/test/test_contentprocessor_tags.rb +13 -0
  77. data/test/test_context.rb +28 -0
  78. data/test/test_node.rb +40 -20
  79. data/test/test_path.rb +106 -65
  80. data/test/test_source_filesystem.rb +1 -1
  81. data/test/test_source_stacked.rb +19 -6
  82. data/test/test_sourcehandler_base.rb +53 -47
  83. data/test/test_sourcehandler_copy.rb +6 -6
  84. data/test/test_sourcehandler_directory.rb +8 -12
  85. data/test/test_sourcehandler_feed.rb +10 -6
  86. data/test/test_sourcehandler_fragment.rb +6 -5
  87. data/test/test_sourcehandler_main.rb +39 -0
  88. data/test/test_sourcehandler_memory.rb +4 -4
  89. data/test/test_sourcehandler_metainfo.rb +10 -10
  90. data/test/test_sourcehandler_page.rb +9 -9
  91. data/test/test_sourcehandler_sitemap.rb +4 -4
  92. data/test/test_sourcehandler_template.rb +14 -14
  93. data/test/test_sourcehandler_virtual.rb +9 -5
  94. data/test/test_tag_base.rb +2 -2
  95. data/test/test_tag_executecommand.rb +1 -1
  96. data/test/test_tag_link.rb +4 -3
  97. data/test/test_tag_menu.rb +15 -15
  98. data/test/test_tag_metainfo.rb +1 -0
  99. data/test/test_tag_relocatable.rb +2 -1
  100. data/test/test_tag_tikz.rb +3 -3
  101. data/test/test_tree.rb +8 -8
  102. data/test/test_website.rb +15 -0
  103. metadata +14 -14
  104. data/test/test_common.rb +0 -18
@@ -19,7 +19,7 @@ module Webgen::SourceHandler
19
19
  #
20
20
  # The paths that are handled by a source handler are specified via path patterns (see
21
21
  # below). During a webgen run the #create_node method for each source paths that matches a
22
- # specified path pattern is called. And when it is time to write out the node, the the #content
22
+ # specified path pattern is called. And when it is time to write out the node, the #content
23
23
  # method is called to retrieve the rendered content.
24
24
  #
25
25
  # A source handler must not take any parameters on initialization and when this module is not
@@ -35,6 +35,7 @@ module Webgen::SourceHandler
35
35
  # It also provides other utility methods:
36
36
  # * #page_from_path
37
37
  # * #content
38
+ # * #parent_node
38
39
  #
39
40
  # == Nodes Created for Paths
40
41
  #
@@ -109,10 +110,11 @@ module Webgen::SourceHandler
109
110
  # class SimpleCopy
110
111
  #
111
112
  # include Webgen::SourceHandler::Base
113
+ # include Webgen::WebsiteAccess
112
114
  #
113
- # def create_node(parent, path)
115
+ # def create_node(path)
114
116
  # path.ext += '.copied'
115
- # super(parent, path)
117
+ # super(path)
116
118
  # end
117
119
  #
118
120
  # def content(node)
@@ -181,9 +183,7 @@ module Webgen::SourceHandler
181
183
  if OutputPathHelpers.public_instance_methods(false).map(&:to_s).include?(method)
182
184
  name = send(method, parent, path, use_lang_part)
183
185
  name += '/' if path.path =~ /\/$/ && name !~ /\/$/
184
- if (node = node_exists?(parent, path, name)) && node.lang == path.meta_info['lang']
185
- name = node.path
186
- elsif node
186
+ if (node = node_exists?(path, name)) && node.lang != path.meta_info['lang']
187
187
  name = send(method, parent, path, (path.meta_info['lang'].nil? ? false : true))
188
188
  name += '/' if path.path =~ /\/$/ && name !~ /\/$/
189
189
  end
@@ -193,24 +193,38 @@ module Webgen::SourceHandler
193
193
  end
194
194
  end
195
195
 
196
- # Check if the node alcn and output path which would be created by #create_node exists. The
196
+ # Check if the node alcn and output path which would be created by #create_node exist. The
197
197
  # +output_path+ to check for can individually be set.
198
- def node_exists?(parent, path, output_path = self.output_path(parent, path))
199
- parent.tree[Webgen::Node.absolute_name(parent, path.lcn, :alcn)] || (!path.meta_info['no_output'] && parent.tree[output_path, :path])
198
+ def node_exists?(path, output_path = self.output_path(parent_node(path), path))
199
+ Webgen::WebsiteAccess.website.tree[path.alcn] || (!path.meta_info['no_output'] && Webgen::WebsiteAccess.website.tree[output_path, :path])
200
200
  end
201
201
 
202
- # Create a node under +parent+ from +path+ if it does not already exists or needs to be
203
- # re-initialized. The found node or the newly created node is returned afterwards. +nil+ is
204
- # returned if no node can be created (e.g. when <tt>path.meta_info['draft']</tt> is set). Some
205
- # additional node information like <tt>:src</tt> and <tt>:processor</tt> is set and the meta
206
- # information is checked for validness. The created/re-initialized node is yielded if a block is
207
- # given.
208
- def create_node(parent, path, output_path = self.output_path(parent, path))
202
+ # Create a node from +path+ if it does not already exists or re-initalize an already existing
203
+ # node. The found node or the newly created node is returned afterwards. +nil+ is returned if no
204
+ # node can be created (e.g. when <tt>path.meta_info['draft']</tt> is set).
205
+ #
206
+ # The +options+ parameter can be used for providing the optional parameters:
207
+ #
208
+ # [<tt>:parent</tt>] The parent node under which the new node should be created. If this is not
209
+ # specified (the usual case), the parent node is determined by the
210
+ # #parent_node method.
211
+ #
212
+ # [<tt>:output_path</tt>] The output path that should be used for the node. If this is not
213
+ # specified (the usual case), the output path is determined via the
214
+ # #output_path method.
215
+ #
216
+ # Some additional node information like <tt>:src</tt> and <tt>:processor</tt> is set and the
217
+ # meta information is checked for validness. The created/re-initialized node is yielded if a
218
+ # block is given.
219
+ def create_node(path, options = {})
209
220
  return nil if path.meta_info['draft']
210
- node = node_exists?(parent, path, output_path)
221
+ parent = options[:parent] || parent_node(path)
222
+ output_path = options[:output_path] || self.output_path(parent, path)
223
+ node = node_exists?(path, output_path)
224
+
211
225
  if node && (node.node_info[:src] != path.source_path || node.node_info[:processor] != self.class.name)
212
- log(:warn) { "Node already exists: source = #{path.source_path} | path = #{node.path} | alcn = #{node.absolute_lcn}"}
213
- return node
226
+ log(:warn) { "Node already exists: source = #{path.source_path} | path = #{node.path} | alcn = #{node.alcn}"}
227
+ return node #TODO: think! should nil be returned?
214
228
  elsif !node
215
229
  node = Webgen::Node.new(parent, output_path, path.cn, path.meta_info)
216
230
  elsif node.flagged?(:reinit)
@@ -218,7 +232,11 @@ module Webgen::SourceHandler
218
232
  else
219
233
  return node
220
234
  end
221
- node['modified_at'] = Time.now unless node['modified_at'].kind_of?(Time)
235
+
236
+ if !node['modified_at'].kind_of?(Time)
237
+ log(:warn) { "Meta information 'modified_at' set to current time in <#{node.alcn}> since its value '#{node['modified_at']}' was of type #{node['modified_at'].class}" } unless node['modified_at'].nil?
238
+ node['modified_at'] = Time.now
239
+ end
222
240
  node.node_info[:src] = path.source_path
223
241
  node.node_info[:creation_path] = path.path
224
242
  node.node_info[:processor] = self.class.name
@@ -226,7 +244,10 @@ module Webgen::SourceHandler
226
244
  node
227
245
  end
228
246
 
229
- # Return the content of the given +node+. This default +content+ method just returns +nil+.
247
+ # Return the content of the given +node+. If the return value is not +nil+ then the node gets
248
+ # written, otherwise it is ignored.
249
+ #
250
+ # This default +content+ method just returns +nil+.
230
251
  def content(node)
231
252
  nil
232
253
  end
@@ -243,6 +264,15 @@ module Webgen::SourceHandler
243
264
  page
244
265
  end
245
266
 
267
+ # Return the parent node for the given +path+.
268
+ def parent_node(path)
269
+ parent_dir = (path.parent_path == '' ? '' : Webgen::Path.new(path.parent_path).alcn)
270
+ if !(parent = Webgen::WebsiteAccess.website.tree[parent_dir])
271
+ raise "The needed parent path <#{parent_dir}> for <#{path.path}> does not exist"
272
+ end
273
+ parent
274
+ end
275
+
246
276
  end
247
277
 
248
278
  end
@@ -9,9 +9,9 @@ module Webgen::SourceHandler
9
9
  include Webgen::WebsiteAccess
10
10
  include Base
11
11
 
12
- # Create the node for +parent+ and +path+. If the +path+ has the name of a content processor as
13
- # the first part in the extension, it is preprocessed.
14
- def create_node(parent, path)
12
+ # Create the node for +path+. If the +path+ has the name of a content processor as the first
13
+ # part in the extension, it is preprocessed.
14
+ def create_node(path)
15
15
  if path.ext.index('.')
16
16
  processor, *rest = path.ext.split('.')
17
17
  if website.blackboard.invoke(:content_processor_names).include?(processor)
@@ -20,7 +20,7 @@ module Webgen::SourceHandler
20
20
  processor = nil
21
21
  end
22
22
  end
23
- super(parent, path) do |node|
23
+ super(path) do |node|
24
24
  node.node_info[:preprocessor] = processor
25
25
  end
26
26
  end
@@ -16,21 +16,15 @@ module Webgen::SourceHandler
16
16
  # ignored). The path +path+ is the path that lead to the creation of these directories.
17
17
  def create_directories(parent, dirname, path)
18
18
  dirname.sub(/^\//, '').split('/').each do |dir|
19
- dir_path = Webgen::Path.new(File.join(parent.absolute_lcn, dir, '/'), path)
20
- nodes = website.blackboard.invoke(:create_nodes, parent.tree, parent.absolute_lcn,
21
- dir_path, self) do |dir_parent, dir_path|
22
- node_exists?(dir_parent, dir_path) || create_node(dir_parent, dir_path)
19
+ dir_path = Webgen::Path.new(File.join(parent.alcn, dir, '/'), path)
20
+ nodes = website.blackboard.invoke(:create_nodes, dir_path, self) do |dir_path|
21
+ node_exists?(dir_path) || create_node(dir_path)
23
22
  end
24
23
  parent = nodes.first
25
24
  end
26
25
  parent
27
26
  end
28
27
 
29
- # Return an empty string to signal that the directory should be written to the output.
30
- def content(node)
31
- ''
32
- end
33
-
34
28
  end
35
29
 
36
30
  end
@@ -15,10 +15,10 @@ module Webgen::SourceHandler
15
15
  website.blackboard.add_listener(:node_changed?, method(:node_changed?))
16
16
  end
17
17
 
18
- # Create atom and/or rss feed files from +parent+ and +path+.
19
- def create_node(parent, path)
18
+ # Create atom and/or rss feed files from +path+.
19
+ def create_node(path)
20
20
  page = page_from_path(path)
21
- path.meta_info['link'] ||= parent.absolute_lcn
21
+ path.meta_info['link'] ||= path.parent_path
22
22
 
23
23
  if MANDATORY_INFOS.any? {|t| path.meta_info[t].nil?}
24
24
  raise "One of #{MANDATORY_INFOS.join('/')} information missing for feed <#{path}>"
@@ -26,7 +26,7 @@ module Webgen::SourceHandler
26
26
 
27
27
  create_feed_node = lambda do |type|
28
28
  path.ext = type
29
- super(parent, path) do |node|
29
+ super(path) do |node|
30
30
  node.node_info[:feed] = page
31
31
  node.node_info[:feed_type] = type
32
32
  end
@@ -41,74 +41,48 @@ module Webgen::SourceHandler
41
41
 
42
42
  # Return the rendered feed represented by +node+.
43
43
  def content(node)
44
- website.cache[[:sourcehandler_feed, node.node_info[:src]]] = feed_entries(node).map {|n| n.absolute_lcn}
44
+ website.cache[[:sourcehandler_feed, node.node_info[:src]]] = feed_entries(node).map {|n| n.alcn}
45
+
45
46
  block_name = node.node_info[:feed_type] + '_template'
46
47
  if node.node_info[:feed].blocks.has_key?(block_name)
47
- node.node_info[:feed].blocks[block_name].
48
- render(Webgen::Context.new(:chain => [node])).content
48
+ node.node_info[:feed].blocks[block_name].render(Webgen::Context.new(:chain => [node])).content
49
49
  else
50
- feed = (website.cache.volatile[:sourcehandler_feed] ||= {})[node.node_info[:src]] ||= build_feed_for(node)
51
- feed.build_xml(node.node_info[:feed_type], (node.node_info[:feed_type] == 'rss' ? node['rss_version'] || 2.0 : nil))
50
+ chain = [node.resolve("/templates/#{node.node_info[:feed_type]}_feed.template"), node]
51
+ node.node_info[:used_nodes] << chain.first.alcn
52
+ chain.first.node_info[:page].blocks['content'].render(Webgen::Context.new(:chain => chain)).content
52
53
  end
53
54
  end
54
55
 
55
- # Helper method for returning the entries for the feed node +node+.
56
+ # Return the entries for the feed +node+.
56
57
  def feed_entries(node)
57
58
  nr_items = (node['number_of_entries'].to_i == 0 ? 10 : node['number_of_entries'].to_i)
58
- patterns = [node['entries']].flatten.map {|pat| Webgen::Common.absolute_path(pat, node.parent.absolute_lcn)}
59
+ patterns = [node['entries']].flatten.map {|pat| Webgen::Path.make_absolute(node.parent.alcn, pat)}
59
60
 
60
61
  node.tree.node_access[:alcn].values.
61
62
  select {|node| patterns.any? {|pat| node =~ pat} && node.node_info[:page]}.
62
63
  sort {|a,b| a['modified_at'] <=> b['modified_at']}[0, nr_items]
63
64
  end
64
65
 
66
+ # Return the feed link URL for the feed +node+.
67
+ def feed_link(node)
68
+ Webgen::Node.url(File.join(node['site_url'], node.tree[node['link']].path), false)
69
+ end
70
+
71
+ # Return the content of an +entry+ of the feed +node+.
72
+ def entry_content(node, entry)
73
+ entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::Context.new(:chain => [entry])).content
74
+ end
75
+
65
76
  #######
66
77
  private
67
78
  #######
68
79
 
69
- # Return the populated FeedTools::Feed object for +node+.
70
- def build_feed_for(node)
71
- require 'feed_tools'
72
- require 'time'
73
-
74
- site_url = node['site_url']
75
-
76
- feed = FeedTools::Feed.new
77
- feed.title = node['title']
78
- feed.description = node['description']
79
- feed.author = node['author']
80
- feed.author.url = node['author_url']
81
- feed.base_uri = site_url
82
- feed.link = File.join(site_url, node.tree[node['link']].path)
83
- feed.id = feed.link
84
-
85
- feed.published = (node['created_at'].kind_of?(Time) ? node['created_at'] : Time.now)
86
- feed.updated = Time.now
87
- feed.generator = 'webgen - Webgen::SourceHandler::Feed'
88
-
89
- node.feed_entries.each do |entry|
90
- item = FeedTools::FeedItem.new
91
- item.title = entry['title']
92
- item.link = File.join(site_url, entry.path)
93
- item.content = entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::Context.new(:chain => [entry])).content
94
- item.updated = entry['modified_at']
95
- item.published = entry['created_at'] if entry['created_at'].kind_of?(Time)
96
- if entry['author']
97
- item.author = entry['author']
98
- item.author.url = entry['author_url']
99
- end
100
- item.id = item.link
101
- feed << item
102
- end
103
- feed
104
- end
105
-
106
80
  # Check if the any of the nodes used by this feed +node+ have changed and then mark the node as
107
81
  # dirty.
108
82
  def node_changed?(node)
109
83
  return if node.node_info[:processor] != self.class.name
110
84
  entries = node.feed_entries
111
- node.flag(:dirty) if entries.map {|n| n.absolute_lcn } != website.cache[[:sourcehandler_feed, node.node_info[:src]]] ||
85
+ node.flag(:dirty) if entries.map {|n| n.alcn } != website.cache[[:sourcehandler_feed, node.node_info[:src]]] ||
112
86
  entries.any? {|n| n.changed?}
113
87
  end
114
88
 
@@ -46,18 +46,20 @@ module Webgen::SourceHandler
46
46
  end
47
47
 
48
48
  # Create nested fragment nodes under +parent+ from +sections+ (which can be created using
49
- # +parse_html_headers+). +path+ is the source path that defines the fragments. The meta
50
- # information +in_menu+ of the fragment nodes is set to the parameter +in_menu+ and the meta
51
- # info +sort_info+ is calculated from the base +si+ value.
52
- def create_fragment_nodes(sections, parent, path, in_menu, si = 1000 )
49
+ # +parse_html_headers+). +path+ is the source path that defines the fragments (which is not the
50
+ # same as the creation path for +parent+). The meta information +in_menu+ of the fragment nodes
51
+ # is set to the parameter +in_menu+ and the meta info +sort_info+ is calculated from the base
52
+ # +si+ value.
53
+ def create_fragment_nodes(sections, parent, path, in_menu, si = 1000)
53
54
  sections.each do |level, id, title, sub_sections|
54
- node = website.blackboard.invoke(:create_nodes, parent.tree, parent.absolute_lcn,
55
- Webgen::Path.new('#' + id, path.source_path),
56
- self) do |cn_parent, cn_path|
55
+ fragment_path = parent.alcn.sub(/#.*$/, '') + '#' + id
56
+ node = website.blackboard.invoke(:create_nodes,
57
+ Webgen::Path.new(fragment_path, path.source_path),
58
+ self) do |cn_path|
57
59
  cn_path.meta_info['title'] = title
58
60
  cn_path.meta_info['in_menu'] = in_menu
59
61
  cn_path.meta_info['sort_info'] = si = si.succ
60
- create_node(cn_parent, cn_path)
62
+ create_node(cn_path, :parent => parent)
61
63
  end.first
62
64
  create_fragment_nodes(sub_sections, node, path, in_menu, si.succ)
63
65
  end
@@ -15,23 +15,22 @@ module Webgen::SourceHandler
15
15
  end
16
16
  end
17
17
 
18
- # Create a node under +parent+ for the +path+. The +source_alcn+ specified the node that creates
19
- # this memory node when written. You have two options for providing the content for this node:
20
- # either you set +data+ to a string (or a Webgen::Path::SourceIO object) or you provide a block
21
- # which takes the created node as argument and return a string (or a Webgen::Path::SourceIO
22
- # object).
23
- def create_node(parent, path, source_alcn, data = nil)
24
- super(parent, path) do |node|
18
+ # Create a node for the +path+. The +source_alcn+ specifies the node that creates this memory
19
+ # node when written. You have two options for providing the content for this node: either you
20
+ # set +data+ to a string (or a Webgen::Path::SourceIO object) or you provide a block which takes
21
+ # the created node as argument and returns a string (or a Webgen::Path::SourceIO object).
22
+ def create_node(path, source_alcn, data = nil)
23
+ super(path) do |node|
25
24
  node.node_info[:memory_source_alcn] = source_alcn
26
- (@data ||= {})[node.absolute_lcn] = lambda { data || yield(node) }
25
+ (@data ||= {})[node.alcn] = lambda { data || yield(node) }
27
26
  end
28
27
  end
29
28
 
30
29
  # Return the content of the memory +node+. If the memory node was not created in this webgen
31
30
  # run, it will be flagged for reinitialization (and therefore recreation).
32
31
  def content(node)
33
- if @data && @data[node.absolute_lcn]
34
- @data[node.absolute_lcn].call
32
+ if @data && @data[node.alcn]
33
+ @data[node.alcn].call
35
34
  else
36
35
  node.flag(:reinit)
37
36
  nil
@@ -22,15 +22,15 @@ module Webgen::SourceHandler
22
22
  self.nodes ||= []
23
23
  end
24
24
 
25
- # Create a meta info node from +parent+ and +path+.
26
- def create_node(parent, path)
25
+ # Create a meta info node from +path+.
26
+ def create_node(path)
27
27
  page = page_from_path(path)
28
- super(parent, path) do |node|
28
+ super(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
31
  if page.blocks.has_key?(block_name) && (data = YAML::load(page.blocks[block_name].content))
32
32
  data.each do |key, value|
33
- key = Webgen::Common.absolute_path(key, parent.absolute_lcn)
33
+ key = Webgen::Path.make_absolute(path.parent_path, key)
34
34
  node.node_info[mi_key][key] = value
35
35
  end
36
36
  end
@@ -38,13 +38,13 @@ module Webgen::SourceHandler
38
38
 
39
39
  mark_all_matched_dirty(node, :no_old_data)
40
40
 
41
- website.cache.permanent[[:sh_metainfo_node_mi, node.absolute_lcn]] = {
41
+ website.cache.permanent[[:sh_metainfo_node_mi, node.alcn]] = {
42
42
  :mi_paths => node.node_info[:mi_paths],
43
43
  :mi_alcn => node.node_info[:mi_alcn]
44
44
  }
45
45
 
46
46
  self.nodes << node unless self.nodes.include?(node)
47
- self.nodes = self.nodes.sort_by {|n| n.absolute_lcn}
47
+ self.nodes = self.nodes.sort_by {|n| n.alcn}
48
48
  end
49
49
  end
50
50
 
@@ -62,7 +62,7 @@ module Webgen::SourceHandler
62
62
 
63
63
  # Return +true+ if any meta information for +node+ provided by +mi_node+ has changed.
64
64
  def meta_info_changed?(mi_node, node, option = nil)
65
- cached = website.cache.permanent[[:sh_metainfo_node_mi, mi_node.absolute_lcn]]
65
+ cached = website.cache.permanent[[:sh_metainfo_node_mi, mi_node.alcn]]
66
66
  (mi_node.node_info[:mi_paths].any? do |pattern, mi|
67
67
  Webgen::Path.match(node.node_info[:creation_path], pattern) &&
68
68
  (option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_paths][pattern])
@@ -87,7 +87,7 @@ module Webgen::SourceHandler
87
87
  end
88
88
 
89
89
  # Update the meta info of matched path before a node is created.
90
- def before_node_created(parent, path)
90
+ def before_node_created(path)
91
91
  self.nodes.each do |node|
92
92
  node.node_info[:mi_paths].each do |pattern, mi|
93
93
  path.meta_info.update(mi) if Webgen::Path.match(path, pattern)
@@ -119,7 +119,7 @@ module Webgen::SourceHandler
119
119
  def before_node_deleted(node)
120
120
  return unless node.node_info[:processor] == self.class.name
121
121
  mark_all_matched_dirty(node, :force)
122
- website.cache.permanent.delete([:sh_metainfo_node_mi, node.absolute_lcn])
122
+ website.cache.permanent.delete([:sh_metainfo_node_mi, node.alcn])
123
123
  self.nodes.delete(node)
124
124
  end
125
125
 
@@ -12,13 +12,13 @@ module Webgen::SourceHandler
12
12
  website.blackboard.add_listener(:node_meta_info_changed?, method(:meta_info_changed?))
13
13
  end
14
14
 
15
- # Create a page file from +parent+ and +path+.
16
- def create_node(parent, path)
15
+ # Create a page file from +path+.
16
+ def create_node(path)
17
17
  page = page_from_path(path)
18
18
  path.meta_info['lang'] ||= website.config['website.lang']
19
19
  path.ext = 'html' if path.ext == 'page'
20
20
 
21
- super(parent, path) do |node|
21
+ super(path) do |node|
22
22
  node.node_info[:sh_page_node_mi] = Webgen::Page.meta_info_from_data(path.io.data)
23
23
  node.node_info[:page] = page
24
24
  end
@@ -31,11 +31,11 @@ module Webgen::SourceHandler
31
31
  chain = [templates, node].flatten
32
32
 
33
33
  if chain.first.node_info[:page].blocks.has_key?(block_name)
34
- node.node_info[:used_nodes] << chain.first.absolute_lcn
34
+ node.node_info[:used_nodes] << chain.first.alcn
35
35
  context = chain.first.node_info[:page].blocks[block_name].render(Webgen::Context.new(:chain => chain))
36
36
  context.content
37
37
  else
38
- raise "Error rendering <#{node.absolute_lcn}>: no block named '#{block_name}' in <#{chain.first.absolute_lcn}>"
38
+ raise "Error rendering <#{node.alcn}>: no block named '#{block_name}' in <#{chain.first.alcn}>"
39
39
  end
40
40
  end
41
41
  alias_method :content, :render_node