webgen 0.5.10 → 0.5.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/ChangeLog +487 -0
  2. data/Rakefile +13 -28
  3. data/VERSION +1 -1
  4. data/bin/webgen +1 -2
  5. data/data/webgen/passive_sources/templates/atom_feed.template +1 -0
  6. data/data/webgen/website_bundles/style/andreas07/src/default.css +2 -2
  7. data/data/webgen/website_skeleton/config.yaml +22 -5
  8. data/doc/contentprocessor.template +2 -2
  9. data/doc/contentprocessor/blocks.page +4 -4
  10. data/doc/contentprocessor/builder.page +2 -3
  11. data/doc/contentprocessor/erb.page +1 -1
  12. data/doc/contentprocessor/erubis.page +5 -5
  13. data/doc/contentprocessor/fragments.page +5 -4
  14. data/doc/contentprocessor/haml.page +2 -3
  15. data/doc/contentprocessor/head.page +16 -6
  16. data/doc/contentprocessor/kramdown.page +49 -0
  17. data/doc/contentprocessor/less.page +34 -0
  18. data/doc/contentprocessor/maruku.page +6 -3
  19. data/doc/contentprocessor/rdiscount.page +3 -3
  20. data/doc/contentprocessor/rdoc.page +1 -1
  21. data/doc/contentprocessor/redcloth.page +1 -1
  22. data/doc/contentprocessor/sass.page +1 -1
  23. data/doc/contentprocessor/tags.page +2 -2
  24. data/doc/contentprocessor/tidy.page +2 -2
  25. data/doc/extensions.page +1 -2
  26. data/doc/extensions.template +5 -5
  27. data/doc/getting_started.page +16 -12
  28. data/doc/index.page +21 -21
  29. data/doc/manual.page +109 -61
  30. data/doc/reference_configuration.page +63 -38
  31. data/doc/reference_metainfo.page +68 -45
  32. data/doc/reference_website_styles.page +5 -1
  33. data/doc/source/filesystem.page +4 -4
  34. data/doc/source/tararchive.page +4 -4
  35. data/doc/sourcehandler.template +2 -2
  36. data/doc/sourcehandler/feed.page +3 -4
  37. data/doc/sourcehandler/metainfo.page +1 -1
  38. data/doc/sourcehandler/page.page +3 -3
  39. data/doc/sourcehandler/sitemap.page +2 -3
  40. data/doc/sourcehandler/template.page +2 -2
  41. data/doc/sourcehandler/virtual.page +5 -5
  42. data/doc/tag.template +1 -1
  43. data/doc/tag/coderay.page +2 -2
  44. data/doc/tag/includefile.page +1 -1
  45. data/doc/tag/langbar.page +4 -1
  46. data/doc/tag/menu.page +3 -3
  47. data/doc/tag/relocatable.page +1 -1
  48. data/doc/upgrading.page +30 -31
  49. data/doc/webgen_page_format.page +6 -6
  50. data/lib/webgen/cache.rb +4 -5
  51. data/lib/webgen/cli/utils.rb +18 -7
  52. data/lib/webgen/cli/webgui_command.rb +4 -2
  53. data/lib/webgen/common.rb +10 -0
  54. data/lib/webgen/configuration.rb +1 -3
  55. data/lib/webgen/contentprocessor.rb +4 -2
  56. data/lib/webgen/contentprocessor/blocks.rb +1 -0
  57. data/lib/webgen/contentprocessor/builder.rb +3 -9
  58. data/lib/webgen/contentprocessor/erb.rb +3 -9
  59. data/lib/webgen/contentprocessor/erubis.rb +3 -9
  60. data/lib/webgen/contentprocessor/haml.rb +10 -11
  61. data/lib/webgen/contentprocessor/head.rb +64 -0
  62. data/lib/webgen/contentprocessor/kramdown.rb +26 -0
  63. data/lib/webgen/contentprocessor/kramdown/html.rb +32 -0
  64. data/lib/webgen/contentprocessor/less.rb +35 -0
  65. data/lib/webgen/contentprocessor/maruku.rb +14 -0
  66. data/lib/webgen/contentprocessor/tags.rb +25 -7
  67. data/lib/webgen/default_config.rb +9 -3
  68. data/lib/webgen/node.rb +92 -0
  69. data/lib/webgen/output.rb +3 -1
  70. data/lib/webgen/source/resource.rb +2 -1
  71. data/lib/webgen/source/tararchive.rb +3 -2
  72. data/lib/webgen/sourcehandler.rb +8 -4
  73. data/lib/webgen/sourcehandler/base.rb +1 -2
  74. data/lib/webgen/sourcehandler/feed.rb +1 -1
  75. data/lib/webgen/sourcehandler/virtual.rb +1 -0
  76. data/lib/webgen/tag/base.rb +1 -1
  77. data/lib/webgen/tag/langbar.rb +5 -2
  78. data/lib/webgen/version.rb +1 -1
  79. data/lib/webgen/website.rb +7 -8
  80. data/misc/default.template +1 -1
  81. data/misc/htmldoc.virtual +13 -1
  82. data/test/test_contentprocessor.rb +1 -1
  83. data/test/test_contentprocessor_blocks.rb +16 -1
  84. data/test/test_contentprocessor_erb.rb +1 -1
  85. data/test/test_contentprocessor_fragments.rb +1 -1
  86. data/test/test_contentprocessor_haml.rb +2 -2
  87. data/test/test_contentprocessor_head.rb +54 -8
  88. data/test/test_contentprocessor_kramdown.rb +50 -0
  89. data/test/test_contentprocessor_less.rb +40 -0
  90. data/test/test_contentprocessor_tags.rb +8 -0
  91. data/test/test_node.rb +102 -41
  92. data/test/test_source_tararchive.rb +5 -1
  93. data/test/test_sourcehandler_feed.rb +5 -2
  94. data/test/test_sourcehandler_virtual.rb +5 -0
  95. data/test/test_tag_langbar.rb +2 -3
  96. metadata +22 -16
  97. 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)
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
- require 'test/helper'
4
+ require 'helper'
5
5
  require 'webgen/page'
