webgen 1.0.0.beta1 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/API.rdoc +64 -11
- data/ChangeLog +391 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/data/webgen/passive_sources/templates/tag.template +1 -1
- data/data/webgen/passive_sources/templates/tikz.template +14 -0
- data/lib/webgen/bundle/built-in/init.rb +9 -7
- data/lib/webgen/bundle_loader.rb +1 -1
- data/lib/webgen/cli/show_command.rb +2 -0
- data/lib/webgen/cli/show_config_command.rb +0 -1
- data/lib/webgen/cli/show_dependencies_command.rb +6 -63
- data/lib/webgen/cli/show_tree_command.rb +85 -0
- data/lib/webgen/content_processor/erb.rb +1 -1
- data/lib/webgen/content_processor/{rdoc.rb → r_doc.rb} +0 -0
- data/lib/webgen/content_processor/{redcloth.rb → red_cloth.rb} +0 -0
- data/lib/webgen/content_processor/ruby.rb +3 -0
- data/lib/webgen/content_processor/sass.rb +10 -6
- data/lib/webgen/content_processor/tikz.rb +10 -20
- data/lib/webgen/context/html_head.rb +7 -0
- data/lib/webgen/item_tracker.rb +42 -15
- data/lib/webgen/item_tracker/file.rb +7 -3
- data/lib/webgen/item_tracker/missing_node.rb +17 -5
- data/lib/webgen/item_tracker/node_content.rb +7 -3
- data/lib/webgen/item_tracker/node_meta_info.rb +8 -3
- data/lib/webgen/item_tracker/nodes.rb +10 -3
- data/lib/webgen/node.rb +4 -29
- data/lib/webgen/node_finder.rb +25 -10
- data/lib/webgen/path.rb +2 -2
- data/lib/webgen/path_handler/base.rb +20 -9
- data/lib/webgen/path_handler/feed.rb +29 -22
- data/lib/webgen/path_handler/page.rb +1 -3
- data/lib/webgen/path_handler/page_utils.rb +114 -33
- data/lib/webgen/path_handler/sitemap.rb +13 -6
- data/lib/webgen/path_handler/template.rb +0 -70
- data/lib/webgen/path_handler/virtual.rb +10 -2
- data/lib/webgen/tag.rb +13 -13
- data/lib/webgen/tag/tikz.rb +2 -1
- data/lib/webgen/test_helper.rb +2 -11
- data/lib/webgen/version.rb +1 -1
- data/test/webgen/content_processor/test_erb.rb +4 -0
- data/test/webgen/content_processor/{test_rdoc.rb → test_r_doc.rb} +1 -1
- data/test/webgen/content_processor/{test_redcloth.rb → test_red_cloth.rb} +1 -1
- data/test/webgen/content_processor/test_sass.rb +2 -2
- data/test/webgen/content_processor/test_tikz.rb +10 -3
- data/test/webgen/item_tracker/test_file.rb +5 -5
- data/test/webgen/item_tracker/test_missing_node.rb +8 -9
- data/test/webgen/item_tracker/test_node_content.rb +5 -6
- data/test/webgen/item_tracker/test_node_meta_info.rb +6 -7
- data/test/webgen/item_tracker/test_nodes.rb +7 -9
- data/test/webgen/path_handler/test_base.rb +4 -5
- data/test/webgen/path_handler/test_page.rb +1 -1
- data/test/webgen/path_handler/test_page_utils.rb +39 -11
- data/test/webgen/path_handler/test_template.rb +5 -45
- data/test/webgen/path_handler/test_virtual.rb +21 -0
- data/test/webgen/tag/test_link.rb +1 -1
- data/test/webgen/tag/test_tikz.rb +2 -2
- data/test/webgen/test_context.rb +10 -0
- data/test/webgen/test_item_tracker.rb +7 -4
- data/test/webgen/test_node.rb +3 -16
- data/test/webgen/test_node_finder.rb +10 -6
- data/test/webgen/test_tag.rb +4 -4
- metadata +218 -216
data/lib/webgen/tag/tikz.rb
CHANGED
@@ -16,7 +16,7 @@ module Webgen
|
|
16
16
|
|
17
17
|
add_tikz_options!(path, context)
|
18
18
|
|
19
|
-
node = context.website.ext.path_handler.create_secondary_nodes(path, body,
|
19
|
+
node = context.website.ext.path_handler.create_secondary_nodes(path, body, context.ref_node.alcn).first
|
20
20
|
|
21
21
|
attrs = {'alt' => ''}.merge(context[:config]['tag.tikz.img_attr']).collect do |name, value|
|
22
22
|
"#{name.to_s}=\"#{value}\""
|
@@ -31,6 +31,7 @@ module Webgen
|
|
31
31
|
path.meta_info[opt] = context[:config][opt]
|
32
32
|
end
|
33
33
|
path.meta_info['pipeline'] = 'tikz'
|
34
|
+
path.meta_info['handler'] = 'copy'
|
34
35
|
end
|
35
36
|
private_class_method :add_tikz_options!
|
36
37
|
|
data/lib/webgen/test_helper.rb
CHANGED
@@ -22,25 +22,16 @@ module Webgen
|
|
22
22
|
|
23
23
|
# A special subclass of Webgen::Node that is used in testing when a "renderable" node is needed,
|
24
24
|
# ie. one that has the necessary info set to be processed via Webgen::PathHandler::PageUtils.
|
25
|
-
class RenderNode < Webgen::Node
|
26
|
-
|
27
|
-
include Webgen::PathHandler::PageUtils
|
25
|
+
class RenderNode < Webgen::PathHandler::PageUtils::Node
|
28
26
|
|
29
27
|
def initialize(page_data, parent, cn, dest_path, meta_info = {})
|
30
28
|
super(parent, cn, dest_path, meta_info)
|
31
29
|
page = Webgen::Page.from_data(page_data)
|
32
30
|
self.node_info[:blocks] = page.blocks
|
31
|
+
self.node_info[:path_handler] = self
|
33
32
|
self.meta_info.update(page.meta_info)
|
34
33
|
end
|
35
34
|
|
36
|
-
def blocks
|
37
|
-
super(self)
|
38
|
-
end
|
39
|
-
|
40
|
-
def render_block(name, context)
|
41
|
-
super(self, name, context)
|
42
|
-
end
|
43
|
-
|
44
35
|
def template_chain
|
45
36
|
[self]
|
46
37
|
end
|
data/lib/webgen/version.rb
CHANGED
@@ -14,6 +14,10 @@ class TestErb < MiniTest::Unit::TestCase
|
|
14
14
|
@context.content = "<%= context[:doit] %>6\n<%= context.ref_node.alcn %>\n<%= context.node.alcn %>\n<%= context.dest_node.alcn %><% context.website %>"
|
15
15
|
assert_equal("hallo6\n/test\n/test\n/test", cp.call(@context).content)
|
16
16
|
|
17
|
+
@website.config['content_processor.erb.trim_mode'] = '%'
|
18
|
+
@context.content = "% 3.times do\na\n% end"
|
19
|
+
assert_equal("a\na\na\n", cp.call(@context).content)
|
20
|
+
|
17
21
|
@context.content = "\n<%= 5* %>"
|
18
22
|
assert_error_on_line(SyntaxError, 2) { cp.call(@context) }
|
19
23
|
end
|
@@ -22,8 +22,8 @@ class TestSass < MiniTest::Unit::TestCase
|
|
22
22
|
assert_error_on_line(Webgen::RenderError, 2) { cp.call(@context) }
|
23
23
|
|
24
24
|
# test @import-ing of sass files
|
25
|
-
content = "#main\n background-image: relocatable('../dir2/file.test')"
|
26
|
-
result = "#main {\n background-image: url(\"../../dir2/file.test\"); }\n"
|
25
|
+
content = "#main\n background-image: url(relocatable('../dir2/file.test') + \"#iefix\")"
|
26
|
+
result = "#main {\n background-image: url(\"../../dir2/file.test#iefix\"); }\n"
|
27
27
|
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
28
28
|
dir = Webgen::Node.new(root, 'dir/', '/dir/')
|
29
29
|
partial = Webgen::Node.new(dir, '_partial.sass', '/dir/_partial.sass')
|
@@ -9,6 +9,12 @@ class TestContentProcessorTikz < MiniTest::Unit::TestCase
|
|
9
9
|
|
10
10
|
def test_static_call
|
11
11
|
setup_context
|
12
|
+
@website.ext.content_processor = Webgen::ContentProcessor.new
|
13
|
+
@website.ext.content_processor.register('Blocks')
|
14
|
+
@website.ext.content_processor.register('Erb')
|
15
|
+
template_data = File.read(File.join(Webgen::Utils.data_dir, 'passive_sources', 'templates', 'tikz.template'))
|
16
|
+
node = RenderNode.new(template_data, @website.tree.dummy_root, '/template', '/template')
|
17
|
+
|
12
18
|
@context.node.expect(:[], nil, ['ignored'])
|
13
19
|
|
14
20
|
call('\tikz \draw (0,0) -- (0,1);', 'test.png', [], '', '72 72', false)
|
@@ -24,9 +30,10 @@ class TestContentProcessorTikz < MiniTest::Unit::TestCase
|
|
24
30
|
@context.content = content
|
25
31
|
@context.dest_node.expect(:dest_path, path)
|
26
32
|
@context.website.config.update('content_processor.tikz.resolution' => res,
|
27
|
-
|
28
|
-
|
29
|
-
|
33
|
+
'content_processor.tikz.transparent' => trans,
|
34
|
+
'content_processor.tikz.libraries' => libs,
|
35
|
+
'content_processor.tikz.opts' => opts,
|
36
|
+
'content_processor.tikz.template' => '/template')
|
30
37
|
Webgen::ContentProcessor::Tikz.call(@context)
|
31
38
|
end
|
32
39
|
|
@@ -19,13 +19,13 @@ class TestItemTrackerFile < MiniTest::Unit::TestCase
|
|
19
19
|
assert_equal(File.mtime(__FILE__), @obj.item_data(__FILE__))
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
refute(@obj.
|
24
|
-
assert(@obj.
|
22
|
+
def test_item_changed?
|
23
|
+
refute(@obj.item_changed?(__FILE__, Time.now))
|
24
|
+
assert(@obj.item_changed?(__FILE__, Time.parse("1980-01-01")))
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
|
27
|
+
def test_referenced_nodes
|
28
|
+
assert_equal([], @obj.referenced_nodes('anything', 'nothing'))
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
@@ -35,36 +35,35 @@ class TestItemTrackerMissingNode < MiniTest::Unit::TestCase
|
|
35
35
|
assert_same(false, @obj.item_data('id', 'lang'))
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def test_item_changed?
|
39
39
|
@website.tree.answer = nil
|
40
40
|
|
41
41
|
# run where missing node item was added
|
42
|
-
assert(@obj.
|
42
|
+
assert(@obj.item_changed?(['alcn', 'lang'], true))
|
43
43
|
|
44
44
|
@website.blackboard.dispatch_msg(:after_all_nodes_written)
|
45
45
|
|
46
46
|
# run where at least one new node was created
|
47
47
|
@website.blackboard.dispatch_msg(:after_node_created)
|
48
|
-
assert(@obj.
|
48
|
+
assert(@obj.item_changed?(['alcn', 'lang'], true))
|
49
49
|
|
50
50
|
@website.blackboard.dispatch_msg(:after_all_nodes_written)
|
51
51
|
@website.blackboard.dispatch_msg(:after_all_nodes_written)
|
52
52
|
|
53
53
|
# run where no new nodes were created and therefore "changing" stops
|
54
|
-
refute(@obj.
|
54
|
+
refute(@obj.item_changed?(['alcn', 'lang'], true))
|
55
55
|
|
56
56
|
@website.blackboard.dispatch_msg(:after_all_nodes_written)
|
57
57
|
@website.blackboard.dispatch_msg(:website_generated)
|
58
58
|
|
59
59
|
# on next invocation of website generation
|
60
60
|
@website.tree.answer = :a42
|
61
|
-
assert(@obj.
|
62
|
-
refute(@obj.
|
61
|
+
assert(@obj.item_changed?(['alcn', 'lang'], true))
|
62
|
+
refute(@obj.item_changed?(['alcn', 'lang'], false))
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
66
|
-
|
67
|
-
refute(@obj.node_referenced?(['other', 'lang'], true, 'alcn'))
|
65
|
+
def test_referenced_nodes
|
66
|
+
assert_equal(['alcn'], @obj.referenced_nodes(['alcn', 'lang'], true))
|
68
67
|
end
|
69
68
|
|
70
69
|
end
|
@@ -18,7 +18,7 @@ class TestNodeContent < MiniTest::Unit::TestCase
|
|
18
18
|
assert_nil(@obj.item_data('alcn'))
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def test_item_changed?
|
22
22
|
item_tracker = MiniTest::Mock.new
|
23
23
|
item_tracker.expect(:node_changed?, true, [:node])
|
24
24
|
ext = MiniTest::Mock.new
|
@@ -26,17 +26,16 @@ class TestNodeContent < MiniTest::Unit::TestCase
|
|
26
26
|
@website.expect(:ext, ext)
|
27
27
|
@website.expect(:tree, {'alcn' => :node})
|
28
28
|
|
29
|
-
assert(@obj.
|
30
|
-
assert(@obj.
|
29
|
+
assert(@obj.item_changed?('unknown', 'old'))
|
30
|
+
assert(@obj.item_changed?('alcn', 'other'))
|
31
31
|
|
32
32
|
@website.verify
|
33
33
|
item_tracker.verify
|
34
34
|
ext.verify
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
|
39
|
-
refute(@obj.node_referenced?('other', nil, 'alcn'))
|
37
|
+
def test_referenced_nodes
|
38
|
+
assert_equal(['alcn'], @obj.referenced_nodes('alcn', nil))
|
40
39
|
end
|
41
40
|
|
42
41
|
end
|
@@ -27,18 +27,17 @@ class TestNodeMetaInfo < MiniTest::Unit::TestCase
|
|
27
27
|
@node.verify
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def test_item_changed?
|
31
31
|
@node.expect(:nil?, false)
|
32
|
-
assert(@obj.
|
33
|
-
assert(@obj.
|
34
|
-
assert(@obj.
|
32
|
+
assert(@obj.item_changed?(['unknown', nil], 'old'))
|
33
|
+
assert(@obj.item_changed?(['alcn', nil], {"key" => 'value', 'other' => 'new'}))
|
34
|
+
assert(@obj.item_changed?(['alcn', 'key'], 'new'))
|
35
35
|
@website.verify
|
36
36
|
@node.verify
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
|
41
|
-
refute(@obj.node_referenced?(['other', nil], 'mi', 'alcn'))
|
39
|
+
def test_referenced_nodes
|
40
|
+
assert_equal(['alcn'], @obj.referenced_nodes(['alcn', nil], 'mi'))
|
42
41
|
end
|
43
42
|
|
44
43
|
end
|
@@ -36,26 +36,24 @@ class TestItemTrackerNodes < MiniTest::Unit::TestCase
|
|
36
36
|
@obj.item_data(*@args2))
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
39
|
+
def test_item_changed?
|
40
40
|
setup_default_nodes(@website.tree)
|
41
41
|
@website.ext.item_tracker = MiniTest::Mock.new
|
42
42
|
@website.ext.item_tracker.expect(:item_changed?, false, [:node_meta_info, nil])
|
43
43
|
|
44
44
|
[@args1, @args2].each do |args|
|
45
45
|
old_data = @obj.item_data(*args)
|
46
|
-
assert(@obj.
|
47
|
-
refute(@obj.
|
46
|
+
assert(@obj.item_changed?(args, []))
|
47
|
+
refute(@obj.item_changed?(args, old_data))
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
51
|
+
def test_referenced_nodes
|
52
52
|
setup_default_nodes(@website.tree)
|
53
53
|
|
54
|
-
assert(
|
55
|
-
|
56
|
-
|
57
|
-
assert(@obj.node_referenced?(@args2, @obj.item_data(*@args2), '/file.en.html'))
|
58
|
-
refute(@obj.node_referenced?(@args2, @obj.item_data(*@args2), '/other.en.html'))
|
54
|
+
assert(["/file.en.html", "/file.de.html", "/other.html", "/other.en.html", "/german.de.html",
|
55
|
+
"/dir/", "/dir2/"].map {|f| @website.tree[f]},
|
56
|
+
@obj.referenced_nodes(@args1, @obj.item_data(*@args1)))
|
59
57
|
end
|
60
58
|
|
61
59
|
end
|
@@ -22,20 +22,19 @@ class TestPathHandlerBase < MiniTest::Unit::TestCase
|
|
22
22
|
@obj = TestPathHandler.new(@website)
|
23
23
|
end
|
24
24
|
|
25
|
-
def test_content
|
26
|
-
assert_nil(@obj.content(nil))
|
27
|
-
end
|
28
|
-
|
29
25
|
def test_create_node
|
30
26
|
count = 0
|
31
27
|
assert_nil(@obj.create_node(Webgen::Path.new('/test.html', 'draft' => true)))
|
32
28
|
|
33
29
|
path = Webgen::Path.new('/path.html', 'dest_path' => '<parent><basename>(.<lang>)<ext>',
|
34
30
|
'modified_at' => 'unknown', 'parent_alcn' => '')
|
35
|
-
node = @obj.create_node(path) {|n| count += 1; assert_kind_of(Webgen::Node, n)}
|
31
|
+
node = @obj.create_node(path) {|n| count += 1; assert_kind_of(Webgen::PathHandler::Base::Node, n)}
|
36
32
|
assert_equal(path, node.node_info[:path])
|
37
33
|
assert_kind_of(Time, node.meta_info['modified_at'])
|
38
34
|
assert_equal(1, count)
|
35
|
+
assert_nil(node.content)
|
36
|
+
def (@obj).content(node); node; end
|
37
|
+
assert_equal(node, node.content)
|
39
38
|
|
40
39
|
second_node = @obj.create_node(path) {|n| count += 1}
|
41
40
|
assert_equal(1, count)
|
@@ -18,7 +18,7 @@ class TestPathHandlerPage < MiniTest::Unit::TestCase
|
|
18
18
|
path = Webgen::Path.new('/default.page', 'dest_path' => '<parent><basename><ext>') { StringIO.new('test') }
|
19
19
|
node = @page.create_nodes(path, ['content'])
|
20
20
|
refute_nil(node)
|
21
|
-
assert_equal(['content'],
|
21
|
+
assert_equal(['content'], node.blocks)
|
22
22
|
assert_equal('/default.en.html', node.alcn)
|
23
23
|
end
|
24
24
|
|
@@ -25,34 +25,62 @@ class TestPageUtils < MiniTest::Unit::TestCase
|
|
25
25
|
assert_equal('value', path.meta_info['key'])
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_template_chain
|
29
|
+
setup_website('path_handler.default_template' => 'default.template')
|
30
|
+
@website.expect(:cache, Webgen::Cache.new)
|
31
|
+
@root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
32
|
+
|
33
|
+
default_template = MyHandler::Node.new(@root, 'default.template', '/default.template')
|
34
|
+
default_de_template = MyHandler::Node.new(@root, 'default.template', '/default.de.template', {'lang' => 'de'})
|
35
|
+
other_template = MyHandler::Node.new(@root, 'other.template', '/other.template')
|
36
|
+
stopped_template = MyHandler::Node.new(@root, 'stopped.html', '/stopped.page', { 'template' => nil})
|
37
|
+
invalid_template = MyHandler::Node.new(@root, 'invalid.template', '/invalid.template', {'template' => 'invalidity'})
|
38
|
+
chained_template = MyHandler::Node.new(@root, 'chained.template', '/chained.template', {'template' => 'other.template'})
|
39
|
+
german_file = MyHandler::Node.new(@root, 'german.page', '/german.html', {'lang' => 'de', 'template' => 'other.template'})
|
40
|
+
dir = Webgen::Node.new(@root, 'dir/', '/dir/')
|
41
|
+
dir_default_template = MyHandler::Node.new(dir, 'default.template', '/dir/default.template')
|
42
|
+
dir_dir = Webgen::Node.new(dir, 'dir/', '/dir/dir/')
|
43
|
+
dir_dir_file = MyHandler::Node.new(dir_dir, 'file.page', '/dir/dir/file.html', {'lang' => 'en'})
|
44
|
+
|
45
|
+
assert_equal([], default_template.template_chain)
|
46
|
+
assert_equal([], stopped_template.template_chain)
|
47
|
+
assert_equal([default_template], other_template.template_chain)
|
48
|
+
assert_equal([default_template], invalid_template.template_chain)
|
49
|
+
assert_equal([default_template, other_template], chained_template.template_chain)
|
50
|
+
assert_equal([default_de_template, other_template], german_file.template_chain)
|
51
|
+
assert_equal([default_template], dir_default_template.template_chain)
|
52
|
+
assert_equal([default_template, dir_default_template], dir_dir_file.template_chain)
|
53
|
+
|
54
|
+
@website.cache.reset_volatile_cache
|
55
|
+
@root.tree.delete_node(default_template)
|
56
|
+
assert_equal([], other_template.template_chain)
|
57
|
+
end
|
58
|
+
|
28
59
|
def test_render_block
|
29
60
|
setup_context
|
30
|
-
node = @context.node
|
31
|
-
node.expect(:blocks, {'content' => 'mycontent'})
|
32
|
-
@context.node.expect(:meta_info, {})
|
33
61
|
@website.ext.content_processor = Webgen::ContentProcessor.new
|
34
|
-
@website.
|
35
|
-
|
62
|
+
node = MyHandler::Node.new(@website.tree.dummy_root, '/', '/')
|
63
|
+
node.node_info[:blocks] = {'content' => 'mycontent'}
|
36
64
|
|
37
65
|
# invalid block name
|
38
|
-
assert_raises(Webgen::RenderError) {
|
66
|
+
assert_raises(Webgen::RenderError) { node.render_block('unknown', @context) }
|
39
67
|
|
40
68
|
# nothing to render because pipeline is empty
|
41
|
-
|
69
|
+
node.render_block('content', @context)
|
42
70
|
assert_equal('mycontent', @context.content)
|
43
71
|
|
44
72
|
# invalid content processor
|
45
|
-
assert_raises(Webgen::Error) {
|
73
|
+
assert_raises(Webgen::Error) { node.render_block('content', @context, ['test']) }
|
46
74
|
|
47
75
|
node.meta_info['blocks'] = {'content' => {'pipeline' => ['test']}}
|
48
|
-
assert_raises(Webgen::Error) {
|
76
|
+
assert_raises(Webgen::Error) { node.render_block('content', @context) }
|
49
77
|
|
50
78
|
# with content processor
|
51
79
|
@website.ext.content_processor.register('test') {|ctx| ctx.content = 'test' + ctx.content; ctx}
|
52
|
-
|
80
|
+
node.render_block('content', @context)
|
53
81
|
assert_equal('testmycontent', @context.content)
|
54
82
|
|
55
|
-
|
83
|
+
node.render_block('content', @context, ['test', 'test'])
|
56
84
|
assert_equal('testtestmycontent', @context.content)
|
57
85
|
end
|
58
86
|
|
@@ -9,56 +9,16 @@ class TestPathHandlerTemplate < MiniTest::Unit::TestCase
|
|
9
9
|
|
10
10
|
include Webgen::TestHelper
|
11
11
|
|
12
|
-
def
|
13
|
-
setup_website
|
14
|
-
@website.
|
15
|
-
|
12
|
+
def test_create_nodes
|
13
|
+
setup_website
|
14
|
+
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
16
15
|
@template = Webgen::PathHandler::Template.new(@website)
|
17
|
-
@root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
18
|
-
end
|
19
16
|
|
20
|
-
def test_create_nodes
|
21
17
|
path = Webgen::Path.new('/default.template', 'dest_path' => '<parent><basename><ext>') { StringIO.new('test') }
|
22
18
|
node = @template.create_nodes(path, ['content'])
|
23
19
|
refute_nil(node)
|
24
|
-
assert_equal(['content'],
|
25
|
-
|
26
|
-
|
27
|
-
def test_template_chain
|
28
|
-
default_template = Webgen::Node.new(@root, 'default.template', '/default.template')
|
29
|
-
default_de_template = Webgen::Node.new(@root, 'default.template', '/default.de.template', {'lang' => 'de'})
|
30
|
-
other_template = Webgen::Node.new(@root, 'other.template', '/other.template')
|
31
|
-
stopped_template = Webgen::Node.new(@root, 'stopped.html', '/stopped.page', { 'template' => nil})
|
32
|
-
invalid_template = Webgen::Node.new(@root, 'invalid.template', '/invalid.template', {'template' => 'invalidity'})
|
33
|
-
chained_template = Webgen::Node.new(@root, 'chained.template', '/chained.template', {'template' => 'other.template'})
|
34
|
-
german_file = Webgen::Node.new(@root, 'german.page', '/german.html', {'lang' => 'de', 'template' => 'other.template'})
|
35
|
-
dir = Webgen::Node.new(@root, 'dir/', '/dir/')
|
36
|
-
dir_default_template = Webgen::Node.new(dir, 'default.template', '/dir/default.template')
|
37
|
-
dir_dir = Webgen::Node.new(dir, 'dir/', '/dir/dir/')
|
38
|
-
dir_dir_file = Webgen::Node.new(dir_dir, 'file.page', '/dir/dir/file.html', {'lang' => 'en'})
|
39
|
-
|
40
|
-
assert_equal([], @template.template_chain(default_template))
|
41
|
-
assert_equal([], @template.template_chain(stopped_template))
|
42
|
-
assert_equal([default_template], @template.template_chain(other_template))
|
43
|
-
assert_equal([default_template], @template.template_chain(invalid_template))
|
44
|
-
assert_equal([default_template, other_template], @template.template_chain(chained_template))
|
45
|
-
assert_equal([default_de_template, other_template], @template.template_chain(german_file))
|
46
|
-
assert_equal([default_template], @template.template_chain(dir_default_template))
|
47
|
-
assert_equal([default_template, dir_default_template], @template.template_chain(dir_dir_file))
|
48
|
-
|
49
|
-
@website.cache.reset_volatile_cache
|
50
|
-
@root.tree.delete_node(default_template)
|
51
|
-
assert_equal([], @template.template_chain(other_template))
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_default_template
|
55
|
-
dir = Webgen::Node.new(@root, 'dir/', '/dir/')
|
56
|
-
template = Webgen::Node.new(@root, 'default.template', '/default.template')
|
57
|
-
|
58
|
-
assert_equal(template, @template.default_template(@root, nil))
|
59
|
-
assert_equal(template, @template.default_template(dir, nil))
|
60
|
-
@website.tree.delete_node(template)
|
61
|
-
assert_nil(@template.default_template(@root, nil))
|
20
|
+
assert_equal(['content'], node.blocks)
|
21
|
+
assert(node['no_output'])
|
62
22
|
end
|
63
23
|
|
64
24
|
end
|