gettalong-webgen 0.5.7.20090227 → 0.5.8.20090507
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/Rakefile +37 -36
- data/data/webgen/resources.yaml +2 -2
- data/data/webgen/webgui/app.rb +11 -0
- data/data/webgen/webgui/controller/main.rb +30 -26
- data/data/webgen/webgui/{view/page.xhtml → layout/default.xhtml} +8 -8
- data/data/webgen/webgui/start.rb +9 -0
- data/data/webgen/webgui/view/create_website.xhtml +6 -14
- data/data/webgen/webgui/view/manage_website.xhtml +2 -2
- data/data/webgen/website_bundles/default/README +6 -0
- data/data/webgen/website_bundles/default/src/index.page +15 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/src/images/background.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/bg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/front.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg2.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/bg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/front.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/print.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/bodybg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/contbg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/footerbg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient1.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient2.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/blinkarrow.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/bodybg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/contentbg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/entrybg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash2.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globe.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globebottom.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/linkarrow.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/menuhover.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/bodybg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/front.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.css +6 -4
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.template +2 -2
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/bodybg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/boxbg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/greypx.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/header.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/innerbg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/leaves.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/tabs.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/browserfix.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/bodybg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/sidebarbg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas08/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-black.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-green.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-orange.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-purple.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-red.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/footerbg.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-black.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-green.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-orange.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-purple.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-red.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/simple/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.template +0 -0
- data/data/webgen/website_skeleton/README +1 -1
- data/data/webgen/website_skeleton/config.yaml +5 -4
- data/doc/contentprocessor/blocks.page +43 -10
- data/doc/contentprocessor/builder.page +1 -1
- data/doc/contentprocessor/erb.page +12 -11
- data/doc/contentprocessor/redcloth.page +3 -1
- data/doc/extensions.page +3 -3
- data/doc/faq.page +13 -10
- data/doc/getting_started.page +12 -15
- data/doc/index.page +7 -1
- data/doc/manual.page +78 -27
- data/doc/reference_configuration.page +166 -3
- data/doc/reference_website_styles.page +28 -0
- data/doc/source/filesystem.page +39 -0
- data/doc/source/tararchive.page +40 -0
- data/doc/tag/tikz.page +2 -1
- data/doc/webgen_page_format.page +13 -12
- data/doc/website_styles.metainfo +8 -0
- data/lib/webgen/blackboard.rb +2 -2
- data/lib/webgen/cache.rb +4 -4
- data/lib/webgen/cli.rb +29 -16
- data/lib/webgen/cli/apply_command.rb +66 -0
- data/lib/webgen/cli/create_command.rb +22 -16
- data/lib/webgen/cli/utils.rb +23 -0
- data/lib/webgen/cli/webgui_command.rb +31 -16
- data/lib/webgen/configuration.rb +8 -6
- data/lib/webgen/contentprocessor.rb +4 -5
- data/lib/webgen/contentprocessor/blocks.rb +2 -0
- data/lib/webgen/contentprocessor/builder.rb +6 -3
- data/lib/webgen/contentprocessor/erb.rb +6 -3
- data/lib/webgen/contentprocessor/erubis.rb +7 -6
- data/lib/webgen/contentprocessor/haml.rb +6 -3
- data/lib/webgen/contentprocessor/rdoc.rb +0 -1
- data/lib/webgen/contentprocessor/redcloth.rb +3 -1
- data/lib/webgen/context.rb +73 -0
- data/lib/webgen/context/nodes.rb +36 -0
- data/lib/webgen/coreext.rb +3 -2
- data/lib/webgen/default_config.rb +3 -1
- data/lib/webgen/deprecated.rb +53 -0
- data/lib/webgen/node.rb +24 -19
- data/lib/webgen/output.rb +50 -7
- data/lib/webgen/page.rb +45 -36
- data/lib/webgen/path.rb +1 -1
- data/lib/webgen/source.rb +32 -4
- data/lib/webgen/source/resource.rb +3 -3
- data/lib/webgen/source/stacked.rb +1 -1
- data/lib/webgen/source/tararchive.rb +73 -0
- data/lib/webgen/sourcehandler.rb +4 -4
- data/lib/webgen/sourcehandler/base.rb +36 -24
- data/lib/webgen/sourcehandler/copy.rb +1 -1
- data/lib/webgen/sourcehandler/feed.rb +2 -2
- data/lib/webgen/sourcehandler/fragment.rb +1 -1
- data/lib/webgen/sourcehandler/metainfo.rb +15 -6
- data/lib/webgen/sourcehandler/page.rb +9 -5
- data/lib/webgen/sourcehandler/virtual.rb +44 -7
- data/lib/webgen/tag/base.rb +19 -13
- data/lib/webgen/tag/link.rb +1 -0
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/webgentask.rb +15 -13
- data/lib/webgen/website.rb +42 -11
- data/lib/webgen/websiteaccess.rb +1 -1
- data/lib/webgen/websitemanager.rb +61 -66
- data/man/man1/webgen.1 +4 -0
- data/misc/default.css +13 -0
- data/misc/default.template +1 -1
- data/misc/htmldoc.metainfo +2 -1
- data/misc/style.page +33 -0
- data/test/test_cli.rb +1 -7
- data/test/test_common_sitemap.rb +2 -2
- data/test/test_contentprocessor_blocks.rb +14 -1
- data/test/test_contentprocessor_builder.rb +3 -1
- data/test/test_contentprocessor_erb.rb +3 -2
- data/test/test_contentprocessor_erubis.rb +3 -3
- data/test/test_contentprocessor_fragments.rb +3 -3
- data/test/test_contentprocessor_haml.rb +3 -2
- data/test/test_contentprocessor_maruku.rb +3 -3
- data/test/test_contentprocessor_rdiscount.rb +1 -1
- data/test/test_contentprocessor_rdoc.rb +1 -1
- data/test/test_contentprocessor_redcloth.rb +9 -2
- data/test/test_contentprocessor_sass.rb +1 -1
- data/test/test_contentprocessor_tags.rb +1 -1
- data/test/{test_contentprocessor_context.rb → test_context.rb} +9 -7
- data/test/test_node.rb +27 -21
- data/test/test_page.rb +4 -4
- data/test/test_source_tararchive.rb +65 -0
- data/test/test_sourcehandler_fragment.rb +1 -1
- data/test/test_sourcehandler_memory.rb +6 -6
- data/test/test_sourcehandler_metainfo.rb +34 -13
- data/test/test_sourcehandler_page.rb +8 -0
- data/test/test_sourcehandler_virtual.rb +51 -12
- data/test/test_tag_breadcrumbtrail.rb +4 -4
- data/test/test_tag_coderay.rb +1 -1
- data/test/test_tag_date.rb +1 -1
- data/test/test_tag_executecommand.rb +1 -1
- data/test/test_tag_includefile.rb +3 -3
- data/test/test_tag_langbar.rb +6 -6
- data/test/test_tag_link.rb +8 -2
- data/test/test_tag_menu.rb +9 -9
- data/test/test_tag_metainfo.rb +1 -1
- data/test/test_tag_relocatable.rb +1 -1
- data/test/test_tag_sitemap.rb +1 -1
- data/test/test_tag_tikz.rb +2 -2
- data/test/test_website.rb +17 -0
- data/test/test_websitemanager.rb +16 -21
- metadata +181 -171
- data/data/webgen/website_templates/default/README +0 -6
- data/data/webgen/website_templates/default/src/index.page +0 -8
- data/data/webgen/website_templates/project/README +0 -5
- data/data/webgen/website_templates/project/src/about.page +0 -12
- data/data/webgen/website_templates/project/src/download.page +0 -15
- data/data/webgen/website_templates/project/src/features.page +0 -8
- data/data/webgen/website_templates/project/src/index.page +0 -9
- data/data/webgen/website_templates/project/src/screenshots.page +0 -18
- data/lib/webgen/contentprocessor/context.rb +0 -89
data/lib/webgen/sourcehandler.rb
CHANGED
@@ -62,7 +62,7 @@ module Webgen
|
|
62
62
|
write_tree(tree)
|
63
63
|
end
|
64
64
|
puts "...done in " + ('%2.4f' % time.real) + ' seconds'
|
65
|
-
end while tree.node_access[:alcn].any? {|name,node| node.flagged(:created) || node.flagged(:reinit)}
|
65
|
+
end while tree.node_access[:alcn].any? {|name,node| node.flagged?(:created) || node.flagged?(:reinit)}
|
66
66
|
:success
|
67
67
|
end
|
68
68
|
|
@@ -86,7 +86,7 @@ module Webgen
|
|
86
86
|
if deleted
|
87
87
|
nodes_to_delete << node
|
88
88
|
#TODO: delete output path
|
89
|
-
elsif (!node.flagged(:created) && find_all_source_paths[node.node_info[:src]].changed?) || node.meta_info_changed?
|
89
|
+
elsif (!node.flagged?(:created) && find_all_source_paths[node.node_info[:src]].changed?) || node.meta_info_changed?
|
90
90
|
node.flag(:reinit)
|
91
91
|
paths_to_use << node.node_info[:src]
|
92
92
|
elsif node.changed?
|
@@ -98,7 +98,7 @@ module Webgen
|
|
98
98
|
used_paths.merge(paths_to_use)
|
99
99
|
paths = create_nodes_from_paths(tree, used_paths.to_a.sort)
|
100
100
|
unused_paths.merge(used_paths - paths)
|
101
|
-
tree.node_access[:alcn].each {|name, node| tree.delete_node(node) if node.flagged(:reinit)}
|
101
|
+
tree.node_access[:alcn].each {|name, node| tree.delete_node(node) if node.flagged?(:reinit)}
|
102
102
|
website.cache.reset_volatile_cache
|
103
103
|
end until used_paths.empty?
|
104
104
|
end
|
@@ -108,7 +108,7 @@ module Webgen
|
|
108
108
|
output = website.blackboard.invoke(:output_instance)
|
109
109
|
|
110
110
|
tree.node_access[:alcn].select do |name, node|
|
111
|
-
use_node = (node != tree.dummy_root && node.flagged(:dirty))
|
111
|
+
use_node = (node != tree.dummy_root && node.flagged?(:dirty))
|
112
112
|
node.unflag(:dirty_meta_info)
|
113
113
|
node.unflag(:created)
|
114
114
|
node.unflag(:dirty)
|
@@ -10,7 +10,7 @@ module Webgen::SourceHandler
|
|
10
10
|
# This module should be included in every source handler as it provides the default methods for
|
11
11
|
# creating nodes.
|
12
12
|
#
|
13
|
-
#
|
13
|
+
# == Implementing Source Handlers
|
14
14
|
#
|
15
15
|
# A source handler is a webgen extension that processes source paths to create nodes and that
|
16
16
|
# provides the rendered content of these nodes. The nodes are later written to the output
|
@@ -27,42 +27,53 @@ module Webgen::SourceHandler
|
|
27
27
|
# not need to reside under the Webgen::SourceHandler namespace but all shipped ones do.
|
28
28
|
#
|
29
29
|
# This base class provides useful default implementations of methods that are used by nearly all
|
30
|
-
# source handler
|
30
|
+
# source handler classes:
|
31
31
|
# * #create_node
|
32
|
+
# * #output_path
|
32
33
|
# * #node_exists?
|
33
34
|
#
|
34
35
|
# It also provides other utility methods:
|
35
36
|
# * #page_from_path
|
36
37
|
# * #content
|
37
38
|
#
|
38
|
-
#
|
39
|
+
# == Nodes Created for Paths
|
39
40
|
#
|
40
41
|
# The main functions of a source handler class are to create one or more nodes for a source path
|
41
42
|
# and to provide the content of these nodes. To achieve this, certain information needs to be set
|
42
|
-
# on a node. If you use the
|
43
|
-
# explicitly because this is done by the
|
43
|
+
# on a created node. If you use the +create_node+ method provided by this base class, you don't
|
44
|
+
# need to set them explicitly because this is done by the method:
|
44
45
|
#
|
45
|
-
# <tt>node_info[:processor]</tt
|
46
|
+
# [<tt>node_info[:processor]</tt>] Has to be set to the class name of the source handler. This is
|
46
47
|
# used by the Node class: all unknown method calls are forwarded
|
47
48
|
# to the node processor.
|
48
|
-
# <tt>node_info[:src]</tt
|
49
|
+
# [<tt>node_info[:src]</tt>] Has to be set to the string version of the path that lead to the
|
49
50
|
# creation of the node.
|
50
|
-
# <tt>node_info[:creation_path]</tt
|
51
|
+
# [<tt>node_info[:creation_path]</tt>] Has to be set to the string version of the path that is
|
51
52
|
# used to create the path.
|
52
|
-
# <tt>meta_info['no_output']</tt
|
53
|
+
# [<tt>meta_info['no_output']</tt>] Has to be set to +true+ on nodes that are used during a
|
53
54
|
# webgen run but do not produce an output file.
|
54
|
-
# <tt>meta_info['modified_at']</tt
|
55
|
+
# [<tt>meta_info['modified_at']</tt>] Has to be set to the current time if not already set
|
55
56
|
# correctly (ie. if not a Time object).
|
56
57
|
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
58
|
+
# If <tt>meta_info['draft']</tt> is set on a path, then no node should be created in +create_node+
|
59
|
+
# and +nil+ has to be returned.
|
60
|
+
#
|
61
|
+
# Note: The difference between +:src+ and +:creation_path+ is that a creation path
|
62
|
+
# need not have an existing source path representation. For example, fragments created from a page
|
63
|
+
# source path have a different +:creation_path+ which includes the fragment part.
|
60
64
|
#
|
61
65
|
# Additional information that is used only for processing purposes should be stored in the
|
62
66
|
# #node_info hash of a node as the #meta_info hash is reserved for real node meta information and
|
63
67
|
# should not be changed once the node is created.
|
64
68
|
#
|
65
|
-
#
|
69
|
+
# == Output Path Names
|
70
|
+
#
|
71
|
+
# The method for creating an output path name for a source path is stored in the meta information
|
72
|
+
# +output_path+. If you don't use the provided method +output_path+, have a look at its
|
73
|
+
# implementation to see how to an output path gets created. Individual output path creation
|
74
|
+
# methods are stored as methods in the OutputPathHelpers module.
|
75
|
+
#
|
76
|
+
# == Path Patterns and Invocation order
|
66
77
|
#
|
67
78
|
# Path patterns define which paths are handled by a specific source handler. These patterns are
|
68
79
|
# specified in the <tt>sourcehandler.patterns</tt> configuration hash as a mapping from the source
|
@@ -76,12 +87,12 @@ module Webgen::SourceHandler
|
|
76
87
|
# invocation rank the earlier the specified source handlers are used.
|
77
88
|
#
|
78
89
|
# The default invocation ranks are:
|
79
|
-
# 1
|
80
|
-
# 5
|
81
|
-
# 9
|
90
|
+
# [1] Early. Normally there is no need to use this rank.
|
91
|
+
# [5] Standard. This is the rank the normal source handler should use.
|
92
|
+
# [9] Late. This rank should be used by source handlers that operate on/use already created nodes
|
82
93
|
# and need to ensure that these nodes are available.
|
83
94
|
#
|
84
|
-
#
|
95
|
+
# == Default Meta Information
|
85
96
|
#
|
86
97
|
# Each source handler can define default meta information that gets automatically set on the
|
87
98
|
# source paths that are passed to the #create_node method.
|
@@ -90,7 +101,7 @@ module Webgen::SourceHandler
|
|
90
101
|
# configuration hash as a mapping from the source handler class name to the meta information
|
91
102
|
# hash.
|
92
103
|
#
|
93
|
-
#
|
104
|
+
# == Sample Source Handler Class
|
94
105
|
#
|
95
106
|
# Following is a simple source handler class example which copies paths from the source to
|
96
107
|
# the output location modifying the extension:
|
@@ -119,9 +130,10 @@ module Webgen::SourceHandler
|
|
119
130
|
#
|
120
131
|
# All public methods of this module are considered to be output path creation methods and must
|
121
132
|
# have the following parameters:
|
122
|
-
#
|
123
|
-
# +
|
124
|
-
# +
|
133
|
+
#
|
134
|
+
# [+parent+] the parent node
|
135
|
+
# [+path+] the path for which the output name should be created
|
136
|
+
# [+use_lang_part+] controls whether the output path name has to include the language part
|
125
137
|
module OutputPathHelpers
|
126
138
|
|
127
139
|
# Default method for creating an output path for +parent+ and source +path+.
|
@@ -201,7 +213,7 @@ module Webgen::SourceHandler
|
|
201
213
|
return node
|
202
214
|
elsif !node
|
203
215
|
node = Webgen::Node.new(parent, output_path, path.cn, path.meta_info)
|
204
|
-
elsif node.flagged(:reinit)
|
216
|
+
elsif node.flagged?(:reinit)
|
205
217
|
node.reinit(output_path, path.meta_info)
|
206
218
|
else
|
207
219
|
return node
|
@@ -224,7 +236,7 @@ module Webgen::SourceHandler
|
|
224
236
|
def page_from_path(path)
|
225
237
|
begin
|
226
238
|
page = Webgen::Page.from_data(path.io.data, path.meta_info)
|
227
|
-
rescue Webgen::
|
239
|
+
rescue Webgen::Page::FormatError => e
|
228
240
|
raise "Error reading source path <#{path}>: #{e.message}"
|
229
241
|
end
|
230
242
|
path.meta_info = page.meta_info
|
@@ -30,7 +30,7 @@ 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
|
-
context = Webgen::
|
33
|
+
context = Webgen::Context.new(:content => io.data, :chain => [node])
|
34
34
|
website.blackboard.invoke(:content_processor, node.node_info[:preprocessor]).call(context)
|
35
35
|
context.content
|
36
36
|
else
|
@@ -45,7 +45,7 @@ module Webgen::SourceHandler
|
|
45
45
|
block_name = node.node_info[:feed_type] + '_template'
|
46
46
|
if node.node_info[:feed].blocks.has_key?(block_name)
|
47
47
|
node.node_info[:feed].blocks[block_name].
|
48
|
-
render(Webgen::
|
48
|
+
render(Webgen::Context.new(:chain => [node])).content
|
49
49
|
else
|
50
50
|
feed = (website.cache.volatile[:sourcehandler_feed] ||= {})[node.node_info[:src]] ||= build_feed_for(node)
|
51
51
|
feed.build_xml(node.node_info[:feed_type], (node.node_info[:feed_type] == 'rss' ? node['rss_version'] || 2.0 : nil))
|
@@ -90,7 +90,7 @@ module Webgen::SourceHandler
|
|
90
90
|
item = FeedTools::FeedItem.new
|
91
91
|
item.title = entry['title']
|
92
92
|
item.link = File.join(site_url, entry.path)
|
93
|
-
item.content = entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::
|
93
|
+
item.content = entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::Context.new(:chain => [entry])).content
|
94
94
|
item.updated = entry['modified_at']
|
95
95
|
item.published = entry['created_at'] if entry['created_at'].kind_of?(Time)
|
96
96
|
if entry['author']
|
@@ -10,7 +10,7 @@ module Webgen::SourceHandler
|
|
10
10
|
include Webgen::WebsiteAccess
|
11
11
|
|
12
12
|
HTML_HEADER_REGEXP = /<h([123456])(?:>|\s([^>]*)>)(.*?)<\/h\1\s*>/i
|
13
|
-
HTML_ATTR_REGEXP = /\s*(\w+)\s*=\s*('|")(
|
13
|
+
HTML_ATTR_REGEXP = /\s*(\w+)\s*=\s*('|")(.+?)\2\s*/
|
14
14
|
|
15
15
|
# Parse the string +content+ for headers +h1+, ..., +h6+ and return the found, nested sections.
|
16
16
|
#
|
@@ -28,10 +28,12 @@ module Webgen::SourceHandler
|
|
28
28
|
super(parent, 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
|
-
YAML::load(page.blocks[block_name].content)
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
if page.blocks.has_key?(block_name) && (data = YAML::load(page.blocks[block_name].content))
|
32
|
+
data.each do |key, value|
|
33
|
+
key = Webgen::Common.absolute_path(key, parent.absolute_lcn)
|
34
|
+
node.node_info[mi_key][key] = value
|
35
|
+
end
|
36
|
+
end
|
35
37
|
end
|
36
38
|
|
37
39
|
mark_all_matched_dirty(node, :no_old_data)
|
@@ -66,7 +68,14 @@ module Webgen::SourceHandler
|
|
66
68
|
(option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_paths][pattern])
|
67
69
|
end || mi_node.node_info[:mi_alcn].any? do |pattern, mi|
|
68
70
|
node =~ pattern && (option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_alcn][pattern])
|
69
|
-
end
|
71
|
+
end || (option == :no_old_data && cached &&
|
72
|
+
((cached[:mi_paths].keys - mi_node.node_info[:mi_paths].keys).any? do |p|
|
73
|
+
Webgen::Path.match(node.node_info[:creation_path], p)
|
74
|
+
end || (cached[:mi_alcn].keys - mi_node.node_info[:mi_alcn].keys).any? do |p|
|
75
|
+
node =~ p
|
76
|
+
end)
|
77
|
+
)
|
78
|
+
)
|
70
79
|
end
|
71
80
|
|
72
81
|
# Mark all nodes that are matched by a path or an alcn specifcation in the meta info node +node+
|
@@ -99,7 +108,7 @@ module Webgen::SourceHandler
|
|
99
108
|
# node in question has changed.
|
100
109
|
def node_meta_info_changed?(node)
|
101
110
|
self.nodes.each do |n|
|
102
|
-
if n.flagged(:created) && meta_info_changed?(n, node)
|
111
|
+
if n.flagged?(:created) && meta_info_changed?(n, node)
|
103
112
|
node.flag(:dirty_meta_info)
|
104
113
|
return
|
105
114
|
end
|
@@ -32,7 +32,7 @@ module Webgen::SourceHandler
|
|
32
32
|
|
33
33
|
if chain.first.node_info[:page].blocks.has_key?(block_name)
|
34
34
|
node.node_info[:used_nodes] << chain.first.absolute_lcn
|
35
|
-
context = chain.first.node_info[:page].blocks[block_name].render(Webgen::
|
35
|
+
context = chain.first.node_info[:page].blocks[block_name].render(Webgen::Context.new(:chain => chain))
|
36
36
|
context.content
|
37
37
|
else
|
38
38
|
raise "Error rendering <#{node.absolute_lcn}>: no block named '#{block_name}' in <#{chain.first.absolute_lcn}>"
|
@@ -47,11 +47,15 @@ module Webgen::SourceHandler
|
|
47
47
|
# Checks if the meta information provided by the file in Webgen Page Format changed.
|
48
48
|
def meta_info_changed?(node)
|
49
49
|
path = website.blackboard.invoke(:source_paths)[node.node_info[:src]]
|
50
|
-
return if node.node_info[:processor] != self.class.name || !path.changed?
|
50
|
+
return if node.node_info[:processor] != self.class.name || (path && !path.changed?)
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
if !path
|
53
|
+
node.flag(:dirty_meta_info)
|
54
|
+
else
|
55
|
+
old_mi = node.node_info[:sh_page_node_mi]
|
56
|
+
new_mi = Webgen::Page.meta_info_from_data(path.io.data)
|
57
|
+
node.flag(:dirty_meta_info) if old_mi && old_mi != new_mi
|
58
|
+
end
|
55
59
|
end
|
56
60
|
|
57
61
|
end
|
@@ -14,17 +14,20 @@ module Webgen::SourceHandler
|
|
14
14
|
include Base
|
15
15
|
include Webgen::WebsiteAccess
|
16
16
|
|
17
|
+
def initialize # :nodoc:
|
18
|
+
website.blackboard.add_listener(:node_meta_info_changed?, method(:node_meta_info_changed?))
|
19
|
+
@path_data = {}
|
20
|
+
end
|
21
|
+
|
17
22
|
# Create all virtual nodes under +parent+ which are specified in +path+.
|
18
23
|
def create_node(parent, path)
|
19
|
-
page = page_from_path(path)
|
20
24
|
nodes = []
|
21
|
-
|
25
|
+
read_data(path).each do |key, meta_info|
|
26
|
+
cache_data = [key, meta_info.dup]
|
27
|
+
|
22
28
|
key = Webgen::Common.absolute_path(key, parent.absolute_lcn) + (key =~ /\/$/ ? '/' : '')
|
23
29
|
temp_parent = create_directories(parent.tree.root, File.dirname(key), path)
|
24
30
|
|
25
|
-
meta_info ||= {}
|
26
|
-
meta_info['modified_at'] = path.meta_info['modified_at']
|
27
|
-
meta_info['no_output'] = true
|
28
31
|
output_path = meta_info.delete('url') || key
|
29
32
|
output_path = (URI::parse(output_path).absolute? || output_path =~ /^\// ?
|
30
33
|
output_path : File.join(temp_parent.absolute_lcn, output_path))
|
@@ -35,10 +38,12 @@ module Webgen::SourceHandler
|
|
35
38
|
nodes += website.blackboard.invoke(:create_nodes, parent.tree, temp_parent.absolute_lcn,
|
36
39
|
Webgen::Path.new(key, path.source_path), self) do |cn_parent, cn_path|
|
37
40
|
cn_path.meta_info.update(meta_info)
|
38
|
-
super(cn_parent, cn_path, output_path)
|
41
|
+
super(cn_parent, cn_path, output_path) do |n|
|
42
|
+
n.node_info[:sh_virtual_cache_data] = cache_data
|
43
|
+
end
|
39
44
|
end
|
40
45
|
end
|
41
|
-
end
|
46
|
+
end
|
42
47
|
nodes.compact
|
43
48
|
end
|
44
49
|
|
@@ -46,6 +51,23 @@ module Webgen::SourceHandler
|
|
46
51
|
private
|
47
52
|
#######
|
48
53
|
|
54
|
+
# Read the entries from the virtual file +data+ and yield the path, and the meta info hash for
|
55
|
+
# each entry. The +parent+ parameter is used for making absolute path values if relative ones
|
56
|
+
# are given.
|
57
|
+
def read_data(path)
|
58
|
+
if !@path_data.has_key?(path) || path.changed?
|
59
|
+
page = page_from_path(path)
|
60
|
+
@path_data[path] = YAML::load(page.blocks['content'].content).collect do |key, meta_info|
|
61
|
+
meta_info ||= {}
|
62
|
+
meta_info['modified_at'] = path.meta_info['modified_at']
|
63
|
+
meta_info['no_output'] = true
|
64
|
+
[key, meta_info]
|
65
|
+
end if page.blocks.has_key?('content')
|
66
|
+
@path_data[path] ||= []
|
67
|
+
end
|
68
|
+
@path_data[path]
|
69
|
+
end
|
70
|
+
|
49
71
|
# Create the needed parent directories for a virtual node.
|
50
72
|
def create_directories(parent, dirname, path)
|
51
73
|
dirname.sub(/^\//, '').split('/').each do |dir|
|
@@ -72,6 +94,21 @@ module Webgen::SourceHandler
|
|
72
94
|
parent
|
73
95
|
end
|
74
96
|
|
97
|
+
# Check if the +node+ is virtual and if, if its meta information has changed. This can only be
|
98
|
+
# the case if the node has been recreated in this run.
|
99
|
+
def node_meta_info_changed?(node)
|
100
|
+
path = website.blackboard.invoke(:source_paths)[node.node_info[:src]]
|
101
|
+
return if node.node_info[:processor] != self.class.name || (path && !path.changed?)
|
102
|
+
|
103
|
+
if !path
|
104
|
+
node.flag(:dirty_meta_info)
|
105
|
+
else
|
106
|
+
old_data = node.node_info[:sh_virtual_cache_data]
|
107
|
+
new_data = read_data(path).find {|key, mi| key == old_data.first}
|
108
|
+
node.flag(:dirty_meta_info) if !new_data || old_data.last != new_data.last
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
75
112
|
end
|
76
113
|
|
77
114
|
end
|
data/lib/webgen/tag/base.rb
CHANGED
@@ -7,7 +7,7 @@ require 'webgen/websiteaccess'
|
|
7
7
|
# This module should be mixed into any class that wants to serve as a webgen tag class. Have a look
|
8
8
|
# a the example below to see how a basic tag class looks like.
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# == Tag classes
|
11
11
|
#
|
12
12
|
# A tag class is a webgen extension that handles specific webgen tags. webgen tags are used to add
|
13
13
|
# dynamic content to page and template files and are made for ease of use.
|
@@ -23,18 +23,21 @@ require 'webgen/websiteaccess'
|
|
23
23
|
# Tag classes *can* also choose to not use this module. If they don't use it they have to provide
|
24
24
|
# the following methods: +set_params+, +create_tag_params+, +call+.
|
25
25
|
#
|
26
|
-
#
|
26
|
+
# == Tag parameters
|
27
27
|
#
|
28
28
|
# webgen tags allow the specification of parameters in the tag definition. The method
|
29
29
|
# +tag_params_list+ returns all configuration entries that can be set this way. And the method
|
30
|
-
# +tag_config_base+ is used to resolve partially stated configuration entries.
|
31
|
-
#
|
32
|
-
#
|
33
|
-
# this key is set to +default+, this means that this entry should be the default mandatory parameter
|
34
|
-
# (used when only a string is provided in the tag definition). There *should* be only one default
|
35
|
-
# mandatory parameter.
|
30
|
+
# +tag_config_base+ is used to resolve partially stated configuration entries. The default method
|
31
|
+
# uses the full class name, strips a <tt>Webgen::</tt> part at the beginning away, substitutes
|
32
|
+
# <tt>.</tt> for <tt>::</tt> and makes everything lowercase.
|
36
33
|
#
|
37
|
-
#
|
34
|
+
# An additional configuration entry option is also used: <tt>:mandatory</tt>. If this key is set to
|
35
|
+
# +true+ for a configuration entry, the entry counts as mandatory and needs to be set in the tag
|
36
|
+
# definition. If this key is set to +default+, this means that this entry should be the default
|
37
|
+
# mandatory parameter (used when only a string is provided in the tag definition). There *should* be
|
38
|
+
# only one default mandatory parameter.
|
39
|
+
#
|
40
|
+
# == Sample Tag Class
|
38
41
|
#
|
39
42
|
# Following is a simple tag class example which just reverses the body text and adds some
|
40
43
|
# information about the context to the result. Note that the class does not reside in the
|
@@ -90,7 +93,7 @@ module Webgen::Tag::Base
|
|
90
93
|
# The parameter +body+ holds the optional body value for the tag.
|
91
94
|
#
|
92
95
|
# The +context+ parameter holds all relevant information for processing. Have a look at the
|
93
|
-
# Webgen::
|
96
|
+
# Webgen::Context class to see what is available.
|
94
97
|
#
|
95
98
|
# The method has to return the result of the tag processing and, optionally, a boolean value
|
96
99
|
# specifying if the result should further be processed (ie. webgen tags replaced).
|
@@ -104,13 +107,16 @@ module Webgen::Tag::Base
|
|
104
107
|
private
|
105
108
|
#######
|
106
109
|
|
107
|
-
# The base part of the configuration name. This
|
108
|
-
#
|
110
|
+
# The base part of the configuration name. This isthe class name without the Webgen module
|
111
|
+
# downcased and all "::" substituted with "." (e.g. Webgen::Tag::Menu -> tag.menu). By overriding
|
112
|
+
# this method one can provide a different way of specifying the base part of the configuration
|
113
|
+
# name.
|
109
114
|
def tag_config_base
|
110
115
|
self.class.name.gsub('::', '.').gsub(/^Webgen\./, '').downcase
|
111
116
|
end
|
112
117
|
|
113
|
-
# Return the list of all parameters for the tag class.
|
118
|
+
# Return the list of all parameters for the tag class. All configuration options starting with
|
119
|
+
# +tag_config_base+ are used.
|
114
120
|
def tag_params_list
|
115
121
|
regexp = /^#{tag_config_base}/
|
116
122
|
website.config.data.keys.select {|key| key =~ regexp}
|
data/lib/webgen/tag/link.rb
CHANGED
@@ -10,6 +10,7 @@ module Webgen::Tag
|
|
10
10
|
# Return a HTML link to the given (A)LCN.
|
11
11
|
def call(tag, body, context)
|
12
12
|
if (dest_node = context.ref_node.resolve(param('tag.link.path'), context.dest_node.lang))
|
13
|
+
context.dest_node.node_info[:used_meta_info_nodes] << dest_node.absolute_lcn
|
13
14
|
context.dest_node.link_to(dest_node, param('tag.link.attr').merge(:lang => context.content_node.lang))
|
14
15
|
else
|
15
16
|
raise ArgumentError, 'Resolving of path failed'
|