gettalong-webgen 0.5.6.20081020 → 0.5.7.20090227
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +3 -0
- data/THANKS +1 -0
- data/bin/webgen +2 -0
- data/data/webgen/webgui/controller/main.rb +2 -0
- data/data/webgen/website_skeleton/ext/init.rb +4 -0
- data/doc/contentprocessor/blocks.page +44 -14
- data/doc/contentprocessor/builder.page +1 -1
- data/doc/contentprocessor/erb.page +1 -1
- data/doc/contentprocessor/erubis.page +1 -1
- data/doc/contentprocessor/fragments.page +1 -1
- data/doc/contentprocessor/haml.page +1 -1
- data/doc/contentprocessor/rdiscount.page +1 -1
- data/doc/contentprocessor/rdoc.page +1 -1
- data/doc/contentprocessor/redcloth.page +1 -1
- data/doc/contentprocessor/sass.page +1 -1
- data/doc/faq.page +7 -2
- data/doc/manual.page +6 -5
- data/doc/reference_metainfo.page +1 -1
- data/doc/sourcehandler/feed.page +9 -1
- data/doc/sourcehandler/sitemap.page +1 -1
- data/doc/tag/coderay.page +1 -1
- data/doc/tag/langbar.page +15 -0
- data/doc/tag/menu.page +1 -1
- data/doc/tag/relocatable.page +2 -2
- data/lib/webgen/blackboard.rb +9 -4
- data/lib/webgen/cache.rb +2 -0
- data/lib/webgen/cli.rb +6 -1
- data/lib/webgen/cli/create_command.rb +2 -0
- data/lib/webgen/cli/run_command.rb +2 -0
- data/lib/webgen/cli/utils.rb +2 -0
- data/lib/webgen/cli/webgui_command.rb +2 -0
- data/lib/webgen/common.rb +12 -1
- data/lib/webgen/common/sitemap.rb +12 -4
- data/lib/webgen/configuration.rb +2 -0
- data/lib/webgen/contentprocessor.rb +2 -0
- data/lib/webgen/contentprocessor/blocks.rb +22 -8
- data/lib/webgen/contentprocessor/builder.rb +2 -0
- data/lib/webgen/contentprocessor/context.rb +2 -0
- data/lib/webgen/contentprocessor/erb.rb +2 -0
- data/lib/webgen/contentprocessor/erubis.rb +2 -0
- data/lib/webgen/contentprocessor/fragments.rb +2 -0
- data/lib/webgen/contentprocessor/haml.rb +2 -0
- data/lib/webgen/contentprocessor/maruku.rb +2 -0
- data/lib/webgen/contentprocessor/rdiscount.rb +2 -0
- data/lib/webgen/contentprocessor/rdoc.rb +2 -0
- data/lib/webgen/contentprocessor/redcloth.rb +2 -0
- data/lib/webgen/contentprocessor/sass.rb +2 -0
- data/lib/webgen/contentprocessor/tags.rb +2 -0
- data/lib/webgen/coreext.rb +2 -0
- data/lib/webgen/default_config.rb +4 -1
- data/lib/webgen/languages.rb +2 -0
- data/lib/webgen/loggable.rb +2 -0
- data/lib/webgen/logger.rb +2 -0
- data/lib/webgen/node.rb +22 -8
- data/lib/webgen/output.rb +3 -1
- data/lib/webgen/output/filesystem.rb +2 -0
- data/lib/webgen/page.rb +2 -0
- data/lib/webgen/path.rb +3 -1
- data/lib/webgen/source.rb +2 -0
- data/lib/webgen/source/filesystem.rb +5 -2
- data/lib/webgen/source/resource.rb +2 -0
- data/lib/webgen/source/stacked.rb +2 -0
- data/lib/webgen/sourcehandler.rb +8 -0
- data/lib/webgen/sourcehandler/base.rb +2 -0
- data/lib/webgen/sourcehandler/copy.rb +2 -0
- data/lib/webgen/sourcehandler/directory.rb +2 -0
- data/lib/webgen/sourcehandler/feed.rb +3 -1
- data/lib/webgen/sourcehandler/fragment.rb +2 -0
- data/lib/webgen/sourcehandler/memory.rb +2 -0
- data/lib/webgen/sourcehandler/metainfo.rb +3 -1
- data/lib/webgen/sourcehandler/page.rb +2 -0
- data/lib/webgen/sourcehandler/sitemap.rb +2 -0
- data/lib/webgen/sourcehandler/template.rb +2 -0
- data/lib/webgen/sourcehandler/virtual.rb +3 -1
- data/lib/webgen/tag.rb +2 -0
- data/lib/webgen/tag/base.rb +2 -0
- data/lib/webgen/tag/breadcrumbtrail.rb +2 -0
- data/lib/webgen/tag/coderay.rb +2 -0
- data/lib/webgen/tag/date.rb +2 -0
- data/lib/webgen/tag/executecommand.rb +2 -0
- data/lib/webgen/tag/includefile.rb +2 -0
- data/lib/webgen/tag/langbar.rb +4 -1
- data/lib/webgen/tag/link.rb +2 -0
- data/lib/webgen/tag/menu.rb +2 -0
- data/lib/webgen/tag/metainfo.rb +2 -0
- data/lib/webgen/tag/relocatable.rb +2 -0
- data/lib/webgen/tag/sitemap.rb +2 -0
- data/lib/webgen/tag/tikz.rb +3 -1
- data/lib/webgen/tree.rb +5 -0
- data/lib/webgen/version.rb +3 -1
- data/lib/webgen/webgentask.rb +2 -0
- data/lib/webgen/website.rb +104 -3
- data/lib/webgen/websiteaccess.rb +2 -0
- data/lib/webgen/websitemanager.rb +2 -0
- data/man/man1/webgen.1 +6 -0
- data/misc/default.css +36 -12
- data/misc/default.template +1 -1
- data/misc/images/error.png +0 -0
- data/misc/images/important.png +0 -0
- data/misc/images/information.png +0 -0
- data/misc/images/warning.png +0 -0
- data/test/helper.rb +4 -0
- data/test/test_blackboard.rb +2 -0
- data/test/test_cache.rb +2 -0
- data/test/test_cli.rb +7 -0
- data/test/test_common.rb +18 -0
- data/test/test_common_sitemap.rb +7 -5
- data/test/test_configuration.rb +2 -0
- data/test/test_contentprocessor.rb +2 -0
- data/test/test_contentprocessor_blocks.rb +22 -1
- data/test/test_contentprocessor_builder.rb +2 -0
- data/test/test_contentprocessor_context.rb +2 -0
- data/test/test_contentprocessor_erb.rb +2 -0
- data/test/test_contentprocessor_erubis.rb +2 -0
- data/test/test_contentprocessor_fragments.rb +2 -0
- data/test/test_contentprocessor_haml.rb +2 -0
- data/test/test_contentprocessor_maruku.rb +2 -0
- data/test/test_contentprocessor_rdiscount.rb +2 -0
- data/test/test_contentprocessor_rdoc.rb +2 -0
- data/test/test_contentprocessor_redcloth.rb +2 -0
- data/test/test_contentprocessor_sass.rb +2 -0
- data/test/test_contentprocessor_tags.rb +2 -0
- data/test/test_languages.rb +2 -0
- data/test/test_loggable.rb +2 -0
- data/test/test_logger.rb +2 -0
- data/test/test_node.rb +2 -0
- data/test/test_output_filesystem.rb +2 -0
- data/test/test_page.rb +2 -0
- data/test/test_path.rb +2 -0
- data/test/test_source_filesystem.rb +17 -0
- data/test/test_source_resource.rb +2 -0
- data/test/test_source_stacked.rb +2 -0
- data/test/test_sourcehandler_base.rb +2 -0
- data/test/test_sourcehandler_copy.rb +2 -0
- data/test/test_sourcehandler_directory.rb +2 -0
- data/test/test_sourcehandler_feed.rb +2 -0
- data/test/test_sourcehandler_fragment.rb +2 -0
- data/test/test_sourcehandler_memory.rb +2 -0
- data/test/test_sourcehandler_metainfo.rb +2 -0
- data/test/test_sourcehandler_page.rb +2 -0
- data/test/test_sourcehandler_sitemap.rb +2 -0
- data/test/test_sourcehandler_template.rb +2 -0
- data/test/test_sourcehandler_virtual.rb +2 -0
- data/test/test_tag_base.rb +4 -0
- data/test/test_tag_breadcrumbtrail.rb +2 -0
- data/test/test_tag_coderay.rb +2 -0
- data/test/test_tag_date.rb +2 -0
- data/test/test_tag_executecommand.rb +2 -0
- data/test/test_tag_includefile.rb +2 -0
- data/test/test_tag_langbar.rb +13 -6
- data/test/test_tag_link.rb +2 -0
- data/test/test_tag_menu.rb +2 -0
- data/test/test_tag_metainfo.rb +2 -0
- data/test/test_tag_relocatable.rb +2 -0
- data/test/test_tag_sitemap.rb +4 -1
- data/test/test_tag_tikz.rb +4 -1
- data/test/test_tree.rb +2 -0
- data/test/test_webgentask.rb +2 -0
- data/test/test_website.rb +6 -4
- data/test/test_websiteaccess.rb +2 -0
- data/test/test_websitemanager.rb +2 -0
- metadata +8 -5
- data/misc/images/error.gif +0 -0
- data/misc/images/exclamation.gif +0 -0
- data/misc/images/information.gif +0 -0
data/lib/webgen/cli/utils.rb
CHANGED
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 =
|
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.
|
data/lib/webgen/configuration.rb
CHANGED
@@ -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
|
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
|
-
|
17
|
-
|
18
|
-
|
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 =
|
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?(
|
32
|
-
|
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[
|
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
|
data/lib/webgen/coreext.rb
CHANGED
@@ -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.')
|
data/lib/webgen/languages.rb
CHANGED
data/lib/webgen/loggable.rb
CHANGED
data/lib/webgen/logger.rb
CHANGED
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
|
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
|
-
|
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
|
-
|
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:
|
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
|
#
|
data/lib/webgen/page.rb
CHANGED
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)
|
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
|
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
|
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
|