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,40 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
|
7
|
+
class TestContentProcessorContext < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@context = Webgen::ContentProcessor::Context.new(:content => 'test', :key => :value, :chain => [:first, :last])
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_initialize
|
14
|
+
context = Webgen::ContentProcessor::Context.new
|
15
|
+
assert_equal('', context.content)
|
16
|
+
assert_kind_of(Webgen::ContentProcessor::AccessHash, context[:processors])
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_clone
|
20
|
+
other = @context.clone(:content => 'new', :key => :other)
|
21
|
+
assert_equal('new', other.content)
|
22
|
+
assert_equal(:other, other[:key])
|
23
|
+
assert_equal([:first, :last], other[:chain])
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_accessors
|
27
|
+
assert_equal(:value, @context[:key])
|
28
|
+
assert_equal([:first, :last], @context[:chain])
|
29
|
+
assert_equal('test', @context.content)
|
30
|
+
assert_equal(:first, @context.ref_node)
|
31
|
+
assert_equal(:last, @context.content_node)
|
32
|
+
assert_equal(:value, @context[:key])
|
33
|
+
@context[:key] = :newvalue
|
34
|
+
assert_equal(:newvalue, @context[:key])
|
35
|
+
assert_equal(:last, @context.dest_node)
|
36
|
+
@context[:dest_node] = :other
|
37
|
+
assert_equal(:other, @context.dest_node)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/tree'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
|
7
|
+
class TestContentProcessorErb < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_call
|
10
|
+
obj = Webgen::ContentProcessor::Erb.new
|
11
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
|
+
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
+
content = "<%= context[:doit] %>6\n<%= ref_node.absolute_lcn %>\n<%= node.absolute_lcn %>\n<%= dest_node.absolute_lcn %><% website %>"
|
14
|
+
context = Webgen::ContentProcessor::Context.new(:content => content, :doit => 'hallo',
|
15
|
+
:chain => [node])
|
16
|
+
obj.call(context)
|
17
|
+
assert_equal("hallo6\n/test\n/test\n/test", context.content)
|
18
|
+
|
19
|
+
context.content = '<%= 5* %>'
|
20
|
+
assert_raise(RuntimeError) { obj.call(context) }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'ostruct'
|
4
|
+
require 'helper'
|
5
|
+
require 'test/unit'
|
6
|
+
require 'webgen/tree'
|
7
|
+
require 'webgen/page'
|
8
|
+
require 'webgen/contentprocessor'
|
9
|
+
|
10
|
+
class TestContentProcessorErubis < Test::Unit::TestCase
|
11
|
+
|
12
|
+
include Test::WebsiteHelper
|
13
|
+
|
14
|
+
def test_call
|
15
|
+
obj = Webgen::ContentProcessor::Erubis.new
|
16
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
17
|
+
node = Webgen::Node.new(root, 'test', 'test')
|
18
|
+
context = Webgen::ContentProcessor::Context.new(:doit => 'hallo', :chain => [node])
|
19
|
+
|
20
|
+
context.content = "<%= context[:doit] %>6\n<%= ref_node.absolute_lcn %>\n<%= node.absolute_lcn %>\n<%= dest_node.absolute_lcn %><% website %>"
|
21
|
+
assert_equal("hallo6\n/test\n/test\n/test", obj.call(context).content)
|
22
|
+
|
23
|
+
context.content = '<%= 5* %>'
|
24
|
+
assert_raise(RuntimeError) { obj.call(context) }
|
25
|
+
|
26
|
+
context.content = "<% for i in [1] %>\n<%= i %>\n<% end %>"
|
27
|
+
assert_equal("1\n", obj.call(context).content)
|
28
|
+
@website.config['contentprocessor.erubis.options'][:trim] = false
|
29
|
+
context.content = "<% for i in [1] %>\n<%== i %>\n<% end %>"
|
30
|
+
assert_equal("\n1\n", obj.call(context).content)
|
31
|
+
|
32
|
+
context[:block] = OpenStruct.new
|
33
|
+
context[:block].options = {'erubis_trim' => true}
|
34
|
+
context.content = "<% for i in [1] %>\n<%== i %>\n<% end %>"
|
35
|
+
assert_equal("1\n", obj.call(context).content)
|
36
|
+
context[:block].options['erubis_use_pi'] = true
|
37
|
+
context.content = "<?rb for i in [1] ?>\n@{i}@\n<?rb end ?>"
|
38
|
+
assert_equal("1\n", obj.call(context).content)
|
39
|
+
context[:block] = nil
|
40
|
+
|
41
|
+
@website.config['contentprocessor.erubis.use_pi'] = true
|
42
|
+
context.content = "<?rb for i in [1] ?>\n@{i}@\n<?rb end ?>"
|
43
|
+
assert_equal("1\n", obj.call(context).content)
|
44
|
+
|
45
|
+
page = Webgen::Page.from_data("--- pipeline:erubis erubis_trim:false erubis_use_pi:false\n<% for i in [1] %>\n<%== i %>\n<% end %>")
|
46
|
+
assert_equal("\n1\n", page.blocks['content'].render(context).content)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'test/helper'
|
5
|
+
require 'webgen/page'
|
6
|
+
require 'webgen/tree'
|
7
|
+
require 'webgen/contentprocessor'
|
8
|
+
|
9
|
+
class TestContentProcessorFragments < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include Test::WebsiteHelper
|
12
|
+
|
13
|
+
def test_process
|
14
|
+
Webgen::SourceHandler::Main.new
|
15
|
+
@website.blackboard.del_service(:source_paths)
|
16
|
+
@website.blackboard.add_service(:source_paths) { Hash.new(path_with_meta_info('/')) }
|
17
|
+
|
18
|
+
obj = Webgen::ContentProcessor::Fragments.new
|
19
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
20
|
+
root.node_info[:src] = '/'
|
21
|
+
processors = { 'fragments' => obj }
|
22
|
+
|
23
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [root], :processors => processors)
|
24
|
+
context.content = '<h1 id="test">Test</h1><h1>Test2</h1>'
|
25
|
+
obj.call(context)
|
26
|
+
assert(root.tree['/#test'])
|
27
|
+
assert_equal(3, root.tree.node_access[:alcn].length)
|
28
|
+
root.tree.delete_node('/#test')
|
29
|
+
|
30
|
+
context[:block] = Webgen::Block.new('content', '', {})
|
31
|
+
obj.call(context)
|
32
|
+
assert(root.tree['/#test'])
|
33
|
+
assert_equal(3, root.tree.node_access[:alcn].length)
|
34
|
+
root.tree.delete_node('/#test')
|
35
|
+
|
36
|
+
context[:block] = Webgen::Block.new('other', '', {})
|
37
|
+
obj.call(context)
|
38
|
+
assert(!root.tree['/#test'])
|
39
|
+
assert_equal(2, root.tree.node_access[:alcn].length)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/tree'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
|
7
|
+
class TestContentProcessorHaml < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_call
|
10
|
+
obj = Webgen::ContentProcessor::Haml.new
|
11
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
|
+
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
+
content = "#content\n %h1 Hallo\n = [node.absolute_lcn, ref_node.absolute_lcn, dest_node.absolute_lcn, website, context.dest_node.absolute_lcn].join"
|
14
|
+
context = Webgen::ContentProcessor::Context.new(:content => content,
|
15
|
+
:chain => [node])
|
16
|
+
obj.call(context)
|
17
|
+
assert_equal("<div id='content'>\n <h1>Hallo</h1>\n /test/test/test/test\n</div>\n", context.content)
|
18
|
+
|
19
|
+
context.content = "#cont\n = unknown"
|
20
|
+
assert_raise(RuntimeError) { obj.call(context) }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/node'
|
5
|
+
require 'webgen/tree'
|
6
|
+
require 'webgen/contentprocessor'
|
7
|
+
|
8
|
+
class TestContentProcessorMaruku < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_call
|
11
|
+
@obj = Webgen::ContentProcessor::Maruku.new
|
12
|
+
node = Webgen::Node.new(Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/'), 'test', 'test')
|
13
|
+
context = Webgen::ContentProcessor::Context.new(:content => '# header', :chain => [node])
|
14
|
+
assert_equal('<h1 id=\'header\'>header</h1>', @obj.call(context).content)
|
15
|
+
|
16
|
+
context.content = "# head*d* {#das .dsaf "
|
17
|
+
assert_raise(RuntimeError) { @obj.call(context)}
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_call_fix_for_invalid_id
|
21
|
+
@obj = Webgen::ContentProcessor::Maruku.new
|
22
|
+
context = Webgen::ContentProcessor::Context.new(:content => '# `test`')
|
23
|
+
assert_equal('<h1 id=\'id1\'><code>test</code></h1>', @obj.call(context).content)
|
24
|
+
|
25
|
+
context = Webgen::ContentProcessor::Context.new(:content => '# `test`')
|
26
|
+
assert_equal('<h1 id=\'id1\'><code>test</code></h1>', @obj.call(context).content)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/node'
|
5
|
+
require 'webgen/tree'
|
6
|
+
require 'webgen/contentprocessor'
|
7
|
+
|
8
|
+
class TestContentProcessorRDiscount < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_call
|
11
|
+
@obj = Webgen::ContentProcessor::RDiscount.new
|
12
|
+
node = Webgen::Node.new(Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/'), 'test', 'test')
|
13
|
+
context = Webgen::ContentProcessor::Context.new(:content => '# header', :chain => [node])
|
14
|
+
assert_equal("<h1>header</h1>\n", @obj.call(context).content)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/tree'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
|
7
|
+
class TestContentProcessorRDoc < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_call
|
10
|
+
obj = Webgen::ContentProcessor::RDoc.new
|
11
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
|
+
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
+
context = Webgen::ContentProcessor::Context.new(:content => "* hello",
|
14
|
+
:chain => [node])
|
15
|
+
assert_equal("<ul>\n<li>hello\n\n</li>\n</ul>\n", obj.call(context).content)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/websiteaccess'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
|
7
|
+
class TestContentProcessorRedCloth < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_call
|
10
|
+
@obj = Webgen::ContentProcessor::RedCloth.new
|
11
|
+
context = Webgen::ContentProcessor::Context.new(:content => 'h1. header')
|
12
|
+
assert_equal('<h1>header</h1>', @obj.call(context).content)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/tree'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
|
7
|
+
class TestContentProcessorSass < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_call
|
10
|
+
obj = Webgen::ContentProcessor::Sass.new
|
11
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
|
+
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
+
context = Webgen::ContentProcessor::Context.new(:content => "#main\n :background-color #000",
|
14
|
+
:chain => [node])
|
15
|
+
obj.call(context)
|
16
|
+
assert_equal("#main {\n background-color: #000; }\n", context.content)
|
17
|
+
|
18
|
+
context.content = "#cont \n = unknown"
|
19
|
+
assert_raise(RuntimeError) { obj.call(context) }
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/tree'
|
6
|
+
require 'webgen/contentprocessor'
|
7
|
+
|
8
|
+
class TestContentProcessorTags < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Test::WebsiteHelper
|
11
|
+
|
12
|
+
class TestTag
|
13
|
+
|
14
|
+
def set_params(*args); end
|
15
|
+
|
16
|
+
def create_tag_params(*args); end
|
17
|
+
|
18
|
+
def call(tag, body, context)
|
19
|
+
case tag
|
20
|
+
when 'body'
|
21
|
+
body
|
22
|
+
when 'bodyproc'
|
23
|
+
[body, true]
|
24
|
+
else
|
25
|
+
tag
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def setup
|
32
|
+
super
|
33
|
+
@obj = Webgen::ContentProcessor::Tags.new
|
34
|
+
@website.config['contentprocessor.tags.map'].delete(:default)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_call
|
38
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [Webgen::Tree.new.dummy_root])
|
39
|
+
context.content = "{test: }"
|
40
|
+
assert_equal('', @obj.call(context).content)
|
41
|
+
|
42
|
+
add_test_tag
|
43
|
+
assert_equal('test', @obj.call(context.clone(:content => "{test: }")).content)
|
44
|
+
assert_equal('thebody', @obj.call(context.clone(:content => "{body::}thebody{body}")).content)
|
45
|
+
assert_equal('test {other:}other test',
|
46
|
+
@obj.call(context.clone(:content => "test{bodyproc::} \\{other:}{other:} {bodyproc}test")).content)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_replace_tags
|
50
|
+
check_returned_tags('sdfsdf{asd', [])
|
51
|
+
check_returned_tags('sdfsdf}asd', [])
|
52
|
+
check_returned_tags('sdfsdf{asd}', [])
|
53
|
+
check_returned_tags('sdfsdf{asd: {}as', [])
|
54
|
+
check_returned_tags('sdfsdf{test: {test1: }}', [['test', ' {test1: }', '']], 'sdfsdftest1')
|
55
|
+
check_returned_tags('sdfsdf{test: {test1: {}}', [['test', '', '']], 'sdfsdf{test: {test1: {}}')
|
56
|
+
check_returned_tags('sdfsdf{test:}{test1: }', [['test', '', ''], ['test1', ' ', '']], 'sdfsdftest1test2')
|
57
|
+
check_returned_tags('sdfsdf{test:}\\{test1: }', [['test', '', '']], "sdfsdftest1{test1: }")
|
58
|
+
check_returned_tags('sdfsdf\\{test:}{test1:}', [['test1', '', '']], "sdfsdf{test:}test1")
|
59
|
+
check_returned_tags('sdfsdf{test: asdf}', [['test', ' asdf', '']], "sdfsdftest1")
|
60
|
+
check_returned_tags('sdfsdf\\{test: asdf}', [], "sdfsdf{test: asdf}")
|
61
|
+
check_returned_tags('sdfsdf\\\\{test: asdf}', [['test', ' asdf', '']], "sdfsdf\\test1")
|
62
|
+
check_returned_tags('sdfsdf\\\\\\{test: asdf}sdf', [['test', ' asdf', '']], "sdfsdf\\{test: asdf}sdf")
|
63
|
+
|
64
|
+
check_returned_tags('before{test::}body{test}', [['test', '', 'body']], "beforetest1")
|
65
|
+
check_returned_tags('before{test::}body{testno}', [], "before{test::}body{testno}")
|
66
|
+
check_returned_tags('before{test::}body\\{test}other{test}', [['test', '', 'body{test}other']], "beforetest1")
|
67
|
+
check_returned_tags('before{test::}body\\{test}{test}', [['test', '', 'body{test}']], "beforetest1")
|
68
|
+
check_returned_tags('before{test::}body\\{test}\\\\{test}after', [['test', '', 'body{test}\\']], "beforetest1after")
|
69
|
+
check_returned_tags('before\\{test::}body{test}', [['test', '', 'body']], "before{test::}body{test}")
|
70
|
+
check_returned_tags('before\\\\{test:: asdf}body{test}after', [['test', ' asdf', 'body']], "before\\test1after")
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_processor_for_tag
|
74
|
+
assert_nil(@obj.instance_eval { processor_for_tag('test') })
|
75
|
+
assert_nil(@obj.instance_eval { processor_for_tag(:default) })
|
76
|
+
add_test_tag
|
77
|
+
assert_not_nil(@obj.instance_eval { processor_for_tag(:default) })
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def add_test_tag
|
83
|
+
@website.config['contentprocessor.tags.map'].update(:default => 'TestContentProcessorTags::TestTag')
|
84
|
+
end
|
85
|
+
|
86
|
+
def check_returned_tags(content, data, result = content)
|
87
|
+
i = 0
|
88
|
+
check_proc = proc do |tag, params, body|
|
89
|
+
assert_equal(data[i][0], tag, 'tag: ' + content)
|
90
|
+
assert_equal(data[i][1], params, 'params: ' + content)
|
91
|
+
assert_equal(data[i][2], body, 'body: ' + content)
|
92
|
+
i += 1
|
93
|
+
'test' + i.to_s
|
94
|
+
end
|
95
|
+
assert_equal(result, @obj.instance_eval { replace_tags(content, Webgen::Tree.new.dummy_root, &check_proc) })
|
96
|
+
assert(i, data.length)
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/languages'
|
5
|
+
|
6
|
+
class TestLanguages < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_get_language
|
9
|
+
assert_nil(Webgen::LanguageManager.language_for_code(nil))
|
10
|
+
|
11
|
+
lang1 = Webgen::LanguageManager.language_for_code('ger')
|
12
|
+
lang2 = Webgen::LanguageManager.language_for_code('deu')
|
13
|
+
lang3 = Webgen::LanguageManager.language_for_code('de')
|
14
|
+
lang4 = Webgen::LanguageManager.language_for_code('en')
|
15
|
+
|
16
|
+
[lang1, lang2, lang3, lang4].each {|lang| assert_kind_of(Webgen::Language, lang)}
|
17
|
+
assert_equal(lang1, lang2)
|
18
|
+
assert_equal(lang3, lang2)
|
19
|
+
assert_not_equal(lang4, lang2)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_find_language
|
23
|
+
langs = Webgen::LanguageManager.find_language('greek')
|
24
|
+
assert_equal(2, langs.length)
|
25
|
+
assert_equal('gre', langs[0].code3chars)
|
26
|
+
assert_equal('grc', langs[1].code3chars)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_language_accessors
|
30
|
+
lang = Webgen::LanguageManager.language_for_code('ger')
|
31
|
+
assert_equal('ger', lang.code3chars)
|
32
|
+
assert_equal('deu', lang.code3chars_alternative)
|
33
|
+
assert_equal('de', lang.code2chars)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_other_methods
|
37
|
+
de = Webgen::LanguageManager.language_for_code('ger')
|
38
|
+
assert_equal('de', de)
|
39
|
+
assert_equal(de, 'de')
|
40
|
+
assert_equal("de", de.to_s)
|
41
|
+
assert_equal("Implicitly de", "Implicitly " + de)
|
42
|
+
assert_kind_of(String, de.inspect)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_sort_method
|
46
|
+
ger = Webgen::LanguageManager.language_for_code('ger')
|
47
|
+
eng = Webgen::LanguageManager.language_for_code('en')
|
48
|
+
ace = Webgen::LanguageManager.language_for_code('ace')
|
49
|
+
|
50
|
+
assert_equal(-1, ger <=> eng)
|
51
|
+
assert_equal(-1, ace <=> ger)
|
52
|
+
assert_equal(-1, ace <=> eng)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_hashing
|
56
|
+
de = Webgen::LanguageManager.language_for_code('ger')
|
57
|
+
en = Webgen::LanguageManager.language_for_code('en')
|
58
|
+
h = {'de' => de, en => en}
|
59
|
+
assert_equal(de, h[de])
|
60
|
+
assert_equal(de, h['de'])
|
61
|
+
assert_equal(en, h[en])
|
62
|
+
assert_not_equal(en, h['en']) # bc 'en'.eql?(en) is false
|
63
|
+
assert_equal(Webgen::LanguageManager.language_for_code('en'),
|
64
|
+
Webgen::LanguageManager.language_for_code(en))
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|