webgen 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/Rakefile +16 -5
  2. data/VERSION +1 -1
  3. data/data/webgen/webgui/controller/main.rb +129 -0
  4. data/data/webgen/webgui/overrides/win32console.rb +0 -0
  5. data/data/webgen/webgui/public/css/jquery.autocomplete.css +50 -0
  6. data/data/webgen/webgui/public/css/ramaze_error.css +90 -0
  7. data/data/webgen/webgui/public/css/style.css +55 -0
  8. data/data/webgen/webgui/public/img/headerbg.jpg +0 -0
  9. data/data/webgen/webgui/public/img/webgen_logo.png +0 -0
  10. data/data/webgen/webgui/public/js/jquery.autocomplete.js +15 -0
  11. data/data/webgen/webgui/public/js/jquery.js +32 -0
  12. data/data/webgen/webgui/view/create_website.xhtml +22 -0
  13. data/data/webgen/webgui/view/error.xhtml +64 -0
  14. data/data/webgen/webgui/view/index.xhtml +22 -0
  15. data/data/webgen/webgui/view/manage_website.xhtml +18 -0
  16. data/data/webgen/webgui/view/page.xhtml +40 -0
  17. data/doc/extensions.page +1 -2
  18. data/doc/getting_started.page +7 -3
  19. data/doc/manual.page +75 -29
  20. data/lib/webgen/cache.rb +17 -9
  21. data/lib/webgen/cli.rb +3 -1
  22. data/lib/webgen/cli/utils.rb +5 -1
  23. data/lib/webgen/cli/webgui_command.rb +48 -0
  24. data/lib/webgen/node.rb +15 -1
  25. data/lib/webgen/output.rb +8 -2
  26. data/lib/webgen/output/filesystem.rb +7 -1
  27. data/lib/webgen/path.rb +7 -4
  28. data/lib/webgen/source/filesystem.rb +4 -2
  29. data/lib/webgen/source/resource.rb +12 -3
  30. data/lib/webgen/sourcehandler.rb +27 -10
  31. data/lib/webgen/sourcehandler/fragment.rb +11 -6
  32. data/lib/webgen/sourcehandler/metainfo.rb +2 -1
  33. data/lib/webgen/sourcehandler/page.rb +21 -1
  34. data/lib/webgen/tag/breadcrumbtrail.rb +2 -2
  35. data/lib/webgen/tag/executecommand.rb +4 -1
  36. data/lib/webgen/tag/includefile.rb +1 -1
  37. data/lib/webgen/tag/langbar.rb +32 -4
  38. data/lib/webgen/tag/menu.rb +13 -8
  39. data/lib/webgen/version.rb +1 -1
  40. data/lib/webgen/website.rb +3 -1
  41. data/lib/webgen/websitemanager.rb +1 -0
  42. data/man/man1/webgen.1 +3 -0
  43. data/misc/default.template +1 -1
  44. data/test/test_cache.rb +5 -5
  45. data/test/test_node.rb +20 -1
  46. data/test/test_output_filesystem.rb +2 -1
  47. data/test/test_page.rb +12 -0
  48. data/test/test_path.rb +14 -0
  49. data/test/test_source_filesystem.rb +1 -1
  50. data/test/test_source_resource.rb +5 -0
  51. data/test/test_sourcehandler_fragment.rb +9 -4
  52. data/test/test_sourcehandler_page.rb +12 -13
  53. data/test/test_sourcehandler_template.rb +1 -2
  54. data/test/test_tag_breadcrumbtrail.rb +3 -2
  55. data/test/test_tag_executecommand.rb +0 -1
  56. data/test/test_tag_langbar.rb +7 -0
  57. data/test/test_tag_menu.rb +1 -1
  58. metadata +65 -2
@@ -15,6 +15,8 @@ module Webgen
15
15
  # <tt>write(path, data, type)</tt>::
16
16
  # Write the data to the given output path. The parameter +type+ specifies the type of the
17
17
  # to be written path: +:file+ or +:directory+.
18
+ # <tt>read(path)</tt>:
19
+ # Return the content of the given path if it exists or raise an error otherwise.
18
20
  #
19
21
  module Output
20
22
 
@@ -22,8 +24,12 @@ module Webgen
22
24
 
23
25
  # Returns an instance of the configured output class.
24
26
  def self.instance
