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/test/helper.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'webgen/blackboard'
|
4
|
+
require 'webgen/website'
|
5
|
+
|
6
|
+
module Test
|
7
|
+
|
8
|
+
module WebsiteHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
@website = Webgen::Website.new('test', nil)
|
13
|
+
@website.init
|
14
|
+
Thread.current[:webgen_website] = @website
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
Thread.current[:webgen_website] = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def path_with_meta_info(path, mi = {}, sh = nil, &block)
|
22
|
+
path = Webgen::Path.new(path, &block)
|
23
|
+
path.meta_info.update(@website.config['sourcehandler.default_meta_info'][:all].merge(mi))
|
24
|
+
path.meta_info.update((@website.config['sourcehandler.default_meta_info'][sh] || {}).merge(mi)) if sh
|
25
|
+
path
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_sitemap_nodes
|
29
|
+
{
|
30
|
+
:root => root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/', {'index_path' => 'index.html'}),
|
31
|
+
:dir1 => dir1 = Webgen::Node.new(root, '/dir1/', 'dir1/'),
|
32
|
+
:file11_en => file11 = Webgen::Node.new(dir1, '/dir1/file11.en.html', 'file11.html', {'lang' => 'en', 'in_menu' => true, 'kind' => 'page'}),
|
33
|
+
:file11_en_f1 => file11_f1 = Webgen::Node.new(file11, '/dir1/file11.en.html#f1', '#f1', {'in_menu' => true}),
|
34
|
+
:dir2 => dir2 = Webgen::Node.new(root, '/dir2/', 'dir2/', {'kind' => 'directory'}),
|
35
|
+
:file21_en => Webgen::Node.new(dir2, '/dir2/file21.en.html', 'file21.html', {'lang' => 'en', 'in_menu' => false, 'kind' => 'other'}),
|
36
|
+
:file1_de => Webgen::Node.new(root, '/file1.de.html', 'file1.html', {'lang' => 'de', 'in_menu' => true, 'kind' => 'page'}),
|
37
|
+
:index_en => Webgen::Node.new(root, '/index.en.html', 'index.html', {'lang' => 'en', 'kind' => 'page'}),
|
38
|
+
:dir3 => dir3 = Webgen::Node.new(root, '/dir3/', 'dir3/', {'kind' => 'directory', 'index_path' => 'index.html'}),
|
39
|
+
:index3_en => Webgen::Node.new(dir3, '/dir3/index.en.html', 'index.html', {'lang' => 'en', 'kind' => 'page'})
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/blackboard'
|
5
|
+
|
6
|
+
class TestBlackboard < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@blackboard = Webgen::Blackboard.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_add_listener
|
13
|
+
assert_raise(ArgumentError) { @blackboard.add_listener(:test, nil) }
|
14
|
+
assert_raise(ArgumentError) { @blackboard.add_listener(:test, 'not callable') }
|
15
|
+
@blackboard.add_listener([:test, :other], proc { throw :called })
|
16
|
+
assert_throws(:called) { @blackboard.dispatch_msg(:test) }
|
17
|
+
assert_throws(:called) { @blackboard.dispatch_msg(:other) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_del_listener
|
21
|
+
listener = proc { throw :called }
|
22
|
+
@blackboard.add_listener(:test, listener)
|
23
|
+
assert_throws(:called) { @blackboard.dispatch_msg(:test) }
|
24
|
+
@blackboard.del_listener(:test, listener)
|
25
|
+
assert_nothing_thrown { @blackboard.dispatch_msg(:test) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_dispatch_msg
|
29
|
+
listener = proc { throw :called }
|
30
|
+
@blackboard.add_listener(:test, listener)
|
31
|
+
assert_throws(:called) { @blackboard.dispatch_msg(:test) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_add_service
|
35
|
+
assert_raise(ArgumentError) { @blackboard.add_service(:test, 'not callable') }
|
36
|
+
@blackboard.add_service(:test) { throw :called }
|
37
|
+
assert_raise(RuntimeError) { @blackboard.add_service(:test, nil) }
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_del_service
|
41
|
+
@blackboard.add_service(:test) { throw :called }
|
42
|
+
assert_throws(:called) { @blackboard.invoke(:test) }
|
43
|
+
@blackboard.del_service(:test)
|
44
|
+
assert_raise(ArgumentError) { @blackboard.invoke(:test) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def service
|
48
|
+
yield :test
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_invoke
|
52
|
+
@blackboard.add_service(:test) { throw :called }
|
53
|
+
assert_throws(:called) { @blackboard.invoke(:test) }
|
54
|
+
assert_raise(ArgumentError) { @blackboard.invoke(:unknown) }
|
55
|
+
|
56
|
+
@blackboard.add_service(:other, method(:service))
|
57
|
+
assert_throws(:test) { @blackboard.invoke(:other) {|p| throw p}}
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/test/test_cache.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/cache'
|
5
|
+
|
6
|
+
class TestCache < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@cache = Webgen::Cache.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def dump_and_restore
|
13
|
+
data = @cache.dump
|
14
|
+
setup
|
15
|
+
@cache.restore(data)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_standard_cache
|
19
|
+
@cache[:key] = :value
|
20
|
+
assert_equal(:value, @cache[:key])
|
21
|
+
dump_and_restore
|
22
|
+
assert_equal(:value, @cache[:key])
|
23
|
+
@cache[:key] = :newvalue
|
24
|
+
assert_equal(:value, @cache[:key])
|
25
|
+
dump_and_restore
|
26
|
+
assert_equal(:newvalue, @cache[:key])
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_permanent_cache
|
30
|
+
@cache.permanent[:key] = :value
|
31
|
+
assert_equal(:value, @cache.permanent[:key])
|
32
|
+
dump_and_restore
|
33
|
+
assert_equal(:value, @cache.permanent[:key])
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_volatile_cache
|
37
|
+
@cache.volatile[:key] = :value
|
38
|
+
assert_equal(:value, @cache.volatile[:key])
|
39
|
+
dump_and_restore
|
40
|
+
assert_equal(nil, @cache.volatile[:key])
|
41
|
+
|
42
|
+
@cache.volatile[:key] = :value
|
43
|
+
obj = @cache.instance('Hash')
|
44
|
+
@cache.reset_volatile_cache
|
45
|
+
assert_equal(nil, @cache.volatile[:key])
|
46
|
+
assert_equal(obj, @cache.instance('Hash'))
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_instance
|
50
|
+
obj = @cache.instance('Hash')
|
51
|
+
assert_kind_of(Hash, obj)
|
52
|
+
assert_equal(obj, @cache.instance('Hash'))
|
53
|
+
@cache.instance('Array')
|
54
|
+
assert_equal(['Hash', 'Array'], @cache.permanent[:classes])
|
55
|
+
dump_and_restore
|
56
|
+
assert_not_nil(@cache.volatile[:classes]['Hash'])
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/test/test_cli.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/cli'
|
5
|
+
|
6
|
+
class TestCLICommandParser < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_initialize
|
9
|
+
cli = Webgen::CLI::CommandParser.new
|
10
|
+
assert_equal('render', cli.main_command.default_command)
|
11
|
+
assert_equal(:normal, cli.verbosity)
|
12
|
+
assert_equal(Logger::WARN, cli.log_level)
|
13
|
+
assert_equal(Dir.pwd, cli.directory)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_website_from_env
|
17
|
+
ENV['WEBGEN_WEBSITE'] = '/webgen/test/site'
|
18
|
+
cli = Webgen::CLI::CommandParser.new
|
19
|
+
assert_equal('/webgen/test/site', cli.directory)
|
20
|
+
end
|
21
|
+
end
|
data/test/test_common.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/common'
|
5
|
+
|
6
|
+
class TestCommon < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_absolute_path
|
9
|
+
assert_raise(ArgumentError) { Webgen::Common.absolute_path('test', 'test') }
|
10
|
+
assert_equal('/', Webgen::Common.absolute_path('/', '/'))
|
11
|
+
assert_equal('/dir', Webgen::Common.absolute_path('/dir', '/other'))
|
12
|
+
assert_equal('/other/dir', Webgen::Common.absolute_path('dir', '/other'))
|
13
|
+
assert_equal('/test/dir', Webgen::Common.absolute_path('../test/dir', '/other'))
|
14
|
+
assert_equal('/', Webgen::Common.absolute_path('/..', '/'))
|
15
|
+
assert_equal('/dir', Webgen::Common.absolute_path('/../dir/.', '/'))
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/tree'
|
6
|
+
require 'webgen/contentprocessor'
|
7
|
+
require 'webgen/common'
|
8
|
+
|
9
|
+
class TestCommonSitemap < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include Test::WebsiteHelper
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
@obj = Webgen::Common::Sitemap.new
|
16
|
+
@nodes = create_sitemap_nodes
|
17
|
+
end
|
18
|
+
|
19
|
+
def do_assert(node, lang, honor_in_menu, any_lang, used_kinds, result)
|
20
|
+
assert_equal(result.map {|name| @nodes[name].absolute_lcn },
|
21
|
+
@obj.create_sitemap(node, lang, {
|
22
|
+
'common.sitemap.honor_in_menu' => honor_in_menu,
|
23
|
+
'common.sitemap.any_lang' => any_lang,
|
24
|
+
'common.sitemap.used_kinds' => used_kinds
|
25
|
+
}).to_lcn_list.flatten)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_create_sitemap_and_node_chagned
|
29
|
+
do_assert(@nodes[:file11_en], 'en', false, false, ['page'],
|
30
|
+
[:dir1, :file11_en, :index_en, :dir3])
|
31
|
+
do_assert(@nodes[:file11_en], 'en', true, false, ['page'],
|
32
|
+
[:dir1, :file11_en])
|
33
|
+
do_assert(@nodes[:file11_en], 'en', false, false, ['page', 'other'],
|
34
|
+
[:dir1, :file11_en, :dir2, :file21_en, :index_en, :dir3])
|
35
|
+
do_assert(@nodes[:file11_en], 'en', false, false, [],
|
36
|
+
[:dir1, :file11_en, :file11_en_f1, :dir2, :file21_en, :index_en, :dir3])
|
37
|
+
do_assert(@nodes[:file11_en], 'en', false, false, ['noone'],
|
38
|
+
[])
|
39
|
+
do_assert(@nodes[:file11_en], 'en', false, false, ['page', 'directory'],
|
40
|
+
[:dir1, :file11_en, :dir2, :index_en, :dir3])
|
41
|
+
do_assert(@nodes[:file11_en], 'en', true, false, ['page', 'directory'],
|
42
|
+
[:dir1, :file11_en])
|
43
|
+
|
44
|
+
do_assert(@nodes[:file1_de], 'de', false, false, ['page'],
|
45
|
+
[:file1_de])
|
46
|
+
do_assert(@nodes[:file1_de], 'de', false, true, ['page'],
|
47
|
+
[:dir1, :file11_en, :file1_de, :index_en, :dir3, :index3_en])
|
48
|
+
|
49
|
+
@nodes[:file11_en].unflag(:dirty)
|
50
|
+
@website.blackboard.dispatch_msg(:node_changed?, @nodes[:file11_en])
|
51
|
+
assert(!@nodes[:file11_en].flagged(:dirty))
|
52
|
+
|
53
|
+
@nodes[:file11_en].flag(:dirty_meta_info)
|
54
|
+
@website.blackboard.dispatch_msg(:node_changed?, @nodes[:file11_en])
|
55
|
+
assert(@nodes[:file11_en].flagged(:dirty))
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/configuration'
|
5
|
+
require 'webgen/sourcehandler'
|
6
|
+
|
7
|
+
class TestConfiguration < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_defining_options
|
10
|
+
@config = Webgen::Configuration.new
|
11
|
+
@config.test.value(:value, :opts => true)
|
12
|
+
assert_equal(:value, @config['test.value'])
|
13
|
+
assert_equal({:opts => true}, @config.meta_info['test.value'])
|
14
|
+
@config.test.value(:other_value, :doc => true)
|
15
|
+
assert_equal(:value, @config['test.value'])
|
16
|
+
assert_equal({:opts => true, :doc => true}, @config.meta_info['test.value'])
|
17
|
+
@config.test.other(:value)
|
18
|
+
assert_equal({}, @config.meta_info['test.other'])
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_get_options
|
22
|
+
@config = Webgen::Configuration.new
|
23
|
+
@config.test.value(:value)
|
24
|
+
assert_equal(:value, @config['test.value'])
|
25
|
+
assert_raise(ArgumentError) { @config['not.existing']}
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_set_options
|
29
|
+
@config = Webgen::Configuration.new
|
30
|
+
@config.test.value(:value)
|
31
|
+
assert_equal(:value, @config['test.value'])
|
32
|
+
@config['test.value'] = :newvalue
|
33
|
+
assert_equal(:newvalue, @config['test.value'])
|
34
|
+
|
35
|
+
assert_raise(ArgumentError) { @config['not.existing'] = :newvalue}
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_set_options_using_helpers
|
39
|
+
@config = Webgen::Configuration.new
|
40
|
+
@config.sourcehandler.default_meta_info({'Webgen::SourceHandler::Page' => {'in_menu' => true}})
|
41
|
+
@config.sourcehandler.patterns({'Webgen::SourceHandler::Page' => ['**/*.page']})
|
42
|
+
|
43
|
+
@config.default_meta_info('Page' => {'in_menu' => false, 'test' => true})
|
44
|
+
assert_equal({'in_menu' => false, 'test' => true}, @config['sourcehandler.default_meta_info']['Webgen::SourceHandler::Page'])
|
45
|
+
@config.default_meta_info('Webgen::SourceHandler::Page' => {'in_menu' => true, :action => 'replace'})
|
46
|
+
assert_equal({'in_menu' => true}, @config['sourcehandler.default_meta_info']['Webgen::SourceHandler::Page'])
|
47
|
+
@config.default_meta_info('Other' => {'in_menu' => false})
|
48
|
+
assert_equal({'in_menu' => false}, @config['sourcehandler.default_meta_info']['Other'])
|
49
|
+
assert_raise(ArgumentError) { @config.default_meta_info([5,6]) }
|
50
|
+
|
51
|
+
@config.patterns('Page' => ['**/*.html'])
|
52
|
+
assert_equal(['**/*.html'], @config['sourcehandler.patterns']['Webgen::SourceHandler::Page'])
|
53
|
+
@config.patterns('Page' => {'del' => ['**/*.html'], 'add' => ['**/*.page']})
|
54
|
+
assert_equal(['**/*.page'], @config['sourcehandler.patterns']['Webgen::SourceHandler::Page'])
|
55
|
+
@config.patterns('Other' => {'del' => ['**/*.html'], 'add' => ['**/*.page']})
|
56
|
+
assert_equal(['**/*.page'], @config['sourcehandler.patterns']['Other'])
|
57
|
+
assert_raise(ArgumentError) { @config.patterns([5,6]) }
|
58
|
+
assert_raise(ArgumentError) { @config.patterns('Page' => 5) }
|
59
|
+
|
60
|
+
@config.default_processing_pipeline('Page' => 'tags,maruku')
|
61
|
+
assert_equal('tags,maruku', @config['sourcehandler.default_meta_info']['Webgen::SourceHandler::Page']['blocks']['default']['pipeline'])
|
62
|
+
@config.default_processing_pipeline('Other' => 'tags,maruku')
|
63
|
+
assert_equal('tags,maruku', @config['sourcehandler.default_meta_info']['Other']['blocks']['default']['pipeline'])
|
64
|
+
assert_raise(ArgumentError) { @config.default_processing_pipeline([5,6]) }
|
65
|
+
assert_raise(ArgumentError) { @config.default_processing_pipeline('Page' => [5,6]) }
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
|
7
|
+
class TestContentProcessor < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Test::WebsiteHelper
|
10
|
+
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
@website.config.data['contentprocessor.map'] = {'test' => Hash}
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_access_hash
|
17
|
+
ah = Webgen::ContentProcessor::AccessHash.new
|
18
|
+
assert(ah.has_key?('test'))
|
19
|
+
assert(!ah.has_key?('other'))
|
20
|
+
assert_kind_of(Hash, ah['test'])
|
21
|
+
assert_nil(ah['other'])
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_list
|
25
|
+
assert_equal(['test'], Webgen::ContentProcessor.list)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_for_name
|
29
|
+
assert_kind_of(Hash, Webgen::ContentProcessor.for_name('test'))
|
30
|
+
assert_nil(Webgen::ContentProcessor.for_name('other'))
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/tree'
|
5
|
+
require 'webgen/page'
|
6
|
+
require 'webgen/contentprocessor'
|
7
|
+
|
8
|
+
class TestContentProcessorBlocks < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_process
|
11
|
+
obj = Webgen::ContentProcessor::Blocks.new
|
12
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
13
|
+
node = Webgen::Node.new(root, 'test', 'test')
|
14
|
+
node.node_info[:page] = Webgen::Page.from_data("--- name:content\ndata\n--- name:other\nother")
|
15
|
+
template = Webgen::Node.new(root, 'template', 'template')
|
16
|
+
template.node_info[:page] = Webgen::Page.from_data("--- name:content pipeline:blocks\nbefore<webgen:block name='content' />after")
|
17
|
+
processors = { 'blocks' => obj }
|
18
|
+
|
19
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [node], :processors => processors)
|
20
|
+
context.content = '<webgen:block name="content" /><webgen:block name="content" chain="template;test" />'
|
21
|
+
obj.call(context)
|
22
|
+
assert_equal('databeforedataafter', context.content)
|
23
|
+
assert_equal(Set.new([node.absolute_lcn, template.absolute_lcn]), node.node_info[:used_nodes])
|
24
|
+
|
25
|
+
context.content = '<webgen:block name="content" node="next" /><webgen:block name="content" chain="template;test" />'
|
26
|
+
obj.call(context)
|
27
|
+
assert_equal('databeforedataafter', context.content)
|
28
|
+
|
29
|
+
context.content = '<webgen:block name="nothing"/>'
|
30
|
+
assert_raise(RuntimeError) { obj.call(context) }
|
31
|
+
|
32
|
+
context.content = '<webgen:block name="content" chain="invalid" /><webgen:block name="content" />'
|
33
|
+
node.node_info[:used_nodes] = Set.new
|
34
|
+
context[:chain] = [node, template, node]
|
35
|
+
obj.call(context)
|
36
|
+
assert_equal('<webgen:block name="content" chain="invalid" />beforedataafter', context.content)
|
37
|
+
assert_equal(Set.new([template.absolute_lcn, node.absolute_lcn]), node.node_info[:used_nodes])
|
38
|
+
|
39
|
+
context.content = 'bef<webgen:block name="other" chain="template;test" notfound="ignore" />aft'
|
40
|
+
obj.call(context)
|
41
|
+
assert_equal('befaft', context.content)
|
42
|
+
|
43
|
+
context.content = '<webgen:block name="other" chain="template" node="first" />'
|
44
|
+
assert_raise(RuntimeError) { obj.call(context) }
|
45
|
+
|
46
|
+
context.content = '<webgen:block name="other" chain="template;test" node="first" />'
|
47
|
+
obj.call(context)
|
48
|
+
assert_equal('other', context.content)
|
49
|
+
|
50
|
+
context.content = '<webgen:block name="other" chain="test" node="first" />'
|
51
|
+
obj.call(context)
|
52
|
+
assert_equal('other', context.content)
|
53
|
+
|
54
|
+
context.content = '<webgen:block name="invalid" node="first" notfound="ignore" /><webgen:block name="content" />'
|
55
|
+
obj.call(context)
|
56
|
+
assert_equal('beforedataafter', context.content)
|
57
|
+
|
58
|
+
context[:chain] = [node, template]
|
59
|
+
context.content = '<webgen:block name="other" node="current" />'
|
60
|
+
obj.call(context)
|
61
|
+
assert_equal('other', context.content)
|
62
|
+
|
63
|
+
context.content = '<webgen:block name="other" node="current" chain="template"/>'
|
64
|
+
obj.call(context)
|
65
|
+
assert_equal('other', context.content)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/tree'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
|
7
|
+
class TestContentProcessorBuilder < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_call
|
10
|
+
obj = Webgen::ContentProcessor::Builder.new
|
11
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
|
+
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
+
content = "xml.div(:path => node.absolute_lcn) { xml.strong('test'); " +
|
14
|
+
"website; context; ref_node; dest_node }"
|
15
|
+
context = Webgen::ContentProcessor::Context.new(:content => content,
|
16
|
+
:chain => [node])
|
17
|
+
assert_equal("<div path=\"/test\">\n <strong>test</strong>\n</div>\n", obj.call(context).content)
|
18
|
+
|
19
|
+
context.content = 'raise "bla"'
|
20
|
+
assert_raise(RuntimeError) { obj.call(context).content }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|