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
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'webgen/sourcehandler/page'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
class TestSourceHandlerPage < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include Test::WebsiteHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
@website.blackboard.del_service(:templates_for_node)
|
13
|
+
@website.blackboard.del_service(:parse_html_sections)
|
14
|
+
@website.blackboard.del_service(:create_fragment_nodes)
|
15
|
+
@website.blackboard.add_service(:templates_for_node) {|node| []}
|
16
|
+
@website.blackboard.add_service(:parse_html_sections) {[]}
|
17
|
+
@website.blackboard.add_service(:create_fragment_nodes) {nil}
|
18
|
+
@obj = Webgen::SourceHandler::Page.new
|
19
|
+
@root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
|
20
|
+
@path = path_with_meta_info('/index.page') {StringIO.new('content')}
|
21
|
+
@path.meta_info.update({'lang'=>'eo', 'test'=>'yes', 'sort_info'=>6})
|
22
|
+
@website.blackboard.add_service(:source_paths) {{@path.path => @path}}
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_create_node
|
26
|
+
node = @obj.create_node(@root, @path.dup)
|
27
|
+
|
28
|
+
assert_not_nil(node)
|
29
|
+
assert_equal('test/index.eo.html', node.path)
|
30
|
+
assert_equal(@obj.class.name, node.node_info[:processor])
|
31
|
+
assert_equal('Index', node['title'])
|
32
|
+
assert_equal('yes', node['test'])
|
33
|
+
assert_equal(6, node['sort_info'])
|
34
|
+
assert_equal(Webgen::LanguageManager.language_for_code('epo'), node.lang)
|
35
|
+
assert_not_nil(@website.cache.permanent[:page_sections]['/test/index.eo.html'])
|
36
|
+
|
37
|
+
assert_nil(@obj.create_node(@root, @path.dup))
|
38
|
+
|
39
|
+
@root.tree.delete_node(node)
|
40
|
+
path = @path.dup
|
41
|
+
def path.changed?
|
42
|
+
false
|
43
|
+
end
|
44
|
+
@obj.create_node(@root, path)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_content
|
48
|
+
node = @obj.create_node(@root, @path)
|
49
|
+
assert_equal("content", @obj.content(node))
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_render_node
|
53
|
+
node = @obj.create_node(@root, @path)
|
54
|
+
assert_equal("content", @obj.render_node(node))
|
55
|
+
assert_raise(RuntimeError) { @obj.render_node(node, 'other') }
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_meta_info_changed
|
59
|
+
node = @obj.create_node(@root, @path)
|
60
|
+
@website.blackboard.dispatch_msg(:node_meta_info_changed?, node)
|
61
|
+
assert(node.meta_info_changed?)
|
62
|
+
|
63
|
+
node.dirty_meta_info = false
|
64
|
+
@website.cache.restore(@website.cache.dump)
|
65
|
+
@website.cache[[:sh_page_node_mi, node.absolute_lcn]]['modified_at'] = Time.now
|
66
|
+
@website.blackboard.dispatch_msg(:node_meta_info_changed?, node)
|
67
|
+
assert(!node.meta_info_changed?)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'webgen/sourcehandler'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
class TestSourceHandlerSitemap < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include Test::WebsiteHelper
|
9
|
+
|
10
|
+
SITEMAP_CONTENT = <<EOF
|
11
|
+
---
|
12
|
+
site_url: http://example.com
|
13
|
+
default_change_freq: daily
|
14
|
+
EOF
|
15
|
+
|
16
|
+
def setup
|
17
|
+
super
|
18
|
+
@nodes = create_sitemap_nodes
|
19
|
+
@nodes.each {|k,v| v['modified_at'] = Time.now}
|
20
|
+
@nodes[:file11_en]['priority'] = 0.9
|
21
|
+
@nodes[:file11_en]['change_freq'] = 'hourly'
|
22
|
+
@obj = Webgen::SourceHandler::Sitemap.new
|
23
|
+
@path = path_with_meta_info('/test.sitemap', {}, @obj.class.name) {StringIO.new(SITEMAP_CONTENT)}
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_node
|
27
|
+
sitemap = @obj.create_node(@nodes[:root], @path)
|
28
|
+
|
29
|
+
assert_not_nil(sitemap)
|
30
|
+
assert_equal('/test.xml', sitemap.path)
|
31
|
+
assert_equal('/test.xml', sitemap.absolute_lcn)
|
32
|
+
|
33
|
+
assert_raise(RuntimeError) do
|
34
|
+
@obj.create_node(@nodes[:root], path_with_meta_info('/test.sitemap', {}, @obj.class.name) {StringIO.new('')})
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_content
|
39
|
+
sitemap = @obj.create_node(@nodes[:root], @path)
|
40
|
+
content = sitemap.content
|
41
|
+
assert_match(/<changefreq>daily<\/changefreq>/, content)
|
42
|
+
assert_match(/<changefreq>hourly<\/changefreq>/, content)
|
43
|
+
assert_match(/<priority>0.5<\/priority>/, content)
|
44
|
+
assert_match(/<priority>0.9<\/priority>/, content)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'webgen/tree'
|
4
|
+
require 'webgen/node'
|
5
|
+
require 'webgen/path'
|
6
|
+
require 'webgen/sourcehandler/template'
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
class TestSourceHandlerTemplate < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include Test::WebsiteHelper
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
@obj = Webgen::SourceHandler::Template.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create_node
|
19
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
20
|
+
node = @obj.create_node(root, path_with_meta_info('/default.template') {StringIO.new('')})
|
21
|
+
|
22
|
+
assert_not_nil(node)
|
23
|
+
assert_not_nil(node.node_info[:page])
|
24
|
+
assert_equal('test/default.template', node.path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_templates_for_node
|
28
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
29
|
+
default_template = Webgen::Node.new(root, 'default.template', 'default.template')
|
30
|
+
default_de_template = Webgen::Node.new(root, 'default.de.template', 'default.template', {'lang' => 'de'})
|
31
|
+
other_template = Webgen::Node.new(root, 'other.template', 'other.template')
|
32
|
+
stopped_template = Webgen::Node.new(root, 'stopped.html', 'stopped.page', { 'template' => nil})
|
33
|
+
invalid_template = Webgen::Node.new(root, 'invalid.template', 'invalid.template', {'template' => 'invalidity'})
|
34
|
+
chained_template = Webgen::Node.new(root, 'chained.template', 'chained.template', {'template' => 'other.template'})
|
35
|
+
german_file = Webgen::Node.new(root, 'german.html', 'german.page', {'lang' => 'de', 'template' => 'other.template'})
|
36
|
+
dir = Webgen::Node.new(root, '/dir/', 'dir')
|
37
|
+
dir_default_template = Webgen::Node.new(dir, '/dir/default.template', 'default.template')
|
38
|
+
|
39
|
+
assert_equal([], @obj.templates_for_node(default_template))
|
40
|
+
assert_equal([], @obj.templates_for_node(stopped_template))
|
41
|
+
assert_equal([default_template], @obj.templates_for_node(other_template))
|
42
|
+
assert_equal([default_template], @obj.templates_for_node(invalid_template))
|
43
|
+
assert_equal([default_template, other_template], @obj.templates_for_node(chained_template))
|
44
|
+
assert_equal([default_de_template, other_template], @obj.templates_for_node(german_file))
|
45
|
+
assert_equal([default_template], @obj.templates_for_node(dir_default_template))
|
46
|
+
|
47
|
+
@website.cache.reset_volatile_cache
|
48
|
+
root.tree.delete_node(default_template)
|
49
|
+
assert_equal([], @obj.templates_for_node(other_template))
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_default_template
|
53
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
54
|
+
dir = Webgen::Node.new(root, 'dir/', 'dir')
|
55
|
+
template = Webgen::Node.new(root, 'default.template', 'default.template')
|
56
|
+
|
57
|
+
assert_equal(template, @obj.default_template(root, nil))
|
58
|
+
assert_equal(template, @obj.default_template(dir, nil))
|
59
|
+
root.tree.delete_node(template)
|
60
|
+
assert_nil(@obj.default_template(root, nil))
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'webgen/sourcehandler'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
class TestSourceHandlerVirtual < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include Test::WebsiteHelper
|
9
|
+
|
10
|
+
CONTENT=<<EOF
|
11
|
+
\\--- !omap
|
12
|
+
- path.de.html:
|
13
|
+
|
14
|
+
- /dir/:
|
15
|
+
title: My Dir
|
16
|
+
|
17
|
+
- /dir/file.html:
|
18
|
+
|
19
|
+
- /directory/path.en.html:
|
20
|
+
url: other.html
|
21
|
+
title: new title
|
22
|
+
|
23
|
+
- api.html:
|
24
|
+
url: http://www.example.com
|
25
|
+
title: Absolute
|
26
|
+
EOF
|
27
|
+
|
28
|
+
def test_create_node
|
29
|
+
obj = Webgen::SourceHandler::Virtual.new
|
30
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
31
|
+
shm = Webgen::SourceHandler::Main.new # for using service :create_nodes
|
32
|
+
time = Time.now
|
33
|
+
nodes = obj.create_node(root, path_with_meta_info('/virtuals', {'modified_at' => time}, obj.class.name) {StringIO.new(CONTENT)})
|
34
|
+
|
35
|
+
nodes.each {|n| assert_equal('/virtuals', n.node_info[:src])}
|
36
|
+
|
37
|
+
path_de = root.tree['/path.de.html']
|
38
|
+
path_en = root.tree['/directory/path.en.html']
|
39
|
+
dir = root.tree['/dir']
|
40
|
+
assert_not_nil(path_de)
|
41
|
+
assert_not_nil(dir)
|
42
|
+
assert_not_nil(path_en)
|
43
|
+
|
44
|
+
assert_equal('new title', path_en['title'])
|
45
|
+
assert_equal(time, path_en['modified_at'])
|
46
|
+
assert(path_en['no_output'])
|
47
|
+
assert_equal('My Dir', dir['title'])
|
48
|
+
assert_equal('directory/other.html', path_de.route_to(path_en))
|
49
|
+
assert_equal('../path.de.html', dir.route_to(path_de))
|
50
|
+
assert_equal('../directory/other.html', dir.route_to(path_en))
|
51
|
+
|
52
|
+
assert_equal('http://www.example.com', root.tree['/api.html'].path)
|
53
|
+
assert_equal('http://www.example.com', root.tree['/path.de.html'].route_to(root.tree['/api.html']))
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'stringio'
|
4
|
+
require 'webgen/tag'
|
5
|
+
require 'webgen/tag/base'
|
6
|
+
|
7
|
+
class TestTagBase < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Test::WebsiteHelper
|
10
|
+
|
11
|
+
class TestTag; include Webgen::Tag::Base; end
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
@website.config.testtagbase.testtag.param1 'param1'
|
16
|
+
@website.config.testtagbase.testtag.param2 nil, :mandatory=> true
|
17
|
+
@website.config.testtagbase.testtag.param3 'param3', :mandatory => 'default'
|
18
|
+
@obj = TestTag.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_tag_config_base
|
22
|
+
assert_equal('testtagbase.testtag', @obj.send(:tag_config_base))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_tag_params_list
|
26
|
+
params = [1,2,3].collect {|i| 'testtagbase.testtag.param' + i.to_s}
|
27
|
+
assert_equal(params.sort, @obj.send(:tag_params_list).sort)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_create_tag_params
|
31
|
+
output = StringIO.new('')
|
32
|
+
@website.logger = ::Logger.new(output)
|
33
|
+
@website.logger.level = Logger::WARN
|
34
|
+
|
35
|
+
output.string = ''
|
36
|
+
assert_equal({}, @obj.create_tag_params("--\nhal:param1\ntest:[;", Webgen::Tree.new.dummy_root))
|
37
|
+
output.rewind; assert_match(/Could not parse the tag params/, output.read)
|
38
|
+
|
39
|
+
output.string = ''
|
40
|
+
set_params(5)
|
41
|
+
assert_equal('param1', @obj.param('testtagbase.testtag.param1'))
|
42
|
+
output.rewind; assert_match(/Not all mandatory parameters/, output.read)
|
43
|
+
output.rewind; assert_match(/Invalid parameter type/, output.read)
|
44
|
+
|
45
|
+
output.string = ''
|
46
|
+
set_params(nil)
|
47
|
+
assert_equal('param1', @obj.param('testtagbase.testtag.param1'))
|
48
|
+
output.rewind; assert_match(/Not all mandatory parameters/, output.read)
|
49
|
+
|
50
|
+
output.string = ''
|
51
|
+
set_params({})
|
52
|
+
assert_equal('param1', @obj.param('testtagbase.testtag.param1'))
|
53
|
+
output.rewind; assert_match(/Not all mandatory parameters/, output.read)
|
54
|
+
|
55
|
+
output.string = ''
|
56
|
+
set_params('test_value')
|
57
|
+
assert_equal('test_value', @obj.param('testtagbase.testtag.param3'))
|
58
|
+
output.rewind; assert_match(/Not all mandatory parameters/, output.read)
|
59
|
+
|
60
|
+
output.string = ''
|
61
|
+
set_params({'param2' => 'test2', 'testtagbase.testtag.param3' => 'test3', 'invalid' => 5})
|
62
|
+
assert_equal('test2', @obj.param('testtagbase.testtag.param2'))
|
63
|
+
assert_equal('test3', @obj.param('testtagbase.testtag.param3'))
|
64
|
+
output.rewind; assert_no_match(/Not all mandatory parameters/, output.read)
|
65
|
+
output.rewind; assert_match(/Invalid parameter 'invalid'/, output.read)
|
66
|
+
|
67
|
+
@website.config.data.delete('testtagbase.testtag.param3')
|
68
|
+
@website.config.meta_info.delete('testtagbase.testtag.param3')
|
69
|
+
output.string = ''
|
70
|
+
set_params('default_value')
|
71
|
+
output.rewind; assert_match(/No default mandatory parameter specified for tag/, output.read)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_call
|
75
|
+
assert_raise(NotImplementedError) { @obj.call(nil, nil, nil) }
|
76
|
+
end
|
77
|
+
|
78
|
+
def set_params(params)
|
79
|
+
@obj.set_params(@obj.send(:create_params_hash, params, Webgen::Tree.new.dummy_root))
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'webgen/tree'
|
4
|
+
require 'webgen/contentprocessor'
|
5
|
+
require 'webgen/tag'
|
6
|
+
|
7
|
+
class TestTagBreadcrumbTrail < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Test::WebsiteHelper
|
10
|
+
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
@obj = Webgen::Tag::BreadcrumbTrail.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_default_nodes
|
17
|
+
{
|
18
|
+
:root => root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/', {'index_path' => 'index.html'}),
|
19
|
+
:dir1 => dir1 = Webgen::Node.new(root, '/dir1/', 'dir1/', {'title' => 'Dir1'}),
|
20
|
+
:dir11 => dir11 = Webgen::Node.new(dir1, '/dir1/dir11/', 'dir11/', {'index_path' => 'index.html'}),
|
21
|
+
:index11_en => Webgen::Node.new(dir11, '/dir1/dir11/index.html', 'index.html',
|
22
|
+
{'lang' => 'en', 'routed_title' => 'Dir11', 'title' => 'Index'}),
|
23
|
+
:file11_en => Webgen::Node.new(dir11, '/dir1/dir11/file111.html', 'file111.html',
|
24
|
+
{'lang' => 'en', 'title' => 'File111'}),
|
25
|
+
:index_en => Webgen::Node.new(root, '/index.html', 'index.html', {'lang' => 'en'}),
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def call(context, separator, omit_index_path, start_level, end_level)
|
30
|
+
@obj.set_params({'tag.breadcrumbtrail.separator' => separator,
|
31
|
+
'tag.breadcrumbtrail.omit_index_path' => omit_index_path,
|
32
|
+
'tag.breadcrumbtrail.start_level' => start_level,
|
33
|
+
'tag.breadcrumbtrail.end_level' => end_level})
|
34
|
+
result = @obj.call('breadcrumbTrail', '', context)
|
35
|
+
@obj.set_params({})
|
36
|
+
result
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_call
|
40
|
+
nodes = create_default_nodes
|
41
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]])
|
42
|
+
|
43
|
+
assert_equal('<a href="../../index.html"></a> / <a href="../">Dir1</a> / <a href="index.html">Dir11</a> / <span>File111</span>',
|
44
|
+
call(context, ' / ', false, 0, -1))
|
45
|
+
assert_equal('<a href="../../index.html"></a> / <a href="../">Dir1</a> / <a href="index.html">Dir11</a> / <span>File111</span>',
|
46
|
+
call(context, ' / ', true, 0, -1))
|
47
|
+
assert_equal('<a href="../">Dir1</a> / <a href="index.html">Dir11</a>',
|
48
|
+
call(context, ' / ', true, 1, -2))
|
49
|
+
assert_equal('<a href="../">Dir1</a> / <a href="index.html">Dir11</a>',
|
50
|
+
call(context, ' / ', false, 1, -2))
|
51
|
+
|
52
|
+
|
53
|
+
context[:chain] = [nodes[:index11_en]]
|
54
|
+
assert_equal('<a href="../../index.html"></a> / <a href="../">Dir1</a> / <span>Dir11</span> / <span>Index</span>',
|
55
|
+
call(context, ' / ', false, 0, -1))
|
56
|
+
assert_equal('<a href="../../index.html"></a> / <a href="../">Dir1</a> / <span>Dir11</span>',
|
57
|
+
call(context, ' / ', true, 0, -1))
|
58
|
+
assert_equal('<a href="../../index.html"></a> / <a href="../">Dir1</a> / <span>Dir11</span>',
|
59
|
+
call(context, ' / ', false, 0, -2))
|
60
|
+
assert_equal('<a href="../../index.html"></a> / <a href="../">Dir1</a>',
|
61
|
+
call(context, ' / ', true, 0, -2))
|
62
|
+
|
63
|
+
assert_equal('<a href="../../index.html"></a> | <a href="../">Dir1</a> | <span>Dir11</span> | <span>Index</span>',
|
64
|
+
call(context, ' | ', false, 0, -1))
|
65
|
+
|
66
|
+
|
67
|
+
nodes[:index11_en]['omit_index_path'] = false
|
68
|
+
assert_equal('<a href="../../index.html"></a> / <a href="../">Dir1</a> / <span>Dir11</span> / <span>Index</span>',
|
69
|
+
call(context, ' / ', true, 0, -1))
|
70
|
+
nodes[:index11_en]['omit_index_path'] = true
|
71
|
+
assert_equal('<a href="../../index.html"></a> / <a href="../">Dir1</a> / <span>Dir11</span>',
|
72
|
+
call(context, ' / ', false, 0, -1))
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_node_changed
|
76
|
+
nodes = create_default_nodes
|
77
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]])
|
78
|
+
call(context, ' / ', false, 0, -1)
|
79
|
+
|
80
|
+
nodes[:file11_en].dirty = false
|
81
|
+
@website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
|
82
|
+
assert(!nodes[:file11_en].dirty)
|
83
|
+
|
84
|
+
nodes[:index11_en].dirty_meta_info = true
|
85
|
+
@website.blackboard.dispatch_msg(:node_changed?, nodes[:file11_en])
|
86
|
+
assert(nodes[:file11_en].dirty)
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'webgen/tag'
|
4
|
+
|
5
|
+
class TestTagCoderay < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include Test::WebsiteHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
super
|
11
|
+
@obj = Webgen::Tag::Coderay.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(context, body, lang, process)
|
15
|
+
@obj.set_params({'tag.coderay.lang' => lang,
|
16
|
+
'tag.coderay.process' => process})
|
17
|
+
result = @obj.call('coderay', body, context)
|
18
|
+
@obj.set_params({})
|
19
|
+
result
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_call
|
23
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/', {'title' => 'Hallo'})
|
24
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [root])
|
25
|
+
|
26
|
+
assert(call(context, 'TestData', 'html', false).include?('TestData'))
|
27
|
+
assert(call(context, '{title:}', :ruby, true).include?('Hallo'))
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'webgen/contentprocessor'
|
4
|
+
require 'webgen/tag'
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
class TestTagDate < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Test::WebsiteHelper
|
10
|
+
|
11
|
+
def test_call
|
12
|
+
@obj = Webgen::Tag::Date.new
|
13
|
+
assert_not_nil(Time.parse(@obj.call('date', '', Webgen::ContentProcessor::Context.new)))
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|