25
- klass, *args = WebsiteAccess.website.config['output']
26
- Object.constant(klass).new(*args)
27
+ classes = (WebsiteAccess.website.cache.volatile[:classes] ||= {})
28
+ unless classes.has_key?(:output_instance)
29
+ klass, *args = WebsiteAccess.website.config['output']
30
+ classes[:output_instance] = Object.constant(klass).new(*args)
31
+ end
32
+ classes[:output_instance]
27
33
  end
28
34
 
29
35
  end
@@ -2,7 +2,8 @@ require 'fileutils'
2
2
 
3
3
  module Webgen::Output
4
4
 
5
- # This class is used to write rendered nodes out to the file system.
5
+ # This class uses the file systems as output device. On initialization a +root+ path is set and
6
+ # all other operations are taken relative to this root path.
6
7
  class FileSystem
7
8
 
8
9
  include Webgen::WebsiteAccess
@@ -56,6 +57,11 @@ module Webgen::Output
56
57
  end
57
58
  end
58
59
 
60
+ # Return the content of the given +path+.
61
+ def read(path)
62
+ File.open(File.join(@root, path), 'rb') {|f| f.read}
63
+ end
64
+
59
65
  end
60
66
 
61
67
  end
@@ -63,11 +63,14 @@ module Webgen
63
63
  analyse(path)
64
64
  end
65
65
 
66
- # Mount this path at the mount point +mp+ and return the new path object.
67
- def mount_at(mp)
66
+ # Mount this path at the mount point +mp+ optionally stripping +prefix+ from the path and return
67
+ # the new path object.
68
+ def mount_at(mp, prefix = nil)
68
69
  temp = dup
