gettalong-webgen 0.5.8.20090507 → 0.5.9.20090620
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -6
- data/data/webgen/passive_sources/images/generated_by_webgen.png +0 -0
- data/data/webgen/passive_sources/images/webgen_logo.png +0 -0
- data/data/webgen/passive_sources/templates/atom_feed.template +38 -0
- data/data/webgen/passive_sources/templates/rss_feed.template +28 -0
- data/data/webgen/resources.yaml +2 -1
- data/doc/contentprocessor/builder.page +1 -1
- data/doc/contentprocessor/erb.page +5 -2
- data/doc/contentprocessor/erubis.page +2 -2
- data/doc/extensions.page +1 -1
- data/doc/manual.page +56 -26
- data/doc/reference_configuration.page +36 -1
- data/doc/reference_website_styles.page +1 -1
- data/doc/sourcehandler/feed.page +6 -11
- data/doc/tag/includefile.page +1 -1
- data/lib/webgen/cli/apply_command.rb +1 -1
- data/lib/webgen/cli/utils.rb +2 -2
- data/lib/webgen/common.rb +0 -9
- data/lib/webgen/contentprocessor/blocks.rb +60 -36
- data/lib/webgen/contentprocessor/builder.rb +2 -2
- data/lib/webgen/contentprocessor/erb.rb +3 -2
- data/lib/webgen/contentprocessor/erubis.rb +2 -2
- data/lib/webgen/contentprocessor/haml.rb +2 -2
- data/lib/webgen/contentprocessor/maruku.rb +1 -1
- data/lib/webgen/contentprocessor/sass.rb +2 -2
- data/lib/webgen/contentprocessor/tags.rb +25 -11
- data/lib/webgen/context.rb +4 -1
- data/lib/webgen/context/render.rb +32 -0
- data/lib/webgen/context/tags.rb +20 -0
- data/lib/webgen/default_config.rb +4 -1
- data/lib/webgen/deprecated.rb +37 -4
- data/lib/webgen/node.rb +37 -38
- data/lib/webgen/path.rb +151 -54
- data/lib/webgen/source.rb +6 -6
- data/lib/webgen/source/stacked.rb +13 -5
- data/lib/webgen/sourcehandler.rb +71 -45
- data/lib/webgen/sourcehandler/base.rb +51 -21
- data/lib/webgen/sourcehandler/copy.rb +4 -4
- data/lib/webgen/sourcehandler/directory.rb +3 -9
- data/lib/webgen/sourcehandler/feed.rb +23 -49
- data/lib/webgen/sourcehandler/fragment.rb +10 -8
- data/lib/webgen/sourcehandler/memory.rb +9 -10
- data/lib/webgen/sourcehandler/metainfo.rb +9 -9
- data/lib/webgen/sourcehandler/page.rb +5 -5
- data/lib/webgen/sourcehandler/sitemap.rb +3 -3
- data/lib/webgen/sourcehandler/template.rb +6 -6
- data/lib/webgen/sourcehandler/virtual.rb +19 -17
- data/lib/webgen/tag/base.rb +34 -26
- data/lib/webgen/tag/breadcrumbtrail.rb +3 -3
- data/lib/webgen/tag/executecommand.rb +3 -3
- data/lib/webgen/tag/langbar.rb +2 -2
- data/lib/webgen/tag/link.rb +3 -3
- data/lib/webgen/tag/menu.rb +2 -2
- data/lib/webgen/tag/metainfo.rb +1 -1
- data/lib/webgen/tag/relocatable.rb +17 -21
- data/lib/webgen/tag/tikz.rb +5 -6
- data/lib/webgen/tree.rb +7 -7
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/website.rb +4 -2
- data/misc/default.css +8 -2
- data/misc/default.template +2 -2
- data/misc/logo.svg +313 -0
- data/misc/style.page +1 -1
- data/test/helper.rb +2 -2
- data/test/test_common_sitemap.rb +1 -1
- data/test/test_contentprocessor_blocks.rb +12 -4
- data/test/test_contentprocessor_builder.rb +2 -1
- data/test/test_contentprocessor_erb.rb +2 -1
- data/test/test_contentprocessor_erubis.rb +1 -1
- data/test/test_contentprocessor_fragments.rb +12 -11
- data/test/test_contentprocessor_haml.rb +2 -1
- data/test/test_contentprocessor_maruku.rb +1 -0
- data/test/test_contentprocessor_rdiscount.rb +1 -0
- data/test/test_contentprocessor_rdoc.rb +1 -0
- data/test/test_contentprocessor_sass.rb +1 -0
- data/test/test_contentprocessor_tags.rb +13 -0
- data/test/test_context.rb +28 -0
- data/test/test_node.rb +40 -20
- data/test/test_path.rb +106 -65
- data/test/test_source_filesystem.rb +1 -1
- data/test/test_source_stacked.rb +19 -6
- data/test/test_sourcehandler_base.rb +53 -47
- data/test/test_sourcehandler_copy.rb +6 -6
- data/test/test_sourcehandler_directory.rb +8 -12
- data/test/test_sourcehandler_feed.rb +10 -6
- data/test/test_sourcehandler_fragment.rb +6 -5
- data/test/test_sourcehandler_main.rb +39 -0
- data/test/test_sourcehandler_memory.rb +4 -4
- data/test/test_sourcehandler_metainfo.rb +10 -10
- data/test/test_sourcehandler_page.rb +9 -9
- data/test/test_sourcehandler_sitemap.rb +4 -4
- data/test/test_sourcehandler_template.rb +14 -14
- data/test/test_sourcehandler_virtual.rb +9 -5
- data/test/test_tag_base.rb +2 -2
- data/test/test_tag_executecommand.rb +1 -1
- data/test/test_tag_link.rb +4 -3
- data/test/test_tag_menu.rb +15 -15
- data/test/test_tag_metainfo.rb +1 -0
- data/test/test_tag_relocatable.rb +2 -1
- data/test/test_tag_tikz.rb +3 -3
- data/test/test_tree.rb +8 -8
- data/test/test_website.rb +15 -0
- metadata +14 -14
- data/test/test_common.rb +0 -18
@@ -62,7 +62,7 @@ class TestSourceFileSystem < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_handling_of_invalid_link
|
65
|
-
return if Config::CONFIG['
|
65
|
+
return if Config::CONFIG['host_os'] =~ /mswin|mingw/
|
66
66
|
dir = File.join(Dir.tmpdir, 'webgen-link-test')
|
67
67
|
FileUtils.mkdir_p(dir)
|
68
68
|
FileUtils.touch(File.join(dir, 'test'))
|
data/test/test_source_stacked.rb
CHANGED
@@ -4,7 +4,7 @@ require 'test/unit'
|
|
4
4
|
require 'helper'
|
5
5
|
require 'webgen/source'
|
6
6
|
|
7
|
-
class
|
7
|
+
class TestSourceStacked < Test::Unit::TestCase
|
8
8
|
|
9
9
|
class TestSource
|
10
10
|
def initialize(paths); @paths = paths; end
|
@@ -14,23 +14,36 @@ class TestSourceFileSystemStacked < Test::Unit::TestCase
|
|
14
14
|
def test_initialize
|
15
15
|
source = Webgen::Source::Stacked.new
|
16
16
|
assert_equal([], source.stack)
|
17
|
-
source
|
17
|
+
assert_equal(false, source.cache_paths)
|
18
|
+
source = Webgen::Source::Stacked.new({'/dir' => 6}, true)
|
18
19
|
assert_equal([['/dir', 6]], source.stack)
|
20
|
+
assert_equal(true, source.cache_paths)
|
19
21
|
end
|
20
22
|
|
21
23
|
def test_add
|
22
24
|
source = Webgen::Source::Stacked.new
|
23
|
-
assert_raise(RuntimeError) { source.add(['dir', 6])}
|
24
|
-
|
25
|
-
|
25
|
+
assert_raise(RuntimeError) { source.add(['dir', 6]) }
|
26
|
+
|
27
|
+
test_source = TestSource.new([Webgen::Path.new('/temp')])
|
28
|
+
source.add('/temp/' => test_source)
|
29
|
+
assert_equal([['/temp/', test_source]], source.stack)
|
30
|
+
|
31
|
+
source.cache_paths = true
|
32
|
+
source.add('/dir/' => test_source)
|
33
|
+
source.paths
|
34
|
+
assert_raise(RuntimeError) { source.add('/dir1/' => test_source) }
|
26
35
|
end
|
27
36
|
|
28
37
|
def test_paths
|
29
38
|
source = Webgen::Source::Stacked.new
|
30
39
|
source.add('/' => TestSource.new([Webgen::Path.new('/hallo/dir'), Webgen::Path.new('/other')]))
|
31
|
-
source.add('/hallo' => TestSource.new([Webgen::Path.new('/dir'), Webgen::Path.new('/other')]))
|
40
|
+
source.add('/hallo/' => TestSource.new([Webgen::Path.new('/dir'), Webgen::Path.new('/other')]))
|
32
41
|
assert_equal(Set.new([Webgen::Path.new('/hallo/dir'), Webgen::Path.new('/other'),
|
33
42
|
Webgen::Path.new('/hallo/other')]), source.paths)
|
43
|
+
|
44
|
+
source.cache_paths = true
|
45
|
+
set = source.paths
|
46
|
+
assert_equal(set.object_id, source.paths.object_id)
|
34
47
|
end
|
35
48
|
|
36
49
|
end
|
@@ -21,89 +21,95 @@ class TestSourceHandlerBase < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_create_node
|
24
|
-
tree = Webgen::Tree.new
|
25
24
|
path = path_with_meta_info('/path.html')
|
26
25
|
count = 0
|
27
26
|
|
28
27
|
path.instance_eval { @source_path = '/path'}
|
29
|
-
node = @obj.create_node(tree.dummy_root
|
28
|
+
node = @obj.create_node(path, :parent => @website.tree.dummy_root) {|n| count +=1 }
|
30
29
|
assert_equal('/path', node.node_info[:src])
|
31
30
|
assert_equal('Object', node.node_info[:processor])
|
32
31
|
assert_kind_of(Time, node['modified_at'])
|
33
32
|
assert_equal(1, count)
|
34
33
|
|
35
|
-
other_node = @obj.create_node(tree.dummy_root
|
34
|
+
other_node = @obj.create_node(path, :parent => @website.tree.dummy_root) {|n| count +=1 }
|
36
35
|
assert_equal(node, other_node)
|
37
36
|
assert_equal(1, count)
|
38
37
|
|
39
38
|
node.flag(:reinit)
|
40
|
-
other_node = @obj.create_node(tree.dummy_root
|
39
|
+
other_node = @obj.create_node(path, :parent => @website.tree.dummy_root) {|n| count +=1 }
|
41
40
|
assert_equal(node, other_node)
|
42
41
|
assert_equal(2, count)
|
43
42
|
|
44
43
|
path.instance_eval { @source_path = '/other' }
|
45
|
-
other_node = @obj.create_node(tree.dummy_root
|
44
|
+
other_node = @obj.create_node(path, :parent => @website.tree.dummy_root) {|n| count +=1 }
|
46
45
|
assert_equal(node, other_node)
|
47
46
|
assert_equal(2, count)
|
48
47
|
end
|
49
48
|
|
50
49
|
def test_node_exists
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
assert_equal(child_de, @obj.node_exists?(node, path_with_meta_info('somename.
|
57
|
-
assert_equal(
|
58
|
-
|
59
|
-
|
60
|
-
assert_equal(
|
61
|
-
assert_equal(nil, @obj.node_exists?(node, path_with_meta_info('unknown')))
|
50
|
+
node = Webgen::Node.new(@website.tree.dummy_root, '/', '/', {'lang' => 'de', :test => :value})
|
51
|
+
child_de = Webgen::Node.new(node, '/somename.html', 'somename.html', {'lang' => 'de'})
|
52
|
+
frag_de = Webgen::Node.new(child_de, '/somename.html#data1', '#othertest')
|
53
|
+
|
54
|
+
assert_equal(child_de, @obj.node_exists?(path_with_meta_info('/somename.de.html')))
|
55
|
+
assert_equal(child_de, @obj.node_exists?(path_with_meta_info('/other.page'), @obj.output_path(node, path_with_meta_info('/somename.html'))))
|
56
|
+
assert_equal(false, @obj.node_exists?(path_with_meta_info('/somename.en.html', {'no_output' => true}),
|
57
|
+
@obj.output_path(node, path_with_meta_info('/somename.html'))))
|
58
|
+
assert_equal(frag_de, @obj.node_exists?(path_with_meta_info('/somename.de.html#othertest')))
|
59
|
+
assert_equal(nil, @obj.node_exists?(path_with_meta_info('/unknown')))
|
62
60
|
end
|
63
61
|
|
64
62
|
def test_output_path
|
65
|
-
node = Webgen::Node.new(Webgen::Tree.new.dummy_root, '
|
66
|
-
assert_raise(RuntimeError) { @obj.output_path(node, path_with_meta_info('test.page', 'output_path' => 'non'))}
|
63
|
+
node = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
64
|
+
assert_raise(RuntimeError) { @obj.output_path(node, path_with_meta_info('/test.page', 'output_path' => 'non'))}
|
67
65
|
end
|
68
66
|
|
69
67
|
def test_standard_output_path
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
assert_equal('test/path.html#frag1', @obj.output_path(frag, path))
|
68
|
+
node = Webgen::Node.new(@website.tree.dummy_root, '/', '/', {'lang' => 'de', :test => :value})
|
69
|
+
|
70
|
+
path = path_with_meta_info('/path.html')
|
71
|
+
assert_equal('/path.html', @obj.output_path(node, path))
|
72
|
+
path = path_with_meta_info('/path.en.html')
|
73
|
+
assert_equal('/path.html', @obj.output_path(node, path))
|
74
|
+
path = path_with_meta_info('/path.eo.html')
|
75
|
+
assert_equal('/path.eo.html', @obj.output_path(node, path))
|
76
|
+
path = path_with_meta_info('/dir/')
|
77
|
+
assert_equal('/dir/', @obj.output_path(node, path))
|
78
|
+
|
79
|
+
other = Webgen::Node.new(node, '/path.html', 'other.page')
|
80
|
+
path = path_with_meta_info('/path.html')
|
81
|
+
assert_equal('/path.html', @obj.output_path(node, path))
|
82
|
+
path = path_with_meta_info('/path.en.html')
|
83
|
+
assert_equal('/path.en.html', @obj.output_path(node, path))
|
84
|
+
|
85
|
+
path = path_with_meta_info('/path.html#frag')
|
86
|
+
assert_equal('/path.html#frag', @obj.output_path(other, path))
|
87
|
+
frag = Webgen::Node.new(other, '/path.html#frag', '#frag')
|
88
|
+
path = path_with_meta_info('/path.html#frag1')
|
89
|
+
assert_equal('/path.html#frag1', @obj.output_path(frag, path))
|
93
90
|
|
94
91
|
path = path_with_meta_info('/')
|
95
|
-
assert_equal('/', @obj.output_path(@tree.dummy_root, path))
|
96
|
-
path = path_with_meta_info('/', 'output_path_style' => [:parent, 'hallo', 56])
|
97
|
-
assert_equal('hallo/', @obj.output_path(@tree.dummy_root, path))
|
92
|
+
assert_equal('/', @obj.output_path(@website.tree.dummy_root, path))
|
93
|
+
path = path_with_meta_info('/test/', 'output_path_style' => [:parent, 'hallo', 56])
|
94
|
+
assert_equal('hallo/', @obj.output_path(@website.tree.dummy_root, path))
|
95
|
+
|
96
|
+
path = path_with_meta_info('/index.en.html')
|
97
|
+
assert_equal('/index.html', @obj.output_path(node, path))
|
98
|
+
index_en = Webgen::Node.new(node, '/index.html', 'index.page', {'lang' => 'en'})
|
99
|
+
assert_equal('/index.html', @obj.output_path(node, path))
|
100
|
+
path = path_with_meta_info('/index.en.html', 'output_path_style' => [:parent, 'hallo.html'])
|
101
|
+
assert_equal('/hallo.html', @obj.output_path(node, path))
|
102
|
+
path = path_with_meta_info('/other.de.html', 'output_path_style' => [:parent, 'index', ['.', :lang], :ext])
|
103
|
+
assert_equal('/index.de.html', @obj.output_path(node, path))
|
98
104
|
|
99
105
|
assert_raise(RuntimeError) do
|
100
|
-
path = path_with_meta_info('path.html', 'output_path_style' => [:parent, :year, '/', :month, '/', :
|
106
|
+
path = path_with_meta_info('/path.html', 'output_path_style' => [:parent, :year, '/', :month, '/', :basename, :ext])
|
101
107
|
@obj.output_path(node, path)
|
102
108
|
end
|
103
109
|
time = Time.parse('2008-09-04 08:15')
|
104
|
-
path = path_with_meta_info('path.html', 'output_path_style' => [:parent, :year, '/', :month, '/', :day, '-', :
|
110
|
+
path = path_with_meta_info('/path.html', 'output_path_style' => [:parent, :year, '/', :month, '/', :day, '-', :basename, :ext],
|
105
111
|
'created_at' => time)
|
106
|
-
assert_equal('
|
112
|
+
assert_equal('/2008/09/04-path.html', @obj.output_path(node, path))
|
107
113
|
end
|
108
114
|
|
109
115
|
def test_content
|
@@ -17,21 +17,21 @@ class TestSourceHandlerCopy < Test::Unit::TestCase
|
|
17
17
|
super
|
18
18
|
@website.config['contentprocessor.map']['test'] = 'TestSourceHandlerCopy::TestCP'
|
19
19
|
@obj = Webgen::SourceHandler::Copy.new
|
20
|
-
@root = Webgen::Node.new(
|
21
|
-
@without = @obj.create_node(
|
22
|
-
@with = @obj.create_node(
|
20
|
+
@root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
21
|
+
@without = @obj.create_node(path_with_meta_info('/default.css') {StringIO.new('# header')})
|
22
|
+
@with = @obj.create_node(path_with_meta_info('/other.test.css') {StringIO.new('# header')})
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_create_node
|
26
26
|
assert_not_nil(@without)
|
27
27
|
assert_equal(nil, @without.node_info[:preprocessor])
|
28
|
-
assert_equal('
|
28
|
+
assert_equal('/default.css', @without.path)
|
29
29
|
|
30
30
|
assert_not_nil(@with)
|
31
31
|
assert_equal('test', @with.node_info[:preprocessor])
|
32
|
-
assert_equal('
|
32
|
+
assert_equal('/other.css', @with.path)
|
33
33
|
|
34
|
-
node = @obj.create_node(
|
34
|
+
node = @obj.create_node(path_with_meta_info('/other.unknown.css') {StringIO.new('# header')})
|
35
35
|
assert_equal(nil, node.node_info[:preprocessor])
|
36
36
|
end
|
37
37
|
|
@@ -11,32 +11,28 @@ class TestSourceHandlerDirectory < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
def test_create_node
|
13
13
|
@obj = Webgen::SourceHandler::Directory.new
|
14
|
-
root = Webgen::Node.new(
|
15
|
-
node = @obj.create_node(
|
14
|
+
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
15
|
+
node = @obj.create_node(path_with_meta_info('/dir/', {:key => :value}) {StringIO.new('')})
|
16
16
|
assert_not_nil(node)
|
17
17
|
assert_equal(:value, node[:key])
|
18
18
|
|
19
19
|
node.flag(:reinit)
|
20
|
-
assert_equal(node, @obj.create_node(
|
20
|
+
assert_equal(node, @obj.create_node(path_with_meta_info('/dir/', {:key => :other}) {StringIO.new('')}))
|
21
21
|
assert_equal(:other, node[:key])
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_create_directories
|
25
25
|
@obj = Webgen::SourceHandler::Directory.new
|
26
26
|
shm = Webgen::SourceHandler::Main.new # for using service :create_nodes
|
27
|
-
root = Webgen::Node.new(
|
28
|
-
dir = @obj.create_node(
|
27
|
+
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
28
|
+
dir = @obj.create_node(path_with_meta_info('/dir/'))
|
29
29
|
|
30
|
-
assert_equal(dir, @obj.create_directories(root, '/dir/', path_with_meta_info('/
|
31
|
-
assert_equal(dir, @obj.create_directories(root, 'dir/', path_with_meta_info('/
|
32
|
-
assert_equal(dir, @obj.create_directories(root, 'dir', path_with_meta_info('/
|
30
|
+
assert_equal(dir, @obj.create_directories(root, '/dir/', path_with_meta_info('/')))
|
31
|
+
assert_equal(dir, @obj.create_directories(root, 'dir/', path_with_meta_info('/')))
|
32
|
+
assert_equal(dir, @obj.create_directories(root, 'dir', path_with_meta_info('/')))
|
33
33
|
|
34
34
|
which = @obj.create_directories(root, 'dir/under/which', path_with_meta_info('/test'))
|
35
35
|
assert_equal(which, @obj.create_directories(root, 'dir/under/which', path_with_meta_info('/test')))
|
36
36
|
end
|
37
37
|
|
38
|
-
def test_content
|
39
|
-
assert_equal('', Webgen::SourceHandler::Directory.new.content(nil))
|
40
|
-
end
|
41
|
-
|
42
38
|
end
|
@@ -20,8 +20,11 @@ hallo
|
|
20
20
|
EOF
|
21
21
|
def setup
|
22
22
|
super
|
23
|
+
shm = Webgen::SourceHandler::Main.new
|
24
|
+
@website.blackboard.del_listener(:node_meta_info_changed?, shm.method(:meta_info_changed?))
|
25
|
+
@website.config['passive_sources'] << ['/', "Webgen::Source::Resource", "webgen-passive-sources"]
|
23
26
|
@nodes = {
|
24
|
-
:root => root = Webgen::Node.new(
|
27
|
+
:root => root = Webgen::Node.new(@website.tree.dummy_root, '/', '/', {'index_path' => 'index.html'}),
|
25
28
|
:file1_en => Webgen::Node.new(root, '/file1.en.html', 'file1.html', {'lang' => 'en', 'in_menu' => true, 'modified_at' => Time.now}),
|
26
29
|
:index_en => Webgen::Node.new(root, '/index.en.html', 'index.html', {'lang' => 'en', 'modified_at' => Time.now - 1, 'author' => 'test'}),
|
27
30
|
}
|
@@ -31,7 +34,7 @@ EOF
|
|
31
34
|
end
|
32
35
|
|
33
36
|
def test_create_node
|
34
|
-
atom_node, rss_node = @obj.create_node(@
|
37
|
+
atom_node, rss_node = @obj.create_node(@path)
|
35
38
|
|
36
39
|
assert_not_nil(atom_node)
|
37
40
|
assert_not_nil(rss_node)
|
@@ -39,24 +42,24 @@ EOF
|
|
39
42
|
assert_equal('atom', atom_node.node_info[:feed_type])
|
40
43
|
assert_equal('rss', rss_node.node_info[:feed_type])
|
41
44
|
|
42
|
-
assert_equal([atom_node, rss_node], @obj.create_node(@
|
45
|
+
assert_equal([atom_node, rss_node], @obj.create_node(@path))
|
43
46
|
end
|
44
47
|
|
45
48
|
def test_content
|
46
|
-
atom_node, rss_node = @obj.create_node(@
|
49
|
+
atom_node, rss_node = @obj.create_node(@path)
|
47
50
|
assert_equal('hallo', rss_node.content)
|
48
51
|
assert(atom_node.content =~ /Thomas Leitner/)
|
49
52
|
assert(atom_node.content =~ /RealContent/)
|
50
53
|
end
|
51
54
|
|
52
55
|
def test_feed_entries
|
53
|
-
atom_node, rss_node = @obj.create_node(@
|
56
|
+
atom_node, rss_node = @obj.create_node(@path)
|
54
57
|
assert_equal([@nodes[:index_en]], atom_node.feed_entries)
|
55
58
|
assert_equal([@nodes[:index_en]], rss_node.feed_entries)
|
56
59
|
end
|
57
60
|
|
58
61
|
def test_node_changed
|
59
|
-
atom_node, rss_node = @obj.create_node(@
|
62
|
+
atom_node, rss_node = @obj.create_node(@path)
|
60
63
|
assert(atom_node.changed?)
|
61
64
|
|
62
65
|
atom_node.content # populate cache
|
@@ -68,6 +71,7 @@ EOF
|
|
68
71
|
atom_node.unflag(:dirty)
|
69
72
|
@nodes[:file1_en].unflag(:dirty)
|
70
73
|
@nodes[:index_en].unflag(:dirty)
|
74
|
+
@website.tree['/templates/atom_feed.template'].unflag(:dirty)
|
71
75
|
assert(!atom_node.changed?)
|
72
76
|
|
73
77
|
atom_node['entries'] = 'file.*.html'
|
@@ -44,19 +44,20 @@ EOF
|
|
44
44
|
|
45
45
|
def test_create_fragment_nodes
|
46
46
|
@obj = Webgen::SourceHandler::Fragment.new
|
47
|
-
root = Webgen::Node.new(
|
48
|
-
path = path_with_meta_info('hallo.html') {StringIO.new('')}
|
49
|
-
node = @obj.create_node(
|
47
|
+
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
48
|
+
path = path_with_meta_info('/hallo.html') {StringIO.new('')}
|
49
|
+
node = @obj.create_node(path)
|
50
50
|
@website.blackboard.add_service(:create_nodes, method(:create_nodes_service))
|
51
51
|
|
52
52
|
sections = @obj.parse_html_headers(YAML::load(TEST_CONTENT).first['data'])
|
53
53
|
@obj.create_fragment_nodes(sections, node, path, 'true')
|
54
|
+
assert_not_nil(root.tree['/hallo.html#test'])
|
54
55
|
assert_equal(node, node.resolve('#test').parent)
|
55
56
|
assert_equal(node.resolve('#test'), node.resolve('#other').parent)
|
56
57
|
end
|
57
58
|
|
58
|
-
def create_nodes_service(
|
59
|
-
[yield(
|
59
|
+
def create_nodes_service(path, sh)
|
60
|
+
[yield(path_with_meta_info(path.path))]
|
60
61
|
end
|
61
62
|
|
62
63
|
def check_sections(sections, valid)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webgen/website'
|
5
|
+
require 'tmpdir'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
class TestSourceHandlerMain < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_output_deletion
|
11
|
+
dir = nil
|
12
|
+
setup_task = lambda do
|
13
|
+
dir = File.join(Dir.tmpdir, 'webgen-' + Process.pid.to_s)
|
14
|
+
FileUtils.rm_rf(dir)
|
15
|
+
FileUtils.mkdir_p(dir)
|
16
|
+
FileUtils.mkdir_p(File.join(dir, 'src'))
|
17
|
+
FileUtils.touch(File.join(dir, 'src', 'test.jpg'))
|
18
|
+
end
|
19
|
+
|
20
|
+
setup_task.call
|
21
|
+
ws = Webgen::Website.new(dir, nil) {|c| c['output.do_deletion'] = false }
|
22
|
+
assert_equal(:success, ws.render)
|
23
|
+
assert(File.exists?(File.join(dir, 'out', 'test.jpg')))
|
24
|
+
FileUtils.rm_rf(File.join(dir, 'src', 'test.jpg'))
|
25
|
+
assert_equal(:success, ws.render)
|
26
|
+
assert(File.exists?(File.join(dir, 'out', 'test.jpg')))
|
27
|
+
|
28
|
+
setup_task.call
|
29
|
+
ws = Webgen::Website.new(dir, nil) {|c| c['output.do_deletion'] = true }
|
30
|
+
assert_equal(:success, ws.render)
|
31
|
+
assert(File.exists?(File.join(dir, 'out', 'test.jpg')))
|
32
|
+
FileUtils.rm_rf(File.join(dir, 'src', 'test.jpg'))
|
33
|
+
assert_equal(:success, ws.render)
|
34
|
+
assert(!File.exists?(File.join(dir, 'out', 'test.jpg')))
|
35
|
+
ensure
|
36
|
+
FileUtils.rm_rf(dir)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -11,18 +11,18 @@ class TestSourceHandlerMemory < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
def test_all
|
13
13
|
obj = Webgen::SourceHandler::Memory.new
|
14
|
-
root = Webgen::Node.new(
|
14
|
+
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
15
15
|
shm = Webgen::SourceHandler::Main.new # for using service :create_nodes
|
16
16
|
root.unflag(:dirty)
|
17
17
|
root.unflag(:created)
|
18
18
|
|
19
|
-
node = obj.create_node(
|
19
|
+
node = obj.create_node(path_with_meta_info('/test.png'), '/', 'data')
|
20
20
|
assert_equal('/', node.node_info[:memory_source_alcn])
|
21
21
|
assert_equal('data', obj.content(node))
|
22
22
|
assert(!node.flagged?(:reinit))
|
23
23
|
root.tree.delete_node(node)
|
24
24
|
|
25
|
-
node = obj.create_node(
|
25
|
+
node = obj.create_node(path_with_meta_info('/test.png'), '/') {|n| assert_equal(node, n); 'data'}
|
26
26
|
assert_equal('/', node.node_info[:memory_source_alcn])
|
27
27
|
assert_equal('data', obj.content(node))
|
28
28
|
assert(!node.flagged?(:reinit))
|
@@ -33,7 +33,7 @@ class TestSourceHandlerMemory < Test::Unit::TestCase
|
|
33
33
|
root.unflag(:dirty)
|
34
34
|
root.tree.delete_node(node)
|
35
35
|
|
36
|
-
node = obj.create_node(
|
36
|
+
node = obj.create_node(path_with_meta_info('/test.png'), '/', 'data')
|
37
37
|
assert_equal('/', node.node_info[:memory_source_alcn])
|
38
38
|
obj.instance_eval { @data = nil }
|
39
39
|
assert_nil(obj.content(node))
|
@@ -32,8 +32,8 @@ EOF
|
|
32
32
|
end
|
33
33
|
|
34
34
|
@obj = Webgen::SourceHandler::Metainfo.new
|
35
|
-
@root = Webgen::Node.new(
|
36
|
-
@node = @obj.create_node(
|
35
|
+
@root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
36
|
+
@node = @obj.create_node(path_with_meta_info('/metainfo', {}, @obj.class.name) {StringIO.new(CONTENT)})
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_create_node
|
@@ -43,20 +43,20 @@ EOF
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_empty_metainfo_file
|
46
|
-
node = @obj.create_node(
|
46
|
+
node = @obj.create_node(path_with_meta_info('/test', {}, @obj.class.name) {StringIO.new('')})
|
47
47
|
assert_equal({}, node.node_info[:mi_paths])
|
48
48
|
assert_equal({}, node.node_info[:mi_alcn])
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_meta_info_changed
|
52
|
-
other = TestSH.new.create_node(
|
52
|
+
other = TestSH.new.create_node(path_with_meta_info('/default.css'))
|
53
53
|
assert(!@obj.send(:meta_info_changed?, @node, other))
|
54
54
|
assert(@obj.send(:meta_info_changed?, @node, other, :force))
|
55
55
|
assert(!@obj.send(:meta_info_changed?, @node, other, :no_old_data))
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_mark_all_matched_dirty
|
59
|
-
other = TestSH.new.create_node(
|
59
|
+
other = TestSH.new.create_node(path_with_meta_info('/default.css'))
|
60
60
|
|
61
61
|
other.unflag(:dirty_meta_info)
|
62
62
|
@obj.send(:mark_all_matched_dirty, @node)
|
@@ -73,18 +73,18 @@ EOF
|
|
73
73
|
|
74
74
|
def test_before_node_created
|
75
75
|
path = path_with_meta_info('/default.css')
|
76
|
-
@website.blackboard.dispatch_msg(:before_node_created,
|
76
|
+
@website.blackboard.dispatch_msg(:before_node_created, path)
|
77
77
|
assert('valbef', path.meta_info['before'])
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_after_node_created
|
81
|
-
other = TestSH.new.create_node(
|
81
|
+
other = TestSH.new.create_node(path_with_meta_info('/default.css'))
|
82
82
|
@website.blackboard.dispatch_msg(:after_node_created, @node)
|
83
83
|
assert('valaft', other['after'])
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_before_node_deleted
|
87
|
-
other = TestSH.new.create_node(
|
87
|
+
other = TestSH.new.create_node(path_with_meta_info('/default.css'))
|
88
88
|
@website.blackboard.dispatch_msg(:before_node_deleted, @node)
|
89
89
|
assert(other.flagged?(:dirty_meta_info))
|
90
90
|
assert(@obj.nodes.empty?)
|
@@ -106,12 +106,12 @@ EOF
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def test_deletion_of_metainfo
|
109
|
-
other = TestSH.new.create_node(
|
109
|
+
other = TestSH.new.create_node(path_with_meta_info('/other.page'))
|
110
110
|
@website.blackboard.dispatch_msg(:after_node_created, other)
|
111
111
|
assert_equal('Not Other', other['title'])
|
112
112
|
|
113
113
|
@node.flag(:reinit)
|
114
|
-
@node = @obj.create_node(
|
114
|
+
@node = @obj.create_node(path_with_meta_info('/metainfo', {}, @obj.class.name) {StringIO.new("")})
|
115
115
|
assert(other.flagged?(:dirty_meta_info))
|
116
116
|
end
|
117
117
|
|