webgen 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/COPYING +4 -0
  2. data/ChangeLog +1037 -0
  3. data/Rakefile +5 -6
  4. data/THANKS +1 -0
  5. data/VERSION +1 -1
  6. data/bin/webgen +1 -1
  7. data/data/webgen/passive_sources/images/generated_by_webgen.png +0 -0
  8. data/data/webgen/passive_sources/images/webgen_logo.png +0 -0
  9. data/data/webgen/passive_sources/stylesheets/coderay-default.css +129 -0
  10. data/data/webgen/passive_sources/templates/atom_feed.template +38 -0
  11. data/data/webgen/passive_sources/templates/rss_feed.template +28 -0
  12. data/data/webgen/passive_sources/templates/sitemap.template +21 -0
  13. data/data/webgen/resources.yaml +2 -1
  14. data/data/webgen/website_skeleton/Rakefile +5 -1
  15. data/doc/contentprocessor/builder.page +2 -2
  16. data/doc/contentprocessor/erb.page +5 -2
  17. data/doc/contentprocessor/erubis.page +2 -2
  18. data/doc/contentprocessor/head.page +21 -0
  19. data/doc/contentprocessor/tidy.page +14 -0
  20. data/doc/extensions.page +1 -1
  21. data/doc/faq.page +2 -2
  22. data/doc/manual.page +108 -43
  23. data/doc/reference_configuration.page +83 -5
  24. data/doc/reference_metainfo.page +24 -4
  25. data/doc/reference_website_styles.page +2 -2
  26. data/doc/sourcehandler/feed.page +11 -13
  27. data/doc/sourcehandler/metainfo.page +10 -3
  28. data/doc/sourcehandler/page.page +4 -4
  29. data/doc/sourcehandler/sitemap.page +8 -7
  30. data/doc/tag/coderay.page +6 -2
  31. data/doc/tag/includefile.page +1 -1
  32. data/doc/tag/menu.page +3 -0
  33. data/lib/webgen/cli/apply_command.rb +1 -1
  34. data/lib/webgen/cli/utils.rb +2 -2
  35. data/lib/webgen/common.rb +0 -9
  36. data/lib/webgen/contentprocessor.rb +18 -3
  37. data/lib/webgen/contentprocessor/blocks.rb +67 -36
  38. data/lib/webgen/contentprocessor/builder.rb +5 -2
  39. data/lib/webgen/contentprocessor/erb.rb +4 -2
  40. data/lib/webgen/contentprocessor/erubis.rb +5 -2
  41. data/lib/webgen/contentprocessor/haml.rb +6 -2
  42. data/lib/webgen/contentprocessor/head.rb +64 -0
  43. data/lib/webgen/contentprocessor/maruku.rb +3 -1
  44. data/lib/webgen/contentprocessor/rdiscount.rb +2 -0
  45. data/lib/webgen/contentprocessor/rdoc.rb +2 -0
  46. data/lib/webgen/contentprocessor/redcloth.rb +2 -0
  47. data/lib/webgen/contentprocessor/sass.rb +5 -3
  48. data/lib/webgen/contentprocessor/tags.rb +40 -24
  49. data/lib/webgen/contentprocessor/tidy.rb +38 -0
  50. data/lib/webgen/context.rb +13 -4
  51. data/lib/webgen/context/render.rb +32 -0
  52. data/lib/webgen/context/tags.rb +20 -0
  53. data/lib/webgen/default_config.rb +15 -4
  54. data/lib/webgen/deprecated.rb +38 -4
  55. data/lib/webgen/error.rb +135 -0
  56. data/lib/webgen/node.rb +48 -40
  57. data/lib/webgen/output.rb +5 -3
  58. data/lib/webgen/output/filesystem.rb +4 -4
  59. data/lib/webgen/page.rb +4 -4
  60. data/lib/webgen/path.rb +161 -58
  61. data/lib/webgen/source.rb +9 -6
  62. data/lib/webgen/source/filesystem.rb +1 -1
  63. data/lib/webgen/source/stacked.rb +13 -5
  64. data/lib/webgen/source/tararchive.rb +6 -2
  65. data/lib/webgen/sourcehandler.rb +100 -54
  66. data/lib/webgen/sourcehandler/base.rb +58 -24
  67. data/lib/webgen/sourcehandler/copy.rb +6 -5
  68. data/lib/webgen/sourcehandler/directory.rb +3 -9
  69. data/lib/webgen/sourcehandler/feed.rb +25 -50
  70. data/lib/webgen/sourcehandler/fragment.rb +10 -8
  71. data/lib/webgen/sourcehandler/memory.rb +9 -10
  72. data/lib/webgen/sourcehandler/metainfo.rb +9 -9
  73. data/lib/webgen/sourcehandler/page.rb +6 -5
  74. data/lib/webgen/sourcehandler/sitemap.rb +22 -22
  75. data/lib/webgen/sourcehandler/template.rb +6 -6
  76. data/lib/webgen/sourcehandler/virtual.rb +19 -17
  77. data/lib/webgen/tag/base.rb +27 -27
  78. data/lib/webgen/tag/breadcrumbtrail.rb +3 -3
  79. data/lib/webgen/tag/coderay.rb +19 -8
  80. data/lib/webgen/tag/executecommand.rb +4 -3
  81. data/lib/webgen/tag/langbar.rb +2 -2
  82. data/lib/webgen/tag/link.rb +8 -7
  83. data/lib/webgen/tag/menu.rb +2 -2
  84. data/lib/webgen/tag/metainfo.rb +1 -1
  85. data/lib/webgen/tag/relocatable.rb +17 -21
  86. data/lib/webgen/tag/tikz.rb +7 -10
  87. data/lib/webgen/tree.rb +7 -7
  88. data/lib/webgen/version.rb +1 -1
  89. data/lib/webgen/website.rb +32 -2
  90. data/misc/default.css +8 -2
  91. data/misc/default.template +2 -2
  92. data/misc/logo.svg +313 -0
  93. data/misc/style.page +1 -1
  94. data/test/helper.rb +18 -2
  95. data/test/test_cli.rb +104 -0
  96. data/test/test_common_sitemap.rb +1 -1
  97. data/test/test_contentprocessor.rb +8 -2
  98. data/test/test_contentprocessor_blocks.rb +17 -8
  99. data/test/test_contentprocessor_builder.rb +13 -2
  100. data/test/test_contentprocessor_erb.rb +9 -3
  101. data/test/test_contentprocessor_erubis.rb +9 -3
  102. data/test/test_contentprocessor_fragments.rb +12 -11
  103. data/test/test_contentprocessor_haml.rb +11 -2
  104. data/test/test_contentprocessor_head.rb +44 -0
  105. data/test/test_contentprocessor_maruku.rb +5 -1
  106. data/test/test_contentprocessor_rdiscount.rb +4 -0
  107. data/test/test_contentprocessor_rdoc.rb +4 -0
  108. data/test/test_contentprocessor_redcloth.rb +5 -1
  109. data/test/test_contentprocessor_sass.rb +8 -2
  110. data/test/test_contentprocessor_tags.rb +22 -7
  111. data/test/test_contentprocessor_tidy.rb +34 -0
  112. data/test/test_context.rb +39 -0
  113. data/test/test_error.rb +85 -0
  114. data/test/test_node.rb +57 -21
  115. data/test/test_page.rb +23 -5
  116. data/test/test_path.rb +120 -64
  117. data/test/test_source_filesystem.rb +1 -1
  118. data/test/test_source_stacked.rb +19 -6
  119. data/test/test_sourcehandler_base.rb +63 -50
  120. data/test/test_sourcehandler_copy.rb +6 -6
  121. data/test/test_sourcehandler_directory.rb +8 -12
  122. data/test/test_sourcehandler_feed.rb +15 -7
  123. data/test/test_sourcehandler_fragment.rb +6 -5
  124. data/test/test_sourcehandler_main.rb +39 -0
  125. data/test/test_sourcehandler_memory.rb +4 -4
  126. data/test/test_sourcehandler_metainfo.rb +20 -11
  127. data/test/test_sourcehandler_page.rb +10 -10
  128. data/test/test_sourcehandler_sitemap.rb +24 -5
  129. data/test/test_sourcehandler_template.rb +18 -15
  130. data/test/test_sourcehandler_virtual.rb +9 -5
  131. data/test/test_tag_base.rb +6 -29
  132. data/test/test_tag_coderay.rb +16 -3
  133. data/test/test_tag_executecommand.rb +2 -2
  134. data/test/test_tag_link.rb +5 -4
  135. data/test/test_tag_menu.rb +15 -15
  136. data/test/test_tag_metainfo.rb +1 -0
  137. data/test/test_tag_relocatable.rb +3 -2
  138. data/test/test_tag_tikz.rb +5 -5
  139. data/test/test_tree.rb +8 -8
  140. data/test/test_website.rb +15 -0
  141. metadata +21 -14
  142. data/test/test_common.rb +0 -18
