webgen 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/AUTHORS +3 -0
  2. data/ChangeLog +426 -0
  3. data/THANKS +1 -0
  4. data/VERSION +1 -1
  5. data/bin/webgen +2 -0
  6. data/data/webgen/webgui/controller/main.rb +2 -0
  7. data/data/webgen/website_skeleton/ext/init.rb +4 -0
  8. data/doc/contentprocessor/blocks.page +44 -14
  9. data/doc/contentprocessor/builder.page +1 -1
  10. data/doc/contentprocessor/erb.page +1 -1
  11. data/doc/contentprocessor/erubis.page +1 -1
  12. data/doc/contentprocessor/fragments.page +1 -1
  13. data/doc/contentprocessor/haml.page +1 -1
  14. data/doc/contentprocessor/rdiscount.page +1 -1
  15. data/doc/contentprocessor/rdoc.page +1 -1
  16. data/doc/contentprocessor/redcloth.page +1 -1
  17. data/doc/contentprocessor/sass.page +1 -1
  18. data/doc/faq.page +7 -2
  19. data/doc/manual.page +6 -5
  20. data/doc/reference_metainfo.page +1 -1
  21. data/doc/sourcehandler/feed.page +9 -1
  22. data/doc/sourcehandler/sitemap.page +1 -1
  23. data/doc/tag/coderay.page +1 -1
  24. data/doc/tag/langbar.page +15 -0
  25. data/doc/tag/menu.page +1 -1
  26. data/doc/tag/relocatable.page +2 -2
  27. data/lib/webgen/blackboard.rb +9 -4
  28. data/lib/webgen/cache.rb +2 -0
  29. data/lib/webgen/cli.rb +6 -1
  30. data/lib/webgen/cli/create_command.rb +2 -0
  31. data/lib/webgen/cli/run_command.rb +2 -0
  32. data/lib/webgen/cli/utils.rb +2 -0
  33. data/lib/webgen/cli/webgui_command.rb +2 -0
  34. data/lib/webgen/common.rb +12 -1
  35. data/lib/webgen/common/sitemap.rb +12 -4
  36. data/lib/webgen/configuration.rb +2 -0
  37. data/lib/webgen/contentprocessor.rb +2 -0
  38. data/lib/webgen/contentprocessor/blocks.rb +22 -8
  39. data/lib/webgen/contentprocessor/builder.rb +2 -0
  40. data/lib/webgen/contentprocessor/context.rb +2 -0
  41. data/lib/webgen/contentprocessor/erb.rb +2 -0
  42. data/lib/webgen/contentprocessor/erubis.rb +2 -0
  43. data/lib/webgen/contentprocessor/fragments.rb +2 -0
  44. data/lib/webgen/contentprocessor/haml.rb +2 -0
  45. data/lib/webgen/contentprocessor/maruku.rb +2 -0
  46. data/lib/webgen/contentprocessor/rdiscount.rb +2 -0
  47. data/lib/webgen/contentprocessor/rdoc.rb +2 -0
  48. data/lib/webgen/contentprocessor/redcloth.rb +2 -0
  49. data/lib/webgen/contentprocessor/sass.rb +2 -0
  50. data/lib/webgen/contentprocessor/tags.rb +2 -0
  51. data/lib/webgen/coreext.rb +2 -0
  52. data/lib/webgen/default_config.rb +4 -1
  53. data/lib/webgen/languages.rb +2 -0
  54. data/lib/webgen/loggable.rb +2 -0
  55. data/lib/webgen/logger.rb +2 -0
  56. data/lib/webgen/node.rb +22 -8
  57. data/lib/webgen/output.rb +3 -1
  58. data/lib/webgen/output/filesystem.rb +2 -0
  59. data/lib/webgen/page.rb +2 -0
  60. data/lib/webgen/path.rb +3 -1
  61. data/lib/webgen/source.rb +2 -0
  62. data/lib/webgen/source/filesystem.rb +5 -2
  63. data/lib/webgen/source/resource.rb +2 -0
  64. data/lib/webgen/source/stacked.rb +2 -0
  65. data/lib/webgen/sourcehandler.rb +8 -0
  66. data/lib/webgen/sourcehandler/base.rb +2 -0
  67. data/lib/webgen/sourcehandler/copy.rb +2 -0
  68. data/lib/webgen/sourcehandler/directory.rb +2 -0
  69. data/lib/webgen/sourcehandler/feed.rb +3 -1
  70. data/lib/webgen/sourcehandler/fragment.rb +2 -0
  71. data/lib/webgen/sourcehandler/memory.rb +2 -0
  72. data/lib/webgen/sourcehandler/metainfo.rb +3 -1
  73. data/lib/webgen/sourcehandler/page.rb +2 -0
  74. data/lib/webgen/sourcehandler/sitemap.rb +2 -0
  75. data/lib/webgen/sourcehandler/template.rb +2 -0
  76. data/lib/webgen/sourcehandler/virtual.rb +3 -1
  77. data/lib/webgen/tag.rb +2 -0
  78. data/lib/webgen/tag/base.rb +2 -0
  79. data/lib/webgen/tag/breadcrumbtrail.rb +2 -0
  80. data/lib/webgen/tag/coderay.rb +2 -0
  81. data/lib/webgen/tag/date.rb +2 -0
  82. data/lib/webgen/tag/executecommand.rb +2 -0
  83. data/lib/webgen/tag/includefile.rb +2 -0
  84. data/lib/webgen/tag/langbar.rb +4 -1
  85. data/lib/webgen/tag/link.rb +2 -0
  86. data/lib/webgen/tag/menu.rb +2 -0
  87. data/lib/webgen/tag/metainfo.rb +2 -0
  88. data/lib/webgen/tag/relocatable.rb +2 -0
  89. data/lib/webgen/tag/sitemap.rb +2 -0
  90. data/lib/webgen/tag/tikz.rb +3 -1
  91. data/lib/webgen/tree.rb +5 -0
  92. data/lib/webgen/version.rb +3 -1
  93. data/lib/webgen/webgentask.rb +2 -0
  94. data/lib/webgen/website.rb +104 -3
  95. data/lib/webgen/websiteaccess.rb +2 -0
  96. data/lib/webgen/websitemanager.rb +2 -0
  97. data/man/man1/webgen.1 +6 -0
  98. data/misc/default.css +36 -12
  99. data/misc/default.template +1 -1
  100. data/misc/images/error.png +0 -0
  101. data/misc/images/important.png +0 -0
  102. data/misc/images/information.png +0 -0
  103. data/misc/images/warning.png +0 -0
  104. data/test/helper.rb +4 -0
  105. data/test/test_blackboard.rb +2 -0
  106. data/test/test_cache.rb +2 -0
  107. data/test/test_cli.rb +7 -0
  108. data/test/test_common.rb +18 -0
  109. data/test/test_common_sitemap.rb +7 -5
  110. data/test/test_configuration.rb +2 -0
  111. data/test/test_contentprocessor.rb +2 -0
  112. data/test/test_contentprocessor_blocks.rb +22 -1
  113. data/test/test_contentprocessor_builder.rb +2 -0
  114. data/test/test_contentprocessor_context.rb +2 -0
  115. data/test/test_contentprocessor_erb.rb +2 -0
  116. data/test/test_contentprocessor_erubis.rb +2 -0
  117. data/test/test_contentprocessor_fragments.rb +2 -0
  118. data/test/test_contentprocessor_haml.rb +2 -0
  119. data/test/test_contentprocessor_maruku.rb +2 -0
  120. data/test/test_contentprocessor_rdiscount.rb +2 -0
  121. data/test/test_contentprocessor_rdoc.rb +2 -0
  122. data/test/test_contentprocessor_redcloth.rb +2 -0
  123. data/test/test_contentprocessor_sass.rb +2 -0
  124. data/test/test_contentprocessor_tags.rb +2 -0
  125. data/test/test_languages.rb +2 -0
  126. data/test/test_loggable.rb +2 -0
  127. data/test/test_logger.rb +2 -0
  128. data/test/test_node.rb +2 -0
  129. data/test/test_output_filesystem.rb +2 -0
  130. data/test/test_page.rb +2 -0
  131. data/test/test_path.rb +2 -0
  132. data/test/test_source_filesystem.rb +17 -0
  133. data/test/test_source_resource.rb +2 -0
  134. data/test/test_source_stacked.rb +2 -0
  135. data/test/test_sourcehandler_base.rb +2 -0
  136. data/test/test_sourcehandler_copy.rb +2 -0
  137. data/test/test_sourcehandler_directory.rb +2 -0
  138. data/test/test_sourcehandler_feed.rb +2 -0
  139. data/test/test_sourcehandler_fragment.rb +2 -0
  140. data/test/test_sourcehandler_memory.rb +2 -0
  141. data/test/test_sourcehandler_metainfo.rb +2 -0
  142. data/test/test_sourcehandler_page.rb +2 -0
  143. data/test/test_sourcehandler_sitemap.rb +2 -0
  144. data/test/test_sourcehandler_template.rb +2 -0
  145. data/test/test_sourcehandler_virtual.rb +2 -0
  146. data/test/test_tag_base.rb +4 -0
  147. data/test/test_tag_breadcrumbtrail.rb +2 -0
  148. data/test/test_tag_coderay.rb +2 -0
  149. data/test/test_tag_date.rb +2 -0
  150. data/test/test_tag_executecommand.rb +2 -0
  151. data/test/test_tag_includefile.rb +2 -0
  152. data/test/test_tag_langbar.rb +13 -6
  153. data/test/test_tag_link.rb +2 -0
  154. data/test/test_tag_menu.rb +2 -0
  155. data/test/test_tag_metainfo.rb +2 -0
  156. data/test/test_tag_relocatable.rb +2 -0
  157. data/test/test_tag_sitemap.rb +4 -1
  158. data/test/test_tag_tikz.rb +4 -1
  159. data/test/test_tree.rb +2 -0
  160. data/test/test_webgentask.rb +2 -0
  161. data/test/test_website.rb +6 -4
  162. data/test/test_websiteaccess.rb +2 -0
  163. data/test/test_websitemanager.rb +2 -0
  164. metadata +8 -6
  165. data/misc/images/error.gif +0 -0
  166. data/misc/images/exclamation.gif +0 -0
  167. data/misc/images/information.gif +0 -0