6
6
  require 'webgen/tree'
7
7
  require 'webgen/contentprocessor'
@@ -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
- assert_raise(Webgen::RenderError) { obj.call(context) }
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 test_call
14
- obj = Webgen::ContentProcessor::Head.new
15
- root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
16
- node = Webgen::Node.new(root, 'test', 'test', {'meta' => {'other' => 'me'}})
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
- context = Webgen::Context.new(:chain => [node])
20
+ def test_meta_information
21
+ context = Webgen::Context.new(:chain => [@node])
19
22
  context.content = '</head>'
20
- obj.call(context)
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
- node['meta'].clear
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&lt;&quot;\" /></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
@@ -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.page', {'lang' => 'en', 'title' => 'somename'}),
21
- :somename_de => child_de = Webgen::Node.new(node, '/somename.de.html', 'somename.page', {'lang' => 'de'}),
22
- :other => Webgen::Node.new(node, '/other.html', 'other.page', {}),
23
- :other_en => Webgen::Node.new(node, '/other1.html', 'other.page', {'lang' => 'en'}),
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', {'lang' => 'en', 'routed_title' => 'routed', 'title' => 'index'}),
32
- :dir2_index_de => Webgen::Node.new(dir2, '/dir2/index.de.html', 'index.html', {'lang' => 'de', 'routed_title' => 'routed_de', 'title' => 'index'}),
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.page', {'lang' => 'de'})
56
- check_proc.call(child, node, 'somename.html', 'somename.page', 'somename.de.page',
57
- '/somename.de.page', '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.page', 'somename.de.page',
67
- '/somename.de.page', 'de', {'title' => 'test'})
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.page', nil))
130
- assert_equal(nodes[:somename_en], n.resolve('somename.page', 'en'))
131
- assert_equal(nodes[:somename_de], n.resolve('somename.page', 'de'))
132
- assert_equal(nil, n.resolve('somename.page', 'fr'))
133
- assert_equal(nodes[:somename_en], n.resolve('somename.en.page', nil))
134
- assert_equal(nodes[:somename_en], n.resolve('somename.en.page', 'en'))
135
- assert_equal(nodes[:somename_en], n.resolve('somename.en.page', 'de'))
136
- assert_equal(nil, n.resolve('somename.fr.page', 'de'))
137
-
138
- assert_equal(nodes[:other], n.resolve('other.page', nil))
139
- assert_equal(nodes[:other], n.resolve('other.page', 'fr'))
140
- assert_equal(nodes[:other_en], n.resolve('other.page', 'en'))
141
- assert_equal(nodes[:other_en], n.resolve('other.en.page', nil))
142
- assert_equal(nodes[:other_en], n.resolve('other.en.page', 'de'))
143
- assert_equal(nil, n.resolve('other.fr.page', nil))
144
- assert_equal(nil, n.resolve('other.fr.page', 'en'))
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.page#othertest', nil))
152
- assert_equal(nodes[:somename_en_frag], nodes[:root].resolve('/somename.page#othertest', 'en'))
153
- assert_equal(nodes[:somename_de_frag], nodes[:root].resolve('/somename.page#othertest', 'de'))
154
- assert_equal(nodes[:somename_en_frag], nodes[:root].resolve('/somename.en.page#othertest'))
155
- assert_equal(nodes[:somename_de_frag], nodes[:root].resolve('/somename.de.page#othertest'))
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*.page'
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*.page'
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*.page'
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