gettalong-webgen 0.5.4.20080929
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +5 -0
- data/COPYING +10 -0
- data/GPL +340 -0
- data/Rakefile +324 -0
- data/THANKS +17 -0
- data/bin/webgen +10 -0
- data/data/webgen/resources.yaml +3 -0
- data/data/webgen/webgui/controller/main.rb +129 -0
- data/data/webgen/webgui/overrides/win32console.rb +0 -0
- data/data/webgen/webgui/public/css/jquery.autocomplete.css +50 -0
- data/data/webgen/webgui/public/css/ramaze_error.css +90 -0
- data/data/webgen/webgui/public/css/style.css +55 -0
- data/data/webgen/webgui/public/img/headerbg.jpg +0 -0
- data/data/webgen/webgui/public/img/webgen_logo.png +0 -0
- data/data/webgen/webgui/public/js/jquery.autocomplete.js +15 -0
- data/data/webgen/webgui/public/js/jquery.js +32 -0
- data/data/webgen/webgui/view/create_website.xhtml +22 -0
- data/data/webgen/webgui/view/error.xhtml +64 -0
- data/data/webgen/webgui/view/index.xhtml +22 -0
- data/data/webgen/webgui/view/manage_website.xhtml +18 -0
- data/data/webgen/webgui/view/page.xhtml +40 -0
- data/data/webgen/website_skeleton/README +10 -0
- data/data/webgen/website_skeleton/Rakefile +40 -0
- data/data/webgen/website_skeleton/config.yaml +17 -0
- data/data/webgen/website_skeleton/ext/init.rb +6 -0
- data/data/webgen/website_styles/1024px/README +13 -0
- data/data/webgen/website_styles/1024px/src/default.css +188 -0
- data/data/webgen/website_styles/1024px/src/default.template +60 -0
- data/data/webgen/website_styles/1024px/src/images/background.gif +0 -0
- data/data/webgen/website_styles/andreas00/README +13 -0
- data/data/webgen/website_styles/andreas00/src/default.css +290 -0
- data/data/webgen/website_styles/andreas00/src/default.template +60 -0
- data/data/webgen/website_styles/andreas00/src/images/bg.gif +0 -0
- data/data/webgen/website_styles/andreas00/src/images/front.jpg +0 -0
- data/data/webgen/website_styles/andreas00/src/images/menubg.gif +0 -0
- data/data/webgen/website_styles/andreas00/src/images/menubg2.gif +0 -0
- data/data/webgen/website_styles/andreas01/README +14 -0
- data/data/webgen/website_styles/andreas01/src/default.css +310 -0
- data/data/webgen/website_styles/andreas01/src/default.template +61 -0
- data/data/webgen/website_styles/andreas01/src/images/bg.gif +0 -0
- data/data/webgen/website_styles/andreas01/src/images/front.jpg +0 -0
- data/data/webgen/website_styles/andreas01/src/print.css +35 -0
- data/data/webgen/website_styles/andreas03/README +14 -0
- data/data/webgen/website_styles/andreas03/src/default.css +223 -0
- data/data/webgen/website_styles/andreas03/src/default.template +58 -0
- data/data/webgen/website_styles/andreas03/src/images/bodybg.png +0 -0
- data/data/webgen/website_styles/andreas03/src/images/contbg.png +0 -0
- data/data/webgen/website_styles/andreas03/src/images/footerbg.png +0 -0
- data/data/webgen/website_styles/andreas03/src/images/gradient1.png +0 -0
- data/data/webgen/website_styles/andreas03/src/images/gradient2.png +0 -0
- data/data/webgen/website_styles/andreas04/README +15 -0
- data/data/webgen/website_styles/andreas04/src/default.css +290 -0
- data/data/webgen/website_styles/andreas04/src/default.template +81 -0
- data/data/webgen/website_styles/andreas04/src/images/blinkarrow.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/bodybg.png +0 -0
- data/data/webgen/website_styles/andreas04/src/images/contentbg.png +0 -0
- data/data/webgen/website_styles/andreas04/src/images/entrybg.png +0 -0
- data/data/webgen/website_styles/andreas04/src/images/flash.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/flash2.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/globe.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/globebottom.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/linkarrow.gif +0 -0
- data/data/webgen/website_styles/andreas04/src/images/menuhover.png +0 -0
- data/data/webgen/website_styles/andreas05/README +14 -0
- data/data/webgen/website_styles/andreas05/src/default.css +33 -0
- data/data/webgen/website_styles/andreas05/src/default.template +40 -0
- data/data/webgen/website_styles/andreas05/src/images/bodybg.gif +0 -0
- data/data/webgen/website_styles/andreas05/src/images/front.png +0 -0
- data/data/webgen/website_styles/andreas06/README +14 -0
- data/data/webgen/website_styles/andreas06/src/default.css +354 -0
- data/data/webgen/website_styles/andreas06/src/default.template +70 -0
- data/data/webgen/website_styles/andreas06/src/images/bodybg.gif +0 -0
- data/data/webgen/website_styles/andreas06/src/images/boxbg.gif +0 -0
- data/data/webgen/website_styles/andreas06/src/images/greypx.gif +0 -0
- data/data/webgen/website_styles/andreas06/src/images/header.jpg +0 -0
- data/data/webgen/website_styles/andreas06/src/images/innerbg.gif +0 -0
- data/data/webgen/website_styles/andreas06/src/images/leaves.jpg +0 -0
- data/data/webgen/website_styles/andreas06/src/images/tabs.gif +0 -0
- data/data/webgen/website_styles/andreas07/README +15 -0
- data/data/webgen/website_styles/andreas07/src/browserfix.css +7 -0
- data/data/webgen/website_styles/andreas07/src/default.css +92 -0
- data/data/webgen/website_styles/andreas07/src/default.template +42 -0
- data/data/webgen/website_styles/andreas07/src/images/bodybg.gif +0 -0
- data/data/webgen/website_styles/andreas07/src/images/sidebarbg.gif +0 -0
- data/data/webgen/website_styles/andreas08/README +14 -0
- data/data/webgen/website_styles/andreas08/src/default.css +224 -0
- data/data/webgen/website_styles/andreas08/src/default.template +51 -0
- data/data/webgen/website_styles/andreas09/README +14 -0
- data/data/webgen/website_styles/andreas09/src/default.css +308 -0
- data/data/webgen/website_styles/andreas09/src/default.template +68 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-black.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-green.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-orange.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-purple.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg-red.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/bodybg.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/footerbg.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-black.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-green.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-orange.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-purple.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover-red.jpg +0 -0
- data/data/webgen/website_styles/andreas09/src/images/menuhover.jpg +0 -0
- data/data/webgen/website_styles/simple/README +6 -0
- data/data/webgen/website_styles/simple/src/default.css +84 -0
- data/data/webgen/website_styles/simple/src/default.template +36 -0
- data/data/webgen/website_templates/default/README +6 -0
- data/data/webgen/website_templates/default/src/index.page +8 -0
- data/data/webgen/website_templates/project/README +5 -0
- data/data/webgen/website_templates/project/src/about.page +12 -0
- data/data/webgen/website_templates/project/src/download.page +15 -0
- data/data/webgen/website_templates/project/src/features.page +8 -0
- data/data/webgen/website_templates/project/src/index.page +9 -0
- data/data/webgen/website_templates/project/src/screenshots.page +18 -0
- data/doc/contentprocessor.template +11 -0
- data/doc/contentprocessor/blocks.page +66 -0
- data/doc/contentprocessor/builder.page +80 -0
- data/doc/contentprocessor/erb.page +56 -0
- data/doc/contentprocessor/erubis.page +46 -0
- data/doc/contentprocessor/haml.page +47 -0
- data/doc/contentprocessor/maruku.page +41 -0
- data/doc/contentprocessor/rdiscount.page +37 -0
- data/doc/contentprocessor/rdoc.page +36 -0
- data/doc/contentprocessor/redcloth.page +39 -0
- data/doc/contentprocessor/sass.page +31 -0
- data/doc/contentprocessor/tags.page +73 -0
- data/doc/extensions.metainfo +29 -0
- data/doc/extensions.page +16 -0
- data/doc/extensions.template +17 -0
- data/doc/faq.page +214 -0
- data/doc/getting_started.page +134 -0
- data/doc/index.page +65 -0
- data/doc/manual.page +532 -0
- data/doc/reference_configuration.page +646 -0
- data/doc/reference_metainfo.page +213 -0
- data/doc/sourcehandler.template +21 -0
- data/doc/sourcehandler/copy.page +19 -0
- data/doc/sourcehandler/directory.page +27 -0
- data/doc/sourcehandler/feed.page +82 -0
- data/doc/sourcehandler/metainfo.page +41 -0
- data/doc/sourcehandler/page.page +30 -0
- data/doc/sourcehandler/sitemap.page +46 -0
- data/doc/sourcehandler/template.page +45 -0
- data/doc/sourcehandler/virtual.page +49 -0
- data/doc/tag.template +25 -0
- data/doc/tag/breadcrumbtrail.page +40 -0
- data/doc/tag/coderay.page +49 -0
- data/doc/tag/date.page +31 -0
- data/doc/tag/executecommand.page +26 -0
- data/doc/tag/includefile.page +32 -0
- data/doc/tag/langbar.page +22 -0
- data/doc/tag/menu.page +92 -0
- data/doc/tag/metainfo.page +29 -0
- data/doc/tag/relocatable.page +38 -0
- data/doc/tag/sitemap.page +31 -0
- data/doc/upgrading.page +139 -0
- data/doc/webgen_page_format.page +128 -0
- data/lib/webgen/blackboard.rb +73 -0
- data/lib/webgen/cache.rb +85 -0
- data/lib/webgen/cli.rb +118 -0
- data/lib/webgen/cli/create_command.rb +64 -0
- data/lib/webgen/cli/run_command.rb +20 -0
- data/lib/webgen/cli/utils.rb +86 -0
- data/lib/webgen/cli/webgui_command.rb +49 -0
- data/lib/webgen/common.rb +10 -0
- data/lib/webgen/common/sitemap.rb +76 -0
- data/lib/webgen/configuration.rb +147 -0
- data/lib/webgen/contentprocessor.rb +96 -0
- data/lib/webgen/contentprocessor/blocks.rb +46 -0
- data/lib/webgen/contentprocessor/builder.rb +26 -0
- data/lib/webgen/contentprocessor/context.rb +90 -0
- data/lib/webgen/contentprocessor/erb.rb +24 -0
- data/lib/webgen/contentprocessor/erubis.rb +40 -0
- data/lib/webgen/contentprocessor/haml.rb +25 -0
- data/lib/webgen/contentprocessor/maruku.rb +18 -0
- data/lib/webgen/contentprocessor/rdiscount.rb +15 -0
- data/lib/webgen/contentprocessor/rdoc.rb +17 -0
- data/lib/webgen/contentprocessor/redcloth.rb +15 -0
- data/lib/webgen/contentprocessor/sass.rb +18 -0
- data/lib/webgen/contentprocessor/tags.rb +134 -0
- data/lib/webgen/coreext.rb +10 -0
- data/lib/webgen/default_config.rb +198 -0
- data/lib/webgen/languages.rb +578 -0
- data/lib/webgen/loggable.rb +23 -0
- data/lib/webgen/logger.rb +78 -0
- data/lib/webgen/node.rb +347 -0
- data/lib/webgen/output.rb +37 -0
- data/lib/webgen/output/filesystem.rb +67 -0
- data/lib/webgen/page.rb +133 -0
- data/lib/webgen/path.rb +182 -0
- data/lib/webgen/source.rb +24 -0
- data/lib/webgen/source/filesystem.rb +58 -0
- data/lib/webgen/source/resource.rb +42 -0
- data/lib/webgen/source/stacked.rb +53 -0
- data/lib/webgen/sourcehandler.rb +202 -0
- data/lib/webgen/sourcehandler/base.rb +211 -0
- data/lib/webgen/sourcehandler/copy.rb +41 -0
- data/lib/webgen/sourcehandler/directory.rb +31 -0
- data/lib/webgen/sourcehandler/feed.rb +121 -0
- data/lib/webgen/sourcehandler/fragment.rb +71 -0
- data/lib/webgen/sourcehandler/metainfo.rb +117 -0
- data/lib/webgen/sourcehandler/page.rb +77 -0
- data/lib/webgen/sourcehandler/sitemap.rb +60 -0
- data/lib/webgen/sourcehandler/template.rb +68 -0
- data/lib/webgen/sourcehandler/virtual.rb +75 -0
- data/lib/webgen/tag.rb +23 -0
- data/lib/webgen/tag/base.rb +162 -0
- data/lib/webgen/tag/breadcrumbtrail.rb +71 -0
- data/lib/webgen/tag/coderay.rb +32 -0
- data/lib/webgen/tag/date.rb +18 -0
- data/lib/webgen/tag/executecommand.rb +29 -0
- data/lib/webgen/tag/includefile.rb +42 -0
- data/lib/webgen/tag/langbar.rb +52 -0
- data/lib/webgen/tag/menu.rb +186 -0
- data/lib/webgen/tag/metainfo.rb +25 -0
- data/lib/webgen/tag/relocatable.rb +53 -0
- data/lib/webgen/tag/sitemap.rb +42 -0
- data/lib/webgen/tree.rb +80 -0
- data/lib/webgen/version.rb +6 -0
- data/lib/webgen/webgentask.rb +148 -0
- data/lib/webgen/website.rb +214 -0
- data/lib/webgen/websiteaccess.rb +29 -0
- data/lib/webgen/websitemanager.rb +125 -0
- data/man/man1/webgen.1 +67 -0
- data/misc/default.css +360 -0
- data/misc/default.template +75 -0
- data/misc/htmldoc.metainfo +25 -0
- data/misc/htmldoc.virtual +5 -0
- data/misc/images/arrow.gif +0 -0
- data/misc/images/error.gif +0 -0
- data/misc/images/exclamation.gif +0 -0
- data/misc/images/headerbg.jpg +0 -0
- data/misc/images/information.gif +0 -0
- data/misc/images/quote.gif +0 -0
- data/setup.rb +1585 -0
- data/test/helper.rb +41 -0
- data/test/test_blackboard.rb +58 -0
- data/test/test_cache.rb +57 -0
- data/test/test_common_sitemap.rb +56 -0
- data/test/test_configuration.rb +66 -0
- data/test/test_contentprocessor.rb +31 -0
- data/test/test_contentprocessor_blocks.rb +34 -0
- data/test/test_contentprocessor_builder.rb +19 -0
- data/test/test_contentprocessor_context.rb +38 -0
- data/test/test_contentprocessor_erb.rb +20 -0
- data/test/test_contentprocessor_erubis.rb +47 -0
- data/test/test_contentprocessor_haml.rb +20 -0
- data/test/test_contentprocessor_maruku.rb +27 -0
- data/test/test_contentprocessor_rdiscount.rb +15 -0
- data/test/test_contentprocessor_rdoc.rb +16 -0
- data/test/test_contentprocessor_redcloth.rb +12 -0
- data/test/test_contentprocessor_sass.rb +20 -0
- data/test/test_contentprocessor_tags.rb +97 -0
- data/test/test_languages.rb +53 -0
- data/test/test_loggable.rb +30 -0
- data/test/test_logger.rb +73 -0
- data/test/test_node.rb +339 -0
- data/test/test_output_filesystem.rb +58 -0
- data/test/test_page.rb +203 -0
- data/test/test_path.rb +131 -0
- data/test/test_source_filesystem.rb +59 -0
- data/test/test_source_resource.rb +26 -0
- data/test/test_source_stacked.rb +34 -0
- data/test/test_sourcehandler_base.rb +92 -0
- data/test/test_sourcehandler_copy.rb +45 -0
- data/test/test_sourcehandler_directory.rb +25 -0
- data/test/test_sourcehandler_feed.rb +74 -0
- data/test/test_sourcehandler_fragment.rb +67 -0
- data/test/test_sourcehandler_metainfo.rb +93 -0
- data/test/test_sourcehandler_page.rb +70 -0
- data/test/test_sourcehandler_sitemap.rb +47 -0
- data/test/test_sourcehandler_template.rb +63 -0
- data/test/test_sourcehandler_virtual.rb +56 -0
- data/test/test_tag_base.rb +82 -0
- data/test/test_tag_breadcrumbtrail.rb +89 -0
- data/test/test_tag_coderay.rb +30 -0
- data/test/test_tag_date.rb +16 -0
- data/test/test_tag_executecommand.rb +39 -0
- data/test/test_tag_includefile.rb +48 -0
- data/test/test_tag_langbar.rb +60 -0
- data/test/test_tag_menu.rb +195 -0
- data/test/test_tag_metainfo.rb +17 -0
- data/test/test_tag_relocatable.rb +57 -0
- data/test/test_tag_sitemap.rb +44 -0
- data/test/test_tree.rb +69 -0
- data/test/test_webgentask.rb +21 -0
- data/test/test_website.rb +96 -0
- data/test/test_websiteaccess.rb +23 -0
- data/test/test_websitemanager.rb +68 -0
- metadata +575 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'webgen/output/filesystem'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
class TestOutputFileSystem < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Test::WebsiteHelper
|
10
|
+
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
@website = Webgen::Website.new(File.join(Dir.tmpdir, 'test_webgen'), nil)
|
14
|
+
@website.init
|
15
|
+
Thread.current[:webgen_website] = @website
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
super
|
20
|
+
FileUtils.rm_rf(File.join(Dir.tmpdir, 'test_webgen'))
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_initialize
|
24
|
+
output = Webgen::Output::FileSystem.new('test')
|
25
|
+
assert_equal(File.join(@website.directory, 'test'), output.root)
|
26
|
+
output = Webgen::Output::FileSystem.new('/tmp/hallo')
|
27
|
+
assert_equal('/tmp/hallo', output.root)
|
28
|
+
output = Webgen::Output::FileSystem.new('../hallo')
|
29
|
+
assert_equal(File.join(@website.directory, '../hallo'), output.root)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_file_methods
|
33
|
+
output = Webgen::Output::FileSystem.new('test')
|
34
|
+
assert(!output.exists?('/dir/hallo'))
|
35
|
+
|
36
|
+
output.write('/dir/hallo', 'content', :file)
|
37
|
+
assert(File.file?(File.join(output.root, 'dir/hallo')))
|
38
|
+
assert(output.exists?('/dir/hallo'))
|
39
|
+
assert_equal('content', File.read(File.join(output.root, 'dir/hallo')))
|
40
|
+
assert_equal('content', output.read('/dir/hallo'))
|
41
|
+
|
42
|
+
output.delete('/dir/hallo')
|
43
|
+
assert(!output.exists?('/dir/hallo'))
|
44
|
+
|
45
|
+
output.write('/dir/hallo', Webgen::Path::SourceIO.new { StringIO.new('content')}, :file)
|
46
|
+
assert_equal('content', File.read(File.join(output.root, 'dir/hallo')))
|
47
|
+
assert(output.exists?('/dir/hallo'))
|
48
|
+
|
49
|
+
output.delete('/dir')
|
50
|
+
assert(!output.exists?('/dir'))
|
51
|
+
|
52
|
+
output.write('/dir', '', :directory)
|
53
|
+
assert(File.directory?(File.join(output.root, 'dir')))
|
54
|
+
|
55
|
+
assert_raise(RuntimeError) { output.write('other', '', :unknown) }
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/test/test_page.rb
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'webgen/page'
|
3
|
+
|
4
|
+
class TestBlock < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_render
|
7
|
+
block = Webgen::Block.new('content', 'some content', {'pipeline' => 'test'})
|
8
|
+
context = {:processors => {}}
|
9
|
+
assert_raise(RuntimeError) { block.render(context) }
|
10
|
+
context[:processors]['test'] = lambda {|context| context[:content] = context[:content].reverse + context[:block].name }
|
11
|
+
assert_equal('some content'.reverse + 'content', block.render(context)[:content])
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class TestPage < Test::Unit::TestCase
|
17
|
+
|
18
|
+
VALID = <<EOF
|
19
|
+
# with more blocks
|
20
|
+
- in: |
|
21
|
+
---
|
22
|
+
key: value
|
23
|
+
---
|
24
|
+
block1
|
25
|
+
---
|
26
|
+
block2
|
27
|
+
--- name:block3
|
28
|
+
--- name:block4
|
29
|
+
yes
|
30
|
+
meta_info: {key: value}
|
31
|
+
blocks:
|
32
|
+
- name: content
|
33
|
+
content: "block1"
|
34
|
+
- name: block2
|
35
|
+
content: "block2"
|
36
|
+
- name: block3
|
37
|
+
content: ''
|
38
|
+
- name: block4
|
39
|
+
content: 'yes'
|
40
|
+
|
41
|
+
# empty file
|
42
|
+
- in: ""
|
43
|
+
meta_info: {}
|
44
|
+
blocks:
|
45
|
+
- name: content
|
46
|
+
content: ''
|
47
|
+
|
48
|
+
# without meta info
|
49
|
+
- in: "hallo"
|
50
|
+
meta_info: {}
|
51
|
+
blocks:
|
52
|
+
- name: content
|
53
|
+
content: "hallo"
|
54
|
+
|
55
|
+
# with empty block
|
56
|
+
- in: |
|
57
|
+
---
|
58
|
+
key: value
|
59
|
+
|
60
|
+
---
|
61
|
+
|
62
|
+
meta_info: {key: value}
|
63
|
+
blocks:
|
64
|
+
- name: content
|
65
|
+
content: ''
|
66
|
+
|
67
|
+
# with only meta information, no blocks
|
68
|
+
- in: |
|
69
|
+
---
|
70
|
+
key: value
|
71
|
+
|
72
|
+
meta_info: {key: value}
|
73
|
+
blocks:
|
74
|
+
- name: content
|
75
|
+
content: ''
|
76
|
+
|
77
|
+
# block with escaped ---
|
78
|
+
- in: |
|
79
|
+
before
|
80
|
+
\\--- in
|
81
|
+
after
|
82
|
+
meta_info: {}
|
83
|
+
blocks:
|
84
|
+
- name: content
|
85
|
+
content: "before\\n--- in\\nafter"
|
86
|
+
|
87
|
+
# no meta info, starting with block with name
|
88
|
+
- in: |
|
89
|
+
--- name:block1
|
90
|
+
meta_info: {}
|
91
|
+
blocks:
|
92
|
+
- name: block1
|
93
|
+
content: ''
|
94
|
+
|
95
|
+
# named block and block with other options
|
96
|
+
- in: |
|
97
|
+
--- name:block
|
98
|
+
content doing -
|
99
|
+
with?: with some things
|
100
|
+
--- other:options test1:true test2:false test3:542
|
101
|
+
meta_info: {}
|
102
|
+
blocks:
|
103
|
+
- name: block
|
104
|
+
content: "content doing -\\nwith?: with some things"
|
105
|
+
- name: block2
|
106
|
+
content: ''
|
107
|
+
options: {other: options, test1: true, test2: false, test3: 542}
|
108
|
+
|
109
|
+
# block with seemingly block start line it
|
110
|
+
- in: |
|
111
|
+
--- name:block
|
112
|
+
content
|
113
|
+
----------- some block start???
|
114
|
+
things
|
115
|
+
meta_info: {}
|
116
|
+
blocks:
|
117
|
+
- name: block
|
118
|
+
content: "content\\n----------- some block start???\\nthings"
|
119
|
+
EOF
|
120
|
+
|
121
|
+
INVALID=<<EOF
|
122
|
+
# invalid meta info: none specified
|
123
|
+
- "---\\n---"
|
124
|
+
|
125
|
+
# invalid meta info: no hash
|
126
|
+
- |
|
127
|
+
---
|
128
|
+
doit
|
129
|
+
---
|
130
|
+
asdf kadsfakl
|
131
|
+
|
132
|
+
# invalid meta info: not in yaml format
|
133
|
+
- |
|
134
|
+
---
|
135
|
+
- doit
|
136
|
+
: * [ }
|
137
|
+
---
|
138
|
+
asdf kadsfakl
|
139
|
+
|
140
|
+
# two blocks with same name
|
141
|
+
- |
|
142
|
+
aasdf
|
143
|
+
asdfdf
|
144
|
+
--- name:name
|
145
|
+
asdkf dsaf
|
146
|
+
--- name:name
|
147
|
+
asdf adsf
|
148
|
+
|
149
|
+
# invalid format
|
150
|
+
- |
|
151
|
+
asdfasd
|
152
|
+
dfdf
|
153
|
+
--- name, incorrect_format
|
154
|
+
lsldf
|
155
|
+
EOF
|
156
|
+
|
157
|
+
def test_invalid_pagefiles
|
158
|
+
testdata = YAML::load(INVALID)
|
159
|
+
testdata.each_with_index do |data, index|
|
160
|
+
assert_raise(Webgen::WebgenPageFormatError, "test item #{index}") { Webgen::Page.from_data(data) }
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_valid_pagefiles
|
165
|
+
YAML::load(VALID).each_with_index do |data, oindex|
|
166
|
+
d = Webgen::Page.from_data(data['in'])
|
167
|
+
assert_equal(data['meta_info'], d.meta_info, "test item #{oindex} - meta info")
|
168
|
+
assert_equal(data['blocks'].length*2, d.blocks.length)
|
169
|
+
data['blocks'].each_with_index do |b, index|
|
170
|
+
index += 1
|
171
|
+
assert_equal(b['name'], d.blocks[index].name, "test item #{oindex} - name")
|
172
|
+
assert_equal(b['content'], d.blocks[index].content, "test item #{oindex} - content")
|
173
|
+
assert_equal(b['options'] || {}, d.blocks[index].options, "test item #{oindex} - options")
|
174
|
+
assert_same(d.blocks[index], d.blocks[b['name']])
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_default_values
|
180
|
+
valid = YAML::load(VALID)
|
181
|
+
d = Webgen::Page.from_data(valid[0]['in'], 'blocks' => {1 => { 'name' => 'other1'}, 2 => { 'name' => 'block7'}})
|
182
|
+
assert_equal({'key' => 'value'}, d.meta_info)
|
183
|
+
assert_equal('other1', d.blocks[1].name)
|
184
|
+
assert_equal('block7', d.blocks[2].name)
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_eol_encodings
|
188
|
+
d = Webgen::Page.from_data("---\ntitle: test\r---\r\ncontent")
|
189
|
+
assert_equal({'title' => 'test'}, d.meta_info)
|
190
|
+
assert_equal('content', d.blocks['content'].content)
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_meta_info_dupped
|
194
|
+
mi = {'key' => 'value'}
|
195
|
+
d = Webgen::Page.from_data("---\ntitle: test\n---\ncontent", mi)
|
196
|
+
assert_equal({'title' => 'test', 'key' => 'value'}, d.meta_info)
|
197
|
+
assert_not_same(mi, d.meta_info)
|
198
|
+
d = Webgen::Page.from_data("content", mi)
|
199
|
+
assert_equal({'key' => 'value'}, d.meta_info)
|
200
|
+
assert_not_same(mi, d.meta_info)
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
data/test/test_path.rb
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'webgen/path'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
class TestPath < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_initialize
|
8
|
+
check_proc = proc do |o, path, dir, bn, lang, ext, cn, oi, title|
|
9
|
+
assert_equal(path, o.path)
|
10
|
+
assert_equal(dir, o.directory)
|
11
|
+
assert_equal(bn, o.cnbase)
|
12
|
+
assert_equal(lang, o.meta_info['lang'])
|
13
|
+
assert_equal(ext, o.ext)
|
14
|
+
assert_equal(cn, o.cn)
|
15
|
+
assert_equal(oi, o.meta_info['sort_info'])
|
16
|
+
assert_equal(title, o.meta_info['title'])
|
17
|
+
end
|
18
|
+
check_proc.call(Webgen::Path.new('5.base_name-one.de.page'),
|
19
|
+
'5.base_name-one.de.page', './', 'base_name-one', 'de', 'page', 'base_name-one.page', 5, 'Base name one')
|
20
|
+
check_proc.call(Webgen::Path.new('dir/default.png'),
|
21
|
+
'dir/default.png', 'dir/', 'default', nil, 'png', 'default.png', nil, 'Default')
|
22
|
+
check_proc.call(Webgen::Path.new('default.en.png'),
|
23
|
+
'default.en.png', './', 'default', 'en', 'png', 'default.png', nil, 'Default')
|
24
|
+
check_proc.call(Webgen::Path.new('default.deu.png'),
|
25
|
+
'default.deu.png', './', 'default', 'de', 'png', 'default.png', nil, 'Default')
|
26
|
+
check_proc.call(Webgen::Path.new('default.template'),
|
27
|
+
'default.template', './', 'default', nil, 'template', 'default.template', nil, 'Default')
|
28
|
+
check_proc.call(Webgen::Path.new('default.en.tar.bz2'),
|
29
|
+
'default.en.tar.bz2', './', 'default', 'en', 'tar.bz2', 'default.tar.bz2', nil, 'Default')
|
30
|
+
check_proc.call(Webgen::Path.new('default.tar.bz2'),
|
31
|
+
'default.tar.bz2', './', 'default', nil, 'tar.bz2', 'default.tar.bz2', nil, 'Default')
|
32
|
+
check_proc.call(Webgen::Path.new('default'),
|
33
|
+
'default', './', 'default', nil, '', 'default', nil, 'Default')
|
34
|
+
check_proc.call(Webgen::Path.new('.htaccess'),
|
35
|
+
'.htaccess', './', '', nil, 'htaccess', '.htaccess', nil, '')
|
36
|
+
|
37
|
+
check_proc.call(Webgen::Path.new('/'),
|
38
|
+
'/', '/', '/', nil, '', '/', nil, '/')
|
39
|
+
check_proc.call(Webgen::Path.new('/dir/'),
|
40
|
+
'/dir/', '/', 'dir', nil, '', 'dir', nil, 'Dir')
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_mount_at
|
44
|
+
p = Webgen::Path.new('test.de.page')
|
45
|
+
p = p.mount_at('/somedir')
|
46
|
+
assert_equal('/somedir/test.de.page', p.path)
|
47
|
+
assert_equal('/somedir/', p.directory)
|
48
|
+
|
49
|
+
p = Webgen::Path.new('/')
|
50
|
+
p = p.mount_at('/somedir')
|
51
|
+
assert_equal('/somedir/', p.path)
|
52
|
+
assert_equal('/', p.directory)
|
53
|
+
assert_equal('somedir', p.cn)
|
54
|
+
assert_equal('Somedir', p.meta_info['title'])
|
55
|
+
|
56
|
+
p = Webgen::Path.new('/source/test.rb')
|
57
|
+
p = p.mount_at('/', '/source/')
|
58
|
+
assert_equal('/test.rb', p.path)
|
59
|
+
assert_equal('/', p.directory)
|
60
|
+
assert_equal('test.rb', p.cn)
|
61
|
+
assert_equal('Test', p.meta_info['title'])
|
62
|
+
|
63
|
+
p = Webgen::Path.new('/source/')
|
64
|
+
p = p.mount_at('/', '/source')
|
65
|
+
assert_equal('/', p.path)
|
66
|
+
assert_equal('/', p.directory)
|
67
|
+
assert_equal('/', p.cn)
|
68
|
+
assert_equal('/', p.meta_info['title'])
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_dup
|
72
|
+
p = Webgen::Path.new('test.de.page')
|
73
|
+
dupped = p.dup
|
74
|
+
dupped.meta_info['title'] = 'changed'
|
75
|
+
assert_equal('Test', p.meta_info['title'])
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_io
|
79
|
+
p = Webgen::Path.new('test.de.page')
|
80
|
+
assert_raise(RuntimeError) { p.io }
|
81
|
+
p = Webgen::Path.new('test.de.page') { StringIO.new('hallo') }
|
82
|
+
assert_equal('hallo', p.io.data)
|
83
|
+
assert_equal('hallo', p.io.stream {|f| f.read })
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_lcn
|
87
|
+
p = Webgen::Path.new('test.de.page')
|
88
|
+
assert_equal('test.page', p.cn)
|
89
|
+
assert_equal('test.de.page', p.lcn)
|
90
|
+
p = Webgen::Path.new('test.page')
|
91
|
+
assert_equal('test.page', p.cn)
|
92
|
+
assert_equal('test.page', p.lcn)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_equality
|
96
|
+
p = Webgen::Path.new('test.de.page')
|
97
|
+
assert_equal('test.de.page', p)
|
98
|
+
assert_equal(Webgen::Path.new('test.de.page'), p)
|
99
|
+
assert_not_equal(5, p)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_hashing
|
103
|
+
path = Webgen::Path.new('test.de.page')
|
104
|
+
h = { 'test.de.page' => :value }
|
105
|
+
assert_equal(:value, h['test.de.page'])
|
106
|
+
assert_equal(:value, h[path])
|
107
|
+
assert(path <=> 'test.de.page')
|
108
|
+
h = { p => :newvalue}
|
109
|
+
assert_nil(h['test.de.page'])
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_matching
|
113
|
+
path = Webgen::Path.new('/dir/to/file.de.page')
|
114
|
+
assert(path =~ '**/*')
|
115
|
+
assert(path =~ '**/file.de.PAGE')
|
116
|
+
assert(path =~ '/dir/*/file.*.page')
|
117
|
+
assert(path !~ '**/*.test')
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_introspection
|
121
|
+
p = Webgen::Path.new('test.de.page')
|
122
|
+
assert_equal('test.de.page', p.to_s)
|
123
|
+
assert(p.inspect.include?('test.de.page'))
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_changed?
|
127
|
+
p = Webgen::Path.new('test.de.page')
|
128
|
+
assert(p.changed?)
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helper'
|
3
|
+
require 'webgen/source/filesystem'
|
4
|
+
|
5
|
+
class TestSourceFileSystemPath < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include Test::WebsiteHelper
|
8
|
+
|
9
|
+
def test_io
|
10
|
+
path = Webgen::Source::FileSystem::Path.new('/test.rb', __FILE__)
|
11
|
+
assert(path.io.data =~ /TestSourceFileSystemPath/)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_changed?
|
15
|
+
path = Webgen::Source::FileSystem::Path.new('/test.rb', __FILE__)
|
16
|
+
assert(!path.changed?)
|
17
|
+
@website.cache.instance_eval { @old_data[[:fs_path, __FILE__]] = File.mtime(__FILE__) - 1 }
|
18
|
+
assert(path.changed?)
|
19
|
+
@website.cache.instance_eval { @old_data[[:fs_path, __FILE__]] = File.mtime(__FILE__) + 1 }
|
20
|
+
assert(!path.changed?)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
class TestSourceFileSystem < Test::Unit::TestCase
|
26
|
+
|
27
|
+
include Test::WebsiteHelper
|
28
|
+
|
29
|
+
def setup
|
30
|
+
super
|
31
|
+
@website = Webgen::Website.new(File.join(File.dirname(__FILE__), '..'), nil)
|
32
|
+
@website.init
|
33
|
+
Thread.current[:webgen_website] = @website
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_initialize
|
37
|
+
source = Webgen::Source::FileSystem.new('test', '**/*.page')
|
38
|
+
assert_equal('**/*.page', source.glob)
|
39
|
+
assert_equal(File.join(File.dirname(__FILE__), '..', 'test'), source.root)
|
40
|
+
|
41
|
+
source = Webgen::Source::FileSystem.new('/tmp/hallo')
|
42
|
+
assert_equal('**/*', source.glob)
|
43
|
+
assert_equal('/tmp/hallo', source.root)
|
44
|
+
|
45
|
+
source = Webgen::Source::FileSystem.new('c:/tmp/hallo')
|
46
|
+
assert_equal('c:/tmp/hallo', source.root)
|
47
|
+
|
48
|
+
source = Webgen::Source::FileSystem.new('../hallo')
|
49
|
+
assert_equal(File.join(@website.directory, '../hallo'), source.root)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_paths
|
53
|
+
source = Webgen::Source::FileSystem.new(File.join(File.dirname(__FILE__), '..', 'lib', 'webgen'), '/source/../**/*')
|
54
|
+
assert(source.paths.length > 1)
|
55
|
+
assert(source.paths.include?(Webgen::Path.new('/source/')))
|
56
|
+
assert(source.paths.include?(Webgen::Path.new('/source/filesystem.rb')))
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|