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