webgen 0.5.10 → 0.5.11
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +487 -0
- data/Rakefile +13 -28
- data/VERSION +1 -1
- data/bin/webgen +1 -2
- data/data/webgen/passive_sources/templates/atom_feed.template +1 -0
- data/data/webgen/website_bundles/style/andreas07/src/default.css +2 -2
- data/data/webgen/website_skeleton/config.yaml +22 -5
- data/doc/contentprocessor.template +2 -2
- data/doc/contentprocessor/blocks.page +4 -4
- data/doc/contentprocessor/builder.page +2 -3
- data/doc/contentprocessor/erb.page +1 -1
- data/doc/contentprocessor/erubis.page +5 -5
- data/doc/contentprocessor/fragments.page +5 -4
- data/doc/contentprocessor/haml.page +2 -3
- data/doc/contentprocessor/head.page +16 -6
- data/doc/contentprocessor/kramdown.page +49 -0
- data/doc/contentprocessor/less.page +34 -0
- data/doc/contentprocessor/maruku.page +6 -3
- data/doc/contentprocessor/rdiscount.page +3 -3
- data/doc/contentprocessor/rdoc.page +1 -1
- data/doc/contentprocessor/redcloth.page +1 -1
- data/doc/contentprocessor/sass.page +1 -1
- data/doc/contentprocessor/tags.page +2 -2
- data/doc/contentprocessor/tidy.page +2 -2
- data/doc/extensions.page +1 -2
- data/doc/extensions.template +5 -5
- data/doc/getting_started.page +16 -12
- data/doc/index.page +21 -21
- data/doc/manual.page +109 -61
- data/doc/reference_configuration.page +63 -38
- data/doc/reference_metainfo.page +68 -45
- data/doc/reference_website_styles.page +5 -1
- data/doc/source/filesystem.page +4 -4
- data/doc/source/tararchive.page +4 -4
- data/doc/sourcehandler.template +2 -2
- data/doc/sourcehandler/feed.page +3 -4
- data/doc/sourcehandler/metainfo.page +1 -1
- data/doc/sourcehandler/page.page +3 -3
- data/doc/sourcehandler/sitemap.page +2 -3
- data/doc/sourcehandler/template.page +2 -2
- data/doc/sourcehandler/virtual.page +5 -5
- data/doc/tag.template +1 -1
- data/doc/tag/coderay.page +2 -2
- data/doc/tag/includefile.page +1 -1
- data/doc/tag/langbar.page +4 -1
- data/doc/tag/menu.page +3 -3
- data/doc/tag/relocatable.page +1 -1
- data/doc/upgrading.page +30 -31
- data/doc/webgen_page_format.page +6 -6
- data/lib/webgen/cache.rb +4 -5
- data/lib/webgen/cli/utils.rb +18 -7
- data/lib/webgen/cli/webgui_command.rb +4 -2
- data/lib/webgen/common.rb +10 -0
- data/lib/webgen/configuration.rb +1 -3
- data/lib/webgen/contentprocessor.rb +4 -2
- data/lib/webgen/contentprocessor/blocks.rb +1 -0
- data/lib/webgen/contentprocessor/builder.rb +3 -9
- data/lib/webgen/contentprocessor/erb.rb +3 -9
- data/lib/webgen/contentprocessor/erubis.rb +3 -9
- data/lib/webgen/contentprocessor/haml.rb +10 -11
- data/lib/webgen/contentprocessor/head.rb +64 -0
- data/lib/webgen/contentprocessor/kramdown.rb +26 -0
- data/lib/webgen/contentprocessor/kramdown/html.rb +32 -0
- data/lib/webgen/contentprocessor/less.rb +35 -0
- data/lib/webgen/contentprocessor/maruku.rb +14 -0
- data/lib/webgen/contentprocessor/tags.rb +25 -7
- data/lib/webgen/default_config.rb +9 -3
- data/lib/webgen/node.rb +92 -0
- data/lib/webgen/output.rb +3 -1
- data/lib/webgen/source/resource.rb +2 -1
- data/lib/webgen/source/tararchive.rb +3 -2
- data/lib/webgen/sourcehandler.rb +8 -4
- data/lib/webgen/sourcehandler/base.rb +1 -2
- data/lib/webgen/sourcehandler/feed.rb +1 -1
- data/lib/webgen/sourcehandler/virtual.rb +1 -0
- data/lib/webgen/tag/base.rb +1 -1
- data/lib/webgen/tag/langbar.rb +5 -2
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/website.rb +7 -8
- data/misc/default.template +1 -1
- data/misc/htmldoc.virtual +13 -1
- data/test/test_contentprocessor.rb +1 -1
- data/test/test_contentprocessor_blocks.rb +16 -1
- data/test/test_contentprocessor_erb.rb +1 -1
- data/test/test_contentprocessor_fragments.rb +1 -1
- data/test/test_contentprocessor_haml.rb +2 -2
- data/test/test_contentprocessor_head.rb +54 -8
- data/test/test_contentprocessor_kramdown.rb +50 -0
- data/test/test_contentprocessor_less.rb +40 -0
- data/test/test_contentprocessor_tags.rb +8 -0
- data/test/test_node.rb +102 -41
- data/test/test_source_tararchive.rb +5 -1
- data/test/test_sourcehandler_feed.rb +5 -2
- data/test/test_sourcehandler_virtual.rb +5 -0
- data/test/test_tag_langbar.rb +2 -3
- metadata +22 -16
- data/lib/webgen/deprecated.rb +0 -87
@@ -15,9 +15,11 @@ class TestContentProcessorBlocks < Test::Unit::TestCase
|
|
15
15
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
16
16
|
node = Webgen::Node.new(root, 'test', 'test')
|
17
17
|
node.node_info[:page] = Webgen::Page.from_data("--- name:content\ndata\n--- name:other\nother")
|
18
|
+
dnode = Webgen::Node.new(root, 'dtest', 'dtest')
|
19
|
+
dnode.node_info[:page] = Webgen::Page.from_data("--- name:content pipeline:erb\n<%= context.dest_node.alcn %>")
|
18
20
|
template = Webgen::Node.new(root, 'template', 'template')
|
19
21
|
template.node_info[:page] = Webgen::Page.from_data("--- name:content pipeline:blocks\nbefore<webgen:block name='content' />after")
|
20
|
-
processors = { 'blocks' => obj }
|
22
|
+
processors = { 'blocks' => obj, 'erb' => Webgen::ContentProcessor::Erb.new }
|
21
23
|
|
22
24
|
context = Webgen::Context.new(:chain => [node], :processors => processors)
|
23
25
|
context.content = '<webgen:block name="content" /><webgen:block name="content" chain="template;test" />'
|
@@ -42,6 +44,19 @@ class TestContentProcessorBlocks < Test::Unit::TestCase
|
|
42
44
|
assert_equal('beforedataafter', context.content)
|
43
45
|
assert_equal(Set.new([template.alcn, node.alcn]), node.node_info[:used_nodes])
|
44
46
|
|
47
|
+
# Test correctly set dest_node
|
48
|
+
context[:chain] = [node]
|
49
|
+
context.content = '<webgen:block name="content" chain="dtest" />'
|
50
|
+
obj.call(context)
|
51
|
+
assert_equal('/test', context.content)
|
52
|
+
|
53
|
+
context.content = '<webgen:block name="content" chain="dtest" />'
|
54
|
+
assert_equal('/test', obj.render_block(context, :chain => [dnode], :name => 'content'))
|
55
|
+
|
56
|
+
|
57
|
+
# Test options "node" and "notfound"
|
58
|
+
context[:chain] = [node, template, node]
|
59
|
+
|
45
60
|
context.content = 'bef<webgen:block name="other" chain="template;test" notfound="ignore" />aft'
|
46
61
|
obj.call(context)
|
47
62
|
assert_equal('befaft', context.content)
|
@@ -13,7 +13,7 @@ class TestContentProcessorErb < Test::Unit::TestCase
|
|
13
13
|
obj = Webgen::ContentProcessor::Erb.new
|
14
14
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
15
15
|
node = Webgen::Node.new(root, 'test', 'test')
|
16
|
-
content = "<%= context[:doit] %>6\n<%= context.ref_node.alcn %>\n<%= context.node.alcn %>\n<%= context.dest_node.alcn %><% website %>"
|
16
|
+
content = "<%= context[:doit] %>6\n<%= context.ref_node.alcn %>\n<%= context.node.alcn %>\n<%= context.dest_node.alcn %><% context.website %>"
|
17
17
|
context = Webgen::Context.new(:content => content, :doit => 'hallo',
|
18
18
|
:chain => [node])
|
19
19
|
obj.call(context)
|
@@ -19,11 +19,11 @@ class TestContentProcessorHaml < Test::Unit::TestCase
|
|
19
19
|
obj.call(context)
|
20
20
|
assert_equal("<div id='content'>\n <h1>Hallo</h1>\n /test/test/test/test\n</div>\n", context.content)
|
21
21
|
|
22
|
-
context.content = "#cont\n %unknown"
|
22
|
+
context.content = "#cont\n % = + unknown"
|
23
23
|
assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
|
24
24
|
|
25
25
|
context.content = "#cont\n = unknown"
|
26
|
-
|
26
|
+
assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
|
27
27
|
|
28
28
|
def obj.require(lib); raise LoadError; end
|
29
29
|
assert_raise(Webgen::LoadError) { obj.call(context) }
|
@@ -10,16 +10,23 @@ class TestContentProcessorHead < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
include Test::WebsiteHelper
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
@obj = Webgen::ContentProcessor::Head.new
|
16
|
+
@root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
17
|
+
@node = Webgen::Node.new(@root, 'test.en', 'test', {'lang' => 'en'})
|
18
|
+
end
|
17
19
|
|
18
|
-
|
20
|
+
def test_meta_information
|
21
|
+
context = Webgen::Context.new(:chain => [@node])
|
19
22
|
context.content = '</head>'
|
20
|
-
|
23
|
+
@node['meta'] = {'other' => 'me'}
|
24
|
+
@obj.call(context)
|
21
25
|
assert_equal("\n<meta name=\"other\" content=\"me\" /></head>", context.content)
|
26
|
+
end
|
22
27
|
|
28
|
+
def test_persistent_information
|
29
|
+
context = Webgen::Context.new(:chain => [@node])
|
23
30
|
context.content = '</head>'
|
24
31
|
context.clone.persistent[:cp_head] = {
|
25
32
|
:js_file => ['hallo.js', 'hallo2.js', 'hallo.js'],
|
@@ -28,8 +35,7 @@ class TestContentProcessorHead < Test::Unit::TestCase
|
|
28
35
|
:css_inline => ["somestyle", "anotherstyle"],
|
29
36
|
:meta => {:lucky => 'me<"'}
|
30
37
|
}
|
31
|
-
|
32
|
-
obj.call(context)
|
38
|
+
@obj.call(context)
|
33
39
|
assert_equal("\n<script type=\"text/javascript\" src=\"hallo.js\"></script>" +
|
34
40
|
"\n<script type=\"text/javascript\" src=\"hallo2.js\"></script>" +
|
35
41
|
"\n<script type=\"text/javascript\">\nsomescript\n</script>" +
|
@@ -41,4 +47,44 @@ class TestContentProcessorHead < Test::Unit::TestCase
|
|
41
47
|
"\n<meta name=\"lucky\" content=\"me<"\" /></head>", context.content)
|
42
48
|
end
|
43
49
|
|
50
|
+
def test_links_to_other_lang_nodes
|
51
|
+
context = Webgen::Context.new(:chain => [@node])
|
52
|
+
context.content = '</head>'
|
53
|
+
@obj.call(context)
|
54
|
+
assert_equal("</head>", context.content)
|
55
|
+
|
56
|
+
de_node = Webgen::Node.new(@root, 'test.de', 'test', {'lang' => 'de'})
|
57
|
+
@obj.call(context)
|
58
|
+
assert_equal("\n<link type=\"text/html\" rel=\"alternate\" hreflang=\"de\" href=\"test.de\" /></head>", context.content)
|
59
|
+
|
60
|
+
context.content = '</head>'
|
61
|
+
de_node['title'] = 'Deutscher Titel'
|
62
|
+
@obj.call(context)
|
63
|
+
assert_equal("\n<link type=\"text/html\" rel=\"alternate\" hreflang=\"de\" href=\"test.de\" " +
|
64
|
+
"lang=\"de\" title=\"Deutscher Titel\" /></head>", context.content)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_javascript_and_css_links
|
68
|
+
context = Webgen::Context.new(:chain => [@node])
|
69
|
+
context.content = '</head>'
|
70
|
+
@node['link'] = {'javascript' => 'http://example.org', 'css' => ['http://example.org', 'test', 'unknown']}
|
71
|
+
@obj.call(context)
|
72
|
+
assert_equal("\n<script type=\"text/javascript\" src=\"http://example.org\"></script>" +
|
73
|
+
"\n<link rel=\"stylesheet\" href=\"http://example.org\" type=\"text/css\" />" +
|
74
|
+
"\n<link rel=\"stylesheet\" href=\"test.en\" type=\"text/css\" /></head>", context.content)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_generic_links
|
78
|
+
context = Webgen::Context.new(:chain => [@node])
|
79
|
+
context.content = '</head>'
|
80
|
+
@node['link'] = {'next' => 'test', 'start' => {'type' => 'text/xhtml', 'href' => 'http://example.org'},
|
81
|
+
'alternate' => ['test', {'type' => 'text/html', 'href' => 'test'}, {'href' => 'unknown'}, {'type' => 'text/html'}]
|
82
|
+
}
|
83
|
+
@obj.call(context)
|
84
|
+
assert_equal("\n<link href=\"test.en\" rel=\"alternate\" />" +
|
85
|
+
"\n<link href=\"test.en\" rel=\"alternate\" type=\"text/html\" />" +
|
86
|
+
"\n<link href=\"test.en\" rel=\"next\" type=\"text/html\" />" +
|
87
|
+
"\n<link href=\"http://example.org\" rel=\"start\" type=\"text/xhtml\" /></head>", context.content)
|
88
|
+
end
|
89
|
+
|
44
90
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/node'
|
6
|
+
require 'webgen/tree'
|
7
|
+
require 'webgen/contentprocessor'
|
8
|
+
|
9
|
+
class TestContentProcessorKramdown < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include Test::WebsiteHelper
|
12
|
+
|
13
|
+
def test_call
|
14
|
+
obj = Webgen::ContentProcessor::Kramdown.new
|
15
|
+
node = Webgen::Node.new(Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/'), 'test', 'test')
|
16
|
+
hello = Webgen::Node.new(node.tree.root, 'hello.en.html', 'hello.html')
|
17
|
+
|
18
|
+
# test normal invocation
|
19
|
+
context = Webgen::Context.new(:content => '# header', :chain => [node])
|
20
|
+
assert_equal("<h1 id=\"header\">header</h1>\n", obj.call(context).content)
|
21
|
+
|
22
|
+
# test automatic handling of links
|
23
|
+
@website.config['contentprocessor.kramdown.handle_links'] = true
|
24
|
+
context.content = 'Link [test](hello.html)'
|
25
|
+
assert_equal("<p>Link <a href=\"hello.en.html\">test</a></p>\n", obj.call(context).content)
|
26
|
+
context.content = 'Link ![test](hello.html)'
|
27
|
+
assert_equal("<p>Link <img alt=\"test\" src=\"hello.en.html\" /></p>\n", obj.call(context).content)
|
28
|
+
|
29
|
+
@website.config['contentprocessor.kramdown.handle_links'] = false
|
30
|
+
context.content = 'Link [test](hello.html)'
|
31
|
+
assert_equal("<p>Link <a href=\"hello.html\">test</a></p>\n", obj.call(context).content)
|
32
|
+
context.content = 'Link ![test](hello.html)'
|
33
|
+
assert_equal("<p>Link <img alt=\"test\" src=\"hello.html\" /></p>\n", obj.call(context).content)
|
34
|
+
|
35
|
+
# test warning messages
|
36
|
+
output = StringIO.new('')
|
37
|
+
@website.logger = ::Logger.new(output)
|
38
|
+
@website.logger.level = Logger::WARN
|
39
|
+
|
40
|
+
context.content = '{::unknownextension::}'
|
41
|
+
obj.call(context)
|
42
|
+
assert_equal("", context.content)
|
43
|
+
output.rewind; assert_match(/No extension named 'unknownextension' found/, output.read)
|
44
|
+
|
45
|
+
# test raised error when library not found
|
46
|
+
def obj.require(lib); raise LoadError; end
|
47
|
+
assert_raise(Webgen::LoadError) { obj.call(context) }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'helper'
|
5
|
+
require 'webgen/tree'
|
6
|
+
require 'webgen/contentprocessor'
|
7
|
+
|
8
|
+
class TestContentProcessorLess < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Test::WebgenAssertions
|
11
|
+
|
12
|
+
def test_call
|
13
|
+
obj = Webgen::ContentProcessor::Less.new
|
14
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
15
|
+
node = Webgen::Node.new(root, 'test', 'test')
|
16
|
+
context = Webgen::Context.new(:content => "div {width: 1 + 1}",
|
17
|
+
:chain => [node])
|
18
|
+
obj.call(context)
|
19
|
+
assert_equal("div { width: 2; }\n", context.content)
|
20
|
+
|
21
|
+
context.content = ".class {color: yellow}\ndiv {width: 1 + }"
|
22
|
+
assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
|
23
|
+
|
24
|
+
context.content = "div { width: 2em + 1px; }"
|
25
|
+
assert_raise(Webgen::RenderError) { obj.call(context) }
|
26
|
+
|
27
|
+
context.content = "div {width: @hallo + 1}"
|
28
|
+
assert_raise(Webgen::RenderError) { obj.call(context) }
|
29
|
+
|
30
|
+
context.content = "div {width: 1px; .mixin;}"
|
31
|
+
assert_raise(Webgen::RenderError) { obj.call(context) }
|
32
|
+
|
33
|
+
context.content = "@import \"hallo\";"
|
34
|
+
assert_raise(Webgen::RenderError) { obj.call(context) }
|
35
|
+
|
36
|
+
def obj.require(lib); raise LoadError; end
|
37
|
+
assert_raise(Webgen::LoadError) { obj.call(context) }
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -78,6 +78,14 @@ class TestContentProcessorTags < Test::Unit::TestCase
|
|
78
78
|
check_returned_tags('before{test::}body\\{test}\\\\{test}after', [['test', '', 'body{test}\\']], "beforetest1after")
|
79
79
|
check_returned_tags('before\\{test::}body{test}', [['test', '', 'body']], "before{test::}body{test}")
|
80
80
|
check_returned_tags('before\\\\{test:: asdf}body{test}after', [['test', ' asdf', 'body']], "before\\test1after")
|
81
|
+
|
82
|
+
check_returned_tags('sdfsüdf{test: }', [['test', ' ', '']], "sdfsüdftest1")
|
83
|
+
check_returned_tags('sdfsüüdf{test: asdf}', [['test', ' asdf', '']], "sdfsüüdftest1")
|
84
|
+
check_returned_tags('sdfsüüdf{test: asüdf}a', [['test', ' asüdf', '']], "sdfsüüdftest1a")
|
85
|
+
check_returned_tags('sdfsüüdf\\{test: asdf}ab', [], "sdfsüüdf{test: asdf}ab")
|
86
|
+
check_returned_tags('sdfsüüdf\\\\{test: asdf}ab', [['test', ' asdf', '']], "sdfsüüdf\\test1ab")
|
87
|
+
check_returned_tags('sdfsüüdf\\\\\\{test: asdf}ab', [], "sdfsüüdf\\{test: asdf}ab")
|
88
|
+
check_returned_tags('sdfsüüdf{test:: asdf}abü{test}ab', [['test', ' asdf', 'abü']], "sdfsüüdftest1ab")
|
81
89
|
end
|
82
90
|
|
83
91
|
def test_processor_for_tag
|
data/test/test_node.rb
CHANGED
@@ -17,19 +17,21 @@ class TestNode < Test::Unit::TestCase
|
|
17
17
|
def create_default_nodes
|
18
18
|
{
|
19
19
|
:root => node = Webgen::Node.new(@tree.dummy_root, '/', '/'),
|
20
|
-
:somename_en => child_en = Webgen::Node.new(node, '/somename.en.html', 'somename.
|
21
|
-
:somename_de => child_de = Webgen::Node.new(node, '/somename.de.html', 'somename.
|
22
|
-
:other => Webgen::Node.new(node, '/other.html', 'other.
|
23
|
-
:other_en => Webgen::Node.new(node, '/other1.html', 'other.
|
20
|
+
:somename_en => child_en = Webgen::Node.new(node, '/somename.en.html', 'somename.html', {'lang' => 'en', 'title' => 'somename en'}),
|
21
|
+
:somename_de => child_de = Webgen::Node.new(node, '/somename.de.html', 'somename.html', {'lang' => 'de', 'title' => 'somename de', 'sort_test' => 1}),
|
22
|
+
:other => Webgen::Node.new(node, '/other.html', 'other.html', {'title' => 'other', 'sort_test' => 5}),
|
23
|
+
:other_en => Webgen::Node.new(node, '/other1.html', 'other.html', {'lang' => 'en', 'title' => 'other en', 'sort_test' => 4}),
|
24
24
|
:somename_en_frag => frag_en = Webgen::Node.new(child_en, '/somename.en.html#frag', '#othertest', {'title' => 'frag'}),
|
25
|
-
:somename_de_frag => Webgen::Node.new(child_de, '/somename.de.html#frag', '#othertest'),
|
26
|
-
:somename_en_fragnest => Webgen::Node.new(frag_en, '/somename.en.html#fragnest/', '#nestedpath'),
|
27
|
-
:dir => dir = Webgen::Node.new(node, '/dir/', 'dir/'),
|
28
|
-
:dir_file => dir_file = Webgen::Node.new(dir, '/dir/file.html', 'file.html'),
|
29
|
-
:dir_file_frag => Webgen::Node.new(dir_file, '/dir/file.html#frag', '#frag'),
|
25
|
+
:somename_de_frag => Webgen::Node.new(child_de, '/somename.de.html#frag', '#othertest', {'title' => 'frag'}),
|
26
|
+
:somename_en_fragnest => Webgen::Node.new(frag_en, '/somename.en.html#fragnest/', '#nestedpath', {'title' => 'fragnest'}),
|
27
|
+
:dir => dir = Webgen::Node.new(node, '/dir/', 'dir/', {'title' => 'dir'}),
|
28
|
+
:dir_file => dir_file = Webgen::Node.new(dir, '/dir/file.html', 'file.html', {'title' => 'file'}),
|
29
|
+
:dir_file_frag => Webgen::Node.new(dir_file, '/dir/file.html#frag', '#frag', {'title' => 'frag'}),
|
30
30
|
:dir2 => dir2 = Webgen::Node.new(node, '/dir2/', 'dir2/', {'index_path' => 'index.html', 'title' => 'dir2'}),
|
31
|
-
:dir2_index_en => Webgen::Node.new(dir2, '/dir2/index.html', 'index.html',
|
32
|
-
|
31
|
+
:dir2_index_en => Webgen::Node.new(dir2, '/dir2/index.html', 'index.html',
|
32
|
+
{'lang' => 'en', 'routed_title' => 'routed', 'title' => 'index en', 'sort_info' => 1}),
|
33
|
+
:dir2_index_de => Webgen::Node.new(dir2, '/dir2/index.de.html', 'index.html',
|
34
|
+
{'lang' => 'de', 'routed_title' => 'routed_de', 'title' => 'index de', 'sort_info' => 2}),
|
33
35
|
}
|
34
36
|
end
|
35
37
|
|
@@ -52,9 +54,9 @@ class TestNode < Test::Unit::TestCase
|
|
52
54
|
node = Webgen::Node.new(@tree.dummy_root, '/', '/', {'lang' => 'de', :test => :value})
|
53
55
|
check_proc.call(node, @tree.dummy_root, '/', '/', '/', '/', nil, {:test => :value})
|
54
56
|
|
55
|
-
child = Webgen::Node.new(node, 'somename.html', 'somename.
|
56
|
-
check_proc.call(child, node, 'somename.html', 'somename.
|
57
|
-
'/somename.de.
|
57
|
+
child = Webgen::Node.new(node, 'somename.html', 'somename.html', {'lang' => 'de'})
|
58
|
+
check_proc.call(child, node, 'somename.html', 'somename.html', 'somename.de.html',
|
59
|
+
'/somename.de.html', 'de', {})
|
58
60
|
|
59
61
|
['http://webgen.rubyforge.org', 'c:\\test'].each_with_index do |abspath, index|
|
60
62
|
cn = 'test' + index.to_s + '.html'
|
@@ -63,8 +65,8 @@ class TestNode < Test::Unit::TestCase
|
|
63
65
|
end
|
64
66
|
|
65
67
|
child.reinit('somename.en.html', {'lang' => 'de', 'title' => 'test'})
|
66
|
-
check_proc.call(child, node, 'somename.en.html', 'somename.
|
67
|
-
'/somename.de.
|
68
|
+
check_proc.call(child, node, 'somename.en.html', 'somename.html', 'somename.de.html',
|
69
|
+
'/somename.de.html', 'de', {'title' => 'test'})
|
68
70
|
end
|
69
71
|
|
70
72
|
def test_type_checkers
|
@@ -126,33 +128,33 @@ class TestNode < Test::Unit::TestCase
|
|
126
128
|
nodes = create_default_nodes
|
127
129
|
|
128
130
|
[nodes[:root], nodes[:somename_de], nodes[:somename_en], nodes[:other]].each do |n|
|
129
|
-
assert_equal(nil, n.resolve('somename.
|
130
|
-
assert_equal(nodes[:somename_en], n.resolve('somename.
|
131
|
-
assert_equal(nodes[:somename_de], n.resolve('somename.
|
132
|
-
assert_equal(nil, n.resolve('somename.
|
133
|
-
assert_equal(nodes[:somename_en], n.resolve('somename.en.
|
134
|
-
assert_equal(nodes[:somename_en], n.resolve('somename.en.
|
135
|
-
assert_equal(nodes[:somename_en], n.resolve('somename.en.
|
136
|
-
assert_equal(nil, n.resolve('somename.fr.
|
137
|
-
|
138
|
-
assert_equal(nodes[:other], n.resolve('other.
|
139
|
-
assert_equal(nodes[:other], n.resolve('other.
|
140
|
-
assert_equal(nodes[:other_en], n.resolve('other.
|
141
|
-
assert_equal(nodes[:other_en], n.resolve('other.en.
|
142
|
-
assert_equal(nodes[:other_en], n.resolve('other.en.
|
143
|
-
assert_equal(nil, n.resolve('other.fr.
|
144
|
-
assert_equal(nil, n.resolve('other.fr.
|
131
|
+
assert_equal(nil, n.resolve('somename.html', nil))
|
132
|
+
assert_equal(nodes[:somename_en], n.resolve('somename.html', 'en'))
|
133
|
+
assert_equal(nodes[:somename_de], n.resolve('somename.html', 'de'))
|
134
|
+
assert_equal(nil, n.resolve('somename.html', 'fr'))
|
135
|
+
assert_equal(nodes[:somename_en], n.resolve('somename.en.html', nil))
|
136
|
+
assert_equal(nodes[:somename_en], n.resolve('somename.en.html', 'en'))
|
137
|
+
assert_equal(nodes[:somename_en], n.resolve('somename.en.html', 'de'))
|
138
|
+
assert_equal(nil, n.resolve('somename.fr.html', 'de'))
|
139
|
+
|
140
|
+
assert_equal(nodes[:other], n.resolve('other.html', nil))
|
141
|
+
assert_equal(nodes[:other], n.resolve('other.html', 'fr'))
|
142
|
+
assert_equal(nodes[:other_en], n.resolve('other.html', 'en'))
|
143
|
+
assert_equal(nodes[:other_en], n.resolve('other.en.html', nil))
|
144
|
+
assert_equal(nodes[:other_en], n.resolve('other.en.html', 'de'))
|
145
|
+
assert_equal(nil, n.resolve('other.fr.html', nil))
|
146
|
+
assert_equal(nil, n.resolve('other.fr.html', 'en'))
|
145
147
|
end
|
146
148
|
|
147
149
|
assert_equal(nodes[:somename_en_frag], nodes[:somename_en].resolve('#othertest', 'de'))
|
148
150
|
assert_equal(nodes[:somename_en_frag], nodes[:somename_en].resolve('#othertest', nil))
|
149
151
|
assert_equal(nodes[:somename_en_fragnest], nodes[:somename_en].resolve('#nestedpath', nil))
|
150
152
|
|
151
|
-
assert_equal(nil, nodes[:root].resolve('/somename.
|
152
|
-
assert_equal(nodes[:somename_en_frag], nodes[:root].resolve('/somename.
|
153
|
-
assert_equal(nodes[:somename_de_frag], nodes[:root].resolve('/somename.
|
154
|
-
assert_equal(nodes[:somename_en_frag], nodes[:root].resolve('/somename.en.
|
155
|
-
assert_equal(nodes[:somename_de_frag], nodes[:root].resolve('/somename.de.
|
153
|
+
assert_equal(nil, nodes[:root].resolve('/somename.html#othertest', nil))
|
154
|
+
assert_equal(nodes[:somename_en_frag], nodes[:root].resolve('/somename.html#othertest', 'en'))
|
155
|
+
assert_equal(nodes[:somename_de_frag], nodes[:root].resolve('/somename.html#othertest', 'de'))
|
156
|
+
assert_equal(nodes[:somename_en_frag], nodes[:root].resolve('/somename.en.html#othertest'))
|
157
|
+
assert_equal(nodes[:somename_de_frag], nodes[:root].resolve('/somename.de.html#othertest'))
|
156
158
|
|
157
159
|
assert_equal(nil, nodes[:dir2].resolve('index.html'))
|
158
160
|
assert_equal(nodes[:dir2_index_en], nodes[:dir2].resolve('index.html', 'en'))
|
@@ -223,11 +225,11 @@ class TestNode < Test::Unit::TestCase
|
|
223
225
|
nodes = create_default_nodes
|
224
226
|
|
225
227
|
assert(!nodes[:dir2_index_en].send(:user_nodes_changed?))
|
226
|
-
nodes[:dir2_index_en]['used_nodes'] = '/some*.
|
228
|
+
nodes[:dir2_index_en]['used_nodes'] = '/some*.html'
|
227
229
|
assert(nodes[:dir2_index_en].send(:user_nodes_changed?))
|
228
|
-
nodes[:dir2_index_en]['used_nodes'] = '../some*.
|
230
|
+
nodes[:dir2_index_en]['used_nodes'] = '../some*.html'
|
229
231
|
assert(nodes[:dir2_index_en].send(:user_nodes_changed?))
|
230
|
-
nodes[:dir2_index_en]['used_nodes'] = '/someAA*.
|
232
|
+
nodes[:dir2_index_en]['used_nodes'] = '/someAA*.html'
|
231
233
|
assert(!nodes[:dir2_index_en].send(:user_nodes_changed?))
|
232
234
|
nodes[:dir2_index_en]['used_nodes'] = 'index.de.html'
|
233
235
|
assert(nodes[:dir2_index_en].send(:user_nodes_changed?))
|
@@ -361,7 +363,7 @@ class TestNode < Test::Unit::TestCase
|
|
361
363
|
nodes[:somename_en].link_to(nodes[:somename_en_frag], 'attr1' => 'val1'))
|
362
364
|
assert_equal('<a href="#frag">frag</a>',
|
363
365
|
nodes[:somename_en].link_to(nodes[:somename_en_frag], :attr1 => 'val1'))
|
364
|
-
assert_equal('<a href="dir2/index.html">index</a>',
|
366
|
+
assert_equal('<a href="dir2/index.html">index en</a>',
|
365
367
|
nodes[:somename_en].link_to(nodes[:dir2_index_en]))
|
366
368
|
|
367
369
|
nodes[:somename_en_frag]['link_attrs'] = {:link_text => 'Default Text', 'class'=>'help'}
|
@@ -400,4 +402,63 @@ class TestNode < Test::Unit::TestCase
|
|
400
402
|
assert_equal("http://example.com/test", Webgen::Node.url("http://example.com/test", false).to_s)
|
401
403
|
end
|
402
404
|
|
405
|
+
def test_find
|
406
|
+
nodes = create_default_nodes
|
407
|
+
|
408
|
+
check = lambda do |correct, result|
|
409
|
+
assert_equal(correct.collect {|n| nodes[n].alcn }, result.to_list.flatten)
|
410
|
+
end
|
411
|
+
|
412
|
+
check.call([:somename_en, :somename_en_frag, :somename_en_fragnest, :somename_de, :somename_de_frag,
|
413
|
+
:other, :other_en, :dir, :dir_file, :dir_file_frag, :dir2, :dir2_index_en, :dir2_index_de],
|
414
|
+
nodes[:root].find())
|
415
|
+
|
416
|
+
# :levels
|
417
|
+
check.call([],
|
418
|
+
nodes[:root].find(:levels => 0))
|
419
|
+
check.call([:somename_en, :somename_de, :other, :other_en, :dir, :dir2],
|
420
|
+
nodes[:root].find(:levels => 1))
|
421
|
+
|
422
|
+
# :alcn
|
423
|
+
check.call([:somename_en, :somename_en_frag, :somename_en_fragnest, :somename_de, :somename_de_frag,
|
424
|
+
:other, :other_en, :dir, :dir2],
|
425
|
+
nodes[:root].find(:alcn => '*'))
|
426
|
+
check.call([:somename_en, :somename_de, :other, :other_en, :dir, :dir2],
|
427
|
+
nodes[:root].find(:alcn => '*', :levels => 1))
|
428
|
+
check.call([:somename_en, :other_en],
|
429
|
+
nodes[:root].find(:alcn => '/*.en.html'))
|
430
|
+
|
431
|
+
# :sort
|
432
|
+
check.call([:somename_en, :somename_en_frag, :somename_en_fragnest, :somename_de, :somename_de_frag,
|
433
|
+
:other, :other_en, :dir, :dir_file, :dir_file_frag, :dir2, :dir2_index_en, :dir2_index_de],
|
434
|
+
nodes[:root].find(:sort => false))
|
435
|
+
check.call([:dir, :dir_file, :dir_file_frag, :dir2, :dir2_index_en, :dir2_index_de, :other, :other_en,
|
436
|
+
:somename_de, :somename_de_frag, :somename_en, :somename_en_frag, :somename_en_fragnest],
|
437
|
+
nodes[:root].find(:sort => true))
|
438
|
+
check.call([:somename_en, :somename_en_frag, :somename_en_fragnest, :dir, :dir_file, :dir_file_frag, :dir2, :dir2_index_en, :dir2_index_de,
|
439
|
+
:somename_de, :somename_de_frag, :other_en, :other],
|
440
|
+
nodes[:root].find(:sort => 'sort_test'))
|
441
|
+
|
442
|
+
# :limit
|
443
|
+
check.call([:somename_en, :somename_en_frag, :somename_en_fragnest, :somename_de, :somename_de_frag],
|
444
|
+
nodes[:root].find(:limit => 5))
|
445
|
+
check.call([:somename_en, :somename_en_frag, :somename_en_fragnest, :somename_de, :somename_de_frag,
|
446
|
+
:other, :other_en, :dir, :dir_file, :dir_file_frag, :dir2, :dir2_index_en, :dir2_index_de],
|
447
|
+
nodes[:root].find(:limit => 100))
|
448
|
+
check.call([:somename_en, :somename_en_frag, :somename_en_fragnest, :somename_de, :somename_de_frag,
|
449
|
+
:other, :other_en, :dir, :dir_file, :dir_file_frag, :dir2, :dir2_index_en, :dir2_index_de],
|
450
|
+
nodes[:root].find(:limit => 'hallo'))
|
451
|
+
|
452
|
+
# :offset
|
453
|
+
check.call([:somename_en, :somename_en_frag, :somename_en_fragnest, :somename_de, :somename_de_frag,
|
454
|
+
:other, :other_en, :dir, :dir_file, :dir_file_frag, :dir2, :dir2_index_en, :dir2_index_de],
|
455
|
+
nodes[:root].find(:offset => 0))
|
456
|
+
check.call([:other, :other_en, :dir, :dir_file, :dir_file_frag, :dir2, :dir2_index_en, :dir2_index_de],
|
457
|
+
nodes[:root].find(:offset => 5))
|
458
|
+
check.call([:somename_en, :somename_en_frag, :somename_en_fragnest, :somename_de, :somename_de_frag,
|
459
|
+
:other, :other_en, :dir, :dir_file, :dir_file_frag, :dir2, :dir2_index_en, :dir2_index_de],
|
460
|
+
nodes[:root].find(:offset => 'hallo'))
|
461
|
+
|
462
|
+
end
|
463
|
+
|
403
464
|
end
|