69
- temp.path = File.join(mp, @path)
70
- if @path == '/'
70
+ temp.path = temp.path.sub(/^#{Regexp.escape(prefix.chomp("/"))}/, '') if prefix #"
71
+ reanalyse = (@path == '/' || temp.path == '/')
72
+ temp.path = File.join(mp, temp.path)
73
+ if reanalyse
71
74
  temp.send(:analyse, temp.path)
72
75
  else
73
76
  temp.directory = File.join(File.dirname(temp.path), '/')
@@ -1,3 +1,4 @@
1
+ require 'pathname'
1
2
  require 'webgen/websiteaccess'
2
3
  require 'webgen/path'
3
4
 
@@ -11,9 +12,10 @@ module Webgen
11
12
 
12
13
  # Create a new object with absolute path +path+ for the file system path +fs_path+.
13
14
  def initialize(path, fs_path)
14
- super(path) { File.open(fs_path, 'r') }
15
+ super(path) { File.open(fs_path, 'rb') }
15
16
  @fs_path = fs_path
16
17
  WebsiteAccess.website.cache[[:fs_path, @fs_path]] = File.mtime(@fs_path)
18
+ @meta_info['modified_at'] = File.mtime(@fs_path)
17
19
  end
18
20
 
19
21
  # Return +true+ if the file system path used by the object has been modified.
@@ -44,7 +46,7 @@ module Webgen
44
46
  # Return all paths under #root which match #glob.
45
47
  def paths
46
48
  @paths ||= Dir.glob(File.join(@root, @glob), File::FNM_DOTMATCH|File::FNM_CASEFOLD).to_set.collect! do |f|
47
- temp = File.expand_path(f.sub(/^#{Regexp.escape(@root)}\/?/, '/'))
49
+ temp = Pathname.new(f.sub(/^#{Regexp.escape(@root)}\/?/, '/')).cleanpath.to_s
48
50
  temp += '/' if File.directory?(f) && temp[-1] != ?/
49
51
  path = Path.new(temp, f)
50
52
  path
@@ -11,9 +11,16 @@ module Webgen::Source
11
11
  # The glob specifying the resources.
12
12
  attr_reader :glob
13
13
 
14
- # Create a new resource source for the the +glob+.
15
- def initialize(glob)
16
- @glob = glob
14
+ # The glob specifying the paths that should be used from the resources.
15
+ attr_reader :paths_glob
16
+
17
+ # The prefix that should optionally be stripped from the paths.
18
+ attr_reader :strip_prefix
19
+
20
+ # Create a new resource source for the the +glob+ and use only those paths matching +paths_glob+
21
+ # while stripping +strip_prefix+ off the path.
22
+ def initialize(glob, paths_glob = nil, strip_prefix = nil)
23
+ @glob, @paths_glob, @strip_prefix = glob, paths_glob, strip_prefix
17
24
  end
18
25
 
19
26
  # Return all paths associated with the resources identified by #glob.
@@ -24,6 +31,8 @@ module Webgen::Source
24
31
  stack.add([['/', constant(infos.first).new(*infos[1..-1])]])
25
32
  end
26
33
  @paths = stack.paths
34
+ @paths = @paths.select {|p| File.fnmatch(@paths_glob, p)} if @paths_glob
35
+ @paths.collect! {|p| p.mount_at('/', @strip_prefix)} if @strip_prefix
27
36
  end
28
37
  @paths
29
38
  end
@@ -31,6 +31,7 @@ module Webgen
31
31
  def initialize #:nodoc:
32
32
  website.blackboard.add_service(:create_nodes, method(:create_nodes))
33
33
  website.blackboard.add_service(:source_paths, method(:find_all_source_paths))
34
+ website.blackboard.add_listener(:node_meta_info_changed?, method(:meta_info_changed?))
34
35
  end
35
36
 
36
37
  # Render the nodes provided in the +tree+. Before the actual rendering is done, the sources
@@ -44,20 +45,19 @@ module Webgen
44
45
  while paths.length > 0
45
46
  used_paths += (paths = Set.new(find_all_source_paths.keys) - used_paths - clean(tree))
46
47
  create_nodes_from_paths(tree, paths)
48
+ website.cache.reset_volatile_cache
47
49
  end
48
50
  end
49
51
  puts "...done in " + ('%2.4f' % time.real) + ' seconds'
50
52
 
51
53
  output = website.blackboard.invoke(:output_instance)
52
54
 
53
- # Enable permanent (till end of run) storing of volatile information
54
- website.cache.enable_volatile_cache
55
-
56
55
  puts "Writing changed nodes..."
57
56
  time = Benchmark.measure do
58
57
  tree.node_access[:alcn].sort.each do |name, node|
58
+ node.dirty_meta_info = node.created = false
59
59
  next if node == tree.dummy_root || !node.dirty
60
- node.dirty = node.created = false
60
+ node.dirty = false
61
61
 
62
62
  begin
63
63
  if !node['no_output'] && (content = node.content)
@@ -85,7 +85,7 @@ module Webgen
85
85
 
86
86
  # Return a hash with all source paths.
87
87
  def find_all_source_paths
88
- if !@paths
88
+ if !defined?(@paths)
89
89
  source = Webgen::Source::Stacked.new(website.config['sources'].collect do |mp, name, *args|
90
90
  [mp, constant(name).new(*args)]
91
91
  end)
@@ -134,8 +134,8 @@ module Webgen
134
134
  raise "The specified parent path <#{parent_path_name}> does not exist"
135
135
  end
136
136
  path = path.dup
137
- path.meta_info.update(website.config['sourcehandler.default_meta_info'][:all])
138
- path.meta_info.update(website.config['sourcehandler.default_meta_info'][source_handler.class.name] || {})
137
+ path.meta_info = default_meta_info(path, source_handler.class.name)
138
+ (website.cache[:sourcehandler_path_mi] ||= {})[[path.path, source_handler.class.name]] = path.meta_info.dup
139
139
  website.blackboard.dispatch_msg(:before_node_created, parent, path)
140
140
  *nodes = if block_given?
141
141
  yield(parent, path)
@@ -148,12 +148,27 @@ module Webgen
148
148
  nodes
149
149
  end
150
150
 
151
+ # Return the default meta info for the pair of +path+ and +sh_name+.
152
+ def default_meta_info(path, sh_name)
153
+ path.meta_info.merge(website.config['sourcehandler.default_meta_info'][:all]).
154
+ merge(website.config['sourcehandler.default_meta_info'][sh_name] || {})
155
+ end
156
+
157
+ # Check if the default meta information for +node+ has changed since the last run.
158
+ def meta_info_changed?(node)
159
+ path = node.node_info[:src]
160
+ cached_mi = website.cache[:sourcehandler_path_mi][[path, node.node_info[:processor]]]
161
+ if !cached_mi || cached_mi != default_meta_info(@paths[path], node.node_info[:processor])
162
+ node.dirty_meta_info = true
163
+ end
164
+ end
151
165
 
152
166
  # Clean the +tree+ by deleting nodes which have changed or which don't have an associated
153
- # source anymore.
167
+ # source anymore. Return all paths for which nodes need to be created.
154
168
  def clean(tree)
155
169
  paths_to_delete = Set.new
156
170
  paths_not_to_delete = Set.new
171
+ nodes_to_be_deleted = Set.new
157
172
  tree.node_access[:alcn].each do |alcn, node|
158
173
  next if node == tree.dummy_root || tree[alcn].nil?
159
174
 
@@ -162,13 +177,15 @@ module Webgen
162
177
  find_all_source_paths[node.node_info[:src]].changed? ||
163
178
  node.changed?)
164
179
  paths_not_to_delete << node.node_info[:src]
165
- tree.delete_node(node, deleted)
166
- #TODO: delete output path
180
+ nodes_to_be_deleted << [node, deleted]
167
181
  else
168
182
  paths_to_delete << node.node_info[:src]
169
183
  end
170
184
  end
171
185
 
186
+ nodes_to_be_deleted.each {|node, deleted| tree.delete_node(node, deleted)}
187
+ #TODO: delete output path
188
+
172
189
  # source paths that should be used
173
190
  paths_to_delete - paths_not_to_delete
174
191
  end
@@ -47,17 +47,22 @@ module Webgen::SourceHandler
47
47
  end
48
48
 
49
49
  # Create nested fragment nodes under +parent+ from +sections+ (which can be created using
50
- # +parse_html_headers+). The meta information +in_menu+ of the fragment nodes is set to the
51
- # parameter +in_menu+ and the meta info +sort_info+ is calculated from the base +si+ value.
52
- def create_fragment_nodes(sections, parent, in_menu, si = 1000 )
50
+ # +parse_html_headers+). +path+ is the source path that defines the fragments. The meta
51
+ # information +in_menu+ of the fragment nodes is set to the parameter +in_menu+ and the meta
52
+ # info +sort_info+ is calculated from the base +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
55
  node = website.blackboard.invoke(:create_nodes, parent.tree, parent.absolute_lcn,
55
- Webgen::Path.new('#' + id), self).first
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)
60
+ end.first
56
61
  node['title'] = title
57
62
  node['in_menu'] = in_menu
58
63
  node['sort_info'] = si = si.succ
59
- node.node_info[:src] = parent.node_info[:src]
60
- create_fragment_nodes(sub_sections, node, in_menu, si.succ)
64
+ node.node_info[:src] = path.path
65
+ create_fragment_nodes(sub_sections, node, path, in_menu, si.succ)
61
66
  end
62
67
  end
63
68
 
@@ -1,3 +1,4 @@
1
+ require 'pathname'
1
2
  require 'yaml'
2
3
  require 'webgen/sourcehandler/base'
3
4
  require 'webgen/websiteaccess'
@@ -28,7 +29,7 @@ module Webgen::SourceHandler
28
29
  [[:mi_paths, 'paths'], [:mi_alcn, 'alcn']].each do |mi_key, block_name|
29
30
  node.node_info[mi_key] = {}
30
31
  YAML::load(page.blocks[block_name].content).each do |key, value|
31
- key = File.expand_path(key =~ /^\// ? key : File.join(parent.absolute_lcn, key))
32
+ key = Pathname.new(key =~ /^\// ? key : File.join(parent.absolute_lcn, key)).cleanpath.to_s
32
33
  node.node_info[mi_key][key.chomp('/')] = value
33
34
  end if page.blocks.has_key?(block_name)
34
35
  end
@@ -9,6 +9,10 @@ module Webgen::SourceHandler
9
9
  include Webgen::WebsiteAccess
10
10
  include Base
11
11
 
12
+ def initialize #:nodoc:
13
+ website.blackboard.add_listener(:node_meta_info_changed?, method(:meta_info_changed?))
14
+ end
15
+
12
16
  # Create a page file from +parent+ and +path+.
13
17
  def create_node(parent, path)
14
18
  page = page_from_path(path)
@@ -16,6 +20,8 @@ module Webgen::SourceHandler
16
20
  path.ext = 'html' if path.ext == 'page'
17
21
 
18
22
  super(parent, path) do |node|
23
+ website.cache[[:sh_page_node_mi, node.absolute_lcn]] = node.meta_info.dup
24
+
19
25
  node.node_info[:page] = page
20
26
  tmp_logger = website.logger
21
27
  website.logger = nil # disabling logging whiling creating fragment nodes
@@ -29,7 +35,8 @@ module Webgen::SourceHandler
29
35
  website.cache.permanent[:page_sections][node.absolute_lcn] = sections
30
36
  website.blackboard.invoke(:create_fragment_nodes,
31
37
  sections,
32
- node, node.meta_info['fragments_in_menu'])
38
+ node, website.blackboard.invoke(:source_paths)[path.path],
39
+ node.meta_info['fragments_in_menu'])
33
40
  website.logger = tmp_logger
34
41
  end
35
42
  end
@@ -50,6 +57,19 @@ module Webgen::SourceHandler
50
57
  end
51
58
  alias_method :content, :render_node
52
59
 
60
+ #######
61
+ private
62
+ #######
63
+
64
+ # Checks if the meta information provided by the file in Webgen Page Format changed.
65
+ 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
+ if website.cache.old_data[ckey] != website.cache.new_data[ckey]
69
+ node.dirty_meta_info = true
70
+ end
71
+ end
72
+
53
73
  end
54
74
 
55
75
  end
@@ -23,8 +23,8 @@ module Webgen::Tag
23
23
  node = node.parent if omit_index_path
24
24
 
25
25
  until node == node.tree.dummy_root
26
- context.dest_node.node_info[:used_nodes] << node.routing_node(context.dest_node.lang).absolute_lcn
27
- context.dest_node.node_info[:used_nodes] << node.absolute_lcn
26
+ context.dest_node.node_info[:used_meta_info_nodes] << node.routing_node(context.dest_node.lang).absolute_lcn
27
+ context.dest_node.node_info[:used_meta_info_nodes] << node.absolute_lcn
28
28
  out.push(context.dest_node.link_to(node.in_lang(context.content_node.lang)))
29
29
  node = node.parent
30
30
  end
@@ -1,6 +1,7 @@
1
1
  require 'webgen/tag'
2
2
  require 'cgi'
3
3
  require "tempfile"
4
+ require 'rbconfig'
4
5
 
5
6
  module Webgen::Tag
6
7
 
@@ -10,10 +11,12 @@ module Webgen::Tag
10
11
 
11
12
  include Webgen::Tag::Base
12
13
 
14
+ BIT_BUCKET = (Config::CONFIG['arch'].include?('mswin32') ? "nul" : "/dev/null")
15
+
13
16
  # Execute the command and return the standard output.
14
17
  def call(tag, body, context)
15
18
  command = param('tag.executecommand.command')
16
- output = `#{command} 2> /dev/null`
19
+ output = `#{command} 2> #{BIT_BUCKET}`
17
20
  if ($? >> 8) != 0
18
21
  raise "Command '#{command}' in <#{context.ref_node.absolute_lcn}> has return value != 0: #{output}"
19
22
  end
@@ -20,7 +20,7 @@ module Webgen::Tag
20
20
  def call(tag, body, context)
21
21
  filename = param('tag.includefile.filename')
22
22
  filename = File.join(website.directory, filename) unless filename =~ /^(\/|\w:)/
23
- content = File.read(filename)
23
+ content = File.open(filename, 'rb') {|f| f.read}
24
24
  content = CGI::escapeHTML(content) if param('tag.includefile.escape_html')
25
25
  (context.dest_node.node_info[:tag_includefile_filenames] ||= []) << [filename, File.mtime(filename)]
26
26
 
@@ -1,4 +1,5 @@
1
1
  require 'webgen/tag'
2
+ require 'webgen/websiteaccess'
2
3
 
3
4
  module Webgen::Tag
4
5
 
@@ -6,17 +7,44 @@ module Webgen::Tag
6
7
  class Langbar
7
8
 
8
9
  include Webgen::Tag::Base
10
+ include Webgen::WebsiteAccess
11
+
12
+ def initialize #:nodoc:
13
+ website.blackboard.add_listener(:node_changed?, method(:node_changed?))
14
+ end
9
15
 
10
16
  # Return a list of all translations of the content page.
11
17
  def call(tag, body, context)
12
- lang_nodes = context.content_node.tree.node_access[:acn][context.content_node.absolute_cn]
13
- nr_langs = lang_nodes.length
18
+ lang_nodes = all_lang_nodes(context.content_node)
19
+ (context.dest_node.node_info[:tag_langbar_data] ||= {})[context.content_node.absolute_cn] = lang_nodes.map {|n| n.absolute_lcn}
14
20
  result = lang_nodes.
15
- reject {|n| (context.content_node.lang == n.lang && !param('tag.langbar.show_own_lang')) }.
21
+ reject {|n| (context.content_node.lang == n.lang && !param('tag.langbar.show_own_lang'))}.
16
22
  sort {|a, b| a.lang <=> b.lang}.
17
23
  collect {|n| context.dest_node.link_to(n, :link_text => n.lang)}.
18
24
  join(param('tag.langbar.separator'))
19
- (param('tag.langbar.show_single_lang') || nr_langs > 1 ? result : "")
25
+ (param('tag.langbar.show_single_lang') || lang_nodes.length > 1 ? result : "")
26
+ end
27
+
28
+ #######
29
+ private
30
+ #######
31
+
32
+ # Return all nodes with the same absolute cn as +node+.
33
+ def all_lang_nodes(node)
34
+ node.tree.node_access[:acn][node.absolute_cn]
35
+ end
36
+
37
+ # Check if the langbar tag for +node+ changed.
38
+ def node_changed?(node)
39
+ return unless (cdata = node.node_info[:tag_langbar_data])
40
+ cdata.each do |acn, clang_nodes|
41
+ lang_nodes = all_lang_nodes(node.tree[acn, :acn]) rescue nil
42
+ if !lang_nodes || lang_nodes.length != clang_nodes.length ||
43
+ lang_nodes.any? {|n| n.meta_info_changed?}
44
+ node.dirty = true
45
+ break
46
+ end
47
+ end
20
48
  end
21
49
 
22
50
  end
@@ -21,6 +21,9 @@ module Webgen::Tag
21
21
  # The encapsulated node.
22
22
  attr_reader :node
23
23
 
24
+ # Set to +true+ if the menu node is in the tree of files.
25
+ attr_writer :is_in_tree_of_files
26
+
24
27
  # Create a new menu node under +parent+ for the real node +node+.
25
28
  def initialize(parent, node)
26
29
  @parent = parent
@@ -28,6 +31,11 @@ module Webgen::Tag
28
31
  @children = []
29
32
  end
30
33
 
34
+ # Return +true+ if the menu node is in the menu tree of only files.
35
+ def is_in_tree_of_files?
36
+ @is_in_tree_of_files
37
+ end
38
+
31
39
  # Sort recursively all children of the node using the wrapped nodes.
32
40
  def sort!
33
41
  self.children.sort! {|a,b| a.node <=> b.node}
@@ -77,7 +85,9 @@ module Webgen::Tag
77
85
  set_params({})
78
86
 
79
87
  if (tree.nil? && !cached_tree.nil?) || (tree_list && tree_list != cached_tree) ||
80
- (tree_list && tree_list.flatten.any? {|alcn| (n = node.tree[alcn]) && (r = n.routing_node(cn.lang)) && r != node && r.changed?})
88
+ (tree_list && tree_list.flatten.any? do |alcn|
89
+ (n = node.tree[alcn]) && (r = n.routing_node(cn.lang)) && r != node && r.meta_info_changed?
90
+ end)
81
91
  node.dirty = true
82
92
  break
83
93
  end
@@ -110,7 +120,7 @@ module Webgen::Tag
110
120
  sub_menu_tree = MenuNode.new(nil, menu_node.node)
111
121
  menu_tree = MenuNode.new(nil, menu_node.node)
112
122
  menu_node.children.each do |child|
113
- next if param('tag.menu.used_nodes') == 'files' && !is_in_menu_tree_of_files?(child)
123
+ next if param('tag.menu.used_nodes') == 'files' && !child.is_in_tree_of_files?
114
124
  menu_tree.children << (this_node = MenuNode.new(menu_tree, child.node))
115
125
  sub_node = child.children.length > 0 ? build_specific_menu_tree(content_node, child, level + 1) : nil
116
126
  sub_node.children.each {|n| this_node.children << n; sub_menu_tree.children << n} if sub_node
@@ -123,11 +133,6 @@ module Webgen::Tag
123
133
  end
124
134
  end
125
135
 
126
- # Return +true+ if +menu_node+ is in the menu tree without fragment nodes.
127
- def is_in_menu_tree_of_files?(menu_node)
128
- (!menu_node.node.is_fragment? && menu_node.node['in_menu']) || menu_node.children.any? {|c| is_in_menu_tree_of_files?(c)}
129
- end
130
-
131
136
  # Create the HTML menu of the +tree+ using the provided +context+.
132
137
  def create_output(context, tree)
133
138
  out = "<ul>"
@@ -177,11 +182,11 @@ module Webgen::Tag
177
182
  sub_node = create_menu_tree(child, menu_node, lang)
178
183
  menu_node.children << sub_node unless sub_node.nil?
179
184
  end
185
+ menu_node.is_in_tree_of_files = (!node.is_fragment? && node['in_menu']) || menu_node.children.any? {|c| c.is_in_tree_of_files?}
180
186
 
181
187
  menu_node.children.empty? ? (node['in_menu'] ? menu_node : nil) : menu_node
182
188
  end
183
189
 
184
-
185
190
  end
186
191
 
187
192
  end