thewoolleyman-webgen 0.5.8.20090419
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +8 -0
- data/COPYING +10 -0
- data/GPL +340 -0
- data/Rakefile +334 -0
- data/THANKS +18 -0
- data/bin/webgen +12 -0
- data/data/webgen/resources.yaml +3 -0
- data/data/webgen/webgui/controller/main.rb +135 -0
- data/data/webgen/webgui/overrides/win32console.rb +0 -0
- data/data/webgen/webgui/public/css/jquery.autocomplete.css +50 -0
- data/data/webgen/webgui/public/css/ramaze_error.css +90 -0
- data/data/webgen/webgui/public/css/style.css +55 -0
- data/data/webgen/webgui/public/img/headerbg.jpg +0 -0
- data/data/webgen/webgui/public/img/webgen_logo.png +0 -0
- data/data/webgen/webgui/public/js/jquery.autocomplete.js +15 -0
- data/data/webgen/webgui/public/js/jquery.js +32 -0
- data/data/webgen/webgui/view/create_website.xhtml +22 -0
- data/data/webgen/webgui/view/error.xhtml +64 -0
- data/data/webgen/webgui/view/index.xhtml +22 -0
- data/data/webgen/webgui/view/manage_website.xhtml +18 -0
- data/data/webgen/webgui/view/page.xhtml +40 -0
- data/data/webgen/website_skeleton/README +10 -0
- data/data/webgen/website_skeleton/Rakefile +40 -0
- data/data/webgen/website_skeleton/config.yaml +17 -0
- data/data/webgen/website_skeleton/ext/init.rb +10 -0
- data/data/webgen/website_styles/1024px/README +13 -0
- data/data/webgen/website_styles/1024px/src/default.css +188 -0
- data/data/webgen/website_styles/1024px/src/default.template +60 -0
- data/data/webgen/website_styles/1024px/src/images/background.gif +0 -0
- data/data/webgen/website_styles/andreas00/README +13 -0
- data/data/webgen/website_styles/andreas00/src/default.css +290 -0
- data/data/webgen/website_styles/andreas00/src/default.template +60 -0
- data/data/webgen/website_styles/andreas00/src/images/bg.gif +0 -0
- data/data/webgen/website_styles/andreas00/src/images/front.jpg +0 -0
- data/data/webgen/website_styles/andreas00/src/images/menubg.gif +0 -0
- data/data/webgen/website_styles/andreas00/src/images/menubg2.gif +0 -0
- data/data/webgen/website_styles/andreas01/README +14 -0
- data/data/webgen/website_styles/andreas01/src/default.css +310 -0
- data/data/webgen/website_styles/andreas01/src/default.template +62 -0
- data/data/webgen/website_styles/andreas01/src/images/bg.gif +0 -0
- data/data/webgen/website_styles/andreas01/src/images/front.jpg +0 -0
- data/data/webgen/website_styles/andreas01/src/print.css +35 -0
- data/data/webgen/website_styles/andreas03/README +14 -0
- data/data/webgen/website_styles/andreas03/src/default.css +223 -0
- data/data/webgen/website_styles/andreas03/src/default.template +58 -0
- data/data/webgen/website_styles/andreas03/src/images/bodybg.png +0 -0
- data/data/webgen/website_styles/andreas03/src/images/contbg.png +0 -0
- data/data/webgen/website_styles/andreas03/src/images/footerbg.png +0 -0
- data/data/webgen/website_styles/andreas03/src/images/gradient1.png +0 -0
- data/data/webgen/website_styles/andreas03/src/images/gradient2.png +0 -0
- data/data/webgen/website_styles/andreas04/README +15 -0
- data/data/webgen/website_styles/andreas04/src/default.css +290 -0
- data/data/webgen/website_styles/andreas04/src/default.template +81 -0
- data/data/webgen/website_styles/andreas04/src/images/blinkarrow.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/bodybg.png +0 -0
- data/data/webgen/website_styles/andreas04/src/images/contentbg.png +0 -0
- data/data/webgen/website_styles/andreas04/src/images/entrybg.png +0 -0
- data/data/webgen/website_styles/andreas04/src/images/flash.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/flash2.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/globe.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/globebottom.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/linkarrow.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/menuhover.png +0 -0
- data/data/webgen/website_styles/andreas05/README +14 -0
- data/data/webgen/website_styles/andreas05/src/default.css +33 -0
- data/data/webgen/website_styles/andreas05/src/default.template +40 -0
- data/data/webgen/website_styles/andreas05/src/images/bodybg.gif +0 -0
- data/data/webgen/website_styles/andreas05/src/images/front.png +0 -0
- data/data/webgen/website_styles/andreas06/README +14 -0
- data/data/webgen/website_styles/andreas06/src/default.css +354 -0
- data/data/webgen/website_styles/andreas06/src/default.template +70 -0
- data/data/webgen/website_styles/andreas06/src/images/bodybg.gif +0 -0
- data/data/webgen/website_styles/andreas06/src/images/boxbg.gif +0 -0
- data/data/webgen/website_styles/andreas06/src/images/greypx.gif +0 -0
- data/data/webgen/website_styles/andreas06/src/images/header.jpg +0 -0
- data/data/webgen/website_styles/andreas06/src/images/innerbg.gif +0 -0
- data/data/webgen/website_styles/andreas06/src/images/leaves.jpg +0 -0
- data/data/webgen/website_styles/andreas06/src/images/tabs.gif +0 -0
- data/data/webgen/website_styles/andreas07/README +15 -0
- data/data/webgen/website_styles/andreas07/src/browserfix.css +7 -0
- data/data/webgen/website_styles/andreas07/src/default.css +92 -0
- data/data/webgen/website_styles/andreas07/src/default.template +42 -0
- data/data/webgen/website_styles/andreas07/src/images/bodybg.gif +0 -0
- data/data/webgen/website_styles/andreas07/src/images/sidebarbg.gif +0 -0
- data/data/webgen/website_styles/andreas08/README +14 -0
- data/data/webgen/website_styles/andreas08/src/default.css +224 -0
- data/data/webgen/website_styles/andreas08/src/default.template +51 -0
- data/data/webgen/website_styles/andreas09/README +14 -0
- data/data/webgen/website_styles/andreas09/src/default.css +308 -0
- data/data/webgen/website_styles/andreas09/src/default.template +68 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-black.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-green.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-orange.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-purple.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-red.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/footerbg.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-black.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-green.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-orange.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-purple.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-red.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover.jpg +0 -0
- data/data/webgen/website_styles/simple/README +6 -0
- data/data/webgen/website_styles/simple/src/default.css +84 -0
- data/data/webgen/website_styles/simple/src/default.template +36 -0
- data/data/webgen/website_templates/default/README +6 -0
- data/data/webgen/website_templates/default/src/index.page +8 -0
- data/data/webgen/website_templates/project/README +5 -0
- data/data/webgen/website_templates/project/src/about.page +12 -0
- data/data/webgen/website_templates/project/src/download.page +15 -0
- data/data/webgen/website_templates/project/src/features.page +8 -0
- data/data/webgen/website_templates/project/src/index.page +9 -0
- data/data/webgen/website_templates/project/src/screenshots.page +18 -0
- data/doc/contentprocessor.template +11 -0
- data/doc/contentprocessor/blocks.page +129 -0
- data/doc/contentprocessor/builder.page +80 -0
- data/doc/contentprocessor/erb.page +59 -0
- data/doc/contentprocessor/erubis.page +46 -0
- data/doc/contentprocessor/fragments.page +25 -0
- data/doc/contentprocessor/haml.page +47 -0
- data/doc/contentprocessor/maruku.page +41 -0
- data/doc/contentprocessor/rdiscount.page +37 -0
- data/doc/contentprocessor/rdoc.page +36 -0
- data/doc/contentprocessor/redcloth.page +39 -0
- data/doc/contentprocessor/sass.page +31 -0
- data/doc/contentprocessor/tags.page +73 -0
- data/doc/extensions.metainfo +29 -0
- data/doc/extensions.page +16 -0
- data/doc/extensions.template +17 -0
- data/doc/faq.page +219 -0
- data/doc/getting_started.page +135 -0
- data/doc/index.page +65 -0
- data/doc/manual.page +589 -0
- data/doc/reference_configuration.page +959 -0
- data/doc/reference_metainfo.page +222 -0
- data/doc/source/filesystem.page +39 -0
- data/doc/source/tararchive.page +40 -0
- data/doc/sourcehandler.template +21 -0
- data/doc/sourcehandler/copy.page +19 -0
- data/doc/sourcehandler/directory.page +27 -0
- data/doc/sourcehandler/feed.page +105 -0
- data/doc/sourcehandler/metainfo.page +41 -0
- data/doc/sourcehandler/page.page +14 -0
- data/doc/sourcehandler/sitemap.page +46 -0
- data/doc/sourcehandler/template.page +45 -0
- data/doc/sourcehandler/virtual.page +49 -0
- data/doc/tag.template +25 -0
- data/doc/tag/breadcrumbtrail.page +40 -0
- data/doc/tag/coderay.page +49 -0
- data/doc/tag/date.page +31 -0
- data/doc/tag/executecommand.page +26 -0
- data/doc/tag/includefile.page +32 -0
- data/doc/tag/langbar.page +44 -0
- data/doc/tag/link.page +44 -0
- data/doc/tag/menu.page +106 -0
- data/doc/tag/metainfo.page +29 -0
- data/doc/tag/relocatable.page +38 -0
- data/doc/tag/sitemap.page +31 -0
- data/doc/tag/tikz.page +158 -0
- data/doc/upgrading.page +139 -0
- data/doc/webgen_page_format.page +129 -0
- data/lib/webgen/blackboard.rb +78 -0
- data/lib/webgen/cache.rb +87 -0
- data/lib/webgen/cli.rb +124 -0
- data/lib/webgen/cli/apply_command.rb +64 -0
- data/lib/webgen/cli/create_command.rb +66 -0
- data/lib/webgen/cli/run_command.rb +22 -0
- data/lib/webgen/cli/utils.rb +88 -0
- data/lib/webgen/cli/webgui_command.rb +72 -0
- data/lib/webgen/common.rb +21 -0
- data/lib/webgen/common/sitemap.rb +83 -0
- data/lib/webgen/configuration.rb +153 -0
- data/lib/webgen/contentprocessor.rb +99 -0
- data/lib/webgen/contentprocessor/blocks.rb +60 -0
- data/lib/webgen/contentprocessor/builder.rb +30 -0
- data/lib/webgen/contentprocessor/context.rb +89 -0
- data/lib/webgen/contentprocessor/erb.rb +28 -0
- data/lib/webgen/contentprocessor/erubis.rb +40 -0
- data/lib/webgen/contentprocessor/fragments.rb +25 -0
- data/lib/webgen/contentprocessor/haml.rb +30 -0
- data/lib/webgen/contentprocessor/maruku.rb +20 -0
- data/lib/webgen/contentprocessor/rdiscount.rb +17 -0
- data/lib/webgen/contentprocessor/rdoc.rb +19 -0
- data/lib/webgen/contentprocessor/redcloth.rb +17 -0
- data/lib/webgen/contentprocessor/sass.rb +20 -0
- data/lib/webgen/contentprocessor/tags.rb +136 -0
- data/lib/webgen/coreext.rb +13 -0
- data/lib/webgen/default_config.rb +215 -0
- data/lib/webgen/languages.rb +589 -0
- data/lib/webgen/loggable.rb +25 -0
- data/lib/webgen/logger.rb +97 -0
- data/lib/webgen/node.rb +391 -0
- data/lib/webgen/output.rb +82 -0
- data/lib/webgen/output/filesystem.rb +69 -0
- data/lib/webgen/page.rb +153 -0
- data/lib/webgen/path.rb +194 -0
- data/lib/webgen/source.rb +54 -0
- data/lib/webgen/source/filesystem.rb +61 -0
- data/lib/webgen/source/resource.rb +44 -0
- data/lib/webgen/source/stacked.rb +55 -0
- data/lib/webgen/source/tararchive.rb +73 -0
- data/lib/webgen/sourcehandler.rb +226 -0
- data/lib/webgen/sourcehandler/base.rb +248 -0
- data/lib/webgen/sourcehandler/copy.rb +43 -0
- data/lib/webgen/sourcehandler/directory.rb +36 -0
- data/lib/webgen/sourcehandler/feed.rb +117 -0
- data/lib/webgen/sourcehandler/fragment.rb +68 -0
- data/lib/webgen/sourcehandler/memory.rb +43 -0
- data/lib/webgen/sourcehandler/metainfo.rb +128 -0
- data/lib/webgen/sourcehandler/page.rb +59 -0
- data/lib/webgen/sourcehandler/sitemap.rb +60 -0
- data/lib/webgen/sourcehandler/template.rb +66 -0
- data/lib/webgen/sourcehandler/virtual.rb +110 -0
- data/lib/webgen/tag.rb +27 -0
- data/lib/webgen/tag/base.rb +170 -0
- data/lib/webgen/tag/breadcrumbtrail.rb +70 -0
- data/lib/webgen/tag/coderay.rb +31 -0
- data/lib/webgen/tag/date.rb +18 -0
- data/lib/webgen/tag/executecommand.rb +30 -0
- data/lib/webgen/tag/includefile.rb +42 -0
- data/lib/webgen/tag/langbar.rb +52 -0
- data/lib/webgen/tag/link.rb +26 -0
- data/lib/webgen/tag/menu.rb +207 -0
- data/lib/webgen/tag/metainfo.rb +25 -0
- data/lib/webgen/tag/relocatable.rb +54 -0
- data/lib/webgen/tag/sitemap.rb +41 -0
- data/lib/webgen/tag/tikz.rb +119 -0
- data/lib/webgen/tree.rb +90 -0
- data/lib/webgen/version.rb +8 -0
- data/lib/webgen/webgentask.rb +152 -0
- data/lib/webgen/website.rb +342 -0
- data/lib/webgen/websiteaccess.rb +31 -0
- data/lib/webgen/websitemanager.rb +127 -0
- data/man/man1/webgen.1 +73 -0
- data/misc/default.css +384 -0
- data/misc/default.template +75 -0
- data/misc/htmldoc.metainfo +25 -0
- data/misc/htmldoc.virtual +5 -0
- data/misc/images/arrow.gif +0 -0
- data/misc/images/error.png +0 -0
- data/misc/images/headerbg.jpg +0 -0
- data/misc/images/important.png +0 -0
- data/misc/images/information.png +0 -0
- data/misc/images/quote.gif +0 -0
- data/misc/images/warning.png +0 -0
- data/setup.rb +1585 -0
- data/test/helper.rb +45 -0
- data/test/test_blackboard.rb +60 -0
- data/test/test_cache.rb +59 -0
- data/test/test_cli.rb +21 -0
- data/test/test_common.rb +18 -0
- data/test/test_common_sitemap.rb +58 -0
- data/test/test_configuration.rb +68 -0
- data/test/test_contentprocessor.rb +33 -0
- data/test/test_contentprocessor_blocks.rb +68 -0
- data/test/test_contentprocessor_builder.rb +23 -0
- data/test/test_contentprocessor_context.rb +40 -0
- data/test/test_contentprocessor_erb.rb +23 -0
- data/test/test_contentprocessor_erubis.rb +49 -0
- data/test/test_contentprocessor_fragments.rb +42 -0
- data/test/test_contentprocessor_haml.rb +23 -0
- data/test/test_contentprocessor_maruku.rb +29 -0
- data/test/test_contentprocessor_rdiscount.rb +17 -0
- data/test/test_contentprocessor_rdoc.rb +18 -0
- data/test/test_contentprocessor_redcloth.rb +15 -0
- data/test/test_contentprocessor_sass.rb +22 -0
- data/test/test_contentprocessor_tags.rb +99 -0
- data/test/test_languages.rb +67 -0
- data/test/test_loggable.rb +32 -0
- data/test/test_logger.rb +94 -0
- data/test/test_node.rb +367 -0
- data/test/test_output_filesystem.rb +60 -0
- data/test/test_page.rb +214 -0
- data/test/test_path.rb +165 -0
- data/test/test_source_filesystem.rb +76 -0
- data/test/test_source_resource.rb +28 -0
- data/test/test_source_stacked.rb +36 -0
- data/test/test_source_tararchive.rb +65 -0
- data/test/test_sourcehandler_base.rb +123 -0
- data/test/test_sourcehandler_copy.rb +47 -0
- data/test/test_sourcehandler_directory.rb +42 -0
- data/test/test_sourcehandler_feed.rb +77 -0
- data/test/test_sourcehandler_fragment.rb +69 -0
- data/test/test_sourcehandler_memory.rb +44 -0
- data/test/test_sourcehandler_metainfo.rb +118 -0
- data/test/test_sourcehandler_page.rb +65 -0
- data/test/test_sourcehandler_sitemap.rb +49 -0
- data/test/test_sourcehandler_template.rb +65 -0
- data/test/test_sourcehandler_virtual.rb +87 -0
- data/test/test_tag_base.rb +85 -0
- data/test/test_tag_breadcrumbtrail.rb +91 -0
- data/test/test_tag_coderay.rb +32 -0
- data/test/test_tag_date.rb +18 -0
- data/test/test_tag_executecommand.rb +41 -0
- data/test/test_tag_includefile.rb +50 -0
- data/test/test_tag_langbar.rb +72 -0
- data/test/test_tag_link.rb +69 -0
- data/test/test_tag_menu.rb +207 -0
- data/test/test_tag_metainfo.rb +19 -0
- data/test/test_tag_relocatable.rb +59 -0
- data/test/test_tag_sitemap.rb +47 -0
- data/test/test_tag_tikz.rb +69 -0
- data/test/test_tree.rb +70 -0
- data/test/test_webgentask.rb +23 -0
- data/test/test_website.rb +98 -0
- data/test/test_websiteaccess.rb +25 -0
- data/test/test_websitemanager.rb +70 -0
- metadata +613 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::SourceHandler
|
4
|
+
|
5
|
+
# This source handler should be used for handling nodes that are created during the write
|
6
|
+
# phase.
|
7
|
+
class Memory
|
8
|
+
|
9
|
+
include Webgen::WebsiteAccess
|
10
|
+
include Base
|
11
|
+
|
12
|
+
def initialize #:nodoc:
|
13
|
+
website.blackboard.add_listener(:node_flagged) do |node, *flags|
|
14
|
+
node.tree[node.node_info[:memory_source_alcn]].flag(:dirty) if node.node_info[:memory_source_alcn]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Create a node under +parent+ for the +path+. The +source_alcn+ specified the node that creates
|
19
|
+
# this memory node when written. You have two options for providing the content for this node:
|
20
|
+
# either you set +data+ to a string (or a Webgen::Path::SourceIO object) or you provide a block
|
21
|
+
# which takes the created node as argument and return a string (or a Webgen::Path::SourceIO
|
22
|
+
# object).
|
23
|
+
def create_node(parent, path, source_alcn, data = nil)
|
24
|
+
super(parent, path) do |node|
|
25
|
+
node.node_info[:memory_source_alcn] = source_alcn
|
26
|
+
(@data ||= {})[node.absolute_lcn] = lambda { data || yield(node) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Return the content of the memory +node+. If the memory node was not created in this webgen
|
31
|
+
# run, it will be flagged for reinitialization (and therefore recreation).
|
32
|
+
def content(node)
|
33
|
+
if @data && @data[node.absolute_lcn]
|
34
|
+
@data[node.absolute_lcn].call
|
35
|
+
else
|
36
|
+
node.flag(:reinit)
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module Webgen::SourceHandler
|
7
|
+
|
8
|
+
# Handles meta information files which provide meta information for other files.
|
9
|
+
class Metainfo
|
10
|
+
|
11
|
+
include Base
|
12
|
+
include Webgen::WebsiteAccess
|
13
|
+
|
14
|
+
CKEY = [:metainfo, :nodes]
|
15
|
+
|
16
|
+
# Upon creation the object registers itself as listener for some node hooks.
|
17
|
+
def initialize
|
18
|
+
website.blackboard.add_listener(:node_meta_info_changed?, method(:node_meta_info_changed?))
|
19
|
+
website.blackboard.add_listener(:before_node_created, method(:before_node_created))
|
20
|
+
website.blackboard.add_listener(:before_node_deleted, method(:before_node_deleted))
|
21
|
+
website.blackboard.add_listener(:after_node_created, method(:after_node_created))
|
22
|
+
self.nodes ||= []
|
23
|
+
end
|
24
|
+
|
25
|
+
# Create a meta info node from +parent+ and +path+.
|
26
|
+
def create_node(parent, path)
|
27
|
+
page = page_from_path(path)
|
28
|
+
super(parent, path) do |node|
|
29
|
+
[[:mi_paths, 'paths'], [:mi_alcn, 'alcn']].each do |mi_key, block_name|
|
30
|
+
node.node_info[mi_key] = {}
|
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
|
37
|
+
end
|
38
|
+
|
39
|
+
mark_all_matched_dirty(node, :no_old_data)
|
40
|
+
|
41
|
+
website.cache.permanent[[:sh_metainfo_node_mi, node.absolute_lcn]] = {
|
42
|
+
:mi_paths => node.node_info[:mi_paths],
|
43
|
+
:mi_alcn => node.node_info[:mi_alcn]
|
44
|
+
}
|
45
|
+
|
46
|
+
self.nodes << node unless self.nodes.include?(node)
|
47
|
+
self.nodes = self.nodes.sort_by {|n| n.absolute_lcn}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def nodes #:nodoc:
|
52
|
+
website.cache.permanent[CKEY]
|
53
|
+
end
|
54
|
+
|
55
|
+
def nodes=(val) #:nodoc:
|
56
|
+
website.cache.permanent[CKEY] = val
|
57
|
+
end
|
58
|
+
|
59
|
+
#######
|
60
|
+
private
|
61
|
+
#######
|
62
|
+
|
63
|
+
# Return +true+ if any meta information for +node+ provided by +mi_node+ has changed.
|
64
|
+
def meta_info_changed?(mi_node, node, option = nil)
|
65
|
+
cached = website.cache.permanent[[:sh_metainfo_node_mi, mi_node.absolute_lcn]]
|
66
|
+
(mi_node.node_info[:mi_paths].any? do |pattern, mi|
|
67
|
+
Webgen::Path.match(node.node_info[:creation_path], pattern) &&
|
68
|
+
(option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_paths][pattern])
|
69
|
+
end || mi_node.node_info[:mi_alcn].any? do |pattern, mi|
|
70
|
+
node =~ pattern && (option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_alcn][pattern])
|
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
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Mark all nodes that are matched by a path or an alcn specifcation in the meta info node +node+
|
82
|
+
# as dirty.
|
83
|
+
def mark_all_matched_dirty(node, option = nil)
|
84
|
+
node.tree.node_access[:alcn].each do |path, n|
|
85
|
+
n.flag(:dirty_meta_info) if meta_info_changed?(node, n, option)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Update the meta info of matched path before a node is created.
|
90
|
+
def before_node_created(parent, path)
|
91
|
+
self.nodes.each do |node|
|
92
|
+
node.node_info[:mi_paths].each do |pattern, mi|
|
93
|
+
path.meta_info.update(mi) if Webgen::Path.match(path, pattern)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Update the meta information of a matched alcn after the node has been created.
|
99
|
+
def after_node_created(node)
|
100
|
+
self.nodes.each do |n|
|
101
|
+
n.node_info[:mi_alcn].each do |pattern, mi|
|
102
|
+
node.meta_info.update(mi) if node =~ pattern
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Check if the +node+ has meta information from any meta info node and if so, if the meta info
|
108
|
+
# node in question has changed.
|
109
|
+
def node_meta_info_changed?(node)
|
110
|
+
self.nodes.each do |n|
|
111
|
+
if n.flagged(:created) && meta_info_changed?(n, node)
|
112
|
+
node.flag(:dirty_meta_info)
|
113
|
+
return
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Delete the meta info node +node+ from the internal array.
|
119
|
+
def before_node_deleted(node)
|
120
|
+
return unless node.node_info[:processor] == self.class.name
|
121
|
+
mark_all_matched_dirty(node, :force)
|
122
|
+
website.cache.permanent.delete([:sh_metainfo_node_mi, node.absolute_lcn])
|
123
|
+
self.nodes.delete(node)
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::SourceHandler
|
4
|
+
|
5
|
+
# Source handler for handling content files in Webgen Page Format.
|
6
|
+
class Page
|
7
|
+
|
8
|
+
include Webgen::WebsiteAccess
|
9
|
+
include Base
|
10
|
+
|
11
|
+
def initialize #:nodoc:
|
12
|
+
website.blackboard.add_listener(:node_meta_info_changed?, method(:meta_info_changed?))
|
13
|
+
end
|
14
|
+
|
15
|
+
# Create a page file from +parent+ and +path+.
|
16
|
+
def create_node(parent, path)
|
17
|
+
page = page_from_path(path)
|
18
|
+
path.meta_info['lang'] ||= website.config['website.lang']
|
19
|
+
path.ext = 'html' if path.ext == 'page'
|
20
|
+
|
21
|
+
super(parent, path) do |node|
|
22
|
+
node.node_info[:sh_page_node_mi] = Webgen::Page.meta_info_from_data(path.io.data)
|
23
|
+
node.node_info[:page] = page
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Render the block called +block_name+ of the given +node+. The parameter +templates+ is set to
|
28
|
+
# the default template chain for the given +node+ but you can assign a custom template chain (an
|
29
|
+
# array of template nodes) if need arises. Return +nil+ if an error occurred.
|
30
|
+
def render_node(node, block_name = 'content', templates = website.blackboard.invoke(:templates_for_node, node))
|
31
|
+
chain = [templates, node].flatten
|
32
|
+
|
33
|
+
if chain.first.node_info[:page].blocks.has_key?(block_name)
|
34
|
+
node.node_info[:used_nodes] << chain.first.absolute_lcn
|
35
|
+
context = chain.first.node_info[:page].blocks[block_name].render(Webgen::ContentProcessor::Context.new(:chain => chain))
|
36
|
+
context.content
|
37
|
+
else
|
38
|
+
raise "Error rendering <#{node.absolute_lcn}>: no block named '#{block_name}' in <#{chain.first.absolute_lcn}>"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
alias_method :content, :render_node
|
42
|
+
|
43
|
+
#######
|
44
|
+
private
|
45
|
+
#######
|
46
|
+
|
47
|
+
# Checks if the meta information provided by the file in Webgen Page Format changed.
|
48
|
+
def meta_info_changed?(node)
|
49
|
+
path = website.blackboard.invoke(:source_paths)[node.node_info[:src]]
|
50
|
+
return if node.node_info[:processor] != self.class.name || !path.changed?
|
51
|
+
|
52
|
+
old_mi = node.node_info[:sh_page_node_mi]
|
53
|
+
new_mi = Webgen::Page.meta_info_from_data(path.io.data)
|
54
|
+
node.flag(:dirty_meta_info) if old_mi && old_mi != new_mi
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Webgen::SourceHandler
|
7
|
+
|
8
|
+
# Source handler for creating an XML sitemap based on the specification of http://sitemaps.org.
|
9
|
+
#
|
10
|
+
# Uses Webgen::Common::Sitemap to generate the needed sitemap tree and to check if a sitemap has
|
11
|
+
# changed.
|
12
|
+
class Sitemap
|
13
|
+
|
14
|
+
include Webgen::WebsiteAccess
|
15
|
+
include Base
|
16
|
+
|
17
|
+
# Create an XML sitemap from +parent+ and +path+.
|
18
|
+
def create_node(parent, path)
|
19
|
+
page_from_path(path)
|
20
|
+
path.ext = 'xml'
|
21
|
+
raise "Needed information site_url missing for sitemap <#{path}>" if path.meta_info['site_url'].nil?
|
22
|
+
super(parent, path)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Return the rendered feed represented by +node+.
|
26
|
+
def content(node)
|
27
|
+
require 'builder'
|
28
|
+
list = website.blackboard.invoke(:create_sitemap, node, node.lang, options_for_node(node)).to_lcn_list.flatten
|
29
|
+
sitemap = ::Builder::XmlMarkup.new(:indent => 2)
|
30
|
+
sitemap.instruct!(:xml, :version => '1.0', :encoding => 'UTF-8')
|
31
|
+
sitemap.urlset(:xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9") do
|
32
|
+
list.each do |alcn|
|
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
|
43
|
+
end
|
44
|
+
sitemap.target!
|
45
|
+
end
|
46
|
+
|
47
|
+
#######
|
48
|
+
private
|
49
|
+
#######
|
50
|
+
|
51
|
+
# Return a hash with the sitemap-creation-options set on the +node+.
|
52
|
+
def options_for_node(node)
|
53
|
+
options = {}
|
54
|
+
node.meta_info.each {|k,v| options[k] = v if k =~ /\./}
|
55
|
+
options
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::SourceHandler
|
4
|
+
|
5
|
+
# Source handler for handling template files in Webgen Page Format.
|
6
|
+
class Template
|
7
|
+
|
8
|
+
include Webgen::WebsiteAccess
|
9
|
+
include Webgen::Loggable
|
10
|
+
include Base
|
11
|
+
|
12
|
+
# Create a template node in +parent+ for +path+.
|
13
|
+
def create_node(parent, path)
|
14
|
+
page = page_from_path(path)
|
15
|
+
super(parent, path) do |node|
|
16
|
+
node.node_info[:page] = page
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Return the template chain for +node+.
|
21
|
+
def templates_for_node(node, lang = node.lang)
|
22
|
+
cached_template = (website.cache.volatile[[node.absolute_lcn, :templates]] ||= {})
|
23
|
+
if cached_template[lang]
|
24
|
+
template_node = cached_template[lang]
|
25
|
+
elsif node['template'].kind_of?(String)
|
26
|
+
template_node = node.resolve(node['template'], lang)
|
27
|
+
if template_node.nil?
|
28
|
+
log(:warn) { "Specified template '#{node['template']}' for <#{node.absolute_lcn}> not found, using default template!" }
|
29
|
+
template_node = default_template(node.parent, lang)
|
30
|
+
end
|
31
|
+
cached_template[lang] = template_node
|
32
|
+
elsif node.meta_info.has_key?('template') && node['template'].nil?
|
33
|
+
template_node = cached_template[lang] = nil
|
34
|
+
else
|
35
|
+
log(:info) { "Using default template in language '#{lang}' for <#{node.absolute_lcn}>" }
|
36
|
+
template_node = default_template(node.parent, lang)
|
37
|
+
if template_node == node && !node.parent.is_root?
|
38
|
+
template_node = default_template(node.parent.parent, lang)
|
39
|
+
end
|
40
|
+
cached_template[lang] = template_node
|
41
|
+
end
|
42
|
+
|
43
|
+
if template_node.nil?
|
44
|
+
[]
|
45
|
+
else
|
46
|
+
(template_node == node ? [] : templates_for_node(template_node, lang) + [template_node])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Return the default template for the directory node +dir+. If the template node is not found,
|
51
|
+
# the parent directories are searched.
|
52
|
+
def default_template(dir_node, lang)
|
53
|
+
template_node = dir_node.resolve(website.config['sourcehandler.template.default_template'], lang)
|
54
|
+
if template_node.nil?
|
55
|
+
if dir_node.is_root?
|
56
|
+
log(:warn) { "No default template in root directory found!" }
|
57
|
+
else
|
58
|
+
template_node = default_template(dir_node.parent, lang)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
template_node
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module Webgen::SourceHandler
|
7
|
+
|
8
|
+
# Handles files which contain specifications for "virtual" nodes, ie. nodes that don't have real
|
9
|
+
# source path.
|
10
|
+
#
|
11
|
+
# This can be used, for example, to provide multiple links to the same node.
|
12
|
+
class Virtual
|
13
|
+
|
14
|
+
include Base
|
15
|
+
include Webgen::WebsiteAccess
|
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
|
+
|
22
|
+
# Create all virtual nodes under +parent+ which are specified in +path+.
|
23
|
+
def create_node(parent, path)
|
24
|
+
nodes = []
|
25
|
+
read_data(path).each do |key, meta_info|
|
26
|
+
cache_data = [key, meta_info.dup]
|
27
|
+
|
28
|
+
key = Webgen::Common.absolute_path(key, parent.absolute_lcn) + (key =~ /\/$/ ? '/' : '')
|
29
|
+
temp_parent = create_directories(parent.tree.root, File.dirname(key), path)
|
30
|
+
|
31
|
+
output_path = meta_info.delete('url') || key
|
32
|
+
output_path = (URI::parse(output_path).absolute? || output_path =~ /^\// ?
|
33
|
+
output_path : File.join(temp_parent.absolute_lcn, output_path))
|
34
|
+
|
35
|
+
if key =~ /\/$/
|
36
|
+
nodes << create_directory(temp_parent, key, path, meta_info)
|
37
|
+
else
|
38
|
+
nodes += website.blackboard.invoke(:create_nodes, parent.tree, temp_parent.absolute_lcn,
|
39
|
+
Webgen::Path.new(key, path.source_path), self) do |cn_parent, cn_path|
|
40
|
+
cn_path.meta_info.update(meta_info)
|
41
|
+
super(cn_parent, cn_path, output_path) do |n|
|
42
|
+
n.node_info[:sh_virtual_cache_data] = cache_data
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
nodes.compact
|
48
|
+
end
|
49
|
+
|
50
|
+
#######
|
51
|
+
private
|
52
|
+
#######
|
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
|
+
|
71
|
+
# Create the needed parent directories for a virtual node.
|
72
|
+
def create_directories(parent, dirname, path)
|
73
|
+
dirname.sub(/^\//, '').split('/').each do |dir|
|
74
|
+
parent = create_directory(parent, File.join(parent.absolute_lcn, dir), path)
|
75
|
+
end
|
76
|
+
parent
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create a virtual directory if it does not already exist.
|
80
|
+
def create_directory(parent, dir, path, meta_info = nil)
|
81
|
+
dir_handler = website.cache.instance('Webgen::SourceHandler::Directory')
|
82
|
+
website.blackboard.invoke(:create_nodes, parent.tree, parent.absolute_lcn,
|
83
|
+
Webgen::Path.new(File.join(dir, '/'), path.source_path),
|
84
|
+
dir_handler) do |par, temp_path|
|
85
|
+
parent = dir_handler.node_exists?(par, temp_path)
|
86
|
+
if (parent && (parent.node_info[:src] == path.source_path) && !meta_info.nil?) ||
|
87
|
+
!parent
|
88
|
+
temp_path.meta_info.update(meta_info) if meta_info
|
89
|
+
parent.flag(:reinit) if parent
|
90
|
+
parent = dir_handler.create_node(par, temp_path)
|
91
|
+
end
|
92
|
+
parent
|
93
|
+
end
|
94
|
+
parent
|
95
|
+
end
|
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.changed?
|
102
|
+
|
103
|
+
old_data = node.node_info[:sh_virtual_cache_data]
|
104
|
+
new_data = read_data(path).find {|key, mi| key == old_data.first}
|
105
|
+
node.flag(:dirty_meta_info) if !new_data || old_data.last != new_data.last
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|