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
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/sourcehandler'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestSourceHandlerMemory < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Test::WebsiteHelper
|
11
|
+
|
12
|
+
def test_all
|
13
|
+
obj = Webgen::SourceHandler::Memory.new
|
14
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
15
|
+
shm = Webgen::SourceHandler::Main.new # for using service :create_nodes
|
16
|
+
root.unflag(:dirty)
|
17
|
+
root.unflag(:created)
|
18
|
+
|
19
|
+
node = obj.create_node(root, path_with_meta_info('/test.png'), '/', 'data')
|
20
|
+
assert_equal('/', node.node_info[:memory_source_alcn])
|
21
|
+
assert_equal('data', obj.content(node))
|
22
|
+
assert(!node.flagged(:reinit))
|
23
|
+
root.tree.delete_node(node)
|
24
|
+
|
25
|
+
node = obj.create_node(root, path_with_meta_info('/test.png'), '/') {|n| assert_equal(node, n); 'data'}
|
26
|
+
assert_equal('/', node.node_info[:memory_source_alcn])
|
27
|
+
assert_equal('data', obj.content(node))
|
28
|
+
assert(!node.flagged(:reinit))
|
29
|
+
|
30
|
+
assert(!root.flagged(:dirty))
|
31
|
+
node.flag(:reinit)
|
32
|
+
assert(root.flagged(:dirty))
|
33
|
+
root.unflag(:dirty)
|
34
|
+
root.tree.delete_node(node)
|
35
|
+
|
36
|
+
node = obj.create_node(root, path_with_meta_info('/test.png'), '/', 'data')
|
37
|
+
assert_equal('/', node.node_info[:memory_source_alcn])
|
38
|
+
obj.instance_eval { @data = nil }
|
39
|
+
assert_nil(obj.content(node))
|
40
|
+
assert(node.flagged(:reinit))
|
41
|
+
assert(root.flagged(:dirty))
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/sourcehandler'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestSourceHandlerMetainfo < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Test::WebsiteHelper
|
11
|
+
|
12
|
+
class TestSH; include Webgen::SourceHandler::Base; end
|
13
|
+
|
14
|
+
CONTENT=<<EOF
|
15
|
+
/default.*:
|
16
|
+
title: new title
|
17
|
+
before: valbef
|
18
|
+
---
|
19
|
+
/default.css:
|
20
|
+
after: valaft
|
21
|
+
|
22
|
+
/other.page:
|
23
|
+
title: Not Other
|
24
|
+
EOF
|
25
|
+
|
26
|
+
def setup
|
27
|
+
super
|
28
|
+
@website.blackboard.add_service(:source_paths) do
|
29
|
+
{'/default.css' => path_with_meta_info('/default.css') {StringIO.new('# header')},
|
30
|
+
'/other.page' => path_with_meta_info('/other.page') {StringIO.new('other page')},
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
@obj = Webgen::SourceHandler::Metainfo.new
|
35
|
+
@root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
36
|
+
@node = @obj.create_node(@root, path_with_meta_info('/metainfo', {}, @obj.class.name) {StringIO.new(CONTENT)})
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_create_node
|
40
|
+
assert_equal({'/default.*' => {'title' => 'new title', 'before' => 'valbef'}}, @node.node_info[:mi_paths])
|
41
|
+
assert_equal({'/default.css' => {'after' => 'valaft'},
|
42
|
+
'/other.page' => {'title' => 'Not Other'}}, @node.node_info[:mi_alcn])
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_empty_metainfo_file
|
46
|
+
node = @obj.create_node(@root, path_with_meta_info('/test', {}, @obj.class.name) {StringIO.new('')})
|
47
|
+
assert_equal({}, node.node_info[:mi_paths])
|
48
|
+
assert_equal({}, node.node_info[:mi_alcn])
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_meta_info_changed
|
52
|
+
other = TestSH.new.create_node(@root, path_with_meta_info('/default.css'))
|
53
|
+
assert(!@obj.send(:meta_info_changed?, @node, other))
|
54
|
+
assert(@obj.send(:meta_info_changed?, @node, other, :force))
|
55
|
+
assert(!@obj.send(:meta_info_changed?, @node, other, :no_old_data))
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_mark_all_matched_dirty
|
59
|
+
other = TestSH.new.create_node(@root, path_with_meta_info('/default.css'))
|
60
|
+
|
61
|
+
other.unflag(:dirty_meta_info)
|
62
|
+
@obj.send(:mark_all_matched_dirty, @node)
|
63
|
+
assert(!other.flagged(:dirty_meta_info))
|
64
|
+
|
65
|
+
other.unflag(:dirty_meta_info)
|
66
|
+
@obj.send(:mark_all_matched_dirty, @node, :force)
|
67
|
+
assert(other.flagged(:dirty_meta_info))
|
68
|
+
|
69
|
+
other.unflag(:dirty_meta_info)
|
70
|
+
@obj.send(:mark_all_matched_dirty, @node, :no_old_data)
|
71
|
+
assert(!other.flagged(:dirty_meta_info))
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_before_node_created
|
75
|
+
path = path_with_meta_info('/default.css')
|
76
|
+
@website.blackboard.dispatch_msg(:before_node_created, @root, path)
|
77
|
+
assert('valbef', path.meta_info['before'])
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_after_node_created
|
81
|
+
other = TestSH.new.create_node(@root, path_with_meta_info('/default.css'))
|
82
|
+
@website.blackboard.dispatch_msg(:after_node_created, @node)
|
83
|
+
assert('valaft', other['after'])
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_before_node_deleted
|
87
|
+
other = TestSH.new.create_node(@root, path_with_meta_info('/default.css'))
|
88
|
+
@website.blackboard.dispatch_msg(:before_node_deleted, @node)
|
89
|
+
assert(other.flagged(:dirty_meta_info))
|
90
|
+
assert(@obj.nodes.empty?)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_node_meta_info_changed
|
94
|
+
@node.unflag(:dirty_meta_info)
|
95
|
+
@website.blackboard.dispatch_msg(:node_meta_info_changed?, @node)
|
96
|
+
assert(!@node.flagged(:dirty_meta_info))
|
97
|
+
|
98
|
+
@node.node_info[:mi_alcn] = @node.node_info[:mi_alcn].dup
|
99
|
+
@node.node_info[:mi_alcn]['/*metainfo'] = {'other' => 'doit'}
|
100
|
+
@website.blackboard.dispatch_msg(:node_meta_info_changed?, @node)
|
101
|
+
assert(@node.flagged(:dirty_meta_info))
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_content
|
105
|
+
assert_nil(@obj.content(nil))
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_deletion_of_metainfo
|
109
|
+
other = TestSH.new.create_node(@root, path_with_meta_info('/other.page'))
|
110
|
+
@website.blackboard.dispatch_msg(:after_node_created, other)
|
111
|
+
assert_equal('Not Other', other['title'])
|
112
|
+
|
113
|
+
@node.flag(:reinit)
|
114
|
+
@node = @obj.create_node(@root, path_with_meta_info('/metainfo', {}, @obj.class.name) {StringIO.new("")})
|
115
|
+
assert(other.flagged(:dirty_meta_info))
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/sourcehandler'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestSourceHandlerPage < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Test::WebsiteHelper
|
11
|
+
|
12
|
+
def setup
|
13
|
+
super
|
14
|
+
@website.blackboard.del_service(:templates_for_node)
|
15
|
+
@website.blackboard.add_service(:templates_for_node) {|node| []}
|
16
|
+
@obj = Webgen::SourceHandler::Page.new
|
17
|
+
@root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
|
18
|
+
@path = path_with_meta_info('/index.page') {StringIO.new('content')}
|
19
|
+
@path.meta_info.update({'lang'=>'eo', 'test'=>'yes', 'sort_info'=>6})
|
20
|
+
@website.blackboard.add_service(:source_paths) {{@path.path => @path}}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_create_node
|
24
|
+
node = @obj.create_node(@root, @path.dup)
|
25
|
+
|
26
|
+
assert_not_nil(node)
|
27
|
+
assert_equal('test/index.eo.html', node.path)
|
28
|
+
assert_equal(@obj.class.name, node.node_info[:processor])
|
29
|
+
assert_equal('Index', node['title'])
|
30
|
+
assert_equal('yes', node['test'])
|
31
|
+
assert_equal(6, node['sort_info'])
|
32
|
+
assert_equal(Webgen::LanguageManager.language_for_code('epo'), node.lang)
|
33
|
+
|
34
|
+
assert_equal(node, @obj.create_node(@root, @path.dup))
|
35
|
+
|
36
|
+
@root.tree.delete_node(node)
|
37
|
+
path = @path.dup
|
38
|
+
def path.changed?
|
39
|
+
false
|
40
|
+
end
|
41
|
+
@obj.create_node(@root, path)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_content
|
45
|
+
node = @obj.create_node(@root, @path)
|
46
|
+
assert_equal("content", @obj.content(node))
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_render_node
|
50
|
+
node = @obj.create_node(@root, @path)
|
51
|
+
assert_equal("content", @obj.render_node(node))
|
52
|
+
assert_raise(RuntimeError) { @obj.render_node(node, 'other') }
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_meta_info_changed
|
56
|
+
node = @obj.create_node(@root, @path)
|
57
|
+
@website.blackboard.dispatch_msg(:node_meta_info_changed?, node)
|
58
|
+
assert(!node.meta_info_changed?)
|
59
|
+
|
60
|
+
@path.instance_eval { @io = Webgen::Path::SourceIO.new {StringIO.new("---\ntitle: test\n---\ncontent")} }
|
61
|
+
@website.blackboard.dispatch_msg(:node_meta_info_changed?, node)
|
62
|
+
assert(node.meta_info_changed?)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/sourcehandler'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestSourceHandlerSitemap < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Test::WebsiteHelper
|
11
|
+
|
12
|
+
SITEMAP_CONTENT = <<EOF
|
13
|
+
---
|
14
|
+
site_url: http://example.com
|
15
|
+
default_change_freq: daily
|
16
|
+
EOF
|
17
|
+
|
18
|
+
def setup
|
19
|
+
super
|
20
|
+
@nodes = create_sitemap_nodes
|
21
|
+
@nodes.each {|k,v| v['modified_at'] = Time.now}
|
22
|
+
@nodes[:file11_en]['priority'] = 0.9
|
23
|
+
@nodes[:file11_en]['change_freq'] = 'hourly'
|
24
|
+
@obj = Webgen::SourceHandler::Sitemap.new
|
25
|
+
@path = path_with_meta_info('/test.sitemap', {}, @obj.class.name) {StringIO.new(SITEMAP_CONTENT)}
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_create_node
|
29
|
+
sitemap = @obj.create_node(@nodes[:root], @path)
|
30
|
+
|
31
|
+
assert_not_nil(sitemap)
|
32
|
+
assert_equal('/test.xml', sitemap.path)
|
33
|
+
assert_equal('/test.xml', sitemap.absolute_lcn)
|
34
|
+
|
35
|
+
assert_raise(RuntimeError) do
|
36
|
+
@obj.create_node(@nodes[:root], path_with_meta_info('/test.sitemap', {}, @obj.class.name) {StringIO.new('')})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_content
|
41
|
+
sitemap = @obj.create_node(@nodes[:root], @path)
|
42
|
+
content = sitemap.content
|
43
|
+
assert_match(/<changefreq>daily<\/changefreq>/, content)
|
44
|
+
assert_match(/<changefreq>hourly<\/changefreq>/, content)
|
45
|
+
assert_match(/<priority>0.5<\/priority>/, content)
|
46
|
+
assert_match(/<priority>0.9<\/priority>/, content)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/tree'
|
6
|
+
require 'webgen/node'
|
7
|
+
require 'webgen/path'
|
8
|
+
require 'webgen/sourcehandler'
|
9
|
+
require 'stringio'
|
10
|
+
|
11
|
+
class TestSourceHandlerTemplate < Test::Unit::TestCase
|
12
|
+
|
13
|
+
include Test::WebsiteHelper
|
14
|
+
|
15
|
+
def setup
|
16
|
+
super
|
17
|
+
@obj = Webgen::SourceHandler::Template.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_create_node
|
21
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
22
|
+
node = @obj.create_node(root, path_with_meta_info('/default.template') {StringIO.new('')})
|
23
|
+
|
24
|
+
assert_not_nil(node)
|
25
|
+
assert_not_nil(node.node_info[:page])
|
26
|
+
assert_equal('test/default.template', node.path)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_templates_for_node
|
30
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
31
|
+
default_template = Webgen::Node.new(root, 'default.template', 'default.template')
|
32
|
+
default_de_template = Webgen::Node.new(root, 'default.de.template', 'default.template', {'lang' => 'de'})
|
33
|
+
other_template = Webgen::Node.new(root, 'other.template', 'other.template')
|
34
|
+
stopped_template = Webgen::Node.new(root, 'stopped.html', 'stopped.page', { 'template' => nil})
|
35
|
+
invalid_template = Webgen::Node.new(root, 'invalid.template', 'invalid.template', {'template' => 'invalidity'})
|
36
|
+
chained_template = Webgen::Node.new(root, 'chained.template', 'chained.template', {'template' => 'other.template'})
|
37
|
+
german_file = Webgen::Node.new(root, 'german.html', 'german.page', {'lang' => 'de', 'template' => 'other.template'})
|
38
|
+
dir = Webgen::Node.new(root, '/dir/', 'dir')
|
39
|
+
dir_default_template = Webgen::Node.new(dir, '/dir/default.template', 'default.template')
|
40
|
+
|
41
|
+
assert_equal([], @obj.templates_for_node(default_template))
|
42
|
+
assert_equal([], @obj.templates_for_node(stopped_template))
|
43
|
+
assert_equal([default_template], @obj.templates_for_node(other_template))
|
44
|
+
assert_equal([default_template], @obj.templates_for_node(invalid_template))
|
45
|
+
assert_equal([default_template, other_template], @obj.templates_for_node(chained_template))
|
46
|
+
assert_equal([default_de_template, other_template], @obj.templates_for_node(german_file))
|
47
|
+
assert_equal([default_template], @obj.templates_for_node(dir_default_template))
|
48
|
+
|
49
|
+
@website.cache.reset_volatile_cache
|
50
|
+
root.tree.delete_node(default_template)
|
51
|
+
assert_equal([], @obj.templates_for_node(other_template))
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_default_template
|
55
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
56
|
+
dir = Webgen::Node.new(root, 'dir/', 'dir')
|
57
|
+
template = Webgen::Node.new(root, 'default.template', 'default.template')
|
58
|
+
|
59
|
+
assert_equal(template, @obj.default_template(root, nil))
|
60
|
+
assert_equal(template, @obj.default_template(dir, nil))
|
61
|
+
root.tree.delete_node(template)
|
62
|
+
assert_nil(@obj.default_template(root, nil))
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/sourcehandler'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestSourceHandlerVirtual < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Test::WebsiteHelper
|
11
|
+
|
12
|
+
CONTENT=<<EOF
|
13
|
+
\\--- !omap
|
14
|
+
- path.de.html:
|
15
|
+
|
16
|
+
- /dir/file.html:
|
17
|
+
|
18
|
+
- /dir/:
|
19
|
+
title: My Dir
|
20
|
+
|
21
|
+
- /directory/path.en.html:
|
22
|
+
url: other.html
|
23
|
+
title: new title
|
24
|
+
|
25
|
+
- api.html:
|
26
|
+
url: http://www.example.com
|
27
|
+
title: Absolute
|
28
|
+
EOF
|
29
|
+
|
30
|
+
def setup
|
31
|
+
super
|
32
|
+
@obj = Webgen::SourceHandler::Virtual.new
|
33
|
+
@root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
34
|
+
shm = Webgen::SourceHandler::Main.new # for using service :create_nodes
|
35
|
+
@time = Time.now
|
36
|
+
@path = path_with_meta_info('/virtuals', {'modified_at' => @time}, @obj.class.name) {StringIO.new(CONTENT)}
|
37
|
+
@nodes = @obj.create_node(@root, @path)
|
38
|
+
@website.blackboard.del_service(:source_paths)
|
39
|
+
@website.blackboard.add_service(:source_paths) {{@path.path => @path}}
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_create_node
|
43
|
+
@nodes.each {|n| assert_equal('/virtuals', n.node_info[:src])}
|
44
|
+
|
45
|
+
path_de = @root.tree['/path.de.html']
|
46
|
+
path_en = @root.tree['/directory/path.en.html']
|
47
|
+
dir = @root.tree['/dir']
|
48
|
+
assert_not_nil(path_de)
|
49
|
+
assert_not_nil(dir)
|
50
|
+
assert_not_nil(path_en)
|
51
|
+
|
52
|
+
assert_equal('new title', path_en['title'])
|
53
|
+
assert_equal(@time, path_en['modified_at'])
|
54
|
+
assert(path_en['no_output'])
|
55
|
+
assert_equal('My Dir', dir['title'])
|
56
|
+
assert_equal('directory/other.html', path_de.route_to(path_en))
|
57
|
+
assert_equal('../path.de.html', dir.route_to(path_de))
|
58
|
+
assert_equal('../directory/other.html', dir.route_to(path_en))
|
59
|
+
|
60
|
+
assert_equal('http://www.example.com', @root.tree['/api.html'].path)
|
61
|
+
assert_equal('http://www.example.com', @root.tree['/path.de.html'].route_to(@root.tree['/api.html']))
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_meta_info_changed
|
65
|
+
# Nothing done, nothing should have changed
|
66
|
+
path_de = @root.tree['/path.de.html']
|
67
|
+
@obj.send(:node_meta_info_changed?, path_de)
|
68
|
+
assert(!path_de.flagged(:dirty_meta_info))
|
69
|
+
|
70
|
+
# Change data, meta info should have changed
|
71
|
+
@path.instance_eval { @io = Webgen::Path::SourceIO.new {StringIO.new("path.de.html:\n title: hallo")} }
|
72
|
+
@obj.send(:node_meta_info_changed?, path_de)
|
73
|
+
assert(path_de.flagged(:dirty_meta_info))
|
74
|
+
|
75
|
+
# Reinit node, meta info of path_de should not change, #create_node should only return one node
|
76
|
+
path_de.flag(:reinit)
|
77
|
+
assert(1, @obj.create_node(@root, @path).length)
|
78
|
+
@obj.send(:node_meta_info_changed?, path_de)
|
79
|
+
assert(!path_de.flagged(:dirty_meta_info))
|
80
|
+
|
81
|
+
# Remove data, meta info should have changed
|
82
|
+
@path.instance_eval { @io = Webgen::Path::SourceIO.new {StringIO.new("patha.de.html:\n title: hallo")} }
|
83
|
+
@obj.send(:node_meta_info_changed?, path_de)
|
84
|
+
assert(path_de.flagged(:dirty_meta_info))
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# -*- encoding: utf-8 -*-
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'helper'
|
7
|
+
require 'stringio'
|
8
|
+
require 'webgen/tag'
|
9
|
+
|
10
|
+
class TestTagBase < Test::Unit::TestCase
|
11
|
+
|
12
|
+
include Test::WebsiteHelper
|
13
|
+
|
14
|
+
class TestTag; include Webgen::Tag::Base; end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
super
|
18
|
+
@website.config.testtagbase.testtag.param1 'param1'
|
19
|
+
@website.config.testtagbase.testtag.param2 nil, :mandatory=> true
|
20
|
+
@website.config.testtagbase.testtag.param3 'param3', :mandatory => 'default'
|
21
|
+
@obj = TestTag.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_tag_config_base
|
25
|
+
assert_equal('testtagbase.testtag', @obj.send(:tag_config_base))
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_tag_params_list
|
29
|
+
params = [1,2,3].collect {|i| 'testtagbase.testtag.param' + i.to_s}
|
30
|
+
assert_equal(params.sort, @obj.send(:tag_params_list).sort)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_create_tag_params
|
34
|
+
output = StringIO.new('')
|
35
|
+
@website.logger = ::Logger.new(output)
|
36
|
+
@website.logger.level = Logger::WARN
|
37
|
+
|
38
|
+
output.string = ''
|
39
|
+
assert_equal({}, @obj.create_tag_params("--\nhal:param1\ntest:[;", Webgen::Tree.new.dummy_root))
|
40
|
+
output.rewind; assert_match(/Could not parse the tag params/, output.read)
|
41
|
+
|
42
|
+
output.string = ''
|
43
|
+
set_params(5)
|
44
|
+
assert_equal('param1', @obj.param('testtagbase.testtag.param1'))
|
45
|
+
output.rewind; assert_match(/Not all mandatory parameters/, output.read)
|
46
|
+
output.rewind; assert_match(/Invalid parameter type/, output.read)
|
47
|
+
|
48
|
+
output.string = ''
|
49
|
+
set_params(nil)
|
50
|
+
assert_equal('param1', @obj.param('testtagbase.testtag.param1'))
|
51
|
+
output.rewind; assert_match(/Not all mandatory parameters/, output.read)
|
52
|
+
|
53
|
+
output.string = ''
|
54
|
+
set_params({})
|
55
|
+
assert_equal('param1', @obj.param('testtagbase.testtag.param1'))
|
56
|
+
output.rewind; assert_match(/Not all mandatory parameters/, output.read)
|
57
|
+
|
58
|
+
output.string = ''
|
59
|
+
set_params('test_value')
|
60
|
+
assert_equal('test_value', @obj.param('testtagbase.testtag.param3'))
|
61
|
+
output.rewind; assert_match(/Not all mandatory parameters/, output.read)
|
62
|
+
|
63
|
+
output.string = ''
|
64
|
+
set_params({'param2' => 'test2', 'testtagbase.testtag.param3' => 'test3', 'invalid' => 5})
|
65
|
+
assert_equal('test2', @obj.param('testtagbase.testtag.param2'))
|
66
|
+
assert_equal('test3', @obj.param('testtagbase.testtag.param3'))
|
67
|
+
output.rewind; assert_no_match(/Not all mandatory parameters/, output.read)
|
68
|
+
output.rewind; assert_match(/Invalid parameter 'invalid'/, output.read)
|
69
|
+
|
70
|
+
@website.config.data.delete('testtagbase.testtag.param3')
|
71
|
+
@website.config.meta_info.delete('testtagbase.testtag.param3')
|
72
|
+
output.string = ''
|
73
|
+
set_params('default_value')
|
74
|
+
output.rewind; assert_match(/No default mandatory parameter specified for tag/, output.read)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_call
|
78
|
+
assert_raise(NotImplementedError) { @obj.call(nil, nil, nil) }
|
79
|
+
end
|
80
|
+
|
81
|
+
def set_params(params)
|
82
|
+
@obj.set_params(@obj.send(:create_params_hash, params, Webgen::Tree.new.dummy_root))
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|