gettalong-webgen 0.5.4.20080929
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +5 -0
- data/COPYING +10 -0
- data/GPL +340 -0
- data/Rakefile +324 -0
- data/THANKS +17 -0
- data/bin/webgen +10 -0
- data/data/webgen/resources.yaml +3 -0
- data/data/webgen/webgui/controller/main.rb +129 -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 +6 -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 +61 -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 +66 -0
- data/doc/contentprocessor/builder.page +80 -0
- data/doc/contentprocessor/erb.page +56 -0
- data/doc/contentprocessor/erubis.page +46 -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 +214 -0
- data/doc/getting_started.page +134 -0
- data/doc/index.page +65 -0
- data/doc/manual.page +532 -0
- data/doc/reference_configuration.page +646 -0
- data/doc/reference_metainfo.page +213 -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 +82 -0
- data/doc/sourcehandler/metainfo.page +41 -0
- data/doc/sourcehandler/page.page +30 -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 +22 -0
- data/doc/tag/menu.page +92 -0
- data/doc/tag/metainfo.page +29 -0
- data/doc/tag/relocatable.page +38 -0
- data/doc/tag/sitemap.page +31 -0
- data/doc/upgrading.page +139 -0
- data/doc/webgen_page_format.page +128 -0
- data/lib/webgen/blackboard.rb +73 -0
- data/lib/webgen/cache.rb +85 -0
- data/lib/webgen/cli.rb +118 -0
- data/lib/webgen/cli/create_command.rb +64 -0
- data/lib/webgen/cli/run_command.rb +20 -0
- data/lib/webgen/cli/utils.rb +86 -0
- data/lib/webgen/cli/webgui_command.rb +49 -0
- data/lib/webgen/common.rb +10 -0
- data/lib/webgen/common/sitemap.rb +76 -0
- data/lib/webgen/configuration.rb +147 -0
- data/lib/webgen/contentprocessor.rb +96 -0
- data/lib/webgen/contentprocessor/blocks.rb +46 -0
- data/lib/webgen/contentprocessor/builder.rb +26 -0
- data/lib/webgen/contentprocessor/context.rb +90 -0
- data/lib/webgen/contentprocessor/erb.rb +24 -0
- data/lib/webgen/contentprocessor/erubis.rb +40 -0
- data/lib/webgen/contentprocessor/haml.rb +25 -0
- data/lib/webgen/contentprocessor/maruku.rb +18 -0
- data/lib/webgen/contentprocessor/rdiscount.rb +15 -0
- data/lib/webgen/contentprocessor/rdoc.rb +17 -0
- data/lib/webgen/contentprocessor/redcloth.rb +15 -0
- data/lib/webgen/contentprocessor/sass.rb +18 -0
- data/lib/webgen/contentprocessor/tags.rb +134 -0
- data/lib/webgen/coreext.rb +10 -0
- data/lib/webgen/default_config.rb +198 -0
- data/lib/webgen/languages.rb +578 -0
- data/lib/webgen/loggable.rb +23 -0
- data/lib/webgen/logger.rb +78 -0
- data/lib/webgen/node.rb +347 -0
- data/lib/webgen/output.rb +37 -0
- data/lib/webgen/output/filesystem.rb +67 -0
- data/lib/webgen/page.rb +133 -0
- data/lib/webgen/path.rb +182 -0
- data/lib/webgen/source.rb +24 -0
- data/lib/webgen/source/filesystem.rb +58 -0
- data/lib/webgen/source/resource.rb +42 -0
- data/lib/webgen/source/stacked.rb +53 -0
- data/lib/webgen/sourcehandler.rb +202 -0
- data/lib/webgen/sourcehandler/base.rb +211 -0
- data/lib/webgen/sourcehandler/copy.rb +41 -0
- data/lib/webgen/sourcehandler/directory.rb +31 -0
- data/lib/webgen/sourcehandler/feed.rb +121 -0
- data/lib/webgen/sourcehandler/fragment.rb +71 -0
- data/lib/webgen/sourcehandler/metainfo.rb +117 -0
- data/lib/webgen/sourcehandler/page.rb +77 -0
- data/lib/webgen/sourcehandler/sitemap.rb +60 -0
- data/lib/webgen/sourcehandler/template.rb +68 -0
- data/lib/webgen/sourcehandler/virtual.rb +75 -0
- data/lib/webgen/tag.rb +23 -0
- data/lib/webgen/tag/base.rb +162 -0
- data/lib/webgen/tag/breadcrumbtrail.rb +71 -0
- data/lib/webgen/tag/coderay.rb +32 -0
- data/lib/webgen/tag/date.rb +18 -0
- data/lib/webgen/tag/executecommand.rb +29 -0
- data/lib/webgen/tag/includefile.rb +42 -0
- data/lib/webgen/tag/langbar.rb +52 -0
- data/lib/webgen/tag/menu.rb +186 -0
- data/lib/webgen/tag/metainfo.rb +25 -0
- data/lib/webgen/tag/relocatable.rb +53 -0
- data/lib/webgen/tag/sitemap.rb +42 -0
- data/lib/webgen/tree.rb +80 -0
- data/lib/webgen/version.rb +6 -0
- data/lib/webgen/webgentask.rb +148 -0
- data/lib/webgen/website.rb +214 -0
- data/lib/webgen/websiteaccess.rb +29 -0
- data/lib/webgen/websitemanager.rb +125 -0
- data/man/man1/webgen.1 +67 -0
- data/misc/default.css +360 -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.gif +0 -0
- data/misc/images/exclamation.gif +0 -0
- data/misc/images/headerbg.jpg +0 -0
- data/misc/images/information.gif +0 -0
- data/misc/images/quote.gif +0 -0
- data/setup.rb +1585 -0
- data/test/helper.rb +41 -0
- data/test/test_blackboard.rb +58 -0
- data/test/test_cache.rb +57 -0
- data/test/test_common_sitemap.rb +56 -0
- data/test/test_configuration.rb +66 -0
- data/test/test_contentprocessor.rb +31 -0
- data/test/test_contentprocessor_blocks.rb +34 -0
- data/test/test_contentprocessor_builder.rb +19 -0
- data/test/test_contentprocessor_context.rb +38 -0
- data/test/test_contentprocessor_erb.rb +20 -0
- data/test/test_contentprocessor_erubis.rb +47 -0
- data/test/test_contentprocessor_haml.rb +20 -0
- data/test/test_contentprocessor_maruku.rb +27 -0
- data/test/test_contentprocessor_rdiscount.rb +15 -0
- data/test/test_contentprocessor_rdoc.rb +16 -0
- data/test/test_contentprocessor_redcloth.rb +12 -0
- data/test/test_contentprocessor_sass.rb +20 -0
- data/test/test_contentprocessor_tags.rb +97 -0
- data/test/test_languages.rb +53 -0
- data/test/test_loggable.rb +30 -0
- data/test/test_logger.rb +73 -0
- data/test/test_node.rb +339 -0
- data/test/test_output_filesystem.rb +58 -0
- data/test/test_page.rb +203 -0
- data/test/test_path.rb +131 -0
- data/test/test_source_filesystem.rb +59 -0
- data/test/test_source_resource.rb +26 -0
- data/test/test_source_stacked.rb +34 -0
- data/test/test_sourcehandler_base.rb +92 -0
- data/test/test_sourcehandler_copy.rb +45 -0
- data/test/test_sourcehandler_directory.rb +25 -0
- data/test/test_sourcehandler_feed.rb +74 -0
- data/test/test_sourcehandler_fragment.rb +67 -0
- data/test/test_sourcehandler_metainfo.rb +93 -0
- data/test/test_sourcehandler_page.rb +70 -0
- data/test/test_sourcehandler_sitemap.rb +47 -0
- data/test/test_sourcehandler_template.rb +63 -0
- data/test/test_sourcehandler_virtual.rb +56 -0
- data/test/test_tag_base.rb +82 -0
- data/test/test_tag_breadcrumbtrail.rb +89 -0
- data/test/test_tag_coderay.rb +30 -0
- data/test/test_tag_date.rb +16 -0
- data/test/test_tag_executecommand.rb +39 -0
- data/test/test_tag_includefile.rb +48 -0
- data/test/test_tag_langbar.rb +60 -0
- data/test/test_tag_menu.rb +195 -0
- data/test/test_tag_metainfo.rb +17 -0
- data/test/test_tag_relocatable.rb +57 -0
- data/test/test_tag_sitemap.rb +44 -0
- data/test/test_tree.rb +69 -0
- data/test/test_webgentask.rb +21 -0
- data/test/test_website.rb +96 -0
- data/test/test_websiteaccess.rb +23 -0
- data/test/test_websitemanager.rb +68 -0
- metadata +575 -0
data/lib/webgen/cli.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'cmdparse'
|
2
|
+
require 'webgen/website'
|
3
|
+
require 'webgen/version'
|
4
|
+
|
5
|
+
module Webgen
|
6
|
+
|
7
|
+
# Namespace for all classes that act as CLI commands.
|
8
|
+
#
|
9
|
+
# = Implementing a CLI command
|
10
|
+
#
|
11
|
+
# Each CLI command class needs to be put into this module and has to end with +Command+, otherwise
|
12
|
+
# it is not used. A CLI command is an extension that can be invoked from the webgen command and
|
13
|
+
# thus needs to be derived from CmdParse::Command. For detailed information on this class and the
|
14
|
+
# whole cmdparse package have a look at http://cmdparse.rubyforge.org!
|
15
|
+
#
|
16
|
+
# = Sample CLI command
|
17
|
+
#
|
18
|
+
# Here is a sample CLI command extension:
|
19
|
+
#
|
20
|
+
# require 'webgen/cli'
|
21
|
+
#
|
22
|
+
# class Webgen::CLI::SampleCommand < CmdParse::Command
|
23
|
+
#
|
24
|
+
# def initialize
|
25
|
+
# super('sample', false)
|
26
|
+
# self.short_desc = "This sample command just outputs its parameters"
|
27
|
+
# self.description = Utils.format("Uses the global verbosity level and outputs additional " +
|
28
|
+
# "information when the level is set to verbose!")
|
29
|
+
# @username = nil
|
30
|
+
# self.options = CmdParse::OptionParserWrapper.new do |opts|
|
31
|
+
# opts.separator "Options:"
|
32
|
+
# opts.on('-u', '--user USER', String,
|
33
|
+
# 'Specify an additional user name to output') {|@username|}
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# def execute(args)
|
38
|
+
# if args.length == 0
|
39
|
+
# raise OptionParser::MissingArgument.new('ARG1 [ARG2 ...]')
|
40
|
+
# else
|
41
|
+
# puts "Command line arguments:"
|
42
|
+
# args.each {|arg| puts arg}
|
43
|
+
# if commandparser.verbosity == :verbose
|
44
|
+
# puts "Yeah, some additional information is always cool!"
|
45
|
+
# end
|
46
|
+
# puts "The entered username: #{@username}" if @username
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# Note the use of Utils.format in the initialize method so that the long text gets wrapped
|
53
|
+
# correctly! The Utils class provides some other useful methods, too!
|
54
|
+
#
|
55
|
+
# For information about which attributes are available on the webgen command parser instance have
|
56
|
+
# a look at Webgen::CLI::CommandParser!
|
57
|
+
module CLI
|
58
|
+
|
59
|
+
autoload :RunCommand, 'webgen/cli/run_command'
|
60
|
+
autoload :CreateCommand, 'webgen/cli/create_command'
|
61
|
+
autoload :WebguiCommand, 'webgen/cli/webgui_command'
|
62
|
+
|
63
|
+
autoload :Utils, 'webgen/cli/utils'
|
64
|
+
|
65
|
+
|
66
|
+
# This is the command parser class used for handling the webgen command line interface. After
|
67
|
+
# creating an instance, the inherited #parse method can be used for parsing the command line
|
68
|
+
# arguments and executing the requested command.
|
69
|
+
class CommandParser < CmdParse::CommandParser
|
70
|
+
|
71
|
+
# The website directory. Default: the current working directory.
|
72
|
+
attr_reader :directory
|
73
|
+
|
74
|
+
# The verbosity level. Default: <tt>:normal</tt>
|
75
|
+
attr_reader :verbosity
|
76
|
+
|
77
|
+
# The log level. Default: <tt>Logger::WARN</tt>
|
78
|
+
attr_reader :log_level
|
79
|
+
|
80
|
+
def initialize # :nodoc:
|
81
|
+
super(true)
|
82
|
+
@directory = Dir.pwd
|
83
|
+
@verbosity = :normal
|
84
|
+
@log_level = ::Logger::WARN
|
85
|
+
@log_filter = nil
|
86
|
+
|
87
|
+
self.program_name = "webgen"
|
88
|
+
self.program_version = Webgen::VERSION
|
89
|
+
self.options = CmdParse::OptionParserWrapper.new do |opts|
|
90
|
+
opts.separator "Global options:"
|
91
|
+
opts.on("--directory DIR", "-d", String, "The website directory (default: the current directory)") {|@directory|}
|
92
|
+
opts.on("--verbose", "-v", "Print more output") { @verbosity = :verbose }
|
93
|
+
opts.on("--quiet", "-q", "No output") { @verbosity = :quiet }
|
94
|
+
opts.on("--log-level LEVEL", "-l", Integer, "The logging level (0..debug, 3..error)") {|@log_level|}
|
95
|
+
opts.on("--log-filter", "-f", Regexp, 'Filter for logging events') {|@log_filter|}
|
96
|
+
end
|
97
|
+
self.add_command(CmdParse::HelpCommand.new)
|
98
|
+
self.add_command(CmdParse::VersionCommand.new)
|
99
|
+
Webgen::CLI.constants.select {|c| c =~ /.+Command$/ }.each do |c|
|
100
|
+
self.add_command(Webgen::CLI.const_get(c).new, (c == 'RunCommand' ? true : false))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Utility method for sub-commands to create the correct Webgen::Website object.
|
105
|
+
def create_website
|
106
|
+
website = Webgen::Website.new(@directory) do |config|
|
107
|
+
config['logger.mask'] = @log_filter
|
108
|
+
end
|
109
|
+
website.logger.level = @log_level
|
110
|
+
website.logger.verbosity = @verbosity
|
111
|
+
website
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'webgen/cli'
|
2
|
+
require 'webgen/websitemanager'
|
3
|
+
|
4
|
+
module Webgen::CLI
|
5
|
+
|
6
|
+
# The CLI command for creating a webgen website.
|
7
|
+
class CreateCommand < CmdParse::Command
|
8
|
+
|
9
|
+
def initialize #:nodoc:
|
10
|
+
super('create', false)
|
11
|
+
self.description = Utils.format("If the verbosity level is set to verbose, the created files are listed.")
|
12
|
+
@template = 'default'
|
13
|
+
@style = 'andreas07'
|
14
|
+
|
15
|
+
self.short_desc = 'Create a basic webgen website with selectable template/style'
|
16
|
+
self.options = CmdParse::OptionParserWrapper.new do |opts|
|
17
|
+
opts.separator "Options:"
|
18
|
+
opts.on('-t', '--template TEMPLATE', String, 'A website template or "none" (default: default)') do |val|
|
19
|
+
@template = (val == 'none' ? nil : val)
|
20
|
+
end
|
21
|
+
opts.on('-s', '--style STYLE', String, 'A website style or "none" (default: andreas07)') do |val|
|
22
|
+
@style = (val == 'none' ? nil : val)
|
23
|
+
end
|
24
|
+
opts.separator ""
|
25
|
+
opts.separator "Arguments:"
|
26
|
+
opts.separator opts.summary_indent + "DIR: the directory in which the website should be created"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def usage # :nodoc:
|
31
|
+
"Usage: #{commandparser.program_name} [global options] create [options] DIR"
|
32
|
+
end
|
33
|
+
|
34
|
+
def show_help # :nodoc:
|
35
|
+
super
|
36
|
+
wm = Webgen::WebsiteManager.new(commandparser.directory)
|
37
|
+
|
38
|
+
puts
|
39
|
+
puts "Available templates and styles:"
|
40
|
+
puts Utils.headline('Templates')
|
41
|
+
wm.templates.sort.each {|name, entry| Utils.hash_output(name, entry.instance_eval { @table }) }
|
42
|
+
puts Utils.headline('Styles')
|
43
|
+
wm.styles.select {|k,v| k =~ /^website-|[^-]+/ }.sort.each {|name, entry| Utils.hash_output(name, entry.instance_eval { @table }) }
|
44
|
+
end
|
45
|
+
|
46
|
+
# Create a webgen website in the directory <tt>args[0]</tt>.
|
47
|
+
def execute(args)
|
48
|
+
if args.length == 0
|
49
|
+
raise OptionParser::MissingArgument.new('DIR')
|
50
|
+
else
|
51
|
+
wm = Webgen::WebsiteManager.new(args[0])
|
52
|
+
paths = wm.create_website
|
53
|
+
paths += wm.apply_template(@template) if @template
|
54
|
+
paths += wm.apply_style(@style) if @style
|
55
|
+
if commandparser.verbosity == :verbose
|
56
|
+
puts "The following files were created in the directory #{args[0]}:"
|
57
|
+
puts paths.sort.collect {|f| "- " + f }.join("\n")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'webgen/cli'
|
2
|
+
|
3
|
+
module Webgen::CLI
|
4
|
+
|
5
|
+
# The CLI command for rendering a webgen website.
|
6
|
+
class RunCommand < CmdParse::Command
|
7
|
+
|
8
|
+
def initialize # :nodoc:
|
9
|
+
super('render', false)
|
10
|
+
self.short_desc = 'Render the webgen website'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Render the website.
|
14
|
+
def execute(args)
|
15
|
+
commandparser.create_website.render
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'facets/ansicode'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
ANSICode.define_ansicolor_method(:lred, '1;31')
|
5
|
+
ANSICode.define_ansicolor_method(:lblue, '1;34')
|
6
|
+
|
7
|
+
module Webgen::CLI
|
8
|
+
|
9
|
+
# Provides methods for other CLI classes for formatting text in a consistent manner.
|
10
|
+
class Utils
|
11
|
+
|
12
|
+
USE_ANSI_COLORS = !Config::CONFIG['arch'].include?('mswin32')
|
13
|
+
DEFAULT_WIDTH = if Config::CONFIG['arch'].include?('mswin32')
|
14
|
+
72
|
15
|
+
else
|
16
|
+
((size = %x{stty size 2>/dev/null}).length > 0 ? size.split.last.to_i : 72) rescue 72
|
17
|
+
end
|
18
|
+
|
19
|
+
# Used for dynamically formatting the text (setting color, bold face, ...).
|
20
|
+
def self.method_missing(id, text = nil)
|
21
|
+
if USE_ANSI_COLORS && ANSICode.respond_to?(id)
|
22
|
+
ANSICode.send(id, text.to_s)
|
23
|
+
else
|
24
|
+
text.to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Return an array of lines which represents the text in +content+ formatted sothat no line is
|
29
|
+
# longer than +width+ characters. The +indent+ parameter specifies the amount of spaces
|
30
|
+
# prepended to each line. If +first_line_indented+ is +true+, then the first line is indented.
|
31
|
+
def self.format(content, indent = 0, first_line_indented = false, width = DEFAULT_WIDTH)
|
32
|
+
content = (content || '').dup
|
33
|
+
length = width - indent
|
34
|
+
|
35
|
+
paragraphs = content.split(/\n\n/)
|
36
|
+
if (0..1) === paragraphs.length
|
37
|
+
pattern = /^(.{0,#{length}})[ \n]/m
|
38
|
+
lines = []
|
39
|
+
while content.length > length
|
40
|
+
if content =~ pattern
|
41
|
+
str = $1
|
42
|
+
len = $&.length
|
43
|
+
else
|
44
|
+
str = content[0, length]
|
45
|
+
len = length
|
46
|
+
end
|
47
|
+
lines << (lines.empty? && !first_line_indented ? '' : ' '*indent) + str.gsub(/\n/, ' ')
|
48
|
+
content.slice!(0, len)
|
49
|
+
end
|
50
|
+
lines << (lines.empty? && !first_line_indented ? '' : ' '*indent) + content.gsub(/\n/, ' ') unless content.strip.empty?
|
51
|
+
lines
|
52
|
+
else
|
53
|
+
((format(paragraphs.shift, indent, first_line_indented, width) << '') +
|
54
|
+
paragraphs.collect {|p| format(p, indent, true, width) << '' }).flatten[0..-2]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Return a headline with the given +text+ and amount of +indent+.
|
59
|
+
def self.headline(text, indent = 2)
|
60
|
+
' '*indent + "#{bold(text)}"
|
61
|
+
end
|
62
|
+
|
63
|
+
# Return a section header with the given +text+ formatted in the given +color+ and indented
|
64
|
+
# according to +indent+. The whole text is also left justified to the column specified with
|
65
|
+
# +ljustlength+.
|
66
|
+
def self.section(text, ljustlength = 0, indent = 4, color = :green)
|
67
|
+
' '*indent + "#{send(color, text)}".ljust(ljustlength - indent + send(color).length)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Creates a listing of the key-value pairs of +hash+ under a section called +name+.
|
71
|
+
def self.hash_output(name, hash)
|
72
|
+
ljust = 20
|
73
|
+
puts section('Name', ljust) + "#{lred(name)}"
|
74
|
+
|
75
|
+
hash.sort_by {|k,v| k.to_s }.each do |name, value|
|
76
|
+
next unless value.respond_to?(:to_str)
|
77
|
+
desc = format(value.to_str, ljust)
|
78
|
+
puts section(name.to_s.capitalize, ljust) + desc.shift
|
79
|
+
desc.each {|line| puts line}
|
80
|
+
end
|
81
|
+
puts
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'webgen/cli'
|
2
|
+
|
3
|
+
module Webgen::CLI
|
4
|
+
|
5
|
+
# The CLI command for starting the webgen webgui.
|
6
|
+
class WebguiCommand < CmdParse::Command
|
7
|
+
|
8
|
+
def initialize # :nodoc:
|
9
|
+
super('webgui', false)
|
10
|
+
self.short_desc = 'Starts the webgen webgui'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Render the website.
|
14
|
+
def execute(args)
|
15
|
+
# some fixes for ramaze-2008.06
|
16
|
+
# - fix for Windows bug when win32console is not installed
|
17
|
+
# - fix for message displayed on shutdown
|
18
|
+
$:.unshift File.join(Webgen.data_dir, 'webgui', 'overrides')
|
19
|
+
require 'win32console'
|
20
|
+
$:.shift
|
21
|
+
require 'ramaze'
|
22
|
+
Ramaze::Log.loggers = []
|
23
|
+
def Ramaze.shutdown; # :nodoc:
|
24
|
+
end
|
25
|
+
|
26
|
+
acquire Webgen.data_dir/:webgui/:controller/'*'
|
27
|
+
Ramaze::Global.setup do |g|
|
28
|
+
g.root = Webgen.data_dir/:webgui
|
29
|
+
g.public_root = Webgen.data_dir/:webgui/:public
|
30
|
+
g.view_root = Webgen.data_dir/:webgui/:view
|
31
|
+
g.adapter = :webrick
|
32
|
+
g.port = 7000
|
33
|
+
end
|
34
|
+
|
35
|
+
puts 'Starting webgui on http://localhost:7000, press Control-C to stop'
|
36
|
+
Thread.new do
|
37
|
+
sleep 2
|
38
|
+
puts 'Launching web browser'
|
39
|
+
require 'launchy'
|
40
|
+
Launchy.open('http://localhost:7000')
|
41
|
+
end
|
42
|
+
|
43
|
+
Ramaze.start
|
44
|
+
puts 'webgui finished'
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'webgen/tag/menu'
|
2
|
+
require 'webgen/websiteaccess'
|
3
|
+
|
4
|
+
module Webgen::Common
|
5
|
+
|
6
|
+
# This class provides functionality for creating sitemaps and checking if a sitemap has changed.
|
7
|
+
class Sitemap
|
8
|
+
|
9
|
+
include Webgen::WebsiteAccess
|
10
|
+
|
11
|
+
def initialize #:nodoc:
|
12
|
+
website.blackboard.add_listener(:node_changed?, method(:node_changed?))
|
13
|
+
end
|
14
|
+
|
15
|
+
# Return the sitemap tree as Webgen::Tag::Menu::MenuNode created for the +node+ in the language
|
16
|
+
# +lang+ using the provided +options+ which can be any configuration option starting with
|
17
|
+
# <tt>common.sitemap</tt>.
|
18
|
+
def create_sitemap(node, lang, options)
|
19
|
+
@options = options
|
20
|
+
tree = recursive_create(nil, node.tree.root, lang).sort!
|
21
|
+
@options = nil
|
22
|
+
(node.node_info[:common_sitemap] ||= {})[[options.to_a.sort, lang]] = tree.to_lcn_list
|
23
|
+
tree
|
24
|
+
end
|
25
|
+
|
26
|
+
#######
|
27
|
+
private
|
28
|
+
#######
|
29
|
+
|
30
|
+
# Recursively create the sitemap.
|
31
|
+
def recursive_create(parent, node, lang, in_sitemap = true)
|
32
|
+
mnode = Webgen::Tag::Menu::MenuNode.new(parent, node)
|
33
|
+
node.children.map do |n|
|
34
|
+
sub_in_sitemap = ((option('common.sitemap.used_kinds').empty? || option('common.sitemap.used_kinds').include?(n['kind'])) &&
|
35
|
+
(option('common.sitemap.any_lang') || n.lang.nil? || n.lang == lang) &&
|
36
|
+
(!option('common.sitemap.honor_in_menu') || n['in_menu']) &&
|
37
|
+
(parent.nil? || node.routing_node(lang) != n))
|
38
|
+
[(!n.children.empty? || sub_in_sitemap ? n : nil), sub_in_sitemap]
|
39
|
+
end.each do |n, sub_in_sitemap|
|
40
|
+
next if n.nil?
|
41
|
+
sub_node = recursive_create(mnode, n, lang, sub_in_sitemap)
|
42
|
+
mnode.children << sub_node unless sub_node.nil?
|
43
|
+
end
|
44
|
+
(mnode.children.empty? && !in_sitemap ? nil : mnode)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Retrieve the configuration option value for +name+. The value is taken from the current
|
48
|
+
# configuration options hash if +name+ is specified there or from the website configuration
|
49
|
+
# otherwise.
|
50
|
+
def option(name)
|
51
|
+
(@options && @options.has_key?(name) ? @options[name] : website.config[name])
|
52
|
+
end
|
53
|
+
|
54
|
+
# Check if the sitemaps for +node+ have changed.
|
55
|
+
def node_changed?(node)
|
56
|
+
return if !node.node_info[:common_sitemap]
|
57
|
+
|
58
|
+
node.node_info[:common_sitemap].each do |(options, lang), cached_tree|
|
59
|
+
@options = options.to_hash
|
60
|
+
tree = recursive_create(nil, node.tree.root, lang).sort!.to_lcn_list
|
61
|
+
@options = nil
|
62
|
+
|
63
|
+
if (tree != cached_tree) ||
|
64
|
+
(tree.flatten.any? do |alcn|
|
65
|
+
(n = node.tree[alcn]) && (r = n.routing_node(lang)) && r.meta_info_changed?
|
66
|
+
end)
|
67
|
+
node.dirty = true
|
68
|
+
break
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
module Webgen
|
2
|
+
|
3
|
+
# Stores the configuration for a webgen website.
|
4
|
+
#
|
5
|
+
# Configuration options should be created like this:
|
6
|
+
#
|
7
|
+
# config.my.new.config 'value', :doc => 'some', :meta => 'info'
|
8
|
+
#
|
9
|
+
# and later accessed or set using the accessor methods #[] and #[]= or a configuration
|
10
|
+
# helper. These helpers are defined in the Helpers module and provide easier access to complex
|
11
|
+
# configuration options.
|
12
|
+
class Configuration
|
13
|
+
|
14
|
+
# Helper class for providing an easy method to define configuration options.
|
15
|
+
class MethodChain
|
16
|
+
|
17
|
+
def initialize(config) #:nodoc:
|
18
|
+
@config = config
|
19
|
+
@name = ''
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(id, *args) #:nodoc:
|
23
|
+
@name += (@name.empty? ? '' : '.') + id.id2name.sub(/(!|=)$/,'')
|
24
|
+
if args.length > 0
|
25
|
+
value = args.shift
|
26
|
+
@config.data[@name] = value unless @config.data.has_key?(@name) # value is set only the first time
|
27
|
+
@config.meta_info[@name] ||= {}
|
28
|
+
@config.meta_info[@name].update(*args) if args.length > 0
|
29
|
+
nil
|
30
|
+
else
|
31
|
+
self
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
# This module provides methods for setting more complex configuration options. It is mixed into
|
38
|
+
# Webgen::Configuration so that its methods can be used. Detailed information on the use of the
|
39
|
+
# methods can be found in the "User Manual" in the "Configuration File" section.
|
40
|
+
#
|
41
|
+
# All public methods defined in this module are available for direct use in the
|
42
|
+
# configuration file, e.g. the method named +default_meta_info+ can be used like this:
|
43
|
+
#
|
44
|
+
# default_meta_info:
|
45
|
+
# Webgen::SourceHandler::Page:
|
46
|
+
# in_menu : true
|
47
|
+
# :action : replace
|
48
|
+
#
|
49
|
+
# All methods have to take exactly one argument, a Hash.
|
50
|
+
#
|
51
|
+
# The special key <tt>:action</tt> should be used for specifying how the configuration option
|
52
|
+
# should be set:
|
53
|
+
#
|
54
|
+
# replace:: Replace the configuration option with the new values.
|
55
|
+
# modify:: Replace old values with new values and add missing ones (useful for hashes and
|
56
|
+
# normally the default value)
|
57
|
+
module Helpers
|
58
|
+
|
59
|
+
# Set the default meta information for source handlers.
|
60
|
+
def default_meta_info(args)
|
61
|
+
args.each do |sh_name, mi|
|
62
|
+
raise ArgumentError, 'Invalid argument for configuration helper default_meta_info' unless mi.kind_of?(Hash)
|
63
|
+
action = mi.delete(:action) || 'modify'
|
64
|
+
mi_hash = (self['sourcehandler.default_meta_info'][complete_source_handler_name(sh_name)] ||= {})
|
65
|
+
case action
|
66
|
+
when 'replace' then mi_hash.replace(mi)
|
67
|
+
else mi_hash.update(mi)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
# Set the path patterns used by source handlers.
|
74
|
+
def patterns(args)
|
75
|
+
args.each do |sh_name, data|
|
76
|
+
pattern_arr = (self['sourcehandler.patterns'][complete_source_handler_name(sh_name)] ||= [])
|
77
|
+
case data
|
78
|
+
when Array then pattern_arr.replace(data)
|
79
|
+
when Hash
|
80
|
+
(data['del'] || []).each {|pat| pattern_arr.delete(pat)}
|
81
|
+
(data['add'] || []).each {|pat| pattern_arr << pat}
|
82
|
+
else
|
83
|
+
raise ArgumentError, 'Invalid argument for configuration helper patterns'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
# Set the default processing pipeline for a source handler.
|
90
|
+
def default_processing_pipeline(args)
|
91
|
+
args.each do |sh_name, pipeline|
|
92
|
+
raise ArgumentError, 'Invalid argument for configuration helper pipeline' unless pipeline.kind_of?(String)
|
93
|
+
mi_hash = (self['sourcehandler.default_meta_info'][complete_source_handler_name(sh_name)] ||= {})
|
94
|
+
((mi_hash['blocks'] ||= {})['default'] ||= {})['pipeline'] = pipeline
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
# Complete +sh_name+ by checking if a source handler called
|
100
|
+
# <tt>Webgen::SourceHandler::SH_NAME</tt> exists.
|
101
|
+
def complete_source_handler_name(sh_name)
|
102
|
+
(Webgen::SourceHandler.constants.include?(sh_name) ? 'Webgen::SourceHandler::' + sh_name : sh_name)
|
103
|
+
end
|
104
|
+
private :complete_source_handler_name
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
include Helpers
|
110
|
+
|
111
|
+
# The hash which stores the meta info for the configuration options.
|
112
|
+
attr_reader :meta_info
|
113
|
+
|
114
|
+
# The configuration options hash.
|
115
|
+
attr_reader :data
|
116
|
+
|
117
|
+
# Create a new Configuration object.
|
118
|
+
def initialize
|
119
|
+
@data = {}
|
120
|
+
@meta_info = {}
|
121
|
+
end
|
122
|
+
|
123
|
+
# Return the configuration option +name+.
|
124
|
+
def [](name)
|
125
|
+
if @data.has_key?(name)
|
126
|
+
@data[name]
|
127
|
+
else
|
128
|
+
raise ArgumentError, "No such configuration option: #{name}"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Set the configuration option +name+ to the provided +value+.
|
133
|
+
def []=(name, value)
|
134
|
+
if @data.has_key?(name)
|
135
|
+
@data[name] = value
|
136
|
+
else
|
137
|
+
raise ArgumentError, "No such configuration option: #{name}"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def method_missing(id, *args) #:nodoc:
|
142
|
+
MethodChain.new(self).method_missing(id, *args)
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|