data/lib/webgen/common.rb CHANGED
@@ -1,10 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'pathname'
4
+
1
5
  module Webgen
2
6
 
3
- # Namespace for classes that provide common functionality.
7
+ # Namespace for classes and methods that provide common functionality.
4
8
  module Common
5
9
 
6
10
  autoload :Sitemap, 'webgen/common/sitemap'
7
11
 
12
+ # Make the given +path+ absolute by prepending the absolute path +base+ if necessary. Also
13
+ # resolves all '..' and '.' references in +path+.
14
+ def self.absolute_path(path, base)
15
+ raise(ArgumentError, 'base has to be an absolute path') unless base =~ /\//
16
+ Pathname.new(path =~ /^\// ? path : File.join(base, path)).cleanpath.to_s
17
+ end
18
+
8
19
  end
9
20
 
10
21
  end
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'webgen/tag'
2
4
  require 'webgen/websiteaccess'
3
5
 
@@ -31,10 +33,7 @@ module Webgen::Common
31
33
  def recursive_create(parent, node, lang, in_sitemap = true)
32
34
  mnode = Webgen::Tag::Menu::MenuNode.new(parent, node)
33
35
  node.children.map do |n|
34
- sub_in_sitemap = ((option('common.sitemap.used_kinds').empty? || option('common.sitemap.used_kinds').include?(n['kind'])) &&
35
- (option('common.sitemap.any_lang') || n.lang.nil? || n.lang == lang) &&
36
- (!option('common.sitemap.honor_in_menu') || n['in_menu']) &&
37
- (parent.nil? || node.routing_node(lang) != n))
36
+ sub_in_sitemap = in_sitemap?(n, lang)
38
37
  [(!n.children.empty? || sub_in_sitemap ? n : nil), sub_in_sitemap]
39
38
  end.each do |n, sub_in_sitemap|
40
39
  next if n.nil?
@@ -44,6 +43,15 @@ module Webgen::Common
44
43
  (mnode.children.empty? && !in_sitemap ? nil : mnode)
45
44
  end
46
45
 
46
+ # Return +true+ if the +child+ of the +node+ is in the sitemap for the language +lang+.
47
+ def in_sitemap?(child, lang, allow_index_file = false)
48
+ ((option('common.sitemap.used_kinds').empty? || option('common.sitemap.used_kinds').include?(child['kind']) ||
49
+ (child.routing_node(lang, false) != child && in_sitemap?(child.routing_node(lang), lang, true))) &&
50
+ (option('common.sitemap.any_lang') || child.lang.nil? || child.lang == lang) &&
51
+ (!option('common.sitemap.honor_in_menu') || child['in_menu']) &&
52
+ (allow_index_file || child.parent == child.tree.root || child.parent.routing_node(lang) != child))
53
+ end
54
+
47
55
  # Retrieve the configuration option value for +name+. The value is taken from the current
48
56
  # configuration options hash if +name+ is specified there or from the website configuration
49
57
  # otherwise.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'facets/symbol/to_proc'
2
4
 
3
5
  module Webgen
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen
2
4
 
3
5
  # Namespace for all content processors.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Replaces special xml tags with the rendered content of a node.
@@ -5,7 +7,8 @@ module Webgen::ContentProcessor
5
7
 
6
8
  include Webgen::Loggable
7
9
 
8
- BLOCK_RE = /<webgen:block\s+name=('|")(\w+)\1\s*(?:\schain=('|")([^'"]+)\3\s*)?\s*\/>/
10
+ BLOCK_RE = /<webgen:block\s*?((?:\s\w+=('|")[^'"]+\2)+)\s*\/>/
11
+ BLOCK_ATTR_RE = /(\w+)=('|")([^'"]+)\2/
9
12
 
10
13
  # Replace that webgen:block xml tags with the rendered content of a node.
11
14
  def call(context)
@@ -13,11 +16,12 @@ module Webgen::ContentProcessor
13
16
  new_chain = (chain.length > 1 ? chain[1..-1] : chain)
14
17
 
15
18
  context.content.gsub!(BLOCK_RE) do |match|
16
- block_name = $2
17
- if $4.nil?
18
- used_chain = new_chain
19
+ attr = {}
20
+ match.scan(BLOCK_ATTR_RE) {|name, sep, content| attr[name] = content}
21
+ if attr['chain'].nil?
22
+ used_chain = new_chain.dup
19
23
  else
20
- paths = $4.split(';')
24
+ paths = attr['chain'].split(';')
21
25
  used_chain = paths.collect do |path|
22
26
  temp_node = context.ref_node.resolve(path.strip, context.dest_node.lang)
23
27
  log(:error) { "Could not resolve <#{path.strip}> in <#{context.ref_node.absolute_lcn}> in '#{match.to_s}'" } if temp_node.nil?
@@ -26,14 +30,24 @@ module Webgen::ContentProcessor
26
30
  next match if used_chain.length != paths.length
27
31
  dest_node = context.content_node
28
32
  end
33
+
34
+ if attr['node'] == 'first'
35
+ used_chain.shift while used_chain.length > 0 && !used_chain.first.node_info[:page].blocks.has_key?(attr['name'])
36
+ end
29
37
  block_node = used_chain.first
30
38
 
31
- if !block_node.node_info[:page].blocks.has_key?(block_name)
32
- raise "Node <#{block_node.absolute_lcn}> has no block named '#{block_name}'"
39
+ if !block_node || !block_node.node_info[:page].blocks.has_key?(attr['name'])
40
+ if attr['notfound'] == 'ignore'
41
+ next ''
42
+ elsif block_node
43
+ raise "Node <#{block_node.absolute_lcn}> has no block named '#{attr['name']}'"
44
+ else
45
+ raise "No node in the chain has a block named '#{attr['name']}'"
46
+ end
33
47
  end
34
48
 
35
49
  context.dest_node.node_info[:used_nodes] << block_node.absolute_lcn
36
- tmp_context = block_node.node_info[:page].blocks[block_name].render(context.clone(:chain => used_chain, :dest_node => dest_node))
50
+ tmp_context = block_node.node_info[:page].blocks[attr['name']].render(context.clone(:chain => used_chain, :dest_node => dest_node))
37
51
  tmp_context.content
38
52
  end
39
53
  context
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Processes content that is valid Ruby to build an XML tree. This is done by using the +builder+
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # The context object that is passed to the +call+ method of a content processor.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Processes embedded Ruby statements.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Processes embedded Ruby statements with the +erubis+ library.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Uses the HTML headers h1, h2, ..., h6 to generate nested fragment nodes.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Processes content in Haml markup using the +haml+ library.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Processes content in Markdown format using the +maruku+ library.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Processes content in Markdown markup with the fast +rdiscount+ library.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Converts content in RDoc markup (the native Ruby documentation format) to HTML. Needs the newer
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Processes content in Textile format using the +redcloth+ library.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::ContentProcessor
2
4
 
3
5
  # Processes content in Sass markup (used for writing CSS files) using the +haml+ library.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'yaml'
2
4
  require 'strscan'
3
5
  require 'webgen/tag'
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  # :nodoc:
2
4
  class Array
3
5
 
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  website = Webgen::WebsiteAccess.website
2
4
  config = website.config
3
5
 
@@ -44,7 +46,7 @@ config.sources [['/', "Webgen::Source::FileSystem", 'src']], :doc => 'One or mor
44
46
 
45
47
  # All things regarding source handler
46
48
  config.sourcehandler.patterns({
47
- 'Webgen::SourceHandler::Copy' => ['**/*.css', '**/*.js', '**/*.html', '**/*.gif', '**/*.jpg', '**/*.png'],
49
+ 'Webgen::SourceHandler::Copy' => ['**/*.css', '**/*.js', '**/*.html', '**/*.gif', '**/*.jpg', '**/*.png', '**/*.ico'],
48
50
  'Webgen::SourceHandler::Directory' => ['**/'],
49
51
  'Webgen::SourceHandler::Metainfo' => ['**/metainfo', '**/*.metainfo'],
50
52
  'Webgen::SourceHandler::Template' => ['**/*.template'],
@@ -175,6 +177,7 @@ config.tag.langbar.separator(' | ', :doc => 'Separates the languages from each o
175
177
  config.tag.langbar.show_single_lang(true, :doc => 'Should the link be shown although the page is only available in one language?')
176
178
  config.tag.langbar.show_own_lang(true, :doc => 'Should the link to the currently displayed language page be shown?')
177
179
  config.tag.langbar.lang_names({}, :doc => 'A map from language code to language names')
180
+ config.tag.langbar.process_output(false, :doc => 'The content of the language bar will be scanned for tags if true.')
178
181
 
179
182
  config.tag.includefile.filename(nil, :doc => 'The name of the file which should be included (relative to the website).', :mandatory => 'default')
180
183
  config.tag.includefile.process_output(true, :doc => 'The file content will be scanned for tags if true.')
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen
2
4
 
3
5
  # Describes a human language which is uniquely identfied by a three letter code and, optionally,
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'webgen/websiteaccess'
2
4
 
3
5
  module Webgen
data/lib/webgen/logger.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'stringio'
2
4
  require 'logger'
3
5
 
data/lib/webgen/node.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'webgen/websiteaccess'
2
4
  require 'webgen/loggable'
3
5
  require 'webgen/path'
@@ -75,13 +77,13 @@ module Webgen
75
77
 
76
78
  # Re-initializes an already initialized node and resets it to its pristine state.
77
79
  def reinit(path, meta_info = {})
78
- old_path = @path
80
+ old_path = @path if defined?(@path)
79
81
  @path = path.freeze
80
82
  @lang = Webgen::LanguageManager.language_for_code(meta_info.delete('lang'))
81
83
  @lang = nil unless is_file?
82
84
  @meta_info = meta_info
83
85
  @flags = Set.new([:dirty, :created])
84
- if @tree
86
+ if defined?(@tree)
85
87
  @tree.node_access[:path].delete(old_path) if old_path
86
88
  @tree.register_path(self)
87
89
  self.node_info.clear
@@ -129,13 +131,15 @@ module Webgen
129
131
  @flags.include?(key)
130
132
  end
131
133
 
132
- # Flag the node with the +keys+. See #flagged for valid keys.
134
+ # Flag the node with the +keys+ and dispatch the message <tt>:node_flagged</tt> with +self+ and
135
+ # +keys+ as arguments. See #flagged for valid keys.
133
136
  def flag(*keys)
134
137
  @flags += keys
135
138
  website.blackboard.dispatch_msg(:node_flagged, self, keys)
136
139
  end
137
140
 
138
- # Remove the flags +keys+ from the node.
141
+ # Remove the flags +keys+ from the node and dispatch the message <tt>:node_unflagged</tt> with
142
+ # +self+ and +keys+ as arguments.
139
143
  def unflag(*keys)
140
144
  @flags.subtract(keys)
141
145
  website.blackboard.dispatch_msg(:node_unflagged, self, keys)
@@ -143,6 +147,10 @@ module Webgen
143
147
 
144
148
  # Return +true+ if the node has changed since the last webgen run. If it has changed, +dirty+ is
145
149
  # set to +true+.
150
+ #
151
+ # Sends the message <tt>:node_changed?</tt> with +self+ as argument unless the node is already
152
+ # dirty. A listener to this message should set the flag <tt>:dirty</tt> on the passed node if he
153
+ # thinks it is dirty.
146
154
  def changed?
147
155
  if_not_checked(:node) do
148
156
  flag(:dirty) if meta_info_changed? ||
@@ -153,6 +161,11 @@ module Webgen
153
161
  end
154
162
 
155
163
  # Return +true+ if the meta information of the node has changed.
164
+ #
165
+ # Sends the message <tt>:node_meta_info_changed?</tt> with +self+ as argument unless the meta
166
+ # information of the node is already dirty. A listener to this message should set the flag
167
+ # <tt>:dirt_meta_info</tt> on the passed node if he thinks that the node's meta information is
168
+ # dirty.
156
169
  def meta_info_changed?
157
170
  if_not_checked(:meta_info) do
158
171
  flag(:dirty_meta_info) if node_info[:used_meta_info_nodes].any? do |n|
@@ -271,8 +284,9 @@ module Webgen
271
284
 
272
285
  # Return the routing node in language +lang+ which is the node that is used when routing to this
273
286
  # node. The returned node can differ from the node itself in case of a directory where the
274
- # routing node is the directory index node.
275
- def routing_node(lang)
287
+ # routing node is the directory index node. If +show_warning+ is +true+ and this node is a
288
+ # directory node, then a warning is logged if no associated index file is found.
289
+ def routing_node(lang, log_warning = true)
276
290
  if !is_directory?
277
291
  self
278
292
  else
@@ -288,12 +302,12 @@ module Webgen
288
302
  if index_node
289
303
  vcache[key] = index_node
290
304
  log(:info) { "Directory index path for <#{absolute_lcn}> => <#{index_node.absolute_lcn}>" }
291
- else
305
+ elsif log_warning
292
306
  vcache[key] = self
293
307
  log(:warn) { "No directory index path found for directory <#{absolute_lcn}>" }
294
308
  end
295
309
  end
296
- vcache[key]
310
+ vcache[key] || self
297
311
  end
298
312
  end
299
313
 
data/lib/webgen/output.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen
2
4
 
3
5
  # Namespace for all classes that know how to write out node content.
@@ -14,7 +16,7 @@ module Webgen
14
16
  # Delete the given output path.
15
17
  # <tt>write(path, data, type)</tt>::
16
18
  # Write the data to the given output path. The parameter +type+ specifies the type of the
17
- # to be written path: +:file+ or +:directory+.
19
+ # to be written path: <tt>:file</tt> or <tt>:directory</tt>.
18
20
  # <tt>read(path)</tt>:
19
21
  # Return the content of the given path if it exists or raise an error otherwise.
20
22
  #
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'fileutils'
2
4
 
3
5
  module Webgen::Output
data/lib/webgen/page.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'yaml'
2
4
 
3
5
  module Webgen
data/lib/webgen/path.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'webgen/languages'
2
4
 
3
5
  module Webgen
@@ -73,7 +75,7 @@ module Webgen
73
75
  # the content of the path.
74
76
  def initialize(path, source_path = path, &ioblock)
75
77
  @meta_info = {}
76
- @io = SourceIO.new(&ioblock) if block_given?
78
+ @io = block_given? ? SourceIO.new(&ioblock) : nil
77
79
  @source_path = source_path
78
80
  analyse(path)
79
81
  end
data/lib/webgen/source.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen
2
4
 
3
5
  # Namespace for all classes that provide source paths.
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'pathname'
2
4
  require 'webgen/websiteaccess'
3
5
  require 'webgen/path'
@@ -45,12 +47,13 @@ module Webgen
45
47
 
46
48
  # Return all paths under #root which match #glob.
47
49
  def paths
48
- @paths ||= Dir.glob(File.join(@root, @glob), File::FNM_DOTMATCH|File::FNM_CASEFOLD).to_set.collect! do |f|
50
+ @paths ||= Dir.glob(File.join(@root, @glob), File::FNM_DOTMATCH|File::FNM_CASEFOLD).to_set.collect do |f|
51
+ next unless File.exists?(f) # handle invalid links
49
52
  temp = Pathname.new(f.sub(/^#{Regexp.escape(@root)}\/?/, '/')).cleanpath.to_s
50
53
  temp += '/' if File.directory?(f) && temp[-1] != ?/
51
54
  path = Path.new(temp, f)
52
55
  path
53
- end
56
+ end.compact
54
57
  end
55
58
 
56
59
  end
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  require 'webgen/websiteaccess'
2
4
  require 'webgen/source'
3
5
 
@@ -1,3 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  module Webgen::Source
2
4
 
3
5
  # This source class is used to stack several sources together.