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,99 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen
|
4
|
+
|
5
|
+
# Namespace for all content processors.
|
6
|
+
#
|
7
|
+
# == Implementing a content processor
|
8
|
+
#
|
9
|
+
# Content processors are used to process the content of files, normally of files in Webgen Page
|
10
|
+
# Format. A content processor only needs to respond to one method called +call+ and must not take
|
11
|
+
# any parameters in the +initialize+ method. This method is invoked with a
|
12
|
+
# Webgen::ContentProcessor::Context object that provides the whole context (especially the content
|
13
|
+
# and the node chain) and the method needs to return this object. During processing a content
|
14
|
+
# processor normally changes the content of the context but it does not need to.
|
15
|
+
#
|
16
|
+
# A self-written content processor does not need to be in the Webgen::ContentProcessor namespace
|
17
|
+
# but all shipped ones do.
|
18
|
+
#
|
19
|
+
# After writing the content processor class, one needs to add it to the
|
20
|
+
# <tt>contentprocessor.map</tt> hash so that it is used by webgen. The key for the entry needs to
|
21
|
+
# be a short name without special characters or spaces and the value is the class name, not as
|
22
|
+
# constant but as a string.
|
23
|
+
#
|
24
|
+
# == Sample Content Processor
|
25
|
+
#
|
26
|
+
# The following sample content processor checks for a meta information +replace_key+ and replaces
|
27
|
+
# strings of the form <tt>replace_key:path/to/node</tt> with a link to the specified node if it is
|
28
|
+
# found.
|
29
|
+
#
|
30
|
+
# Note how the content node, the reference node and the destination node are used sothat the
|
31
|
+
# correct meta information is used, the node is correctly resolved and the correct relative link
|
32
|
+
# is calculated respectively!
|
33
|
+
#
|
34
|
+
# class SampleProcessor
|
35
|
+
#
|
36
|
+
# def call(context)
|
37
|
+
# if !context.content_node['replace_key'].to_s.empty?
|
38
|
+
# context.content.gsub!(/#{context.content_node['replace_key']}:([\w\/.]+)/ ) do |match|
|
39
|
+
# link_node = context.ref_node.resolve($1, context.content_node.lang)
|
40
|
+
# if link_node
|
41
|
+
# context.dest_node.link_to(link_node, :lang => context.content_node.lang)
|
42
|
+
# else
|
43
|
+
# match
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
# context
|
48
|
+
# rescue Exception => e
|
49
|
+
# raise "Error while replacing special key: #{e.message}"
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# WebsiteAccess.website.config['contentprocessor.map']['replacer'] = 'SampleProcessor'
|
55
|
+
#
|
56
|
+
module ContentProcessor
|
57
|
+
|
58
|
+
autoload :Context, 'webgen/contentprocessor/context'
|
59
|
+
autoload :Tags, 'webgen/contentprocessor/tags'
|
60
|
+
autoload :Blocks, 'webgen/contentprocessor/blocks'
|
61
|
+
autoload :Maruku, 'webgen/contentprocessor/maruku'
|
62
|
+
autoload :RedCloth, 'webgen/contentprocessor/redcloth'
|
63
|
+
autoload :Erb, 'webgen/contentprocessor/erb'
|
64
|
+
autoload :Haml, 'webgen/contentprocessor/haml'
|
65
|
+
autoload :Sass, 'webgen/contentprocessor/sass'
|
66
|
+
autoload :RDoc, 'webgen/contentprocessor/rdoc'
|
67
|
+
autoload :Builder, 'webgen/contentprocessor/builder'
|
68
|
+
autoload :Erubis, 'webgen/contentprocessor/erubis'
|
69
|
+
autoload :RDiscount, 'webgen/contentprocessor/rdiscount'
|
70
|
+
autoload :Fragments, 'webgen/contentprocessor/fragments'
|
71
|
+
|
72
|
+
# Return the list of all available content processors.
|
73
|
+
def self.list
|
74
|
+
WebsiteAccess.website.config['contentprocessor.map'].keys
|
75
|
+
end
|
76
|
+
|
77
|
+
# Return the content processor object identified by +name+.
|
78
|
+
def self.for_name(name)
|
79
|
+
klass = WebsiteAccess.website.config['contentprocessor.map'][name]
|
80
|
+
klass.nil? ? nil : WebsiteAccess.website.cache.instance(klass)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Helper class for accessing content processors in a Webgen::ContentProcessor::Context object.
|
84
|
+
class AccessHash
|
85
|
+
|
86
|
+
# Check if a content processor called +name+ exists.
|
87
|
+
def has_key?(name)
|
88
|
+
Webgen::ContentProcessor.list.include?(name)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Return (and proboably initialize) the content processor called +name+.
|
92
|
+
def [](name)
|
93
|
+
Webgen::ContentProcessor.for_name(name)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::ContentProcessor
|
4
|
+
|
5
|
+
# Replaces special xml tags with the rendered content of a node.
|
6
|
+
class Blocks
|
7
|
+
|
8
|
+
include Webgen::Loggable
|
9
|
+
|
10
|
+
BLOCK_RE = /<webgen:block\s*?((?:\s\w+=('|")[^'"]+\2)+)\s*\/>/
|
11
|
+
BLOCK_ATTR_RE = /(\w+)=('|")([^'"]+)\2/
|
12
|
+
|
13
|
+
# Replace that webgen:block xml tags with the rendered content of a node.
|
14
|
+
def call(context)
|
15
|
+
chain = context[:chain]
|
16
|
+
new_chain = (chain.length > 1 ? chain[1..-1] : chain)
|
17
|
+
|
18
|
+
context.content.gsub!(BLOCK_RE) do |match|
|
19
|
+
attr = {}
|
20
|
+
match.scan(BLOCK_ATTR_RE) {|name, sep, content| attr[name] = content}
|
21
|
+
if attr['chain'].nil?
|
22
|
+
used_chain = new_chain.dup
|
23
|
+
else
|
24
|
+
paths = attr['chain'].split(';')
|
25
|
+
used_chain = paths.collect do |path|
|
26
|
+
temp_node = context.ref_node.resolve(path.strip, context.dest_node.lang)
|
27
|
+
log(:error) { "Could not resolve <#{path.strip}> in <#{context.ref_node.absolute_lcn}> in '#{match.to_s}'" } if temp_node.nil?
|
28
|
+
temp_node
|
29
|
+
end.compact
|
30
|
+
next match if used_chain.length != paths.length
|
31
|
+
dest_node = context.content_node
|
32
|
+
end
|
33
|
+
|
34
|
+
if attr['node'] == 'first'
|
35
|
+
used_chain.shift while used_chain.length > 0 && !used_chain.first.node_info[:page].blocks.has_key?(attr['name'])
|
36
|
+
elsif attr['node'] == 'current'
|
37
|
+
used_chain = context[:chain].dup
|
38
|
+
end
|
39
|
+
block_node = used_chain.first
|
40
|
+
|
41
|
+
if !block_node || !block_node.node_info[:page].blocks.has_key?(attr['name'])
|
42
|
+
if attr['notfound'] == 'ignore'
|
43
|
+
next ''
|
44
|
+
elsif block_node
|
45
|
+
raise "Node <#{block_node.absolute_lcn}> has no block named '#{attr['name']}'"
|
46
|
+
else
|
47
|
+
raise "No node in the chain has a block named '#{attr['name']}'"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context.dest_node.node_info[:used_nodes] << block_node.absolute_lcn
|
52
|
+
tmp_context = block_node.node_info[:page].blocks[attr['name']].render(context.clone(:chain => used_chain, :dest_node => dest_node))
|
53
|
+
tmp_context.content
|
54
|
+
end
|
55
|
+
context
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::ContentProcessor
|
4
|
+
|
5
|
+
# Processes content that is valid Ruby to build an XML tree. This is done by using the +builder+
|
6
|
+
# library.
|
7
|
+
class Builder
|
8
|
+
|
9
|
+
include Webgen::WebsiteAccess
|
10
|
+
|
11
|
+
# Process the content of +context+ which needs to be valid Ruby code. The special variable +xml+
|
12
|
+
# should be used to construct the XML content.
|
13
|
+
def call(context)
|
14
|
+
require 'builder'
|
15
|
+
|
16
|
+
node = context.content_node
|
17
|
+
ref_node = context.ref_node
|
18
|
+
dest_node = context.dest_node
|
19
|
+
|
20
|
+
xml = ::Builder::XmlMarkup.new(:indent => 2)
|
21
|
+
eval(context.content, binding, context.ref_node.absolute_lcn)
|
22
|
+
context.content = xml.target!
|
23
|
+
context
|
24
|
+
rescue Exception => e
|
25
|
+
raise RuntimeError, "Error using Builder in <#{context.ref_node.absolute_lcn}> to generate XML: #{e.message}", e.backtrace
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::ContentProcessor
|
4
|
+
|
5
|
+
# The context object that is passed to the +call+ method of a content processor.
|
6
|
+
#
|
7
|
+
# The needed context variables are stored in the +options+ hash. You can set any options you like,
|
8
|
+
# however, there are three noteworthy options:
|
9
|
+
#
|
10
|
+
# [<tt>:content</tt>] The content string that should be processed.
|
11
|
+
# [<tt>:processors</tt>] Normally an AccessHash object providing access to all available content processors.
|
12
|
+
# [<tt>:chain</tt>] The chain of nodes that is processed. There are some utiltity methods for getting
|
13
|
+
# special nodes of the chain (see #ref_node, #content_node and #dest_node).
|
14
|
+
class Context
|
15
|
+
|
16
|
+
include Webgen::WebsiteAccess
|
17
|
+
public :website
|
18
|
+
|
19
|
+
# Processing options
|
20
|
+
attr_accessor :options
|
21
|
+
|
22
|
+
# Create a new Context object. You can use the +options+ hash to set needed options. The
|
23
|
+
# <tt>:content</tt> option is set to an empty string if not specified in +options+ and
|
24
|
+
# <tt>:processors</tt> is set to a new AccessHash if not specified in +options+.
|
25
|
+
def initialize(options = {})
|
26
|
+
@options = {
|
27
|
+
:content => '',
|
28
|
+
:processors => Webgen::ContentProcessor::AccessHash.new
|
29
|
+
}.merge(options)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create a copy of the current object. You can use the +options+ parameter to override options
|
33
|
+
# of the current Context object in the newly created Context object.
|
34
|
+
def clone(options = {})
|
35
|
+
self.class.new(@options.merge(options))
|
36
|
+
end
|
37
|
+
|
38
|
+
# Return the value of the option +name+.
|
39
|
+
def [](name)
|
40
|
+
@options[name]
|
41
|
+
end
|
42
|
+
|
43
|
+
# Set the option +name+ to the given +value.
|
44
|
+
def []=(name, value)
|
45
|
+
@options[name] = value
|
46
|
+
end
|
47
|
+
|
48
|
+
# Return the <tt>:content</tt> option.
|
49
|
+
def content
|
50
|
+
@options[:content]
|
51
|
+
end
|
52
|
+
|
53
|
+
# Set the <tt>:content</tt> option to the given +value+.
|
54
|
+
def content=(value)
|
55
|
+
@options[:content] = value
|
56
|
+
end
|
57
|
+
|
58
|
+
# Return the node which represents the file into which everything gets rendered. This is
|
59
|
+
# normally the same node as <tt>#content_node</tt> but can differ in special cases. For example,
|
60
|
+
# when rendering the content of node called <tt>my.page</tt> into the output of the node
|
61
|
+
# <tt>this.page</tt>, <tt>this.page</tt> would be the +dest_node+ and <tt>my.page</tt> would be
|
62
|
+
# the +content_node+.
|
63
|
+
#
|
64
|
+
# The +dest_node+ is not included in the chain but can be set via the option
|
65
|
+
# <tt>:dest_node</tt>!
|
66
|
+
#
|
67
|
+
# The returned node should be used as source node for calculating relative paths to other nodes.
|
68
|
+
def dest_node
|
69
|
+
@options[:dest_node] || self.content_node
|
70
|
+
end
|
71
|
+
|
72
|
+
# Return the reference node, ie. the node which provided the original content for this context
|
73
|
+
# object.
|
74
|
+
#
|
75
|
+
# The returned node should be used, for example, for resolving relative paths.
|
76
|
+
def ref_node
|
77
|
+
@options[:chain] && @options[:chain].first
|
78
|
+
end
|
79
|
+
|
80
|
+
# Return the node that is ultimately rendered.
|
81
|
+
#
|
82
|
+
# This node should be used, for example, for retrieving meta information.
|
83
|
+
def content_node
|
84
|
+
@options[:chain] && @options[:chain].last
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::ContentProcessor
|
4
|
+
|
5
|
+
# Processes embedded Ruby statements.
|
6
|
+
class Erb
|
7
|
+
|
8
|
+
include Webgen::WebsiteAccess
|
9
|
+
|
10
|
+
# Process the Ruby statements embedded in the content of +context+.
|
11
|
+
def call(context)
|
12
|
+
require 'erb'
|
13
|
+
|
14
|
+
node = context.content_node
|
15
|
+
ref_node = context.ref_node
|
16
|
+
dest_node = context.dest_node
|
17
|
+
|
18
|
+
erb = ERB.new(context.content)
|
19
|
+
erb.filename = context.ref_node.absolute_lcn
|
20
|
+
context.content = erb.result(binding)
|
21
|
+
context
|
22
|
+
rescue Exception => e
|
23
|
+
raise RuntimeError, "Erb processing failed in <#{context.ref_node.absolute_lcn}>: #{e.message}", e.backtrace
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::ContentProcessor
|
4
|
+
|
5
|
+
# Processes embedded Ruby statements with the +erubis+ library.
|
6
|
+
class Erubis
|
7
|
+
|
8
|
+
include Webgen::WebsiteAccess
|
9
|
+
|
10
|
+
# Process the Ruby statements embedded in the content of +context+.
|
11
|
+
def call(context)
|
12
|
+
require 'erubis'
|
13
|
+
# including Erubis because of problem with resolving Erubis::XmlHelper et al
|
14
|
+
self.class.class_eval "include ::Erubis"
|
15
|
+
|
16
|
+
node = context.content_node
|
17
|
+
ref_node = context.ref_node
|
18
|
+
dest_node = context.dest_node
|
19
|
+
|
20
|
+
options = website.config['contentprocessor.erubis.options']
|
21
|
+
if context[:block]
|
22
|
+
use_pi = context[:block].options['erubis_use_pi']
|
23
|
+
context[:block].options.select {|k,v| k =~ /^erubis_/}.
|
24
|
+
each {|k,v| options[k.sub(/^erubis_/, '').to_sym] = v }
|
25
|
+
end
|
26
|
+
erubis = if (!use_pi.nil? && use_pi) || (use_pi.nil? && website.config['contentprocessor.erubis.use_pi'])
|
27
|
+
::Erubis::PI::Eruby.new(context.content, options)
|
28
|
+
else
|
29
|
+
::Erubis::Eruby.new(context.content, options)
|
30
|
+
end
|
31
|
+
erubis.filename = context.ref_node.absolute_lcn
|
32
|
+
context.content = erubis.result(binding)
|
33
|
+
context
|
34
|
+
rescue Exception => e
|
35
|
+
raise RuntimeError, "Erubis processing failed in <#{context.ref_node.absolute_lcn}>: #{e.message}", e.backtrace
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::ContentProcessor
|
4
|
+
|
5
|
+
# Uses the HTML headers h1, h2, ..., h6 to generate nested fragment nodes.
|
6
|
+
class Fragments
|
7
|
+
|
8
|
+
include Webgen::WebsiteAccess
|
9
|
+
|
10
|
+
# Generate the nested fragment nodes from <tt>context.content</tt> under
|
11
|
+
# <tt>content.content_node</tt> but only if there is no associated <tt>:block</tt> data in
|
12
|
+
# +context+ or the block is named +content+.
|
13
|
+
def call(context)
|
14
|
+
if !context[:block] || context[:block].name == 'content'
|
15
|
+
sections = website.blackboard.invoke(:parse_html_headers, context.content)
|
16
|
+
website.blackboard.invoke(:create_fragment_nodes, sections, context.content_node,
|
17
|
+
website.blackboard.invoke(:source_paths)[context.content_node.node_info[:src]],
|
18
|
+
context.content_node.meta_info['fragments_in_menu'])
|
19
|
+
end
|
20
|
+
context
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::ContentProcessor
|
4
|
+
|
5
|
+
# Processes content in Haml markup using the +haml+ library.
|
6
|
+
class Haml
|
7
|
+
|
8
|
+
include Webgen::WebsiteAccess
|
9
|
+
|
10
|
+
# Convert the content in +haml+ markup to HTML.
|
11
|
+
def call(context)
|
12
|
+
require 'haml'
|
13
|
+
|
14
|
+
locals = {
|
15
|
+
:context => context,
|
16
|
+
:website => website,
|
17
|
+
:node => context.content_node,
|
18
|
+
:ref_node => context.ref_node,
|
19
|
+
:dest_node => context.dest_node,
|
20
|
+
}
|
21
|
+
context.content = ::Haml::Engine.new(context.content, :filename => context.ref_node.absolute_lcn).
|
22
|
+
render(Object.new, locals)
|
23
|
+
context
|
24
|
+
rescue Exception => e
|
25
|
+
raise RuntimeError, "Error converting Haml markup to HTML in <#{context.ref_node.absolute_lcn}>: #{e.message}", e.backtrace
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::ContentProcessor
|
4
|
+
|
5
|
+
# Processes content in Markdown format using the +maruku+ library.
|
6
|
+
class Maruku
|
7
|
+
|
8
|
+
# Convert the content in +context+ to HTML.
|
9
|
+
def call(context)
|
10
|
+
require 'maruku'
|
11
|
+
$uid = 0 #fix for invalid fragment ids on second run
|
12
|
+
context.content = ::Maruku.new(context.content, :on_error => :raise).to_html
|
13
|
+
context
|
14
|
+
rescue Exception => e
|
15
|
+
raise RuntimeError, "Maruku to HTML conversion failed for <#{context.ref_node.absolute_lcn}>: #{e.message}", e.backtrace
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::ContentProcessor
|
4
|
+
|
5
|
+
# Processes content in Markdown markup with the fast +rdiscount+ library.
|
6
|
+
class RDiscount
|
7
|
+
|
8
|
+
# Convert the content in +context+ to HTML.
|
9
|
+
def call(context)
|
10
|
+
require 'rdiscount'
|
11
|
+
context.content = ::RDiscount.new(context.content).to_html
|
12
|
+
context
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|