webgen 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +870 -0
- data/Rakefile +37 -36
- data/VERSION +1 -1
- data/data/webgen/resources.yaml +2 -2
- data/data/webgen/webgui/app.rb +11 -0
- data/data/webgen/webgui/controller/main.rb +30 -26
- data/data/webgen/webgui/{view/page.xhtml → layout/default.xhtml} +8 -8
- data/data/webgen/webgui/start.rb +9 -0
- data/data/webgen/webgui/view/create_website.xhtml +6 -14
- data/data/webgen/webgui/view/manage_website.xhtml +2 -2
- data/data/webgen/website_bundles/default/README +6 -0
- data/data/webgen/website_bundles/default/src/index.page +15 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/src/images/background.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/bg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/front.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg2.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/bg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/front.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/print.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/bodybg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/contbg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/footerbg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient1.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient2.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/blinkarrow.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/bodybg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/contentbg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/entrybg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash2.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globe.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globebottom.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/linkarrow.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/menuhover.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/bodybg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/front.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.css +6 -4
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.template +2 -2
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/bodybg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/boxbg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/greypx.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/header.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/innerbg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/leaves.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/tabs.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/browserfix.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/bodybg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/sidebarbg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas08/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-black.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-green.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-orange.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-purple.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-red.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/footerbg.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-black.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-green.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-orange.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-purple.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-red.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/simple/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.template +0 -0
- data/data/webgen/website_skeleton/README +1 -1
- data/data/webgen/website_skeleton/config.yaml +5 -4
- data/doc/contentprocessor/blocks.page +43 -10
- data/doc/contentprocessor/builder.page +1 -1
- data/doc/contentprocessor/erb.page +12 -11
- data/doc/contentprocessor/redcloth.page +3 -1
- data/doc/extensions.page +3 -3
- data/doc/faq.page +13 -10
- data/doc/getting_started.page +12 -15
- data/doc/index.page +7 -1
- data/doc/manual.page +78 -27
- data/doc/reference_configuration.page +166 -3
- data/doc/reference_website_styles.page +28 -0
- data/doc/source/filesystem.page +39 -0
- data/doc/source/tararchive.page +40 -0
- data/doc/tag/tikz.page +2 -1
- data/doc/webgen_page_format.page +13 -12
- data/doc/website_styles.metainfo +8 -0
- data/lib/webgen/blackboard.rb +2 -2
- data/lib/webgen/cache.rb +4 -4
- data/lib/webgen/cli.rb +29 -16
- data/lib/webgen/cli/apply_command.rb +66 -0
- data/lib/webgen/cli/create_command.rb +22 -16
- data/lib/webgen/cli/utils.rb +23 -0
- data/lib/webgen/cli/webgui_command.rb +31 -16
- data/lib/webgen/configuration.rb +8 -6
- data/lib/webgen/contentprocessor.rb +4 -5
- data/lib/webgen/contentprocessor/blocks.rb +2 -0
- data/lib/webgen/contentprocessor/builder.rb +6 -3
- data/lib/webgen/contentprocessor/erb.rb +6 -3
- data/lib/webgen/contentprocessor/erubis.rb +7 -6
- data/lib/webgen/contentprocessor/haml.rb +6 -3
- data/lib/webgen/contentprocessor/rdoc.rb +0 -1
- data/lib/webgen/contentprocessor/redcloth.rb +3 -1
- data/lib/webgen/context.rb +73 -0
- data/lib/webgen/context/nodes.rb +36 -0
- data/lib/webgen/coreext.rb +3 -2
- data/lib/webgen/default_config.rb +3 -1
- data/lib/webgen/deprecated.rb +53 -0
- data/lib/webgen/node.rb +24 -19
- data/lib/webgen/output.rb +50 -7
- data/lib/webgen/page.rb +45 -36
- data/lib/webgen/path.rb +1 -1
- data/lib/webgen/source.rb +32 -4
- data/lib/webgen/source/resource.rb +3 -3
- data/lib/webgen/source/stacked.rb +1 -1
- data/lib/webgen/source/tararchive.rb +73 -0
- data/lib/webgen/sourcehandler.rb +4 -4
- data/lib/webgen/sourcehandler/base.rb +36 -24
- data/lib/webgen/sourcehandler/copy.rb +1 -1
- data/lib/webgen/sourcehandler/feed.rb +2 -2
- data/lib/webgen/sourcehandler/fragment.rb +1 -1
- data/lib/webgen/sourcehandler/metainfo.rb +15 -6
- data/lib/webgen/sourcehandler/page.rb +9 -5
- data/lib/webgen/sourcehandler/virtual.rb +44 -7
- data/lib/webgen/tag/base.rb +19 -13
- data/lib/webgen/tag/link.rb +1 -0
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/webgentask.rb +15 -13
- data/lib/webgen/website.rb +42 -11
- data/lib/webgen/websiteaccess.rb +1 -1
- data/lib/webgen/websitemanager.rb +61 -66
- data/man/man1/webgen.1 +4 -0
- data/misc/default.css +13 -0
- data/misc/default.template +1 -1
- data/misc/htmldoc.metainfo +2 -1
- data/misc/style.page +33 -0
- data/test/test_cli.rb +1 -7
- data/test/test_common_sitemap.rb +2 -2
- data/test/test_contentprocessor_blocks.rb +14 -1
- data/test/test_contentprocessor_builder.rb +3 -1
- data/test/test_contentprocessor_erb.rb +3 -2
- data/test/test_contentprocessor_erubis.rb +3 -3
- data/test/test_contentprocessor_fragments.rb +3 -3
- data/test/test_contentprocessor_haml.rb +3 -2
- data/test/test_contentprocessor_maruku.rb +3 -3
- data/test/test_contentprocessor_rdiscount.rb +1 -1
- data/test/test_contentprocessor_rdoc.rb +1 -1
- data/test/test_contentprocessor_redcloth.rb +9 -2
- data/test/test_contentprocessor_sass.rb +1 -1
- data/test/test_contentprocessor_tags.rb +1 -1
- data/test/{test_contentprocessor_context.rb → test_context.rb} +9 -7
- data/test/test_node.rb +27 -21
- data/test/test_page.rb +4 -4
- data/test/test_source_tararchive.rb +65 -0
- data/test/test_sourcehandler_fragment.rb +1 -1
- data/test/test_sourcehandler_memory.rb +6 -6
- data/test/test_sourcehandler_metainfo.rb +34 -13
- data/test/test_sourcehandler_page.rb +8 -0
- data/test/test_sourcehandler_virtual.rb +51 -12
- data/test/test_tag_breadcrumbtrail.rb +4 -4
- data/test/test_tag_coderay.rb +1 -1
- data/test/test_tag_date.rb +1 -1
- data/test/test_tag_executecommand.rb +1 -1
- data/test/test_tag_includefile.rb +3 -3
- data/test/test_tag_langbar.rb +6 -6
- data/test/test_tag_link.rb +8 -2
- data/test/test_tag_menu.rb +9 -9
- data/test/test_tag_metainfo.rb +1 -1
- data/test/test_tag_relocatable.rb +1 -1
- data/test/test_tag_sitemap.rb +1 -1
- data/test/test_tag_tikz.rb +2 -2
- data/test/test_website.rb +17 -0
- data/test/test_websitemanager.rb +16 -21
- metadata +146 -187
- data/data/webgen/website_templates/default/README +0 -6
- data/data/webgen/website_templates/default/src/index.page +0 -8
- data/data/webgen/website_templates/project/README +0 -5
- data/data/webgen/website_templates/project/src/about.page +0 -12
- data/data/webgen/website_templates/project/src/download.page +0 -15
- data/data/webgen/website_templates/project/src/features.page +0 -8
- data/data/webgen/website_templates/project/src/index.page +0 -9
- data/data/webgen/website_templates/project/src/screenshots.page +0 -18
- data/lib/webgen/contentprocessor/context.rb +0 -89
@@ -10,7 +10,9 @@ class TestContentProcessorBuilder < Test::Unit::TestCase
|
|
10
10
|
obj = Webgen::ContentProcessor::Builder.new
|
11
11
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
12
|
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
-
|
13
|
+
content = "xml.div(:path => context.node.absolute_lcn) { xml.strong('test'); " +
|
14
|
+
"context.website; context; context.ref_node; context.dest_node }"
|
15
|
+
context = Webgen::Context.new(:content => content,
|
14
16
|
:chain => [node])
|
15
17
|
assert_equal("<div path=\"/test\">\n <strong>test</strong>\n</div>\n", obj.call(context).content)
|
16
18
|
|
@@ -10,10 +10,11 @@ class TestContentProcessorErb < Test::Unit::TestCase
|
|
10
10
|
obj = Webgen::ContentProcessor::Erb.new
|
11
11
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
12
|
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
-
|
13
|
+
content = "<%= context[:doit] %>6\n<%= context.ref_node.absolute_lcn %>\n<%= context.node.absolute_lcn %>\n<%= context.dest_node.absolute_lcn %><% website %>"
|
14
|
+
context = Webgen::Context.new(:content => content, :doit => 'hallo',
|
14
15
|
:chain => [node])
|
15
16
|
obj.call(context)
|
16
|
-
assert_equal(
|
17
|
+
assert_equal("hallo6\n/test\n/test\n/test", context.content)
|
17
18
|
|
18
19
|
context.content = '<%= 5* %>'
|
19
20
|
assert_raise(RuntimeError) { obj.call(context) }
|
@@ -15,10 +15,10 @@ class TestContentProcessorErubis < Test::Unit::TestCase
|
|
15
15
|
obj = Webgen::ContentProcessor::Erubis.new
|
16
16
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
17
17
|
node = Webgen::Node.new(root, 'test', 'test')
|
18
|
-
context = Webgen::
|
18
|
+
context = Webgen::Context.new(:doit => 'hallo', :chain => [node])
|
19
19
|
|
20
|
-
context.content =
|
21
|
-
assert_equal(
|
20
|
+
context.content = "<%= context[:doit] %>6\n<%= context.ref_node.absolute_lcn %>\n<%= context.node.absolute_lcn %>\n<%= context.dest_node.absolute_lcn %><% context.website %>"
|
21
|
+
assert_equal("hallo6\n/test\n/test\n/test", obj.call(context).content)
|
22
22
|
|
23
23
|
context.content = '<%= 5* %>'
|
24
24
|
assert_raise(RuntimeError) { obj.call(context) }
|
@@ -20,20 +20,20 @@ class TestContentProcessorFragments < Test::Unit::TestCase
|
|
20
20
|
root.node_info[:src] = '/'
|
21
21
|
processors = { 'fragments' => obj }
|
22
22
|
|
23
|
-
context = Webgen::
|
23
|
+
context = Webgen::Context.new(:chain => [root], :processors => processors)
|
24
24
|
context.content = '<h1 id="test">Test</h1><h1>Test2</h1>'
|
25
25
|
obj.call(context)
|
26
26
|
assert(root.tree['/#test'])
|
27
27
|
assert_equal(3, root.tree.node_access[:alcn].length)
|
28
28
|
root.tree.delete_node('/#test')
|
29
29
|
|
30
|
-
context[:block] = Webgen::Block.new('content', '', {})
|
30
|
+
context[:block] = Webgen::Page::Block.new('content', '', {})
|
31
31
|
obj.call(context)
|
32
32
|
assert(root.tree['/#test'])
|
33
33
|
assert_equal(3, root.tree.node_access[:alcn].length)
|
34
34
|
root.tree.delete_node('/#test')
|
35
35
|
|
36
|
-
context[:block] = Webgen::Block.new('other', '', {})
|
36
|
+
context[:block] = Webgen::Page::Block.new('other', '', {})
|
37
37
|
obj.call(context)
|
38
38
|
assert(!root.tree['/#test'])
|
39
39
|
assert_equal(2, root.tree.node_access[:alcn].length)
|
@@ -10,10 +10,11 @@ class TestContentProcessorHaml < Test::Unit::TestCase
|
|
10
10
|
obj = Webgen::ContentProcessor::Haml.new
|
11
11
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
12
|
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
-
|
13
|
+
content = "#content\n %h1 Hallo\n = [context.node.absolute_lcn, context.ref_node.absolute_lcn, context.dest_node.absolute_lcn, context.website, context.dest_node.absolute_lcn].join"
|
14
|
+
context = Webgen::Context.new(:content => content,
|
14
15
|
:chain => [node])
|
15
16
|
obj.call(context)
|
16
|
-
assert_equal("<div id='content'>\n <h1>Hallo</h1>\n /test\n</div>\n", context.content)
|
17
|
+
assert_equal("<div id='content'>\n <h1>Hallo</h1>\n /test/test/test/test\n</div>\n", context.content)
|
17
18
|
|
18
19
|
context.content = "#cont\n = unknown"
|
19
20
|
assert_raise(RuntimeError) { obj.call(context) }
|
@@ -10,7 +10,7 @@ class TestContentProcessorMaruku < Test::Unit::TestCase
|
|
10
10
|
def test_call
|
11
11
|
@obj = Webgen::ContentProcessor::Maruku.new
|
12
12
|
node = Webgen::Node.new(Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/'), 'test', 'test')
|
13
|
-
context = Webgen::
|
13
|
+
context = Webgen::Context.new(:content => '# header', :chain => [node])
|
14
14
|
assert_equal('<h1 id=\'header\'>header</h1>', @obj.call(context).content)
|
15
15
|
|
16
16
|
context.content = "# head*d* {#das .dsaf "
|
@@ -19,10 +19,10 @@ class TestContentProcessorMaruku < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
def test_call_fix_for_invalid_id
|
21
21
|
@obj = Webgen::ContentProcessor::Maruku.new
|
22
|
-
context = Webgen::
|
22
|
+
context = Webgen::Context.new(:content => '# `test`')
|
23
23
|
assert_equal('<h1 id=\'id1\'><code>test</code></h1>', @obj.call(context).content)
|
24
24
|
|
25
|
-
context = Webgen::
|
25
|
+
context = Webgen::Context.new(:content => '# `test`')
|
26
26
|
assert_equal('<h1 id=\'id1\'><code>test</code></h1>', @obj.call(context).content)
|
27
27
|
end
|
28
28
|
|
@@ -10,7 +10,7 @@ class TestContentProcessorRDiscount < Test::Unit::TestCase
|
|
10
10
|
def test_call
|
11
11
|
@obj = Webgen::ContentProcessor::RDiscount.new
|
12
12
|
node = Webgen::Node.new(Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/'), 'test', 'test')
|
13
|
-
context = Webgen::
|
13
|
+
context = Webgen::Context.new(:content => '# header', :chain => [node])
|
14
14
|
assert_equal("<h1>header</h1>\n", @obj.call(context).content)
|
15
15
|
end
|
16
16
|
|
@@ -10,7 +10,7 @@ class TestContentProcessorRDoc < Test::Unit::TestCase
|
|
10
10
|
obj = Webgen::ContentProcessor::RDoc.new
|
11
11
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
12
|
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
-
context = Webgen::
|
13
|
+
context = Webgen::Context.new(:content => "* hello",
|
14
14
|
:chain => [node])
|
15
15
|
assert_equal("<ul>\n<li>hello\n\n</li>\n</ul>\n", obj.call(context).content)
|
16
16
|
end
|
@@ -1,15 +1,22 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
|
+
require 'helper'
|
4
5
|
require 'webgen/websiteaccess'
|
5
6
|
require 'webgen/contentprocessor'
|
6
7
|
|
7
8
|
class TestContentProcessorRedCloth < Test::Unit::TestCase
|
8
9
|
|
10
|
+
include Test::WebsiteHelper
|
11
|
+
|
9
12
|
def test_call
|
10
13
|
@obj = Webgen::ContentProcessor::RedCloth.new
|
11
|
-
context = Webgen::
|
12
|
-
assert_equal(
|
14
|
+
context = Webgen::Context.new(:content => "h1. header\n\nthis\nis\nsome\ntext")
|
15
|
+
assert_equal("<h1>header</h1>\n<p>this\nis\nsome\ntext</p>", @obj.call(context).content)
|
16
|
+
|
17
|
+
context.content = "h1. header\n\nthis\nis\nsome\ntext"
|
18
|
+
@website.config['contentprocessor.redcloth.hard_breaks'] = true
|
19
|
+
assert_equal("<h1>header</h1>\n<p>this<br />\nis<br />\nsome<br />\ntext</p>", @obj.call(context).content)
|
13
20
|
end
|
14
21
|
|
15
22
|
end
|
@@ -10,7 +10,7 @@ class TestContentProcessorSass < Test::Unit::TestCase
|
|
10
10
|
obj = Webgen::ContentProcessor::Sass.new
|
11
11
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
12
|
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
-
context = Webgen::
|
13
|
+
context = Webgen::Context.new(:content => "#main\n :background-color #000",
|
14
14
|
:chain => [node])
|
15
15
|
obj.call(context)
|
16
16
|
assert_equal("#main {\n background-color: #000; }\n", context.content)
|
@@ -35,7 +35,7 @@ class TestContentProcessorTags < Test::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_call
|
38
|
-
context = Webgen::
|
38
|
+
context = Webgen::Context.new(:chain => [Webgen::Tree.new.dummy_root])
|
39
39
|
context.content = "{test: }"
|
40
40
|
assert_equal('', @obj.call(context).content)
|
41
41
|
|
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'helper'
|
5
|
-
require 'webgen/
|
5
|
+
require 'webgen/context'
|
6
6
|
|
7
|
-
class
|
7
|
+
class TestContext < Test::Unit::TestCase
|
8
8
|
|
9
9
|
def setup
|
10
|
-
@context = Webgen::
|
10
|
+
@context = Webgen::Context.new(:content => 'test', :key => :value, :chain => [:first, :last])
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_initialize
|
14
|
-
context = Webgen::
|
14
|
+
context = Webgen::Context.new
|
15
15
|
assert_equal('', context.content)
|
16
16
|
assert_kind_of(Webgen::ContentProcessor::AccessHash, context[:processors])
|
17
17
|
end
|
@@ -27,11 +27,13 @@ class TestContentProcessorContext < Test::Unit::TestCase
|
|
27
27
|
assert_equal(:value, @context[:key])
|
28
28
|
assert_equal([:first, :last], @context[:chain])
|
29
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
30
|
@context[:key] = :newvalue
|
34
31
|
assert_equal(:newvalue, @context[:key])
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_node_methods
|
35
|
+
assert_equal(:first, @context.ref_node)
|
36
|
+
assert_equal(:last, @context.content_node)
|
35
37
|
assert_equal(:last, @context.dest_node)
|
36
38
|
@context[:dest_node] = :other
|
37
39
|
assert_equal(:other, @context.dest_node)
|
data/test/test_node.rb
CHANGED
@@ -42,8 +42,8 @@ class TestNode < Test::Unit::TestCase
|
|
42
42
|
assert_equal(alcn, node.absolute_lcn)
|
43
43
|
assert_equal(lang, node.lang)
|
44
44
|
assert_kind_of(Webgen::Language, node.lang) if node.lang
|
45
|
-
assert(node.flagged(:dirty))
|
46
|
-
assert(node.flagged(:created))
|
45
|
+
assert(node.flagged?(:dirty))
|
46
|
+
assert(node.flagged?(:created))
|
47
47
|
assert_equal(mi, node.meta_info)
|
48
48
|
assert_equal({:used_nodes => Set.new, :used_meta_info_nodes => Set.new}, node.node_info)
|
49
49
|
mi.each {|k,v| assert_equal(v, node[k])}
|
@@ -86,18 +86,18 @@ class TestNode < Test::Unit::TestCase
|
|
86
86
|
|
87
87
|
def test_flags
|
88
88
|
node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
89
|
-
assert(node.flagged(:created))
|
90
|
-
assert(node.flagged(:dirty))
|
89
|
+
assert(node.flagged?(:created))
|
90
|
+
assert(node.flagged?(:dirty))
|
91
91
|
node.unflag(:dirty)
|
92
|
-
assert(!node.flagged(:dirty))
|
92
|
+
assert(!node.flagged?(:dirty))
|
93
93
|
node.flag(:a, :b, :c)
|
94
|
-
assert(node.flagged(:a))
|
95
|
-
assert(node.flagged(:b))
|
96
|
-
assert(node.flagged(:c))
|
94
|
+
assert(node.flagged?(:a))
|
95
|
+
assert(node.flagged?(:b))
|
96
|
+
assert(node.flagged?(:c))
|
97
97
|
node.unflag(:a, :b, :c)
|
98
|
-
assert(!node.flagged(:a))
|
99
|
-
assert(!node.flagged(:b))
|
100
|
-
assert(!node.flagged(:c))
|
98
|
+
assert(!node.flagged?(:a))
|
99
|
+
assert(!node.flagged?(:b))
|
100
|
+
assert(!node.flagged?(:c))
|
101
101
|
end
|
102
102
|
|
103
103
|
def test_in_lang
|
@@ -166,22 +166,34 @@ class TestNode < Test::Unit::TestCase
|
|
166
166
|
|
167
167
|
def test_changed
|
168
168
|
node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
169
|
-
node.unflag(:dirty, :created)
|
169
|
+
node.unflag(:dirty, :dirty_meta_info, :created)
|
170
170
|
|
171
171
|
calls = 0
|
172
172
|
@website.blackboard.add_listener(:node_changed?) {|n| assert(node, n); node.flag(:dirty); calls += 1}
|
173
|
-
node.changed?
|
173
|
+
assert(node.changed?)
|
174
174
|
assert_equal(1, calls)
|
175
|
-
node.changed?
|
175
|
+
assert(node.changed?)
|
176
176
|
assert_equal(1, calls)
|
177
177
|
|
178
|
+
# Test :used_nodes array checking
|
178
179
|
node.unflag(:dirty)
|
179
180
|
node.node_info[:used_nodes] << node.absolute_lcn
|
180
181
|
node.node_info[:used_nodes] << 'unknown alcn'
|
181
182
|
node.node_info[:used_nodes] << @tree.dummy_root.absolute_lcn
|
182
|
-
node.changed?
|
183
|
+
assert(node.changed?)
|
183
184
|
assert_equal(1, calls)
|
184
185
|
|
186
|
+
# Test :used_nodes array checking
|
187
|
+
node.unflag(:dirty)
|
188
|
+
node.node_info[:used_nodes] = Set.new
|
189
|
+
node.node_info[:used_meta_info_nodes] << node.absolute_lcn
|
190
|
+
assert(node.changed?)
|
191
|
+
assert_equal(2, calls)
|
192
|
+
node.unflag(:dirty)
|
193
|
+
node.node_info[:used_meta_info_nodes] << 'unknown alcn'
|
194
|
+
assert(node.changed?)
|
195
|
+
assert_equal(2, calls)
|
196
|
+
|
185
197
|
# Test circular depdendence
|
186
198
|
other_node = Webgen::Node.new(@tree.dummy_root, '/other', 'test.l', {'lang' => 'de', :test => :value})
|
187
199
|
other_node.flag(:dirty, :created)
|
@@ -201,12 +213,6 @@ class TestNode < Test::Unit::TestCase
|
|
201
213
|
assert_equal(1, calls)
|
202
214
|
assert(node.meta_info_changed?)
|
203
215
|
assert_equal(1, calls)
|
204
|
-
|
205
|
-
node.unflag(:dirty_meta_info)
|
206
|
-
node.node_info[:used_meta_info_nodes] << node.absolute_lcn
|
207
|
-
node.node_info[:used_meta_info_nodes] << 'unknown alcn'
|
208
|
-
assert(node.meta_info_changed?)
|
209
|
-
assert_equal(1, calls)
|
210
216
|
end
|
211
217
|
|
212
218
|
def test_method_missing
|
data/test/test_page.rb
CHANGED
@@ -6,7 +6,7 @@ require 'webgen/page'
|
|
6
6
|
class TestBlock < Test::Unit::TestCase
|
7
7
|
|
8
8
|
def test_render
|
9
|
-
block = Webgen::Block.new('content', 'some content', {'pipeline' => 'test'})
|
9
|
+
block = Webgen::Page::Block.new('content', 'some content', {'pipeline' => 'test'})
|
10
10
|
context = {:processors => {}}
|
11
11
|
assert_raise(RuntimeError) { block.render(context) }
|
12
12
|
context[:processors]['test'] = lambda {|context| context[:content] = context[:content].reverse + context[:block].name }
|
@@ -161,12 +161,12 @@ EOF
|
|
161
161
|
def test_invalid_pagefiles
|
162
162
|
testdata = YAML::load(INVALID_MI)
|
163
163
|
testdata.each_with_index do |data, index|
|
164
|
-
assert_raise(Webgen::
|
165
|
-
assert_raise(Webgen::
|
164
|
+
assert_raise(Webgen::Page::FormatError, "test mi item #{index}") { Webgen::Page.from_data(data) }
|
165
|
+
assert_raise(Webgen::Page::FormatError, "test mi item #{index}") { Webgen::Page.meta_info_from_data(data) }
|
166
166
|
end
|
167
167
|
testdata = YAML::load(INVALID_BLOCKS)
|
168
168
|
testdata.each_with_index do |data, index|
|
169
|
-
assert_raise(Webgen::
|
169
|
+
assert_raise(Webgen::Page::FormatError, "test blocks item #{index}") { Webgen::Page.from_data(data) }
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/source'
|
6
|
+
|
7
|
+
class TestSourceTarArchive < Test::Unit::TestCase
|
8
|
+
|
9
|
+
class FakeStream
|
10
|
+
|
11
|
+
def open
|
12
|
+
require 'stringio'
|
13
|
+
sio = StringIO.new
|
14
|
+
stream = Archive::Tar::Minitar::Writer.new(sio)
|
15
|
+
stream.mkdir('/test', :mtime => (Time.now - 5).to_i, :mode => 0100755)
|
16
|
+
stream.add_file('/test/hallo.page', :mtime => (Time.now - 4).to_i, :mode => 0100644) do |os, opts|
|
17
|
+
os.write('This is the contents!')
|
18
|
+
end
|
19
|
+
stream.add_file('/other.page', :mtime => (Time.now - 4).to_i, :mode => 0100644) do |os, opts|
|
20
|
+
os.write('This is other content!')
|
21
|
+
end
|
22
|
+
sio.rewind
|
23
|
+
sio
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
include Test::WebsiteHelper
|
29
|
+
|
30
|
+
def setup
|
31
|
+
super
|
32
|
+
@website = Webgen::Website.new(File.join(File.dirname(__FILE__), '..'), nil)
|
33
|
+
@website.init
|
34
|
+
Thread.current[:webgen_website] = @website
|
35
|
+
@stream = FakeStream.new
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_initialize
|
39
|
+
source = Webgen::Source::TarArchive.new(@stream)
|
40
|
+
assert_equal(@stream, source.uri)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_paths
|
44
|
+
source = Webgen::Source::TarArchive.new(@stream)
|
45
|
+
assert_equal(3, source.paths.length)
|
46
|
+
assert(source.paths.include?(Webgen::Path.new('/test/')))
|
47
|
+
assert(source.paths.include?(Webgen::Path.new('/test/hallo.page')))
|
48
|
+
assert_equal('This is the contents!', source.paths.find {|p| p.path == '/test/hallo.page'}.io.data)
|
49
|
+
|
50
|
+
source = Webgen::Source::TarArchive.new(@stream, '/test/*')
|
51
|
+
assert_equal(1, source.paths.length)
|
52
|
+
assert(source.paths.include?(Webgen::Path.new('/test/hallo.page')))
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_path_changed?
|
56
|
+
stream = @stream
|
57
|
+
source = Webgen::Source::TarArchive.new(stream)
|
58
|
+
source.paths.each do |path|
|
59
|
+
assert(!path.changed?)
|
60
|
+
@website.cache.instance_eval { @old_data[[:tararchive_path, stream, path.path]] = Time.now - 60 }
|
61
|
+
assert(path.changed?)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -19,17 +19,17 @@ class TestSourceHandlerMemory < Test::Unit::TestCase
|
|
19
19
|
node = obj.create_node(root, path_with_meta_info('/test.png'), '/', 'data')
|
20
20
|
assert_equal('/', node.node_info[:memory_source_alcn])
|
21
21
|
assert_equal('data', obj.content(node))
|
22
|
-
assert(!node.flagged(:reinit))
|
22
|
+
assert(!node.flagged?(:reinit))
|
23
23
|
root.tree.delete_node(node)
|
24
24
|
|
25
25
|
node = obj.create_node(root, path_with_meta_info('/test.png'), '/') {|n| assert_equal(node, n); 'data'}
|
26
26
|
assert_equal('/', node.node_info[:memory_source_alcn])
|
27
27
|
assert_equal('data', obj.content(node))
|
28
|
-
assert(!node.flagged(:reinit))
|
28
|
+
assert(!node.flagged?(:reinit))
|
29
29
|
|
30
|
-
assert(!root.flagged(:dirty))
|
30
|
+
assert(!root.flagged?(:dirty))
|
31
31
|
node.flag(:reinit)
|
32
|
-
assert(root.flagged(:dirty))
|
32
|
+
assert(root.flagged?(:dirty))
|
33
33
|
root.unflag(:dirty)
|
34
34
|
root.tree.delete_node(node)
|
35
35
|
|
@@ -37,8 +37,8 @@ class TestSourceHandlerMemory < Test::Unit::TestCase
|
|
37
37
|
assert_equal('/', node.node_info[:memory_source_alcn])
|
38
38
|
obj.instance_eval { @data = nil }
|
39
39
|
assert_nil(obj.content(node))
|
40
|
-
assert(node.flagged(:reinit))
|
41
|
-
assert(root.flagged(:dirty))
|
40
|
+
assert(node.flagged?(:reinit))
|
41
|
+
assert(root.flagged?(:dirty))
|
42
42
|
end
|
43
43
|
|
44
44
|
end
|
@@ -12,29 +12,40 @@ class TestSourceHandlerMetainfo < Test::Unit::TestCase
|
|
12
12
|
class TestSH; include Webgen::SourceHandler::Base; end
|
13
13
|
|
14
14
|
CONTENT=<<EOF
|
15
|
-
|
15
|
+
/default.*:
|
16
16
|
title: new title
|
17
17
|
before: valbef
|
18
18
|
---
|
19
|
-
|
19
|
+
/default.css:
|
20
20
|
after: valaft
|
21
|
+
|
22
|
+
/other.page:
|
23
|
+
title: Not Other
|
21
24
|
EOF
|
22
25
|
|
23
26
|
def setup
|
24
27
|
super
|
25
28
|
@website.blackboard.add_service(:source_paths) do
|
26
|
-
{'/default.css' => path_with_meta_info('/default.css') {StringIO.new('# header')}
|
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
|
+
}
|
27
32
|
end
|
28
33
|
|
29
34
|
@obj = Webgen::SourceHandler::Metainfo.new
|
30
|
-
@root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '
|
35
|
+
@root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
31
36
|
@node = @obj.create_node(@root, path_with_meta_info('/metainfo', {}, @obj.class.name) {StringIO.new(CONTENT)})
|
32
37
|
end
|
33
38
|
|
34
39
|
def test_create_node
|
35
|
-
|
36
|
-
assert_equal({'
|
37
|
-
|
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])
|
38
49
|
end
|
39
50
|
|
40
51
|
def test_meta_info_changed
|
@@ -49,15 +60,15 @@ EOF
|
|
49
60
|
|
50
61
|
other.unflag(:dirty_meta_info)
|
51
62
|
@obj.send(:mark_all_matched_dirty, @node)
|
52
|
-
assert(!other.flagged(:dirty_meta_info))
|
63
|
+
assert(!other.flagged?(:dirty_meta_info))
|
53
64
|
|
54
65
|
other.unflag(:dirty_meta_info)
|
55
66
|
@obj.send(:mark_all_matched_dirty, @node, :force)
|
56
|
-
assert(other.flagged(:dirty_meta_info))
|
67
|
+
assert(other.flagged?(:dirty_meta_info))
|
57
68
|
|
58
69
|
other.unflag(:dirty_meta_info)
|
59
70
|
@obj.send(:mark_all_matched_dirty, @node, :no_old_data)
|
60
|
-
assert(!other.flagged(:dirty_meta_info))
|
71
|
+
assert(!other.flagged?(:dirty_meta_info))
|
61
72
|
end
|
62
73
|
|
63
74
|
def test_before_node_created
|
@@ -75,23 +86,33 @@ EOF
|
|
75
86
|
def test_before_node_deleted
|
76
87
|
other = TestSH.new.create_node(@root, path_with_meta_info('/default.css'))
|
77
88
|
@website.blackboard.dispatch_msg(:before_node_deleted, @node)
|
78
|
-
assert(other.flagged(:dirty_meta_info))
|
89
|
+
assert(other.flagged?(:dirty_meta_info))
|
79
90
|
assert(@obj.nodes.empty?)
|
80
91
|
end
|
81
92
|
|
82
93
|
def test_node_meta_info_changed
|
83
94
|
@node.unflag(:dirty_meta_info)
|
84
95
|
@website.blackboard.dispatch_msg(:node_meta_info_changed?, @node)
|
85
|
-
assert(!@node.flagged(:dirty_meta_info))
|
96
|
+
assert(!@node.flagged?(:dirty_meta_info))
|
86
97
|
|
87
98
|
@node.node_info[:mi_alcn] = @node.node_info[:mi_alcn].dup
|
88
99
|
@node.node_info[:mi_alcn]['/*metainfo'] = {'other' => 'doit'}
|
89
100
|
@website.blackboard.dispatch_msg(:node_meta_info_changed?, @node)
|
90
|
-
assert(@node.flagged(:dirty_meta_info))
|
101
|
+
assert(@node.flagged?(:dirty_meta_info))
|
91
102
|
end
|
92
103
|
|
93
104
|
def test_content
|
94
105
|
assert_nil(@obj.content(nil))
|
95
106
|
end
|
96
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
|
+
|
97
118
|
end
|