tiddlywiki_cp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +674 -0
- data/History.txt +4 -0
- data/Manifest.txt +68 -0
- data/README.txt +3 -0
- data/Rakefile +123 -0
- data/bin/tiddlywiki_cp +13 -0
- data/lib/tiddlywiki_cp/converters.rb +36 -0
- data/lib/tiddlywiki_cp/file2file.rb +32 -0
- data/lib/tiddlywiki_cp/file2tiddler.rb +42 -0
- data/lib/tiddlywiki_cp/r4tw.rb +763 -0
- data/lib/tiddlywiki_cp/tiddler2directory.rb +27 -0
- data/lib/tiddlywiki_cp/tiddler2file.rb +41 -0
- data/lib/tiddlywiki_cp/tiddler2tiddlywiki.rb +29 -0
- data/lib/tiddlywiki_cp/tiddler_css.rb +39 -0
- data/lib/tiddlywiki_cp/tiddler_html.rb +39 -0
- data/lib/tiddlywiki_cp/tiddler_js.rb +39 -0
- data/lib/tiddlywiki_cp/tiddlywiki2file.rb +29 -0
- data/lib/tiddlywiki_cp/version.rb +24 -0
- data/lib/tiddlywiki_cp.rb +378 -0
- data/scripts/txt2html +67 -0
- data/setup.rb +1585 -0
- data/test/content/a +0 -0
- data/test/content/a.div +0 -0
- data/test/content/b +0 -0
- data/test/content/e +3 -0
- data/test/content/e.div +1 -0
- data/test/content/html_entities.html +6 -0
- data/test/content/test_fetch.html +6 -0
- data/test/content/universe.html +10522 -0
- data/test/r4tw/addtag.rb +93 -0
- data/test/r4tw/all.rb +29 -0
- data/test/r4tw/createfrom.rb +62 -0
- data/test/r4tw/empties/2.1.3.html +7087 -0
- data/test/r4tw/empties/2.2.0.beta5.html +8726 -0
- data/test/r4tw/fromremote.rb +19 -0
- data/test/r4tw/fromurl.rb +28 -0
- data/test/r4tw/shadows.rb +27 -0
- data/test/r4tw/tiddler.rb +70 -0
- data/test/r4tw/tiddlerfromurl.rb +23 -0
- data/test/r4tw/tiddlywiki.rb +66 -0
- data/test/r4tw/utils.rb +55 -0
- data/test/r4tw/withcontent/2.2.0.beta5.html +8739 -0
- data/test/r4tw/withcontent/22b5index.html +13523 -0
- data/test/r4tw/withcontent/empty2.html +7084 -0
- data/test/r4tw/withcontent/nothing.js +1 -0
- data/test/r4tw/write_all_tiddlers_to.rb +62 -0
- data/test/test_all.rb +8 -0
- data/test/test_helper.rb +36 -0
- data/test/test_tiddler_css.rb +55 -0
- data/test/test_tiddler_html.rb +54 -0
- data/test/test_tiddler_js.rb +56 -0
- data/test/test_tiddlywiki_cp.rb +341 -0
- data/website/files/DefaultTiddlers.tiddler +2 -0
- data/website/files/DefaultTiddlers.tiddler.div +1 -0
- data/website/files/Introduction.tiddler +12 -0
- data/website/files/Introduction.tiddler.div +1 -0
- data/website/files/MainMenu.tiddler +1 -0
- data/website/files/MainMenu.tiddler.div +1 -0
- data/website/files/SiteSubtitle.tiddler +1 -0
- data/website/files/SiteSubtitle.tiddler.div +1 -0
- data/website/files/SiteTitle.tiddler +1 -0
- data/website/files/SiteTitle.tiddler.div +1 -0
- data/website/files/Usage.tiddler +55 -0
- data/website/files/Usage.tiddler.div +1 -0
- data/website/files/WebDAVSavingPlugin.js +234 -0
- data/website/files/WebDAVSavingPlugin.js.div +1 -0
- data/website/index.html +9144 -0
- data/website/index.xml +336 -0
- metadata +116 -0
@@ -0,0 +1 @@
|
|
1
|
+
// hey there
|
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
$LOAD_PATH << "..";
|
7
|
+
require 'r4tw'
|
8
|
+
|
9
|
+
class TiddlyWikiTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
|
13
|
+
@tw = make_tw { source_file "#{this_dir(__FILE__)}/withcontent/2.2.0.beta5.html" }
|
14
|
+
FileUtils.remove_dir 'spit' if File.exists? 'spit'
|
15
|
+
Dir.mkdir 'spit'
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
FileUtils.remove_dir 'spit'
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_text
|
24
|
+
@tw.add_tiddler_from('tiddler' => 'js tiddler',
|
25
|
+
'text' => ';',
|
26
|
+
'tags' => 'systemConfig',
|
27
|
+
'modified' => Time.now.convertToYYYYMMDDHHMM
|
28
|
+
)
|
29
|
+
@tw.write_all_tiddlers_to 'spit'
|
30
|
+
@tw.tiddlers.each do |t|
|
31
|
+
if t.tags and t.tags.include? "systemConfig"
|
32
|
+
type = 'js'
|
33
|
+
else
|
34
|
+
type = 'tiddler'
|
35
|
+
end
|
36
|
+
file = "#{this_dir(__FILE__)}/spit/#{t.name}.#{type}"
|
37
|
+
assert_equal(t.text, File.read(file))
|
38
|
+
if t.modified
|
39
|
+
assert_equal(t.modified, File.mtime(file).convertToYYYYMMDDHHMM)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_divs
|
45
|
+
@tw.write_all_tiddlers_to('spit', true)
|
46
|
+
@tw.tiddlers.each do |t|
|
47
|
+
file = "#{this_dir(__FILE__)}/spit/#{t.name}.tiddler"
|
48
|
+
assert_equal(t.text, File.read(file))
|
49
|
+
assert_equal(t.to_fields_string(true).join(' '), File.read("#{file}.div"))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_slash
|
54
|
+
slash_title = 'title with / in / the name'
|
55
|
+
@tw.add_tiddler_from('tiddler' => slash_title,
|
56
|
+
'text' => 'ABC'
|
57
|
+
)
|
58
|
+
@tw.write_all_tiddlers_to('spit', true)
|
59
|
+
assert(File.exists?('spit/title with %2F in %2F the name.tiddler'))
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/test/test_all.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2007 Loic Dachary <loic@dachary.org>
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
require 'test/unit'
|
18
|
+
require 'fileutils'
|
19
|
+
require File.dirname(__FILE__) + '/../lib/tiddlywiki_cp'
|
20
|
+
|
21
|
+
module TiddlyBase
|
22
|
+
|
23
|
+
def rm_out
|
24
|
+
FileUtils.remove_dir 'spit' if File.exists? 'spit'
|
25
|
+
end
|
26
|
+
|
27
|
+
def setup
|
28
|
+
rm_out
|
29
|
+
Dir.mkdir 'spit'
|
30
|
+
end
|
31
|
+
|
32
|
+
def teardown
|
33
|
+
rm_out
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2007 Loic Dachary <loic@dachary.org>
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
18
|
+
|
19
|
+
module TiddlywikiCp
|
20
|
+
|
21
|
+
class TestTiddler < Test::Unit::TestCase
|
22
|
+
include TiddlyBase
|
23
|
+
|
24
|
+
def test_tiddler_css
|
25
|
+
t = TiddlyWikiCp.new
|
26
|
+
tiddler = Tiddler.new
|
27
|
+
assert_equal(false, t.tiddler_css?(tiddler))
|
28
|
+
tiddler.from_scratch({'tiddler', 'StyleSheet'})
|
29
|
+
assert_equal(TiddlyWikiCp::TIDDLER_CSS, t.tiddler_css?(tiddler))
|
30
|
+
tiddler.from_scratch({'tiddler', 'Styles'})
|
31
|
+
assert_equal(TiddlyWikiCp::TIDDLER_CSS, t.tiddler_css?(tiddler))
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_css2directory
|
35
|
+
t = TiddlyWikiCp.new
|
36
|
+
tiddler = 'DesignStyle'
|
37
|
+
uri = "#{this_dir(__FILE__)}/content/universe.html#" + tiddler
|
38
|
+
t.css2directory(uri, 'spit')
|
39
|
+
assert(File.exists?('spit/' + tiddler + '.' + TiddlyWikiCp::TIDDLER_CSS))
|
40
|
+
assert(File.exists?('spit/' + tiddler + '.' + TiddlyWikiCp::TIDDLER_CSS + '.div'))
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_css2file
|
44
|
+
assert(TiddlyWikiCp.new.respond_to?(:css2file))
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_css2tiddlywiki
|
48
|
+
assert(TiddlyWikiCp.new.respond_to?(:css2tiddlywiki))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end # module TiddlywikiCp
|
53
|
+
# Local Variables:
|
54
|
+
# compile-command: "RUBYLIB='../lib/tiddlywiki_cp:../lib' ruby test_tiddler_css.rb"
|
55
|
+
# End:
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2007 Loic Dachary <loic@dachary.org>
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
18
|
+
|
19
|
+
module TiddlywikiCp
|
20
|
+
|
21
|
+
class TestTiddler < Test::Unit::TestCase
|
22
|
+
include TiddlyBase
|
23
|
+
|
24
|
+
def test_tiddler_html
|
25
|
+
t = TiddlyWikiCp.new
|
26
|
+
tiddler = Tiddler.new
|
27
|
+
assert_equal(false, t.tiddler_html?(tiddler))
|
28
|
+
tiddler.from_scratch({'tiddler', 'TemplateFoo'})
|
29
|
+
assert_equal(TiddlyWikiCp::TIDDLER_HTML, t.tiddler_html?(tiddler))
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_html2directory
|
33
|
+
t = TiddlyWikiCp.new
|
34
|
+
tiddler = 'DesignTemplate'
|
35
|
+
uri = "#{this_dir(__FILE__)}/content/universe.html#" + tiddler
|
36
|
+
t.html2directory(uri, 'spit')
|
37
|
+
assert(File.exists?('spit/' + tiddler + '.' + TiddlyWikiCp::TIDDLER_HTML))
|
38
|
+
assert(File.exists?('spit/' + tiddler + '.' + TiddlyWikiCp::TIDDLER_HTML + '.div'))
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_html2file
|
42
|
+
assert(TiddlyWikiCp.new.respond_to?(:html2file))
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_html2tiddlywiki
|
46
|
+
assert(TiddlyWikiCp.new.respond_to?(:html2tiddlywiki))
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end # module TiddlywikiCp
|
52
|
+
# Local Variables:
|
53
|
+
# compile-command: "RUBYLIB='../lib/tiddlywiki_cp:../lib' ruby test_tiddler_html.rb"
|
54
|
+
# End:
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2007 Loic Dachary <loic@dachary.org>
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
18
|
+
require 'tiddlywiki_cp/tiddler_js'
|
19
|
+
|
20
|
+
module TiddlywikiCp
|
21
|
+
|
22
|
+
class TestTiddler < Test::Unit::TestCase
|
23
|
+
include TiddlyBase
|
24
|
+
|
25
|
+
def test_tiddler_js?
|
26
|
+
t = TiddlyWikiCp.new
|
27
|
+
tiddler = Tiddler.new
|
28
|
+
assert_equal(nil, t.tiddler_js?(tiddler))
|
29
|
+
tiddler.from_scratch({'tags', ['bla']})
|
30
|
+
assert_equal(false, t.tiddler_js?(tiddler))
|
31
|
+
tiddler.from_scratch({'tags', ['systemConfig']})
|
32
|
+
assert_equal(TiddlyWikiCp::TIDDLER_JS, t.tiddler_js?(tiddler))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_js2directory
|
36
|
+
t = TiddlyWikiCp.new
|
37
|
+
tiddler = 'GenerateRssHijack'
|
38
|
+
uri = "#{this_dir(__FILE__)}/content/universe.html#" + tiddler
|
39
|
+
t.js2directory(uri, 'spit')
|
40
|
+
assert(File.exists?('spit/' + tiddler + '.' + TiddlyWikiCp::TIDDLER_JS))
|
41
|
+
assert(File.exists?('spit/' + tiddler + '.' + TiddlyWikiCp::TIDDLER_JS + '.div'))
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_js2file
|
45
|
+
assert(TiddlyWikiCp.new.respond_to?(:js2file))
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_js2tiddlywiki
|
49
|
+
assert(TiddlyWikiCp.new.respond_to?(:js2tiddlywiki))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end # module TiddlywikiCp
|
54
|
+
# Local Variables:
|
55
|
+
# compile-command: "RUBYLIB='../lib/tiddlywiki_cp:../lib' ruby test_tiddler_js.rb"
|
56
|
+
# End:
|
@@ -0,0 +1,341 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2007 Loic Dachary <loic@dachary.org>
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
18
|
+
require 'open-uri'
|
19
|
+
|
20
|
+
module TiddlywikiCp
|
21
|
+
|
22
|
+
class TiddlyWikiCp
|
23
|
+
|
24
|
+
attr_accessor :stdout
|
25
|
+
|
26
|
+
def puts(string)
|
27
|
+
if ! defined?(@stdout):
|
28
|
+
@stdout = []
|
29
|
+
end
|
30
|
+
@stdout.push(string)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class TestTiddlywikiCp < Test::Unit::TestCase
|
36
|
+
include TiddlyBase
|
37
|
+
|
38
|
+
def test_main
|
39
|
+
t = TiddlyWikiCp.new
|
40
|
+
a = "#{this_dir(__FILE__)}/content/a" # existing file without .div
|
41
|
+
t.main([a, 'spit/a'])
|
42
|
+
assert(File.exists?('spit/a'))
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_parse!
|
46
|
+
t = TiddlyWikiCp.new
|
47
|
+
|
48
|
+
options = t.parse!([])
|
49
|
+
|
50
|
+
assert_equal(false, options.times)
|
51
|
+
assert(t.parse!(['-t']).times)
|
52
|
+
assert(t.parse!(['--times']).times)
|
53
|
+
|
54
|
+
assert_equal(false, options.recursive)
|
55
|
+
assert(t.parse!(['-r']).recursive)
|
56
|
+
assert(t.parse!(['--recursive']).recursive)
|
57
|
+
|
58
|
+
t.reset
|
59
|
+
assert_equal(false, options.recursive)
|
60
|
+
assert_equal(false, options.times)
|
61
|
+
t.parse!(['-a'])
|
62
|
+
assert(t.options.recursive)
|
63
|
+
assert(t.options.times)
|
64
|
+
t.reset
|
65
|
+
t.parse!(['--all'])
|
66
|
+
assert(t.options.recursive)
|
67
|
+
assert(t.options.times)
|
68
|
+
t.reset
|
69
|
+
|
70
|
+
assert_equal(false, options.verbose)
|
71
|
+
assert(t.parse!(['-v']).verbose)
|
72
|
+
assert(t.parse!(['--verbose']).verbose)
|
73
|
+
|
74
|
+
assert_equal(false, options.dry_run)
|
75
|
+
assert(t.parse!(['-n']).dry_run)
|
76
|
+
assert(t.parse!(['--dry-run']).dry_run)
|
77
|
+
|
78
|
+
assert_equal([], options.includes)
|
79
|
+
assert_equal(['a'], t.parse!(['-i', 'a']).includes)
|
80
|
+
assert_equal(['a'], t.parse!(['--include', 'a']).includes)
|
81
|
+
|
82
|
+
assert_equal([], options.excludes)
|
83
|
+
assert_equal(['a'], t.parse!(['--exclude', 'a']).excludes)
|
84
|
+
|
85
|
+
t.parse!(['--version'])
|
86
|
+
assert_equal(VERSION::STRING, t.stdout[0])
|
87
|
+
t.stdout = []
|
88
|
+
|
89
|
+
t.parse!(['--help'])
|
90
|
+
assert_match('Usage:', t.stdout[0])
|
91
|
+
t.stdout = []
|
92
|
+
|
93
|
+
args = ['-t', 'b', 'c']
|
94
|
+
options = t.parse!(args)
|
95
|
+
assert_equal(['b', 'c'], args)
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_run
|
99
|
+
t = TiddlyWikiCp.new
|
100
|
+
|
101
|
+
#
|
102
|
+
# not enough arguments
|
103
|
+
#
|
104
|
+
assert_raise RuntimeError do
|
105
|
+
t.run([])
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# destination is not a directory/tiddlywiki
|
110
|
+
#
|
111
|
+
a = "#{this_dir(__FILE__)}/content/a" # fake tiddler file
|
112
|
+
|
113
|
+
assert_equal(TiddlyWikiCp::CONTAINER_FILE, t.uri2container(a))
|
114
|
+
assert_raise RuntimeError do
|
115
|
+
t.run([a, a, a])
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# copy file to file
|
120
|
+
#
|
121
|
+
a_c = "spit/a"
|
122
|
+
t.run([a, a_c])
|
123
|
+
assert(File.exists?(a_c))
|
124
|
+
assert(File.exists?("#{a_c}.div"))
|
125
|
+
|
126
|
+
#
|
127
|
+
# copy file to tiddlywiki
|
128
|
+
#
|
129
|
+
e = "#{this_dir(__FILE__)}/content/e" # good tiddler file
|
130
|
+
|
131
|
+
tiddlywiki = "#{this_dir(__FILE__)}/content/universe.html" # regular tiddlywiki
|
132
|
+
FileUtils.cp(tiddlywiki, "spit/t.html")
|
133
|
+
t.run([e, "spit/t.html"])
|
134
|
+
|
135
|
+
t = TiddlyWikiCp.new
|
136
|
+
assert_equal('ETiddler', t.uri2tiddlywiki("spit/t.html").get_tiddler('ETiddler').tiddler)
|
137
|
+
|
138
|
+
#
|
139
|
+
# dry run
|
140
|
+
#
|
141
|
+
t.options.dry_run = true
|
142
|
+
a_fake = "spit/a_fake"
|
143
|
+
t.run([a, a_fake])
|
144
|
+
assert(!File.exists?(a_fake))
|
145
|
+
assert_equal("copy '#{a}' '#{a_fake}'", t.stdout[0])
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_args2from
|
149
|
+
t = TiddlyWikiCp.new
|
150
|
+
|
151
|
+
a = "#{this_dir(__FILE__)}/content/a" # fake tiddler file
|
152
|
+
b = "#{this_dir(__FILE__)}/content/b" # existing file without .div
|
153
|
+
c = "#{this_dir(__FILE__)}/content/c" # no existent file
|
154
|
+
d = "#{this_dir(__FILE__)}/content/d" # directory
|
155
|
+
tiddlywiki = "#{this_dir(__FILE__)}/content/universe.html" # regular tiddlywiki
|
156
|
+
tiddler = "#{this_dir(__FILE__)}/content/universe.html#Implementation" # regular tiddler
|
157
|
+
|
158
|
+
#
|
159
|
+
# Non recursive
|
160
|
+
#
|
161
|
+
t.options.excludes = []
|
162
|
+
assert_equal([a], t.args2from([a], false))
|
163
|
+
t.options.excludes.push('a$')
|
164
|
+
assert_equal([], t.args2from([a], false))
|
165
|
+
|
166
|
+
assert_raises Errno::ENOENT do
|
167
|
+
t.args2from([b], false)
|
168
|
+
end
|
169
|
+
|
170
|
+
assert_raises Errno::ENOENT do
|
171
|
+
t.args2from([c], false)
|
172
|
+
end
|
173
|
+
|
174
|
+
assert_equal([tiddlywiki], t.args2from([tiddlywiki], false))
|
175
|
+
assert_equal([tiddler], t.args2from([tiddler], false))
|
176
|
+
|
177
|
+
assert_raises RuntimeError do
|
178
|
+
t.args2from([d], false)
|
179
|
+
end
|
180
|
+
|
181
|
+
#
|
182
|
+
# Recursive
|
183
|
+
#
|
184
|
+
t.options.excludes = []
|
185
|
+
assert_equal([a], t.args2from([a], true))
|
186
|
+
t.options.excludes.push('a$')
|
187
|
+
assert_equal([], t.args2from([a], true))
|
188
|
+
|
189
|
+
assert_raises Errno::ENOENT do
|
190
|
+
t.args2from([b], true)
|
191
|
+
end
|
192
|
+
|
193
|
+
assert_raises Errno::ENOENT do
|
194
|
+
t.args2from([c], true)
|
195
|
+
end
|
196
|
+
|
197
|
+
title = '#Implementation'
|
198
|
+
t.options.includes = [title]
|
199
|
+
assert_equal([tiddlywiki + title], t.args2from([tiddlywiki], true))
|
200
|
+
|
201
|
+
assert_equal([tiddler], t.args2from([tiddler], true))
|
202
|
+
|
203
|
+
assert_equal([], t.args2from([d], true))
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_uri2type
|
208
|
+
t = TiddlyWikiCp.new
|
209
|
+
assert_equal(TiddlyWikiCp::TIDDLER_JS, t.uri2type("#{this_dir(__FILE__)}/content/universe.html#GenerateRssHijack"))
|
210
|
+
assert_equal(TiddlyWikiCp::TIDDLER_DEFAULT, t.uri2type("#{this_dir(__FILE__)}/content/universe.html#Scope"))
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_uri2container
|
214
|
+
t = TiddlyWikiCp.new
|
215
|
+
assert_equal(TiddlyWikiCp::CONTAINER_TIDDLYWIKI, t.uri2container("#{this_dir(__FILE__)}/content/universe.html"))
|
216
|
+
assert_equal(TiddlyWikiCp::CONTAINER_TIDDLER, t.uri2container("#{this_dir(__FILE__)}/content/universe.html#Implementation"))
|
217
|
+
assert_equal(TiddlyWikiCp::CONTAINER_DIRECTORY, t.uri2container("."))
|
218
|
+
assert_equal(TiddlyWikiCp::CONTAINER_FILE, t.uri2container("whatever"))
|
219
|
+
assert_equal(TiddlyWikiCp::CONTAINER_FILE, t.uri2container("#{this_dir(__FILE__)}/content/html_entities.html"))
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_accept?
|
223
|
+
t = TiddlyWikiCp.new
|
224
|
+
assert(t.accept?('a'))
|
225
|
+
|
226
|
+
t.options.includes.push('a')
|
227
|
+
assert(t.accept?('a'))
|
228
|
+
assert_equal(false, t.accept?('b'))
|
229
|
+
|
230
|
+
t.options.excludes.push('ab')
|
231
|
+
assert(t.accept?('a'))
|
232
|
+
assert_equal(false, t.accept?('b'))
|
233
|
+
assert_equal(false, t.accept?('ab'))
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_tiddler2filename
|
237
|
+
assert_equal('D/a%2Fb%2Fc', TiddlyWikiCp.tiddler2filename('D', 'F#a/b/c'))
|
238
|
+
assert_raise RuntimeError do
|
239
|
+
TiddlyWikiCp.tiddler2filename('D', 'a/b/c')
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_uri2tiddlywiki
|
244
|
+
t = TiddlyWikiCp.new
|
245
|
+
uri = "#{this_dir(__FILE__)}/content/universe.html"
|
246
|
+
tw = t.uri2tiddlywiki("#{uri}#f")
|
247
|
+
assert_equal('Implementation', tw.get_tiddler('Implementation').name)
|
248
|
+
assert_equal(t.tiddlywiki_cache[uri], tw)
|
249
|
+
tw.get_tiddler('Implementation').rename('Other Implementation')
|
250
|
+
tw = t.uri2tiddlywiki("#{uri}#f")
|
251
|
+
assert_equal(nil, tw.get_tiddler('Implementation'))
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_read_write_uri
|
255
|
+
t = TiddlyWikiCp.new
|
256
|
+
content = t.read_uri("#{this_dir(__FILE__)}/content/html_entities.html")
|
257
|
+
assert_equal(content.length, File.size("#{this_dir(__FILE__)}/content/html_entities.html"))
|
258
|
+
t.write_uri("spit/out.html", content)
|
259
|
+
assert_equal(File.size("#{this_dir(__FILE__)}/content/html_entities.html"), File.size("spit/out.html"))
|
260
|
+
assert_equal(t.file_cache["spit/out.html"], File.read("spit/out.html"))
|
261
|
+
|
262
|
+
assert_raise Errno::ENOENT do
|
263
|
+
t.read_uri("unlikely_to_exists")
|
264
|
+
end
|
265
|
+
|
266
|
+
assert_raise OpenURI::HTTPError, Errno::ECONNREFUSED do
|
267
|
+
t.read_uri('http://127.0.0.1/unlikely_to_exists')
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_without_fragment
|
272
|
+
assert_equal('http://a.com/', TiddlyWikiCp.without_fragment('http://a.com/#f'))
|
273
|
+
assert_equal('/dir/file', TiddlyWikiCp.without_fragment('/dir/file#f'))
|
274
|
+
assert_equal('/dir/file', TiddlyWikiCp.without_fragment('/dir/file'))
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_tiddler_uri?
|
278
|
+
assert_equal(false, TiddlyWikiCp.tiddler_uri?('http://domain.com/'))
|
279
|
+
assert_equal(false, TiddlyWikiCp.tiddler_uri?('/dir/file.html'))
|
280
|
+
assert(TiddlyWikiCp.tiddler_uri?('http://domain.com/#tiddler'))
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_tiddlywiki?
|
284
|
+
t = TiddlyWikiCp.new
|
285
|
+
assert(t.tiddlywiki?("#{this_dir(__FILE__)}/content/universe.html"))
|
286
|
+
assert_equal(nil, t.tiddlywiki?("#{this_dir(__FILE__)}/content/html_entities.html"))
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_tiddler2file
|
290
|
+
t = TiddlyWikiCp.new
|
291
|
+
a = "#{this_dir(__FILE__)}/content/universe.html#Implementation"
|
292
|
+
t.tiddler2file(a, "-")
|
293
|
+
assert(t.stdout.select{ |l| l =~ /Implementation/ })
|
294
|
+
t.options.times = true
|
295
|
+
tiddler = t.uri2tiddlywiki(a).get_tiddler('Implementation')
|
296
|
+
t.tiddler2file(a, "spit/a")
|
297
|
+
assert(Time.convertFromYYYYMMDDHHMM(tiddler.modified), File.mtime("spit/a"))
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_file2tiddler
|
301
|
+
t = TiddlyWikiCp.new
|
302
|
+
a = "#{this_dir(__FILE__)}/content/universe.html#Implementation"
|
303
|
+
tiddler = t.uri2tiddlywiki(a).get_tiddler('Implementation')
|
304
|
+
original_modified = tiddler.modified
|
305
|
+
t.tiddler2file(a, "spit/a")
|
306
|
+
t = TiddlyWikiCp.new
|
307
|
+
t.options.times = true
|
308
|
+
t.file2tiddler("spit/a", a)
|
309
|
+
tiddler = t.uri2tiddlywiki(a).get_tiddler('Implementation')
|
310
|
+
assert(original_modified != tiddler.modified)
|
311
|
+
assert(Time.convertFromYYYYMMDDHHMM(tiddler.modified), File.mtime("spit/a"))
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_tiddler2directory
|
315
|
+
t = TiddlyWikiCp.new
|
316
|
+
t.tiddler2directory("#{this_dir(__FILE__)}/content/universe.html#Implementation", "spit")
|
317
|
+
assert(File.exists?('spit/Implementation.tiddler'))
|
318
|
+
end
|
319
|
+
|
320
|
+
def test_tiddler2tiddlywiki
|
321
|
+
u = "#{this_dir(__FILE__)}/content/universe.html"
|
322
|
+
t = TiddlyWikiCp.new
|
323
|
+
FileUtils.cp(u, "spit/t.html")
|
324
|
+
tiddler = t.uri2tiddlywiki(u).get_tiddler("Implementation")
|
325
|
+
tiddler.rename('NEW')
|
326
|
+
t.tiddler2tiddlywiki("#{u}#NEW", "spit/t.html")
|
327
|
+
assert(t.uri2tiddlywiki("spit/t.html").get_tiddler("NEW"))
|
328
|
+
end
|
329
|
+
|
330
|
+
def test_tiddlywiki2file
|
331
|
+
t = TiddlyWikiCp.new
|
332
|
+
t.tiddlywiki2file("#{this_dir(__FILE__)}/content/universe.html", "spit/u.html")
|
333
|
+
assert(File.exists?('spit/u.html'))
|
334
|
+
end
|
335
|
+
|
336
|
+
end
|
337
|
+
|
338
|
+
end # module TiddlywikiCp
|
339
|
+
# Local Variables:
|
340
|
+
# compile-command: "RUBYLIB='../lib/tiddlywiki_cp:../lib' ruby test_tiddlywiki_cp.rb"
|
341
|
+
# End:
|
@@ -0,0 +1 @@
|
|
1
|
+
title="DefaultTiddlers" modifier="loic" modified="200707211643" created="200707211620" changecount="2"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
a ruby gem (http://rubyforge.org/projects/tiddlywikicp/) providing a library and a command line interface to copy [[tiddlywiki|http://tiddlywiki.com/]] tiddlers to files and vice versa.
|
2
|
+
|
3
|
+
Development is discussed at irc.freenode.net#tiddlywiki
|
4
|
+
|
5
|
+
This tiddlywiki was created using the following commands:
|
6
|
+
{{{
|
7
|
+
tiddlywiki_cp 'http://tiddlylab.bidix.info/#WebDAVSavingPlugin' website/index.html
|
8
|
+
tiddlywiki_cp -a website/index.html website/files
|
9
|
+
( echo '{{''{' ; RUBYLIB=lib ruby bin/tiddlywiki_cp --help ; echo '}}''}' ) > website/files/Usage
|
10
|
+
tiddlywiki_cp -a website/files website/index.html
|
11
|
+
}}}
|
12
|
+
Loic Dachary <mailto:loic@dachary.org>
|
@@ -0,0 +1 @@
|
|
1
|
+
title="Introduction" modifier="loic" modified="200707211647" created="200707211630" changecount="5"
|
@@ -0,0 +1 @@
|
|
1
|
+
[[Usage]]
|
@@ -0,0 +1 @@
|
|
1
|
+
title="MainMenu" modifier="loic" modified="200707211621" created="200707211619" changecount="2"
|
@@ -0,0 +1 @@
|
|
1
|
+
copy tiddlers to files and vice versa
|
@@ -0,0 +1 @@
|
|
1
|
+
title="SiteSubtitle" modifier="loic" modified="200707211623" created="200707211618" changecount="1"
|
@@ -0,0 +1 @@
|
|
1
|
+
tiddlywiki_cp
|
@@ -0,0 +1 @@
|
|
1
|
+
title="SiteTitle" modifier="loic" modified="200707211623" created="200707211617" changecount="1"
|