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,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/tree'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
require 'webgen/tag'
|
7
|
+
|
8
|
+
class TestTagMetainfo < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_call
|
11
|
+
@obj = Webgen::Tag::Metainfo.new
|
12
|
+
node = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'hallo.page', 'hallo.page', 'test' => 10, 'lang' => 'en')
|
13
|
+
c = Webgen::ContentProcessor::Context.new(:chain => [node])
|
14
|
+
assert_equal('', @obj.call('invalid', '', c))
|
15
|
+
assert_equal('10', @obj.call('test', '', c))
|
16
|
+
assert_equal('en', @obj.call('lang', '', c))
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/tree'
|
6
|
+
require 'webgen/contentprocessor'
|
7
|
+
require 'webgen/tag'
|
8
|
+
|
9
|
+
class TestTagRelocatable < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include Test::WebsiteHelper
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
@obj = Webgen::Tag::Relocatable.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(context)
|
19
|
+
@obj.call('relocatable', '', context)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_call
|
23
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
24
|
+
node = Webgen::Node.new(root, '/file.html', 'file.html', {'lang' => 'en'})
|
25
|
+
dir = Webgen::Node.new(root, '/dir/', 'dir/', 'index_path' => "index.html")
|
26
|
+
file = Webgen::Node.new(dir, '/dir/file.html', 'file.html', {'lang' => 'en'})
|
27
|
+
Webgen::Node.new(dir, '/dir/other.de.html', 'other.html', {'lang' => 'de'})
|
28
|
+
Webgen::Node.new(file, '/dir/file.html#fragment', '#fragment')
|
29
|
+
dir2 = Webgen::Node.new(root, '/dir2/', 'dir2/', 'index_path' => "index.html")
|
30
|
+
Webgen::Node.new(dir2, '/dir2/index.html', 'index.html')
|
31
|
+
|
32
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [node])
|
33
|
+
|
34
|
+
# basic node resolving
|
35
|
+
@obj.set_params('tag.relocatable.path' => 'dir/file.html')
|
36
|
+
assert_equal('dir/file.html', call(context))
|
37
|
+
@obj.set_params('tag.relocatable.path' => 'dir/other.html')
|
38
|
+
assert_equal('', call(context))
|
39
|
+
|
40
|
+
# non-existing fragments
|
41
|
+
@obj.set_params('tag.relocatable.path' => 'file.html#hallo')
|
42
|
+
assert_equal('', call(context))
|
43
|
+
|
44
|
+
# absolute paths
|
45
|
+
@obj.set_params('tag.relocatable.path' => 'http://test.com')
|
46
|
+
assert_equal('http://test.com', call(context))
|
47
|
+
|
48
|
+
# directory paths
|
49
|
+
@obj.set_params('tag.relocatable.path' => 'dir')
|
50
|
+
assert_equal('dir/', call(context))
|
51
|
+
@obj.set_params('tag.relocatable.path' => 'dir2')
|
52
|
+
assert_equal('dir2/index.html', call(context))
|
53
|
+
|
54
|
+
# invalid paths
|
55
|
+
@obj.set_params('tag.relocatable.path' => ':/asdf=-)')
|
56
|
+
assert_equal('', call(context))
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/tree'
|
6
|
+
require 'webgen/contentprocessor'
|
7
|
+
require 'webgen/tag'
|
8
|
+
|
9
|
+
class TestTagSitemap < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include Test::WebsiteHelper
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
@obj = Webgen::Tag::Sitemap.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(context, honor_in_menu, any_lang, used_kinds)
|
19
|
+
@obj.set_params({'common.sitemap.honor_in_menu' => honor_in_menu,
|
20
|
+
'common.sitemap.any_lang' => any_lang,
|
21
|
+
'common.sitemap.used_kinds' => used_kinds})
|
22
|
+
result = @obj.call('sitemap', '', context)
|
23
|
+
@obj.set_params({})
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_call
|
28
|
+
nodes = create_sitemap_nodes
|
29
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [nodes[:file11_en]])
|
30
|
+
|
31
|
+
assert_equal("<ul><li><a href=\"./\"></a>" +
|
32
|
+
"<ul><li><span></span>"+
|
33
|
+
"<ul><li><a href=\"#f1\"></a></li></ul></li></ul></li>" +
|
34
|
+
"<li><a href=\"../dir2/\"></a>" +
|
35
|
+
"<ul><li><a href=\"../dir2/file21.en.html\"></a></li></ul></li>"+
|
36
|
+
"<li><a href=\"../index.en.html\"></a></li>" +
|
37
|
+
"<li><a href=\"../dir3/index.en.html\"></a></li></ul>",
|
38
|
+
call(context, false, false, []))
|
39
|
+
assert_equal("",
|
40
|
+
call(context, false, false, ['noone']))
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_tag_config_base
|
44
|
+
assert_equal('common.sitemap', @obj.send(:tag_config_base))
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/tag'
|
6
|
+
|
7
|
+
class TestTagTikZ < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Test::WebsiteHelper
|
10
|
+
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
@obj = Webgen::Tag::TikZ.new
|
14
|
+
Webgen::SourceHandler::Main.new # service create_nodes
|
15
|
+
Webgen::SourceHandler::Directory.new # service create_directories
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(context, body, path, libs, opts, res, trans, imgattr)
|
19
|
+
@obj.set_params({'tag.tikz.path' => path, 'tag.tikz.libraries' => libs,
|
20
|
+
'tag.tikz.opts' => opts, 'tag.tikz.resolution' => res,
|
21
|
+
'tag.tikz.transparent' => trans, 'tag.tikz.img_attr' => imgattr})
|
22
|
+
result = @obj.call('tikz', body, context)
|
23
|
+
@obj.set_params({})
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_call
|
28
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
29
|
+
node = Webgen::Node.new(root, '/file.html', 'file.page')
|
30
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [node])
|
31
|
+
|
32
|
+
output = call(context, '\tikz \draw (0,0) -- (0,1);', 'test.png', [], '', '72 72', false, {})
|
33
|
+
assert_equal('<img src="test.png" />', output)
|
34
|
+
assert(root.tree['/test.png'])
|
35
|
+
assert_not_nil(root.tree['/test.png'].content)
|
36
|
+
root.tree.delete_node('/test.png')
|
37
|
+
|
38
|
+
output = call(context, '\tikz \asdfasdfasf', 'test.png', [], '', '72 72', false, {})
|
39
|
+
assert_equal('<img src="test.png" />', output)
|
40
|
+
assert(root.tree['/test.png'])
|
41
|
+
assert_nil(root.tree['/test.png'].content)
|
42
|
+
root.tree.delete_node('/test.png')
|
43
|
+
|
44
|
+
output = call(context, '\tikz \draw (0,0) -- (0,1);', '/images/test.gif', ['arrows'], '->', '72 72', true, {'alt' => 'title'})
|
45
|
+
assert_equal('<img src="images/test.gif" alt="title" />', output)
|
46
|
+
assert(root.tree['/images/test.gif'])
|
47
|
+
assert_not_nil(root.tree['/images/test.gif'].content)
|
48
|
+
root.tree.delete_node('/images/test.gif')
|
49
|
+
|
50
|
+
output = call(context, '\tikz \draw (0,0) -- (0,1);', 'images/../img/test.png', [], '', '300 72', true, {})
|
51
|
+
assert_equal('<img src="img/test.png" />', output)
|
52
|
+
assert(root.tree['/img/test.png'])
|
53
|
+
assert_not_nil(root.tree['/img/test.png'].content)
|
54
|
+
root.tree.delete_node('/img/test.png')
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_run_command
|
58
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
59
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [root])
|
60
|
+
assert_equal("hallo\n", @obj.send(:run_command, echo_cmd('hallo'), context))
|
61
|
+
assert_nil(@obj.send(:run_command, 'unknown_command 2>&1', context))
|
62
|
+
end
|
63
|
+
|
64
|
+
def echo_cmd(data)
|
65
|
+
(Config::CONFIG['arch'].include?('mswin32') ? "echo #{data}" : "echo '#{data}'")
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
end
|
data/test/test_tree.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/tree'
|
6
|
+
|
7
|
+
class TestTree < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Test::WebsiteHelper
|
10
|
+
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
@tree = Webgen::Tree.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_initialize
|
17
|
+
assert_not_nil(@tree.dummy_root)
|
18
|
+
assert_equal('', @tree.dummy_root.absolute_lcn)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_root
|
22
|
+
root = Webgen::Node.new(@tree.dummy_root, '/', '/')
|
23
|
+
assert_equal(root, @tree.root)
|
24
|
+
assert_equal('/', root.absolute_lcn)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_register_node_and_register_path
|
28
|
+
# Tree#register_node/_path is called when creating a node
|
29
|
+
node = Webgen::Node.new(@tree.dummy_root, 'dummy/', 'dummy')
|
30
|
+
assert_equal(node, @tree['/dummy', :alcn])
|
31
|
+
assert_equal(node, @tree['/dummy', :acn])
|
32
|
+
assert_equal(node, @tree['dummy/', :path])
|
33
|
+
assert_raise(RuntimeError) { Webgen::Node.new(@tree.dummy_root, '/', 'dummy') }
|
34
|
+
assert_raise(RuntimeError) { Webgen::Node.new(@tree.dummy_root, 'dummy/', 'other') }
|
35
|
+
assert_nothing_raised { Webgen::Node.new(@tree.dummy_root, 'dummy/', 'unknown', {'no_output' => true}) }
|
36
|
+
Webgen::Node.new(@tree.dummy_root, 'new', 'new', {'no_output' => true})
|
37
|
+
assert(!@tree['new', :path])
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_delete_node
|
41
|
+
nrcalls = 0
|
42
|
+
@website.blackboard.add_listener(:before_node_deleted) { nrcalls += 1 }
|
43
|
+
|
44
|
+
root = Webgen::Node.new(@tree.dummy_root, '/', '/')
|
45
|
+
file = Webgen::Node.new(root, 'testfile', 'testfile')
|
46
|
+
dir = Webgen::Node.new(root, 'testdir/', 'testdir')
|
47
|
+
|
48
|
+
@tree.delete_node(@tree.dummy_root)
|
49
|
+
assert_not_nil(@tree[''])
|
50
|
+
|
51
|
+
assert_nothing_raised { @tree.delete_node('/unknown_path') }
|
52
|
+
|
53
|
+
@tree.delete_node(file)
|
54
|
+
assert_nil(@tree['/testfile'])
|
55
|
+
assert_nil(@tree['/testfile', :acn])
|
56
|
+
assert_nil(@tree.node_info['/testfile'])
|
57
|
+
assert_equal(1, root.children.size)
|
58
|
+
assert_equal(1, nrcalls)
|
59
|
+
|
60
|
+
@tree.delete_node('/')
|
61
|
+
assert_nil(@tree['/testdir'])
|
62
|
+
assert_nil(@tree['/testdir', :acn])
|
63
|
+
assert_nil(@tree.node_info['/testdir'])
|
64
|
+
assert_nil(@tree['/'])
|
65
|
+
assert_nil(@tree.node_info['/'])
|
66
|
+
assert_equal(3, nrcalls)
|
67
|
+
assert_equal([@tree.dummy_root], @tree.node_access[:alcn].values)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/webgentask'
|
5
|
+
|
6
|
+
class TestWebgenTask < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include Rake
|
9
|
+
|
10
|
+
def test_create
|
11
|
+
site = Webgen::WebgenTask.new('doit') do |s|
|
12
|
+
s.clobber_outdir = true
|
13
|
+
s.config_block = lambda {|c| c}
|
14
|
+
s.directory = 'website'
|
15
|
+
end
|
16
|
+
assert_equal('website', site.directory)
|
17
|
+
assert_equal(true, site.clobber_outdir)
|
18
|
+
assert_equal(5, site.config_block[5])
|
19
|
+
assert(Task['doit'])
|
20
|
+
assert(Task['clobber_doit'])
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/website'
|
5
|
+
require 'tmpdir'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
class TestWebsite < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_initialize
|
11
|
+
ws = Webgen::Website.new('dir') do
|
12
|
+
assert_equal(ws, Webgen::WebsiteAccess.website)
|
13
|
+
throw :called
|
14
|
+
end
|
15
|
+
assert_nil(ws.blackboard)
|
16
|
+
assert_nil(ws.cache)
|
17
|
+
assert_nil(ws.config)
|
18
|
+
assert_nil(ws.tree)
|
19
|
+
assert_equal('dir', ws.directory)
|
20
|
+
assert_throws(:called) { ws.init }
|
21
|
+
assert_nil(Thread.current[:webgen_website])
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_autoload_service
|
25
|
+
ws = Webgen::Website.new('unknown', nil)
|
26
|
+
ws.init
|
27
|
+
ws.instance_eval { @cache = Webgen::Cache.new }
|
28
|
+
ws.autoload_service('[]', 'Hash')
|
29
|
+
assert_equal([], ws.cache.permanent[:classes])
|
30
|
+
ws.blackboard.invoke('[]', 5)
|
31
|
+
assert_equal(['Hash'], ws.cache.permanent[:classes])
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_init
|
35
|
+
ws = Webgen::Website.new('hallo')
|
36
|
+
ws.init
|
37
|
+
assert_not_nil(ws.config)
|
38
|
+
assert_not_nil(ws.blackboard)
|
39
|
+
assert_not_nil(ws.cache)
|
40
|
+
assert_not_nil(ws.tree)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_render_of_non_webgen_website
|
44
|
+
ws = Webgen::Website.new(File.dirname(__FILE__), nil) do |config|
|
45
|
+
config['website.cache'] = [:string, '']
|
46
|
+
end
|
47
|
+
assert_nil(ws.render)
|
48
|
+
assert(ws.config['website.cache'][1].length == 0)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_execute_in_env
|
52
|
+
ws = Webgen::Website.new('hallo')
|
53
|
+
assert_nil(Webgen::WebsiteAccess.website)
|
54
|
+
ws.execute_in_env { assert_not_nil(Webgen::WebsiteAccess.website) }
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_read_config_file
|
58
|
+
dir = File.join(Dir.tmpdir, 'webgen-' + Process.pid.to_s)
|
59
|
+
FileUtils.mkdir_p(dir)
|
60
|
+
|
61
|
+
ws = Webgen::Website.new(dir)
|
62
|
+
ws.init
|
63
|
+
assert_equal('', ws.logger.log_output)
|
64
|
+
FileUtils.touch(File.join(dir, 'config.yml'))
|
65
|
+
ws.init
|
66
|
+
assert_match(/spelling error/, ws.logger.log_output)
|
67
|
+
|
68
|
+
File.open(File.join(dir, 'config.yaml'), 'w+') {|f| f.write('- unknown')}
|
69
|
+
assert_raise(Webgen::Website::ConfigFileInvalid) { ws.init }
|
70
|
+
|
71
|
+
File.open(File.join(dir, 'config.yaml'), 'w+') {|f| f.write('webgen.unknown: doit')}
|
72
|
+
assert_raise(Webgen::Website::ConfigFileInvalid) { ws.init }
|
73
|
+
|
74
|
+
File.open(File.join(dir, 'config.yaml'), 'w+') {|f| f.write("website.lang: de\ndefault_meta_info: {:all: {hallo: du}}")}
|
75
|
+
ws.init
|
76
|
+
assert_equal('de', ws.config['website.lang'])
|
77
|
+
assert_equal('du', ws.config['sourcehandler.default_meta_info'][:all]['hallo'])
|
78
|
+
ensure
|
79
|
+
FileUtils.rm_rf(dir)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_clean
|
83
|
+
dir = File.join(Dir.tmpdir, 'webgen-' + Process.pid.to_s)
|
84
|
+
FileUtils.mkdir_p(dir)
|
85
|
+
FileUtils.mkdir_p(File.join(dir, 'src'))
|
86
|
+
FileUtils.touch(File.join(dir, 'src', 'test.jpg'))
|
87
|
+
|
88
|
+
ws = Webgen::Website.new(dir, nil)
|
89
|
+
assert_equal(:success, ws.render)
|
90
|
+
assert(File.exists?(File.join(dir, 'out', 'test.jpg')))
|
91
|
+
ws.clean
|
92
|
+
assert(!File.exists?(File.join(dir, 'out', 'test.jpg')))
|
93
|
+
assert(File.directory?(File.join(dir, 'out')))
|
94
|
+
ws.clean(true)
|
95
|
+
assert(!File.directory?(File.join(dir, 'out')))
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/websiteaccess'
|
5
|
+
|
6
|
+
|
7
|
+
class TestWebsiteaccess < Test::Unit::TestCase
|
8
|
+
|
9
|
+
class WSAccessSubClass
|
10
|
+
include Webgen::WebsiteAccess
|
11
|
+
|
12
|
+
def get_private_website
|
13
|
+
website
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_accessors
|
18
|
+
Thread.current[:webgen_website] = :value
|
19
|
+
assert_equal(:value, Webgen::WebsiteAccess.website)
|
20
|
+
assert_equal(:value, WSAccessSubClass.website)
|
21
|
+
assert_equal(:value, WSAccessSubClass.new.get_private_website)
|
22
|
+
Thread.current[:webgen_website] = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'helper'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'webgen/websitemanager'
|
8
|
+
|
9
|
+
class TestWebsiteManager < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def test_initialize
|
12
|
+
wm = Webgen::WebsiteManager.new('.')
|
13
|
+
t = wm.templates['default']
|
14
|
+
assert_equal('Thomas Leitner', t.author)
|
15
|
+
assert(t.paths.length > 0)
|
16
|
+
|
17
|
+
s = wm.styles['1024px']
|
18
|
+
assert(s.paths.length > 0)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_create_website
|
22
|
+
with_tmpdir do |dir|
|
23
|
+
wm = Webgen::WebsiteManager.new(dir)
|
24
|
+
wm.create_website
|
25
|
+
assert(File.directory?(File.join(dir, 'ext')))
|
26
|
+
assert(File.directory?(File.join(dir, 'src')))
|
27
|
+
assert(File.file?(File.join(dir, 'README')))
|
28
|
+
assert(File.file?(File.join(dir, 'config.yaml')))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_apply_template
|
33
|
+
with_tmpdir do |dir|
|
34
|
+
wm = Webgen::WebsiteManager.new(dir)
|
35
|
+
assert_raise(RuntimeError) { wm.apply_template('default') }
|
36
|
+
|
37
|
+
Dir.mkdir(dir)
|
38
|
+
wm.apply_template('default')
|
39
|
+
assert(File.directory?(File.join(dir, 'src')))
|
40
|
+
assert(File.file?(File.join(dir, 'src', 'index.page')))
|
41
|
+
|
42
|
+
assert_raise(ArgumentError) { wm.apply_template('unknown-template') }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_apply_style
|
47
|
+
dir = with_tmpdir
|
48
|
+
wm = Webgen::WebsiteManager.new(dir)
|
49
|
+
assert_raise(RuntimeError) { wm.apply_style('simple') }
|
50
|
+
|
51
|
+
wm.styles.each do |name, infos|
|
52
|
+
Dir.mkdir(dir)
|
53
|
+
wm.apply_style(name)
|
54
|
+
assert(File.directory?(File.join(dir, 'src')))
|
55
|
+
assert(File.file?(File.join(dir, 'src', 'default.template')))
|
56
|
+
assert(File.file?(File.join(dir, 'src', 'default.css')))
|
57
|
+
FileUtils.rm_rf(dir)
|
58
|
+
end
|
59
|
+
assert_raise(ArgumentError) { wm.apply_style('unknown-style') }
|
60
|
+
end
|
61
|
+
|
62
|
+
def with_tmpdir
|
63
|
+
dir = File.join(Dir.tmpdir, 'webgen-' + Process.pid.to_s)
|
64
|
+
yield(dir) if block_given?
|
65
|
+
dir
|
66
|
+
ensure
|
67
|
+
FileUtils.rm_rf(dir)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|