@@ -17,7 +17,7 @@ class TestCommonSitemap < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  def do_assert(node, lang, honor_in_menu, any_lang, used_kinds, result)
20
- assert_equal(result.map {|name| @nodes[name].absolute_lcn },
20
+ assert_equal(result.map {|name| @nodes[name].alcn },
21
21
  @obj.create_sitemap(node, lang, {
22
22
  'common.sitemap.honor_in_menu' => honor_in_menu,
23
23
  'common.sitemap.any_lang' => any_lang,
@@ -10,7 +10,7 @@ class TestContentProcessor < Test::Unit::TestCase
10
10
 
11
11
  def setup
12
12
  super
13
- @website.config.data['contentprocessor.map'] = {'test' => Hash}
13
+ @website.config.data['contentprocessor.map'] = {'test' => Hash, 'binary' => [Hash, :binary]}
14
14
  end
15
15
 
16
16
  def test_access_hash
@@ -22,12 +22,18 @@ class TestContentProcessor < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  def test_list
25
- assert_equal(['test'], Webgen::ContentProcessor.list)
25
+ assert_equal(['binary', 'test'], Webgen::ContentProcessor.list.sort)
26
26
  end
27
27
 
28
28
  def test_for_name
29
29
  assert_kind_of(Hash, Webgen::ContentProcessor.for_name('test'))
30
+ assert_kind_of(Hash, Webgen::ContentProcessor.for_name('binary'))
30
31
  assert_nil(Webgen::ContentProcessor.for_name('other'))
31
32
  end
32
33
 
34
+ def test_is_binary
35
+ assert(!Webgen::ContentProcessor.is_binary?('test'))
36
+ assert(Webgen::ContentProcessor.is_binary?('binary'))
37
+ end
38
+
33
39
  end
@@ -1,13 +1,16 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
+ require 'helper'
4
5
  require 'webgen/tree'
5
6
  require 'webgen/page'
6
7
  require 'webgen/contentprocessor'
7
8
 
8
9
  class TestContentProcessorBlocks < Test::Unit::TestCase
9
10
 
10
- def test_process
11
+ include Test::WebsiteHelper
12
+
13
+ def test_call_and_render_node
11
14
  obj = Webgen::ContentProcessor::Blocks.new
12
15
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
13
16
  node = Webgen::Node.new(root, 'test', 'test')
@@ -20,28 +23,31 @@ class TestContentProcessorBlocks < Test::Unit::TestCase
20
23
  context.content = '<webgen:block name="content" /><webgen:block name="content" chain="template;test" />'
21
24
  obj.call(context)
22
25
  assert_equal('databeforedataafter', context.content)
23
- assert_equal(Set.new([node.absolute_lcn, template.absolute_lcn]), node.node_info[:used_nodes])
26
+ assert_equal(Set.new([node.alcn, template.alcn]), node.node_info[:used_nodes])
24
27
 
25
28
  context.content = '<webgen:block name="content" node="next" /><webgen:block name="content" chain="template;test" />'
26
29
  obj.call(context)
27
30
  assert_equal('databeforedataafter', context.content)
28
31
 
29
- context.content = '<webgen:block name="nothing"/>'
30
- assert_raise(RuntimeError) { obj.call(context) }
32
+ context.content = "\nsadfasdf<webgen:block name='nothing'/>"
33
+ assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
34
+
35
+ context.content = '<webgen:block name="content" chain="invalid" />'
36
+ assert_error_on_line(Webgen::RenderError, 1) { obj.call(context) }
31
37
 
32
- context.content = '<webgen:block name="content" chain="invalid" /><webgen:block name="content" />'
38
+ context.content = '<webgen:block name="content" />'
33
39
  node.node_info[:used_nodes] = Set.new
34
40
  context[:chain] = [node, template, node]
35
41
  obj.call(context)
36
- assert_equal('<webgen:block name="content" chain="invalid" />beforedataafter', context.content)
37
- assert_equal(Set.new([template.absolute_lcn, node.absolute_lcn]), node.node_info[:used_nodes])
42
+ assert_equal('beforedataafter', context.content)
43
+ assert_equal(Set.new([template.alcn, node.alcn]), node.node_info[:used_nodes])
38
44
 
39
45
  context.content = 'bef<webgen:block name="other" chain="template;test" notfound="ignore" />aft'
40
46
  obj.call(context)
41
47
  assert_equal('befaft', context.content)
42
48
 
43
49
  context.content = '<webgen:block name="other" chain="template" node="first" />'
44
- assert_raise(RuntimeError) { obj.call(context) }
50
+ assert_error_on_line(Webgen::RenderError, 1) { obj.call(context) }
45
51
 
46
52
  context.content = '<webgen:block name="other" chain="template;test" node="first" />'
47
53
  obj.call(context)
@@ -63,6 +69,9 @@ class TestContentProcessorBlocks < Test::Unit::TestCase
63
69
  context.content = '<webgen:block name="other" node="current" chain="template"/>'
64
70
  obj.call(context)
65
71
  assert_equal('other', context.content)
72
+
73
+ assert_equal('other', obj.render_block(context, :chain => [template], :name => 'other', :node => 'current'))
74
+ assert_equal('beforedataafter', obj.render_block(context, :chain => [template, node], :name => 'content', :node => 'first'))
66
75
  end
67
76
 
68
77
  end
@@ -1,23 +1,34 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
+ require 'helper'
4
5
  require 'webgen/tree'
5
6
  require 'webgen/contentprocessor'
6
7
 
7
8
  class TestContentProcessorBuilder < Test::Unit::TestCase
8
9
 
10
+ include Test::WebgenAssertions
11
+
9
12
  def test_call
10
13
  obj = Webgen::ContentProcessor::Builder.new
11
14
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
12
15
  node = Webgen::Node.new(root, 'test', 'test')
13
- content = "xml.div(:path => context.node.absolute_lcn) { xml.strong('test'); " +
16
+ content = "xml.div(:path => context.node.alcn) { xml.strong('test'); " +
14
17
  "context.website; context; context.ref_node; context.dest_node }"
15
18
  context = Webgen::Context.new(:content => content,
16
19
  :chain => [node])
17
20
  assert_equal("<div path=\"/test\">\n <strong>test</strong>\n</div>\n", obj.call(context).content)
18
21
 
19
22
  context.content = 'raise "bla"'
20
- assert_raise(RuntimeError) { obj.call(context).content }
23
+
24
+ context.content = "xml.div do \n5+5\n+=+6\nend"
25
+ assert_error_on_line(Webgen::RenderError, 3) { obj.call(context) }
26
+
27
+ context.content = "xml.div do \n5+5\nunknown\n++6\nend"
28
+ assert_error_on_line(Webgen::RenderError, 3) { obj.call(context) }
29
+
30
+ def obj.require(lib); raise LoadError; end
31
+ assert_raise(Webgen::LoadError) { obj.call(context) }
21
32
  end
22
33
 
23
34
  end
@@ -1,23 +1,29 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
+ require 'helper'
4
5
  require 'webgen/tree'
5
6
  require 'webgen/contentprocessor'
6
7
 
7
8
  class TestContentProcessorErb < Test::Unit::TestCase
8
9
 
10
+ include Test::WebgenAssertions
11
+
9
12
  def test_call
10
13
  obj = Webgen::ContentProcessor::Erb.new
11
14
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
12
15
  node = Webgen::Node.new(root, 'test', 'test')
13
- content = "<%= context[:doit] %>6\n<%= context.ref_node.absolute_lcn %>\n<%= context.node.absolute_lcn %>\n<%= context.dest_node.absolute_lcn %><% website %>"
16
+ content = "<%= context[:doit] %>6\n<%= context.ref_node.alcn %>\n<%= context.node.alcn %>\n<%= context.dest_node.alcn %><% website %>"
14
17
  context = Webgen::Context.new(:content => content, :doit => 'hallo',
15
18
  :chain => [node])
16
19
  obj.call(context)
17
20
  assert_equal("hallo6\n/test\n/test\n/test", context.content)
18
21
 
19
- context.content = '<%= 5* %>'
20
- assert_raise(RuntimeError) { obj.call(context) }
22
+ context.content = "\n<%= 5* %>"
23
+ assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
24
+
25
+ context.content = "\n\n<% unknown %>"
26
+ assert_error_on_line(Webgen::RenderError, 3) { obj.call(context) }
21
27
  end
22
28
 
23
29
  end
@@ -17,11 +17,14 @@ class TestContentProcessorErubis < Test::Unit::TestCase
17
17
  node = Webgen::Node.new(root, 'test', 'test')
18
18
  context = Webgen::Context.new(:doit => 'hallo', :chain => [node])
19
19
 
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 %>"
20
+ context.content = "<%= context[:doit] %>6\n<%= context.ref_node.alcn %>\n<%= context.node.alcn %>\n<%= context.dest_node.alcn %><% context.website %>"
21
21
  assert_equal("hallo6\n/test\n/test\n/test", obj.call(context).content)
22
22
 
23
- context.content = '<%= 5* %>'
24
- assert_raise(RuntimeError) { obj.call(context) }
23
+ context.content = "\n<%= 5* %>"
24
+ assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
25
+
26
+ context.content = "\n\n<% unknown %>"
27
+ assert_error_on_line(Webgen::RenderError, 3) { obj.call(context) }
25
28
 
26
29
  context.content = "<% for i in [1] %>\n<%= i %>\n<% end %>"
27
30
  assert_equal("1\n", obj.call(context).content)
@@ -44,6 +47,9 @@ class TestContentProcessorErubis < Test::Unit::TestCase
44
47
 
45
48
  page = Webgen::Page.from_data("--- pipeline:erubis erubis_trim:false erubis_use_pi:false\n<% for i in [1] %>\n<%== i %>\n<% end %>")
46
49
  assert_equal("\n1\n", page.blocks['content'].render(context).content)
50
+
51
+ def obj.require(lib); raise LoadError; end
52
+ assert_raise(Webgen::LoadError) { obj.call(context) }
47
53
  end
48
54
 
49
55
  end
@@ -13,30 +13,31 @@ class TestContentProcessorFragments < Test::Unit::TestCase
13
13
  def test_process
14
14
  Webgen::SourceHandler::Main.new
15
15
  @website.blackboard.del_service(:source_paths)
16
- @website.blackboard.add_service(:source_paths) { Hash.new(path_with_meta_info('/')) }
16
+ @website.blackboard.add_service(:source_paths) { Hash.new(path_with_meta_info('/test.html')) }
17
17
 
18
18
  obj = Webgen::ContentProcessor::Fragments.new
19
19
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
20
- root.node_info[:src] = '/'
20
+ node = Webgen::Node.new(root, '/test.html', 'test.html')
21
+ node.node_info[:src] = '/test.html'
21
22
  processors = { 'fragments' => obj }
22
23
 
23
- context = Webgen::Context.new(:chain => [root], :processors => processors)
24
+ context = Webgen::Context.new(:chain => [node], :processors => processors)
24
25
  context.content = '<h1 id="test">Test</h1><h1>Test2</h1>'
25
26
  obj.call(context)
26
- assert(root.tree['/#test'])
27
- assert_equal(3, root.tree.node_access[:alcn].length)
28
- root.tree.delete_node('/#test')
27
+ assert(root.tree['/test.html#test'])
28
+ assert_equal(4, root.tree.node_access[:alcn].length)
29
+ root.tree.delete_node('/test.html#test')
29
30
 
30
31
  context[:block] = Webgen::Page::Block.new('content', '', {})
31
32
  obj.call(context)
32
- assert(root.tree['/#test'])
33
- assert_equal(3, root.tree.node_access[:alcn].length)
34
- root.tree.delete_node('/#test')
33
+ assert(root.tree['/test.html#test'])
34
+ assert_equal(4, root.tree.node_access[:alcn].length)
35
+ root.tree.delete_node('/test.html#test')
35
36
 
36
37
  context[:block] = Webgen::Page::Block.new('other', '', {})
37
38
  obj.call(context)
38
- assert(!root.tree['/#test'])
39
- assert_equal(2, root.tree.node_access[:alcn].length)
39
+ assert(!root.tree['/test.html#test'])
40
+ assert_equal(3, root.tree.node_access[:alcn].length)
40
41
  end
41
42
 
42
43
  end
@@ -1,23 +1,32 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
+ require 'helper'
4
5
  require 'webgen/tree'
5
6
  require 'webgen/contentprocessor'
6
7
 
7
8
  class TestContentProcessorHaml < Test::Unit::TestCase
8
9
 
10
+ include Test::WebgenAssertions
11
+
9
12
  def test_call
10
13
  obj = Webgen::ContentProcessor::Haml.new
11
14
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
12
15
  node = Webgen::Node.new(root, 'test', 'test')
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"
16
+ content = "#content\n %h1 Hallo\n = [context.node.alcn, context.ref_node.alcn, context.dest_node.alcn, context.website, context.dest_node.alcn].join"
14
17
  context = Webgen::Context.new(:content => content,
15
18
  :chain => [node])
16
19
  obj.call(context)
17
20
  assert_equal("<div id='content'>\n <h1>Hallo</h1>\n /test/test/test/test\n</div>\n", context.content)
18
21
 
22
+ context.content = "#cont\n %unknown"
23
+ assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
24
+
19
25
  context.content = "#cont\n = unknown"
20
- assert_raise(RuntimeError) { obj.call(context) }
26
+ assert_raise(Webgen::RenderError) { obj.call(context) }
27
+
28
+ def obj.require(lib); raise LoadError; end
29
+ assert_raise(Webgen::LoadError) { obj.call(context) }
21
30
  end
22
31
 
23
32
  end
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'helper'
5
+ require 'webgen/tree'
6
+ require 'webgen/page'
7
+ require 'webgen/contentprocessor'
8
+
9
+ class TestContentProcessorHead < Test::Unit::TestCase
10
+
11
+ include Test::WebsiteHelper
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'}})
17
+
18
+ context = Webgen::Context.new(:chain => [node])
19
+ context.content = '</head>'
20
+ obj.call(context)
21
+ assert_equal("\n<meta name=\"other\" content=\"me\" /></head>", context.content)
22
+
23
+ context.content = '</head>'
24
+ context.clone.persistent[:cp_head] = {
25
+ :js_file => ['hallo.js', 'hallo2.js', 'hallo.js'],
26
+ :js_inline => ["somescript", "anotherscript"],
27
+ :css_file => ['hallo.css', 'hallo2.css', 'hallo.css'],
28
+ :css_inline => ["somestyle", "anotherstyle"],
29
+ :meta => {:lucky => 'me<"'}
30
+ }
31
+ node['meta'].clear
32
+ obj.call(context)
33
+ assert_equal("\n<script type=\"text/javascript\" src=\"hallo.js\"></script>" +
34
+ "\n<script type=\"text/javascript\" src=\"hallo2.js\"></script>" +
35
+ "\n<script type=\"text/javascript\">\nsomescript\n</script>" +
36
+ "\n<script type=\"text/javascript\">\nanotherscript\n</script>" +
37
+ "\n<link rel=\"stylesheet\" href=\"hallo.css\" type=\"text/css\"/>" +
38
+ "\n<link rel=\"stylesheet\" href=\"hallo2.css\" type=\"text/css\"/>" +
39
+ "\n<style type=\"text/css\"><![CDATA[/\nsomestyle\n]]></style>" +
40
+ "\n<style type=\"text/css\"><![CDATA[/\nanotherstyle\n]]></style>" +
41
+ "\n<meta name=\"lucky\" content=\"me&lt;&quot;\" /></head>", context.content)
42
+ end
43
+
44
+ end
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
+ require 'helper'
4
5
  require 'webgen/node'
5
6
  require 'webgen/tree'
6
7
  require 'webgen/contentprocessor'
@@ -14,7 +15,10 @@ class TestContentProcessorMaruku < Test::Unit::TestCase
14
15
  assert_equal('<h1 id=\'header\'>header</h1>', @obj.call(context).content)
15
16
 
16
17
  context.content = "# head*d* {#das .dsaf "
17
- assert_raise(RuntimeError) { @obj.call(context)}
18
+ assert_raise(Webgen::RenderError) { @obj.call(context)}
19
+
20
+ def @obj.require(lib); raise LoadError; end
21
+ assert_raise(Webgen::LoadError) { @obj.call(context) }
18
22
  end
19
23
 
20
24
  def test_call_fix_for_invalid_id
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
+ require 'helper'
4
5
  require 'webgen/node'
5
6
  require 'webgen/tree'
6
7
  require 'webgen/contentprocessor'
@@ -12,6 +13,9 @@ class TestContentProcessorRDiscount < Test::Unit::TestCase
12
13
  node = Webgen::Node.new(Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/'), 'test', 'test')
13
14
  context = Webgen::Context.new(:content => '# header', :chain => [node])
14
15
  assert_equal("<h1>header</h1>\n", @obj.call(context).content)
16
+
17
+ def @obj.require(lib); raise LoadError; end
18
+ assert_raise(Webgen::LoadError) { @obj.call(context) }
15
19
  end
16
20
 
17
21
  end
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
+ require 'helper'
4
5
  require 'webgen/tree'
5
6
  require 'webgen/contentprocessor'
6
7
 
@@ -13,6 +14,9 @@ class TestContentProcessorRDoc < Test::Unit::TestCase
13
14
  context = Webgen::Context.new(:content => "* hello",
14
15
  :chain => [node])
15
16
  assert_equal("<ul>\n<li>hello\n\n</li>\n</ul>\n", obj.call(context).content)
17
+
18
+ def obj.require(lib); raise LoadError; end
19
+ assert_raise(Webgen::LoadError) { obj.call(context) }
16
20
  end
17
21
 
18
22
  end
@@ -11,12 +11,16 @@ class TestContentProcessorRedCloth < Test::Unit::TestCase
11
11
 
12
12
  def test_call
13
13
  @obj = Webgen::ContentProcessor::RedCloth.new
14
- context = Webgen::Context.new(:content => "h1. header\n\nthis\nis\nsome\ntext")
14
+ node = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
15
+ context = Webgen::Context.new(:content => "h1. header\n\nthis\nis\nsome\ntext", :chain => [node])
15
16
  assert_equal("<h1>header</h1>\n<p>this\nis\nsome\ntext</p>", @obj.call(context).content)
16
17
 
17
18
  context.content = "h1. header\n\nthis\nis\nsome\ntext"
18
19
  @website.config['contentprocessor.redcloth.hard_breaks'] = true
19
20
  assert_equal("<h1>header</h1>\n<p>this<br />\nis<br />\nsome<br />\ntext</p>", @obj.call(context).content)
21
+
22
+ def @obj.require(lib); raise LoadError; end
23
+ assert_raise(Webgen::LoadError) { @obj.call(context) }
20
24
  end
21
25
 
22
26
  end
@@ -1,11 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
+ require 'helper'
4
5
  require 'webgen/tree'
5
6
  require 'webgen/contentprocessor'
6
7
 
7
8
  class TestContentProcessorSass < Test::Unit::TestCase
8
9
 
10
+ include Test::WebgenAssertions
11
+
9
12
  def test_call
10
13
  obj = Webgen::ContentProcessor::Sass.new
11
14
  root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
@@ -15,8 +18,11 @@ class TestContentProcessorSass < Test::Unit::TestCase
15
18
  obj.call(context)
16
19
  assert_equal("#main {\n background-color: #000; }\n", context.content)
17
20
 
18
- context.content = "#cont \n = unknown"
19
- assert_raise(RuntimeError) { obj.call(context) }
21
+ context.content = "#cont\n = 5"
22
+ assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
23
+
24
+ def obj.require(lib); raise LoadError; end
25
+ assert_raise(Webgen::LoadError) { obj.call(context) }
20
26
  end
21
27
 
22
28
  end
@@ -15,6 +15,8 @@ class TestContentProcessorTags < Test::Unit::TestCase
15
15
 
16
16
  def create_tag_params(*args); end
17
17
 
18
+ def create_params_hash(*args); end
19
+
18
20
  def call(tag, body, context)
19
21
  case tag
20
22
  when 'body'
@@ -36,9 +38,6 @@ class TestContentProcessorTags < Test::Unit::TestCase
36
38
 
37
39
  def test_call
38
40
  context = Webgen::Context.new(:chain => [Webgen::Tree.new.dummy_root])
39
- context.content = "{test: }"
40
- assert_equal('', @obj.call(context).content)
41
-
42
41
  add_test_tag
43
42
  assert_equal('test', @obj.call(context.clone(:content => "{test: }")).content)
44
43
  assert_equal('thebody', @obj.call(context.clone(:content => "{body::}thebody{body}")).content)
@@ -46,13 +45,24 @@ class TestContentProcessorTags < Test::Unit::TestCase
46
45
  @obj.call(context.clone(:content => "test{bodyproc::} \\{other:}{other:} {bodyproc}test")).content)
47
46
  end
48
47
 
48
+ def test_process_tag
49
+ context = Webgen::Context.new(:chain => [Webgen::Tree.new.dummy_root])
50
+ context.content = "\n{test: }"
51
+ assert_error_on_line(Webgen::RenderError, 2) { @obj.call(context) }
52
+
53
+ add_test_tag
54
+ assert_equal('test', @obj.process_tag('test', {'something' => 'new'}, '', context))
55
+ assert_equal('test', @obj.process_tag('test', '{something: new}', '', context))
56
+ assert_equal('thebody', @obj.process_tag('body', '{something: new}', 'thebody', context))
57
+ end
58
+
49
59
  def test_replace_tags
50
60
  check_returned_tags('sdfsdf{asd', [])
51
61
  check_returned_tags('sdfsdf}asd', [])
52
62
  check_returned_tags('sdfsdf{asd}', [])
53
- check_returned_tags('sdfsdf{asd: {}as', [])
63
+ check_returned_tags('sdfsdf{asd: {}as', [], true)
54
64
  check_returned_tags('sdfsdf{test: {test1: }}', [['test', ' {test1: }', '']], 'sdfsdftest1')
55
- check_returned_tags('sdfsdf{test: {test1: {}}', [['test', '', '']], 'sdfsdf{test: {test1: {}}')
65
+ check_returned_tags('sdfsdf{test: {test1: {}}', [], true)
56
66
  check_returned_tags('sdfsdf{test:}{test1: }', [['test', '', ''], ['test1', ' ', '']], 'sdfsdftest1test2')
57
67
  check_returned_tags('sdfsdf{test:}\\{test1: }', [['test', '', '']], "sdfsdftest1{test1: }")
58
68
  check_returned_tags('sdfsdf\\{test:}{test1:}', [['test1', '', '']], "sdfsdf{test:}test1")
@@ -62,7 +72,7 @@ class TestContentProcessorTags < Test::Unit::TestCase
62
72
  check_returned_tags('sdfsdf\\\\\\{test: asdf}sdf', [['test', ' asdf', '']], "sdfsdf\\{test: asdf}sdf")
63
73
 
64
74
  check_returned_tags('before{test::}body{test}', [['test', '', 'body']], "beforetest1")
65
- check_returned_tags('before{test::}body{testno}', [], "before{test::}body{testno}")
75
+ check_returned_tags('before{test::}body{testno}', [], true)
66
76
  check_returned_tags('before{test::}body\\{test}other{test}', [['test', '', 'body{test}other']], "beforetest1")
67
77
  check_returned_tags('before{test::}body\\{test}{test}', [['test', '', 'body{test}']], "beforetest1")
68
78
  check_returned_tags('before{test::}body\\{test}\\\\{test}after', [['test', '', 'body{test}\\']], "beforetest1after")
@@ -92,7 +102,12 @@ class TestContentProcessorTags < Test::Unit::TestCase
92
102
  i += 1
93
103
  'test' + i.to_s
94
104
  end
95
- assert_equal(result, @obj.instance_eval { replace_tags(content, Webgen::Tree.new.dummy_root, &check_proc) })
105
+ context = Webgen::Context.new(:chain => [Webgen::Tree.new.dummy_root], :content => content)
106
+ if result.kind_of?(TrueClass)
107
+ assert_error_on_line(Webgen::RenderError, 1) { @obj.send(:replace_tags, context, &check_proc) }
108
+ else
109
+ assert_equal(result, @obj.instance_eval { replace_tags(context, &check_proc) })
110
+ end
96
111
  assert(i, data.length)
97
112
  end
98
113