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
data/lib/webgen/tag.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen
|
4
|
+
|
5
|
+
# Namespace for all classes that are useable by Webgen::ContentProcessor::Tag.
|
6
|
+
#
|
7
|
+
# Have a look at the documentation for Webgen::Tag::Base for details on how to implement a tag
|
8
|
+
# class.
|
9
|
+
module Tag
|
10
|
+
|
11
|
+
autoload :Base, 'webgen/tag/base'
|
12
|
+
autoload :Relocatable, 'webgen/tag/relocatable'
|
13
|
+
autoload :Metainfo, 'webgen/tag/metainfo'
|
14
|
+
autoload :Menu, 'webgen/tag/menu'
|
15
|
+
autoload :BreadcrumbTrail, 'webgen/tag/breadcrumbtrail'
|
16
|
+
autoload :Langbar, 'webgen/tag/langbar'
|
17
|
+
autoload :IncludeFile, 'webgen/tag/includefile'
|
18
|
+
autoload :ExecuteCommand, 'webgen/tag/executecommand'
|
19
|
+
autoload :Coderay, 'webgen/tag/coderay'
|
20
|
+
autoload :Date, 'webgen/tag/date'
|
21
|
+
autoload :Sitemap, 'webgen/tag/sitemap'
|
22
|
+
autoload :TikZ, 'webgen/tag/tikz'
|
23
|
+
autoload :Link, 'webgen/tag/link'
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'webgen/loggable'
|
5
|
+
require 'webgen/websiteaccess'
|
6
|
+
|
7
|
+
# This module should be mixed into any class that wants to serve as a webgen tag class. Have a look
|
8
|
+
# a the example below to see how a basic tag class looks like.
|
9
|
+
#
|
10
|
+
# == Tag classes
|
11
|
+
#
|
12
|
+
# A tag class is a webgen extension that handles specific webgen tags. webgen tags are used to add
|
13
|
+
# dynamic content to page and template files and are made for ease of use.
|
14
|
+
#
|
15
|
+
# A tag class can handle multiple different tags. Just add a (tag name)-(class name) pair to the
|
16
|
+
# <tt>contentprocessor.tags.map</tt> configuration entry for each tag name you want to associate
|
17
|
+
# with the tag class. The special name <tt>:default</tt> is used for the default tag class which is
|
18
|
+
# called if a tag with an unknown tag name is encountered.
|
19
|
+
#
|
20
|
+
# The only method needed to be written is +call+ which is called by the tags content processor to
|
21
|
+
# the actual processing. And the +initialize+ method must not take any parameters!
|
22
|
+
#
|
23
|
+
# Tag classes *can* also choose to not use this module. If they don't use it they have to provide
|
24
|
+
# the following methods: +set_params+, +create_tag_params+, +call+.
|
25
|
+
#
|
26
|
+
# == Tag parameters
|
27
|
+
#
|
28
|
+
# webgen tags allow the specification of parameters in the tag definition. The method
|
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. 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.
|
33
|
+
#
|
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
|
41
|
+
#
|
42
|
+
# Following is a simple tag class example which just reverses the body text and adds some
|
43
|
+
# information about the context to the result. Note that the class does not reside in the
|
44
|
+
# Webgen::Tag namespace and that the configuration entry is therefore also not under the
|
45
|
+
# <tt>tag.</tt> namespace.
|
46
|
+
#
|
47
|
+
# class Reverser
|
48
|
+
#
|
49
|
+
# include Webgen::Tag::Base
|
50
|
+
#
|
51
|
+
# def call(tag, body, context)
|
52
|
+
# result = param('do_reverse') ? body.reverse : body
|
53
|
+
# result += "Node: " + context.content_node.absolute_lcn + " (" + context.content_node['title'] + ")"
|
54
|
+
# result += "Reference node: " + context.ref_node.absolute_lcn
|
55
|
+
# result
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# WebsiteAccess.website.config.reverser.do_reverse nil, :mandatory => default
|
61
|
+
# WebsiteAccess.website.config['contentprocessor.tags.map']['reverse'] = 'Reverser'
|
62
|
+
#
|
63
|
+
module Webgen::Tag::Base
|
64
|
+
|
65
|
+
include Webgen::Loggable
|
66
|
+
include Webgen::WebsiteAccess
|
67
|
+
|
68
|
+
# Return a hash with parameter values extracted from the string +tag_config+.
|
69
|
+
def create_tag_params(tag_config, ref_node)
|
70
|
+
begin
|
71
|
+
config = YAML::load("--- #{tag_config}")
|
72
|
+
rescue ArgumentError => e
|
73
|
+
log(:error) { "Could not parse the tag params '#{tag_config}' in <#{ref_node.absolute_lcn}>: #{e.message}" }
|
74
|
+
config = {}
|
75
|
+
end
|
76
|
+
create_params_hash(config, ref_node)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Set the current parameter configuration to +params+.
|
80
|
+
def set_params(params)
|
81
|
+
@params = params
|
82
|
+
end
|
83
|
+
|
84
|
+
# Retrieve the parameter value for +name+. The value is taken from the current parameter
|
85
|
+
# configuration if the parameter is specified there or from the website configuration otherwise.
|
86
|
+
def param(name)
|
87
|
+
(@params && @params.has_key?(name) ? @params[name] : website.config[name])
|
88
|
+
end
|
89
|
+
|
90
|
+
# Default implementation for processing a tag. The parameter +tag+ specifies the name of the tag
|
91
|
+
# which should be processed (useful for tag classes which process different tags).
|
92
|
+
#
|
93
|
+
# The parameter +body+ holds the optional body value for the tag.
|
94
|
+
#
|
95
|
+
# The +context+ parameter holds all relevant information for processing. Have a look at the
|
96
|
+
# Webgen::ContentProcessor::Context class to see what is available.
|
97
|
+
#
|
98
|
+
# The method has to return the result of the tag processing and, optionally, a boolean value
|
99
|
+
# specifying if the result should further be processed (ie. webgen tags replaced).
|
100
|
+
#
|
101
|
+
# Needs to be redefined by classes that mixin this module!
|
102
|
+
def call(tag, body, context)
|
103
|
+
raise NotImplementedError
|
104
|
+
end
|
105
|
+
|
106
|
+
#######
|
107
|
+
private
|
108
|
+
#######
|
109
|
+
|
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.
|
114
|
+
def tag_config_base
|
115
|
+
self.class.name.gsub('::', '.').gsub(/^Webgen\./, '').downcase
|
116
|
+
end
|
117
|
+
|
118
|
+
# Return the list of all parameters for the tag class. All configuration options starting with
|
119
|
+
# +tag_config_base+ are used.
|
120
|
+
def tag_params_list
|
121
|
+
regexp = /^#{tag_config_base}/
|
122
|
+
website.config.data.keys.select {|key| key =~ regexp}
|
123
|
+
end
|
124
|
+
|
125
|
+
# Create the parameter hash from +config+ which needs to be a Hash, a String or +nil+.
|
126
|
+
def create_params_hash(config, node)
|
127
|
+
params = tag_params_list
|
128
|
+
result = case config
|
129
|
+
when Hash then create_from_hash(config, params, node)
|
130
|
+
when String then create_from_string(config, params, node)
|
131
|
+
when NilClass then {}
|
132
|
+
else
|
133
|
+
log(:error) { "Invalid parameter type (#{config.class}) for tag '#{self.class.name}' in <#{node.absolute_lcn}>" }
|
134
|
+
{}
|
135
|
+
end
|
136
|
+
|
137
|
+
unless params.all? {|k| !website.config.meta_info[k][:mandatory] || result.has_key?(k)}
|
138
|
+
log(:error) { "Not all mandatory parameters for tag '#{self.class.name}' in <#{node.absolute_lcn}> set" }
|
139
|
+
end
|
140
|
+
|
141
|
+
result
|
142
|
+
end
|
143
|
+
|
144
|
+
# Return a valid parameter hash taking values from +config+ which has to be a Hash.
|
145
|
+
def create_from_hash(config, params, node)
|
146
|
+
result = {}
|
147
|
+
config.each do |key, value|
|
148
|
+
if params.include?(key)
|
149
|
+
result[key] = value
|
150
|
+
elsif params.include?(tag_config_base + '.' + key)
|
151
|
+
result[tag_config_base + '.' + key] = value
|
152
|
+
else
|
153
|
+
log(:warn) { "Invalid parameter '#{key}' for tag '#{self.class.name}' in <#{node.absolute_lcn}>" }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
result
|
157
|
+
end
|
158
|
+
|
159
|
+
# Return a valid parameter hash by setting +value+ to the default mandatory parameter.
|
160
|
+
def create_from_string(value, params, node)
|
161
|
+
param_name = params.find {|k| website.config.meta_info[k][:mandatory] == 'default'}
|
162
|
+
if param_name.nil?
|
163
|
+
log(:error) { "No default mandatory parameter specified for tag '#{self.class.name}' but set in <#{node.absolute_lcn}>"}
|
164
|
+
{}
|
165
|
+
else
|
166
|
+
{param_name => value}
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::Tag
|
4
|
+
|
5
|
+
# Generates a breadcrumb trail for the page. This is especially useful when pages are in deep
|
6
|
+
# hierarchies of directories.
|
7
|
+
class BreadcrumbTrail
|
8
|
+
|
9
|
+
include Webgen::WebsiteAccess
|
10
|
+
include Base
|
11
|
+
|
12
|
+
def initialize #:nodoc:
|
13
|
+
website.blackboard.add_listener(:node_changed?, method(:node_changed?))
|
14
|
+
end
|
15
|
+
|
16
|
+
# Create the breadcrumb trail.
|
17
|
+
def call(tag, body, context)
|
18
|
+
out = breadcrumb_trail_list(context.content_node)
|
19
|
+
(context.dest_node.node_info[:tag_breadcrumb_trail] ||= {})[[@params.to_a.sort, context.content_node.absolute_lcn]] = out.map {|n| n.absolute_lcn}
|
20
|
+
out = out.map {|n| context.dest_node.link_to(n, :lang => context.content_node.lang) }.
|
21
|
+
join(param('tag.breadcrumbtrail.separator'))
|
22
|
+
log(:debug) { "Breadcrumb trail for <#{context.content_node.absolute_lcn}>: #{out}" }
|
23
|
+
out
|
24
|
+
end
|
25
|
+
|
26
|
+
#######
|
27
|
+
private
|
28
|
+
#######
|
29
|
+
|
30
|
+
# Return the list of nodes that make up the breadcrumb trail of +node+ according to the current
|
31
|
+
# parameters.
|
32
|
+
def breadcrumb_trail_list(node)
|
33
|
+
list = []
|
34
|
+
omit_index_path = if node.meta_info.has_key?('omit_index_path')
|
35
|
+
node['omit_index_path']
|
36
|
+
else
|
37
|
+
param('tag.breadcrumbtrail.omit_index_path')
|
38
|
+
end
|
39
|
+
omit_index_path = omit_index_path && node.parent.routing_node(node.lang) == node
|
40
|
+
|
41
|
+
node = node.parent if omit_index_path
|
42
|
+
|
43
|
+
until node == node.tree.dummy_root
|
44
|
+
list.unshift(node)
|
45
|
+
node = node.parent
|
46
|
+
end
|
47
|
+
list[param('tag.breadcrumbtrail.start_level')..param('tag.breadcrumbtrail.end_level')].to_a
|
48
|
+
end
|
49
|
+
|
50
|
+
# Check if the breadcrumb trails for +node+ have changed.
|
51
|
+
def node_changed?(node)
|
52
|
+
return if !node.node_info[:tag_breadcrumb_trail]
|
53
|
+
|
54
|
+
node.node_info[:tag_breadcrumb_trail].each do |(params, cn_alcn), cached_list|
|
55
|
+
cn = node.tree[cn_alcn]
|
56
|
+
set_params(params.to_hash)
|
57
|
+
list = breadcrumb_trail_list(cn)
|
58
|
+
set_params({})
|
59
|
+
|
60
|
+
if (list.map {|n| n.absolute_lcn} != cached_list) ||
|
61
|
+
list.any? {|n| (r = n.routing_node(cn.lang)) && r != node && r.meta_info_changed?}
|
62
|
+
node.flag(:dirty)
|
63
|
+
break
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::Tag
|
4
|
+
|
5
|
+
# Provides syntax highlighting via the +coderay+ library.
|
6
|
+
class Coderay
|
7
|
+
|
8
|
+
include Webgen::Tag::Base
|
9
|
+
include Webgen::WebsiteAccess
|
10
|
+
|
11
|
+
# Highlight the body of the block.
|
12
|
+
def call(tag, body, context)
|
13
|
+
require 'coderay'
|
14
|
+
options = {
|
15
|
+
:css => :style,
|
16
|
+
:wrap => param('tag.coderay.wrap').to_sym,
|
17
|
+
:line_numbers => (param('tag.coderay.line_numbers') ? :inline : nil),
|
18
|
+
:line_number_start => param('tag.coderay.line_number_start'),
|
19
|
+
:tab_width => param('tag.coderay.tab_width'),
|
20
|
+
:bold_every => param('tag.coderay.bold_every')
|
21
|
+
}
|
22
|
+
|
23
|
+
if param('tag.coderay.process_body')
|
24
|
+
body = website.blackboard.invoke(:content_processor, 'tags').call(context.clone(:content => body)).content
|
25
|
+
end
|
26
|
+
CodeRay.scan(body, param('tag.coderay.lang').to_sym).html(options)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::Tag
|
4
|
+
|
5
|
+
# Prints out the date using a format string which will be passed to Time#strftime. Therefore you
|
6
|
+
# can use everything Time#strftime offers.
|
7
|
+
class Date
|
8
|
+
|
9
|
+
include Base
|
10
|
+
|
11
|
+
# Return the current date formatted as specified.
|
12
|
+
def call(tag, body, context)
|
13
|
+
Time.now.strftime(param('tag.date.format'))
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'rbconfig'
|
6
|
+
|
7
|
+
module Webgen::Tag
|
8
|
+
|
9
|
+
# Executes the given command and returns the standard output. All special HTML characters are
|
10
|
+
# escaped.
|
11
|
+
class ExecuteCommand
|
12
|
+
|
13
|
+
include Webgen::Tag::Base
|
14
|
+
|
15
|
+
BIT_BUCKET = (Config::CONFIG['arch'].include?('mswin32') ? "nul" : "/dev/null")
|
16
|
+
|
17
|
+
# Execute the command and return the standard output.
|
18
|
+
def call(tag, body, context)
|
19
|
+
command = param('tag.executecommand.command')
|
20
|
+
output = `#{command} 2> #{BIT_BUCKET}`
|
21
|
+
if ($? >> 8) != 0
|
22
|
+
raise "Command '#{command}' in <#{context.ref_node.absolute_lcn}> has return value != 0: #{output}"
|
23
|
+
end
|
24
|
+
output = CGI::escapeHTML(output) if param('tag.executecommand.escape_html')
|
25
|
+
[output, param('tag.executecommand.process_output')]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Webgen::Tag
|
6
|
+
|
7
|
+
# Includes a file verbatim and optionally escapes all special HTML characters and processes webgen
|
8
|
+
# tags in it.
|
9
|
+
class IncludeFile
|
10
|
+
|
11
|
+
include Webgen::Tag::Base
|
12
|
+
include Webgen::WebsiteAccess
|
13
|
+
|
14
|
+
def initialize #:nodoc:
|
15
|
+
website.blackboard.add_listener(:node_changed?, method(:node_changed?))
|
16
|
+
end
|
17
|
+
|
18
|
+
# Include the specified file verbatim in the output, optionally escaping special HTML characters
|
19
|
+
# and processing tags in it.
|
20
|
+
def call(tag, body, context)
|
21
|
+
filename = param('tag.includefile.filename')
|
22
|
+
filename = File.join(website.directory, filename) unless filename =~ /^(\/|\w:)/
|
23
|
+
content = File.open(filename, 'rb') {|f| f.read}
|
24
|
+
content = CGI::escapeHTML(content) if param('tag.includefile.escape_html')
|
25
|
+
(context.dest_node.node_info[:tag_includefile_filenames] ||= []) << [filename, File.mtime(filename)]
|
26
|
+
|
27
|
+
[content, param('tag.includefile.process_output')]
|
28
|
+
end
|
29
|
+
|
30
|
+
#######
|
31
|
+
private
|
32
|
+
#######
|
33
|
+
|
34
|
+
def node_changed?(node)
|
35
|
+
if filenames = node.node_info[:tag_includefile_filenames]
|
36
|
+
node.flag(:dirty) if filenames.any? {|f, mtime| File.mtime(f) > mtime}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Webgen::Tag
|
4
|
+
|
5
|
+
# Generates a list with all the languages of the page.
|
6
|
+
class Langbar
|
7
|
+
|
8
|
+
include Webgen::Tag::Base
|
9
|
+
include Webgen::WebsiteAccess
|
10
|
+
|
11
|
+
def initialize #:nodoc:
|
12
|
+
website.blackboard.add_listener(:node_changed?, method(:node_changed?))
|
13
|
+
end
|
14
|
+
|
15
|
+
# Return a list of all translations of the content page.
|
16
|
+
def call(tag, body, context)
|
17
|
+
lang_nodes = all_lang_nodes(context.content_node)
|
18
|
+
(context.dest_node.node_info[:tag_langbar_data] ||= {})[context.content_node.absolute_cn] = lang_nodes.map {|n| n.absolute_lcn}
|
19
|
+
result = lang_nodes.
|
20
|
+
reject {|n| (context.content_node.lang == n.lang && !param('tag.langbar.show_own_lang'))}.
|
21
|
+
sort {|a, b| a.lang <=> b.lang}.
|
22
|
+
collect {|n| context.dest_node.link_to(n, :link_text => (param('tag.langbar.lang_names')[n.lang] || n.lang), :lang => n.lang)}.
|
23
|
+
join(param('tag.langbar.separator'))
|
24
|
+
|
25
|
+
[(param('tag.langbar.show_single_lang') || lang_nodes.length > 1 ? result : ""), param('tag.langbar.process_output')]
|
26
|
+
end
|
27
|
+
|
28
|
+
#######
|
29
|
+
private
|
30
|
+
#######
|
31
|
+
|
32
|
+
# Return all nodes with the same absolute cn as +node+.
|
33
|
+
def all_lang_nodes(node)
|
34
|
+
node.tree.node_access[:acn][node.absolute_cn]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Check if the langbar tag for +node+ changed.
|
38
|
+
def node_changed?(node)
|
39
|
+
return unless (cdata = node.node_info[:tag_langbar_data])
|
40
|
+
cdata.each do |acn, clang_nodes|
|
41
|
+
lang_nodes = all_lang_nodes(node.tree[acn, :acn]) rescue nil
|
42
|
+
if !lang_nodes || lang_nodes.length != clang_nodes.length ||
|
43
|
+
lang_nodes.any? {|n| n.meta_info_changed?}
|
44
|
+
node.flag(:dirty)
|
45
|
+
break
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|