webgen 0.5.8 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +4 -0
- data/ChangeLog +1037 -0
- data/Rakefile +5 -6
- data/THANKS +1 -0
- data/VERSION +1 -1
- data/bin/webgen +1 -1
- data/data/webgen/passive_sources/images/generated_by_webgen.png +0 -0
- data/data/webgen/passive_sources/images/webgen_logo.png +0 -0
- data/data/webgen/passive_sources/stylesheets/coderay-default.css +129 -0
- data/data/webgen/passive_sources/templates/atom_feed.template +38 -0
- data/data/webgen/passive_sources/templates/rss_feed.template +28 -0
- data/data/webgen/passive_sources/templates/sitemap.template +21 -0
- data/data/webgen/resources.yaml +2 -1
- data/data/webgen/website_skeleton/Rakefile +5 -1
- data/doc/contentprocessor/builder.page +2 -2
- data/doc/contentprocessor/erb.page +5 -2
- data/doc/contentprocessor/erubis.page +2 -2
- data/doc/contentprocessor/head.page +21 -0
- data/doc/contentprocessor/tidy.page +14 -0
- data/doc/extensions.page +1 -1
- data/doc/faq.page +2 -2
- data/doc/manual.page +108 -43
- data/doc/reference_configuration.page +83 -5
- data/doc/reference_metainfo.page +24 -4
- data/doc/reference_website_styles.page +2 -2
- data/doc/sourcehandler/feed.page +11 -13
- data/doc/sourcehandler/metainfo.page +10 -3
- data/doc/sourcehandler/page.page +4 -4
- data/doc/sourcehandler/sitemap.page +8 -7
- data/doc/tag/coderay.page +6 -2
- data/doc/tag/includefile.page +1 -1
- data/doc/tag/menu.page +3 -0
- data/lib/webgen/cli/apply_command.rb +1 -1
- data/lib/webgen/cli/utils.rb +2 -2
- data/lib/webgen/common.rb +0 -9
- data/lib/webgen/contentprocessor.rb +18 -3
- data/lib/webgen/contentprocessor/blocks.rb +67 -36
- data/lib/webgen/contentprocessor/builder.rb +5 -2
- data/lib/webgen/contentprocessor/erb.rb +4 -2
- data/lib/webgen/contentprocessor/erubis.rb +5 -2
- data/lib/webgen/contentprocessor/haml.rb +6 -2
- data/lib/webgen/contentprocessor/head.rb +64 -0
- data/lib/webgen/contentprocessor/maruku.rb +3 -1
- 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 +5 -3
- data/lib/webgen/contentprocessor/tags.rb +40 -24
- data/lib/webgen/contentprocessor/tidy.rb +38 -0
- data/lib/webgen/context.rb +13 -4
- data/lib/webgen/context/render.rb +32 -0
- data/lib/webgen/context/tags.rb +20 -0
- data/lib/webgen/default_config.rb +15 -4
- data/lib/webgen/deprecated.rb +38 -4
- data/lib/webgen/error.rb +135 -0
- data/lib/webgen/node.rb +48 -40
- data/lib/webgen/output.rb +5 -3
- data/lib/webgen/output/filesystem.rb +4 -4
- data/lib/webgen/page.rb +4 -4
- data/lib/webgen/path.rb +161 -58
- data/lib/webgen/source.rb +9 -6
- data/lib/webgen/source/filesystem.rb +1 -1
- data/lib/webgen/source/stacked.rb +13 -5
- data/lib/webgen/source/tararchive.rb +6 -2
- data/lib/webgen/sourcehandler.rb +100 -54
- data/lib/webgen/sourcehandler/base.rb +58 -24
- data/lib/webgen/sourcehandler/copy.rb +6 -5
- data/lib/webgen/sourcehandler/directory.rb +3 -9
- data/lib/webgen/sourcehandler/feed.rb +25 -50
- data/lib/webgen/sourcehandler/fragment.rb +10 -8
- data/lib/webgen/sourcehandler/memory.rb +9 -10
- data/lib/webgen/sourcehandler/metainfo.rb +9 -9
- data/lib/webgen/sourcehandler/page.rb +6 -5
- data/lib/webgen/sourcehandler/sitemap.rb +22 -22
- data/lib/webgen/sourcehandler/template.rb +6 -6
- data/lib/webgen/sourcehandler/virtual.rb +19 -17
- data/lib/webgen/tag/base.rb +27 -27
- data/lib/webgen/tag/breadcrumbtrail.rb +3 -3
- data/lib/webgen/tag/coderay.rb +19 -8
- data/lib/webgen/tag/executecommand.rb +4 -3
- data/lib/webgen/tag/langbar.rb +2 -2
- data/lib/webgen/tag/link.rb +8 -7
- data/lib/webgen/tag/menu.rb +2 -2
- data/lib/webgen/tag/metainfo.rb +1 -1
- data/lib/webgen/tag/relocatable.rb +17 -21
- data/lib/webgen/tag/tikz.rb +7 -10
- data/lib/webgen/tree.rb +7 -7
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/website.rb +32 -2
- data/misc/default.css +8 -2
- data/misc/default.template +2 -2
- data/misc/logo.svg +313 -0
- data/misc/style.page +1 -1
- data/test/helper.rb +18 -2
- data/test/test_cli.rb +104 -0
- data/test/test_common_sitemap.rb +1 -1
- data/test/test_contentprocessor.rb +8 -2
- data/test/test_contentprocessor_blocks.rb +17 -8
- data/test/test_contentprocessor_builder.rb +13 -2
- data/test/test_contentprocessor_erb.rb +9 -3
- data/test/test_contentprocessor_erubis.rb +9 -3
- data/test/test_contentprocessor_fragments.rb +12 -11
- data/test/test_contentprocessor_haml.rb +11 -2
- data/test/test_contentprocessor_head.rb +44 -0
- data/test/test_contentprocessor_maruku.rb +5 -1
- data/test/test_contentprocessor_rdiscount.rb +4 -0
- data/test/test_contentprocessor_rdoc.rb +4 -0
- data/test/test_contentprocessor_redcloth.rb +5 -1
- data/test/test_contentprocessor_sass.rb +8 -2
- data/test/test_contentprocessor_tags.rb +22 -7
- data/test/test_contentprocessor_tidy.rb +34 -0
- data/test/test_context.rb +39 -0
- data/test/test_error.rb +85 -0
- data/test/test_node.rb +57 -21
- data/test/test_page.rb +23 -5
- data/test/test_path.rb +120 -64
- data/test/test_source_filesystem.rb +1 -1
- data/test/test_source_stacked.rb +19 -6
- data/test/test_sourcehandler_base.rb +63 -50
- data/test/test_sourcehandler_copy.rb +6 -6
- data/test/test_sourcehandler_directory.rb +8 -12
- data/test/test_sourcehandler_feed.rb +15 -7
- data/test/test_sourcehandler_fragment.rb +6 -5
- data/test/test_sourcehandler_main.rb +39 -0
- data/test/test_sourcehandler_memory.rb +4 -4
- data/test/test_sourcehandler_metainfo.rb +20 -11
- data/test/test_sourcehandler_page.rb +10 -10
- data/test/test_sourcehandler_sitemap.rb +24 -5
- data/test/test_sourcehandler_template.rb +18 -15
- data/test/test_sourcehandler_virtual.rb +9 -5
- data/test/test_tag_base.rb +6 -29
- data/test/test_tag_coderay.rb +16 -3
- data/test/test_tag_executecommand.rb +2 -2
- data/test/test_tag_link.rb +5 -4
- data/test/test_tag_menu.rb +15 -15
- data/test/test_tag_metainfo.rb +1 -0
- data/test/test_tag_relocatable.rb +3 -2
- data/test/test_tag_tikz.rb +5 -5
- data/test/test_tree.rb +8 -8
- data/test/test_website.rb +15 -0
- metadata +21 -14
- data/test/test_common.rb +0 -18
|
@@ -9,9 +9,9 @@ module Webgen::SourceHandler
|
|
|
9
9
|
include Webgen::WebsiteAccess
|
|
10
10
|
include Base
|
|
11
11
|
|
|
12
|
-
# Create the node for +
|
|
13
|
-
#
|
|
14
|
-
def create_node(
|
|
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(
|
|
23
|
+
super(path) do |node|
|
|
24
24
|
node.node_info[:preprocessor] = processor
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -30,7 +30,8 @@ module Webgen::SourceHandler
|
|
|
30
30
|
def content(node)
|
|
31
31
|
io = website.blackboard.invoke(:source_paths)[node.node_info[:src]].io
|
|
32
32
|
if node.node_info[:preprocessor]
|
|
33
|
-
|
|
33
|
+
is_binary = website.blackboard.invoke(:content_processor_binary?, node.node_info[:preprocessor])
|
|
34
|
+
context = Webgen::Context.new(:content => io.data(is_binary ? 'rb' : 'r'), :chain => [node])
|
|
34
35
|
website.blackboard.invoke(:content_processor, node.node_info[:preprocessor]).call(context)
|
|
35
36
|
context.content
|
|
36
37
|
else
|
|
@@ -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.
|
|
20
|
-
nodes = website.blackboard.invoke(:create_nodes,
|
|
21
|
-
|
|
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,18 +15,19 @@ 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 +
|
|
19
|
-
def create_node(
|
|
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'] ||=
|
|
21
|
+
path.meta_info['link'] ||= path.parent_path
|
|
22
22
|
|
|
23
23
|
if MANDATORY_INFOS.any? {|t| path.meta_info[t].nil?}
|
|
24
|
-
raise "
|
|
24
|
+
raise Webgen::NodeCreationError.new("At least one of #{MANDATORY_INFOS.join('/')} is missing",
|
|
25
|
+
self.class.name, path)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
create_feed_node = lambda do |type|
|
|
28
29
|
path.ext = type
|
|
29
|
-
super(
|
|
30
|
+
super(path) do |node|
|
|
30
31
|
node.node_info[:feed] = page
|
|
31
32
|
node.node_info[:feed_type] = type
|
|
32
33
|
end
|
|
@@ -41,74 +42,48 @@ module Webgen::SourceHandler
|
|
|
41
42
|
|
|
42
43
|
# Return the rendered feed represented by +node+.
|
|
43
44
|
def content(node)
|
|
44
|
-
website.cache[[:sourcehandler_feed, node.node_info[:src]]] = feed_entries(node).map {|n| n.
|
|
45
|
+
website.cache[[:sourcehandler_feed, node.node_info[:src]]] = feed_entries(node).map {|n| n.alcn}
|
|
46
|
+
|
|
45
47
|
block_name = node.node_info[:feed_type] + '_template'
|
|
46
48
|
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
|
|
49
|
+
node.node_info[:feed].blocks[block_name].render(Webgen::Context.new(:chain => [node])).content
|
|
49
50
|
else
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
chain = [node.resolve("/templates/#{node.node_info[:feed_type]}_feed.template"), node]
|
|
52
|
+
node.node_info[:used_nodes] << chain.first.alcn
|
|
53
|
+
chain.first.node_info[:page].blocks['content'].render(Webgen::Context.new(:chain => chain)).content
|
|
52
54
|
end
|
|
53
55
|
end
|
|
54
56
|
|
|
55
|
-
#
|
|
57
|
+
# Return the entries for the feed +node+.
|
|
56
58
|
def feed_entries(node)
|
|
57
59
|
nr_items = (node['number_of_entries'].to_i == 0 ? 10 : node['number_of_entries'].to_i)
|
|
58
|
-
patterns = [node['entries']].flatten.map {|pat| Webgen::
|
|
60
|
+
patterns = [node['entries']].flatten.map {|pat| Webgen::Path.make_absolute(node.parent.alcn, pat)}
|
|
59
61
|
|
|
60
62
|
node.tree.node_access[:alcn].values.
|
|
61
63
|
select {|node| patterns.any? {|pat| node =~ pat} && node.node_info[:page]}.
|
|
62
64
|
sort {|a,b| a['modified_at'] <=> b['modified_at']}[0, nr_items]
|
|
63
65
|
end
|
|
64
66
|
|
|
67
|
+
# Return the feed link URL for the feed +node+.
|
|
68
|
+
def feed_link(node)
|
|
69
|
+
Webgen::Node.url(File.join(node['site_url'], node.tree[node['link']].path), false)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Return the content of an +entry+ of the feed +node+.
|
|
73
|
+
def entry_content(node, entry)
|
|
74
|
+
entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::Context.new(:chain => [entry])).content
|
|
75
|
+
end
|
|
76
|
+
|
|
65
77
|
#######
|
|
66
78
|
private
|
|
67
79
|
#######
|
|
68
80
|
|
|
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
81
|
# Check if the any of the nodes used by this feed +node+ have changed and then mark the node as
|
|
107
82
|
# dirty.
|
|
108
83
|
def node_changed?(node)
|
|
109
84
|
return if node.node_info[:processor] != self.class.name
|
|
110
85
|
entries = node.feed_entries
|
|
111
|
-
node.flag(:dirty) if entries.map {|n| n.
|
|
86
|
+
node.flag(:dirty) if entries.map {|n| n.alcn } != website.cache[[:sourcehandler_feed, node.node_info[:src]]] ||
|
|
112
87
|
entries.any? {|n| n.changed?}
|
|
113
88
|
end
|
|
114
89
|
|
|
@@ -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
|
|
50
|
-
#
|
|
51
|
-
# info +sort_info+ is calculated from the base
|
|
52
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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(
|
|
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
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
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.
|
|
34
|
-
@data[node.
|
|
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 +
|
|
26
|
-
def create_node(
|
|
25
|
+
# Create a meta info node from +path+.
|
|
26
|
+
def create_node(path)
|
|
27
27
|
page = page_from_path(path)
|
|
28
|
-
super(
|
|
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::
|
|
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.
|
|
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.
|
|
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.
|
|
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(
|
|
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.
|
|
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 +
|
|
16
|
-
def create_node(
|
|
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(
|
|
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,12 @@ 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.
|
|
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 "
|
|
38
|
+
raise Webgen::RenderError.new("No block named '#{block_name}'",
|
|
39
|
+
self.class.name, node.alcn, chain.first.alcn)
|
|
39
40
|
end
|
|
40
41
|
end
|
|
41
42
|
alias_method :content, :render_node
|
|
@@ -14,34 +14,34 @@ module Webgen::SourceHandler
|
|
|
14
14
|
include Webgen::WebsiteAccess
|
|
15
15
|
include Base
|
|
16
16
|
|
|
17
|
-
# Create an XML sitemap from +
|
|
18
|
-
def create_node(
|
|
19
|
-
page_from_path(path)
|
|
17
|
+
# Create an XML sitemap from +path+.
|
|
18
|
+
def create_node(path)
|
|
19
|
+
page = page_from_path(path)
|
|
20
20
|
path.ext = 'xml'
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
if path.meta_info['site_url'].nil?
|
|
22
|
+
raise Webgen::NodeCreationError.new("Needed information site_url is missing",
|
|
23
|
+
self.class.name, path)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
super(path) do |node|
|
|
27
|
+
node.node_info[:sitemap] = page
|
|
28
|
+
end
|
|
23
29
|
end
|
|
24
30
|
|
|
25
31
|
# Return the rendered feed represented by +node+.
|
|
26
32
|
def content(node)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
item = node.tree[alcn]
|
|
34
|
-
sitemap.url do |url|
|
|
35
|
-
sitemap.loc(URI.escape(File.join(node['site_url'], item.path)))
|
|
36
|
-
sitemap.lastmod(item['modified_at'].iso8601)
|
|
37
|
-
changefreq = item['change_freq'] || node['default_change_freq']
|
|
38
|
-
sitemap.changefreq(changefreq) if changefreq
|
|
39
|
-
priority = item['priority'] || node['default_priority']
|
|
40
|
-
sitemap.priority(priority) if priority
|
|
41
|
-
end
|
|
42
|
-
end
|
|
33
|
+
if node.node_info[:sitemap].blocks.has_key?('template')
|
|
34
|
+
node.node_info[:sitemap].blocks['template'].render(Webgen::Context.new(:chain => [node])).content
|
|
35
|
+
else
|
|
36
|
+
chain = [node.resolve("/templates/sitemap.template"), node]
|
|
37
|
+
node.node_info[:used_nodes] << chain.first.alcn
|
|
38
|
+
chain.first.node_info[:page].blocks['content'].render(Webgen::Context.new(:chain => chain)).content
|
|
43
39
|
end
|
|
44
|
-
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Return the alcns of the sitemap +node+ as a flat list.
|
|
43
|
+
def alcns(node)
|
|
44
|
+
website.blackboard.invoke(:create_sitemap, node, node.lang, options_for_node(node)).to_lcn_list.flatten
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
#######
|
|
@@ -9,30 +9,30 @@ module Webgen::SourceHandler
|
|
|
9
9
|
include Webgen::Loggable
|
|
10
10
|
include Base
|
|
11
11
|
|
|
12
|
-
# Create a template node
|
|
13
|
-
def create_node(
|
|
12
|
+
# Create a template node for +path+.
|
|
13
|
+
def create_node(path)
|
|
14
14
|
page = page_from_path(path)
|
|
15
|
-
super(
|
|
15
|
+
super(path) do |node|
|
|
16
16
|
node.node_info[:page] = page
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
# Return the template chain for +node+.
|
|
21
21
|
def templates_for_node(node, lang = node.lang)
|
|
22
|
-
cached_template = (website.cache.volatile[[node.
|
|
22
|
+
cached_template = (website.cache.volatile[[node.alcn, :templates]] ||= {})
|
|
23
23
|
if cached_template[lang]
|
|
24
24
|
template_node = cached_template[lang]
|
|
25
25
|
elsif node['template'].kind_of?(String)
|
|
26
26
|
template_node = node.resolve(node['template'], lang)
|
|
27
27
|
if template_node.nil?
|
|
28
|
-
log(:warn) { "Specified template '#{node['template']}' for <#{node.
|
|
28
|
+
log(:warn) { "Specified template '#{node['template']}' for <#{node.alcn}> not found, using default template!" }
|
|
29
29
|
template_node = default_template(node.parent, lang)
|
|
30
30
|
end
|
|
31
31
|
cached_template[lang] = template_node
|
|
32
32
|
elsif node.meta_info.has_key?('template') && node['template'].nil?
|
|
33
33
|
template_node = cached_template[lang] = nil
|
|
34
34
|
else
|
|
35
|
-
log(:info) { "Using default template in language '#{lang}' for <#{node.
|
|
35
|
+
log(:info) { "Using default template in language '#{lang}' for <#{node.alcn}>" }
|
|
36
36
|
template_node = default_template(node.parent, lang)
|
|
37
37
|
if template_node == node && !node.parent.is_root?
|
|
38
38
|
template_node = default_template(node.parent.parent, lang)
|
|
@@ -19,26 +19,25 @@ module Webgen::SourceHandler
|
|
|
19
19
|
@path_data = {}
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
# Create all virtual nodes
|
|
23
|
-
def create_node(
|
|
22
|
+
# Create all virtual nodes which are specified in +path+.
|
|
23
|
+
def create_node(path)
|
|
24
24
|
nodes = []
|
|
25
25
|
read_data(path).each do |key, meta_info|
|
|
26
26
|
cache_data = [key, meta_info.dup]
|
|
27
27
|
|
|
28
|
-
key = Webgen::
|
|
29
|
-
temp_parent = create_directories(
|
|
28
|
+
key = Webgen::Path.make_absolute(path.parent_path, key) + (key =~ /\/$/ ? '/' : '')
|
|
29
|
+
temp_parent = create_directories(File.dirname(key), path)
|
|
30
30
|
|
|
31
31
|
output_path = meta_info.delete('url') || key
|
|
32
32
|
output_path = (URI::parse(output_path).absolute? || output_path =~ /^\// ?
|
|
33
|
-
output_path : File.join(temp_parent.
|
|
33
|
+
output_path : File.join(temp_parent.alcn, output_path))
|
|
34
34
|
|
|
35
35
|
if key =~ /\/$/
|
|
36
|
-
nodes << create_directory(
|
|
36
|
+
nodes << create_directory(key, path, meta_info)
|
|
37
37
|
else
|
|
38
|
-
nodes += website.blackboard.invoke(:create_nodes,
|
|
39
|
-
Webgen::Path.new(key, path.source_path), self) do |cn_parent, cn_path|
|
|
38
|
+
nodes += website.blackboard.invoke(:create_nodes, Webgen::Path.new(key, path.source_path), self) do |cn_path|
|
|
40
39
|
cn_path.meta_info.update(meta_info)
|
|
41
|
-
super(
|
|
40
|
+
super(cn_path, :output_path => output_path) do |n|
|
|
42
41
|
n.node_info[:sh_virtual_cache_data] = cache_data
|
|
43
42
|
end
|
|
44
43
|
end
|
|
@@ -69,25 +68,28 @@ module Webgen::SourceHandler
|
|
|
69
68
|
end
|
|
70
69
|
|
|
71
70
|
# Create the needed parent directories for a virtual node.
|
|
72
|
-
def create_directories(
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
def create_directories(dirname, path)
|
|
72
|
+
parent = website.tree.root
|
|
73
|
+
dirname.sub(/^\//, '').split('/').inject('/') do |parent_path, dir|
|
|
74
|
+
parent_path = File.join(parent_path, dir)
|
|
75
|
+
parent = create_directory(parent_path, path)
|
|
75
76
|
end
|
|
76
77
|
parent
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
# Create a virtual directory if it does not already exist.
|
|
80
|
-
def create_directory(
|
|
81
|
+
def create_directory(dir, path, meta_info = nil)
|
|
81
82
|
dir_handler = website.cache.instance('Webgen::SourceHandler::Directory')
|
|
82
|
-
website.
|
|
83
|
+
parent = website.tree.root
|
|
84
|
+
website.blackboard.invoke(:create_nodes,
|
|
83
85
|
Webgen::Path.new(File.join(dir, '/'), path.source_path),
|
|
84
|
-
dir_handler) do |
|
|
85
|
-
parent = dir_handler.node_exists?(
|
|
86
|
+
dir_handler) do |temp_path|
|
|
87
|
+
parent = dir_handler.node_exists?(temp_path)
|
|
86
88
|
if (parent && (parent.node_info[:src] == path.source_path) && !meta_info.nil?) ||
|
|
87
89
|
!parent
|
|
88
90
|
temp_path.meta_info.update(meta_info) if meta_info
|
|
89
91
|
parent.flag(:reinit) if parent
|
|
90
|
-
parent = dir_handler.create_node(
|
|
92
|
+
parent = dir_handler.create_node(temp_path)
|
|
91
93
|
end
|
|
92
94
|
parent
|
|
93
95
|
end
|