tiddlywiki_cp 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +5 -0
- data/Rakefile +1 -0
- data/lib/tiddlywiki_cp/file2tiddler.rb +14 -4
- data/lib/tiddlywiki_cp/r4tw.rb +19 -10
- data/lib/tiddlywiki_cp/tiddler_js.rb +1 -1
- data/lib/tiddlywiki_cp/version.rb +2 -2
- data/lib/tiddlywiki_cp.rb +20 -5
- data/test/content/universe.html +1 -1
- data/test/test_tiddlywiki_cp.rb +51 -2
- data/website/files/MainMenu.tiddler +3 -1
- data/website/index.html +150 -2
- metadata +2 -2
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -83,6 +83,7 @@ desc 'Generate website files'
|
|
83
83
|
task :website_generate do
|
84
84
|
Dir['website/**/*.txt'].each do |txt|
|
85
85
|
sh %{ ( echo '{{{' ; RUBYLIB=lib ruby bin/tiddlywiki_cp --help ; echo '}}}' ) > website/files/Usage }
|
86
|
+
sh %{ ( echo '{{{' ; hg log ; echo '}}}' ) > website/files/Usage }
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
@@ -20,12 +20,22 @@ module TiddlywikiCp
|
|
20
20
|
|
21
21
|
def file2tiddler(from, to)
|
22
22
|
content = read_uri(from)
|
23
|
-
div_from = "#{from}.div"
|
24
|
-
div = File.read(div_from).to_s
|
25
|
-
content = "<div #{div}>\n<pre>#{content}</pre>\n</div>"
|
26
23
|
|
27
24
|
tiddlywiki = uri2tiddlywiki(to)
|
28
|
-
tiddler = Tiddler.new
|
25
|
+
tiddler = Tiddler.new
|
26
|
+
#
|
27
|
+
# set tiddler meta data
|
28
|
+
#
|
29
|
+
div_from = "#{from}.div"
|
30
|
+
div = File.read(div_from).to_s
|
31
|
+
Tiddler.parse_attributes(div, tiddler.fields)
|
32
|
+
#
|
33
|
+
# set tiddler content
|
34
|
+
#
|
35
|
+
tiddler.fields['text'] = content
|
36
|
+
#
|
37
|
+
# set tiddler times
|
38
|
+
#
|
29
39
|
if @options.times
|
30
40
|
tiddler.fields['modified'] = File.mtime(from).convertToYYYYMMDDHHMM
|
31
41
|
end
|
data/lib/tiddlywiki_cp/r4tw.rb
CHANGED
@@ -231,17 +231,21 @@ class Tiddler
|
|
231
231
|
self
|
232
232
|
end
|
233
233
|
|
234
|
-
def
|
235
|
-
|
236
|
-
field_str = match_data[1]
|
237
|
-
text_str = match_data[2]
|
238
|
-
|
239
|
-
field_str.scan(/ ([\w\.]+)="([^"]+)"/) do |field_name,field_value|
|
234
|
+
def self.parse_attributes(attributes, map) #:nodoc:
|
235
|
+
attributes.scan(/([\w\.]+)="([^"]+)"/) do |field_name,field_value|
|
240
236
|
if field_name == "title"
|
241
237
|
field_name = "tiddler"
|
242
238
|
end
|
243
|
-
|
239
|
+
map[field_name] = field_value
|
244
240
|
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def from_div(div_str,use_pre=false, decodeHTML=true) #:nodoc:
|
244
|
+
match_data = div_str.match(/<div([^>]+)>(.*?)<\/div>/m)
|
245
|
+
field_str = match_data[1]
|
246
|
+
text_str = match_data[2]
|
247
|
+
|
248
|
+
Tiddler.parse_attributes(field_str, @fields)
|
245
249
|
|
246
250
|
text_str.sub!(/\n<pre>/,'')
|
247
251
|
text_str.sub!(/<\/pre>\n/,'')
|
@@ -467,6 +471,7 @@ class TiddlyWiki
|
|
467
471
|
def initialize(use_pre=false)
|
468
472
|
@use_pre = use_pre
|
469
473
|
@tiddlers = []
|
474
|
+
@core_hacks = []
|
470
475
|
end
|
471
476
|
|
472
477
|
# this should replace all the add_tiddler_from_blah methods
|
@@ -479,6 +484,12 @@ class TiddlyWiki
|
|
479
484
|
end
|
480
485
|
end
|
481
486
|
|
487
|
+
def use_pre_from_raw()
|
488
|
+
if @raw =~ /var version = \{title: "TiddlyWiki", major: 2, minor: 2/
|
489
|
+
@use_pre = true
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
482
493
|
# initialise a TiddlyWiki from a source file
|
483
494
|
# will treat empty_file as a url if it looks like one
|
484
495
|
# note that it doesn't have to be literally empty
|
@@ -493,9 +504,7 @@ class TiddlyWiki
|
|
493
504
|
# stupid ctrl (\r) char
|
494
505
|
#@raw.eat_ctrl_m!
|
495
506
|
|
496
|
-
|
497
|
-
@use_pre = true
|
498
|
-
end
|
507
|
+
use_pre_from_raw
|
499
508
|
|
500
509
|
@core_hacks = []
|
501
510
|
@orig_tiddlers = get_orig_tiddlers
|
data/lib/tiddlywiki_cp.rb
CHANGED
@@ -52,7 +52,7 @@ module TiddlywikiCp
|
|
52
52
|
@options.dry_run = false
|
53
53
|
@options.includes = []
|
54
54
|
@options.excludes = []
|
55
|
-
@options.ignores = ['
|
55
|
+
@options.ignores = ['(CVS|\.hg|\.svn)$', '(#|~|.div)$']
|
56
56
|
end
|
57
57
|
|
58
58
|
def main(argv) #:nodoc:
|
@@ -267,8 +267,7 @@ module TiddlywikiCp
|
|
267
267
|
type = uri2container(uri)
|
268
268
|
if type == CONTAINER_TIDDLER
|
269
269
|
print "uri2type '#{uri}' " if @options.verbose
|
270
|
-
|
271
|
-
tiddler = uri2tiddlywiki(uri).get_tiddler(fragment)
|
270
|
+
tiddler = uri2tiddler(uri)
|
272
271
|
predicates = methods.select{ |m| m =~ /^tiddler_.*?/ }.sort
|
273
272
|
predicates.each do |p|
|
274
273
|
got_type = self.send(p.intern, tiddler)
|
@@ -332,11 +331,27 @@ module TiddlywikiCp
|
|
332
331
|
end
|
333
332
|
return Pathname.new(directory).join(fragment.gsub('/', '%2F')).to_s
|
334
333
|
end
|
335
|
-
|
334
|
+
|
335
|
+
def uri2tiddler(uri) #:nodoc:
|
336
|
+
fragment = uri.split('#')[1]
|
337
|
+
return uri2tiddlywiki(uri).get_tiddler(fragment)
|
338
|
+
end
|
339
|
+
|
336
340
|
def uri2tiddlywiki(uri) #:nodoc:
|
337
341
|
uri = TiddlyWikiCp.without_fragment(uri)
|
338
342
|
if ! @tiddlywiki_cache.has_key?(uri)
|
339
|
-
|
343
|
+
tiddlywiki = TiddlyWiki.new
|
344
|
+
#
|
345
|
+
# read all tiddlers verbatim (do not decode content)
|
346
|
+
#
|
347
|
+
tiddlywiki.raw = read_uri(uri)
|
348
|
+
tiddlywiki.instance_eval do
|
349
|
+
use_pre_from_raw
|
350
|
+
@tiddlers = tiddlywiki.tiddler_divs.map do |tiddler_div|
|
351
|
+
Tiddler.new.from_div(tiddler_div, @use_pre)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
@tiddlywiki_cache[uri] = tiddlywiki
|
340
355
|
end
|
341
356
|
return @tiddlywiki_cache[uri]
|
342
357
|
end
|
data/test/content/universe.html
CHANGED
@@ -1039,7 +1039,7 @@ See http://tiddlylab.bidix.info/#PasswordOptionPlugin</pre>
|
|
1039
1039
|
</pre>
|
1040
1040
|
</div>
|
1041
1041
|
<div title="Rationale" modifier="loic" modified="200705082004" created="200703051559" tags="toRSS">
|
1042
|
-
<pre>When running a networked service there is a need to experiment with a clone while the original is still available to the public. Virtual machines are easy to setup based on a backup of an existing virtual server. Switches, cables and firewalls are less intuitives to replicate.</pre>
|
1042
|
+
<pre>When running a < > " & networked service there is a need to experiment with a clone while the original is still available to the public. Virtual machines are easy to setup based on a backup of an existing virtual server. Switches, cables and firewalls are less intuitives to replicate.</pre>
|
1043
1043
|
</div>
|
1044
1044
|
<div title="SVN based development using emacs" modifier="YourName" modified="200705091558" created="200705081952" tags="[[Use Cases]] toRSS">
|
1045
1045
|
<pre>** Proppy wants to use his ssh private key from withing the vserver to gain write access to a SVN repository
|
data/test/test_tiddlywiki_cp.rb
CHANGED
@@ -152,6 +152,7 @@ class TestTiddlywikiCp < Test::Unit::TestCase
|
|
152
152
|
b = "#{this_dir(__FILE__)}/content/b" # existing file without .div
|
153
153
|
c = "#{this_dir(__FILE__)}/content/c" # no existent file
|
154
154
|
d = "#{this_dir(__FILE__)}/content/d" # directory
|
155
|
+
i = "#{this_dir(__FILE__)}/content/ignored#" # ignored
|
155
156
|
tiddlywiki = "#{this_dir(__FILE__)}/content/universe.html" # regular tiddlywiki
|
156
157
|
tiddler = "#{this_dir(__FILE__)}/content/universe.html#Implementation" # regular tiddler
|
157
158
|
|
@@ -186,6 +187,8 @@ class TestTiddlywikiCp < Test::Unit::TestCase
|
|
186
187
|
t.options.excludes.push('a$')
|
187
188
|
assert_equal([], t.args2from([a], true))
|
188
189
|
|
190
|
+
assert_equal([], t.args2from([i], true))
|
191
|
+
|
189
192
|
assert_raises Errno::ENOENT do
|
190
193
|
t.args2from([b], true)
|
191
194
|
end
|
@@ -219,6 +222,17 @@ class TestTiddlywikiCp < Test::Unit::TestCase
|
|
219
222
|
assert_equal(TiddlyWikiCp::CONTAINER_FILE, t.uri2container("#{this_dir(__FILE__)}/content/html_entities.html"))
|
220
223
|
end
|
221
224
|
|
225
|
+
def test_ignore?
|
226
|
+
t = TiddlyWikiCp.new
|
227
|
+
assert(t.ignore?('a/b/#'))
|
228
|
+
assert(t.ignore?('a/b/~'))
|
229
|
+
assert(t.ignore?('a/b/foo.div'))
|
230
|
+
assert(t.ignore?('a/b/foo.div'))
|
231
|
+
assert(t.ignore?('a/b/.svn'))
|
232
|
+
assert(t.ignore?('a/b/CVS'))
|
233
|
+
assert(t.ignore?('a/b/.hg'))
|
234
|
+
end
|
235
|
+
|
222
236
|
def test_accept?
|
223
237
|
t = TiddlyWikiCp.new
|
224
238
|
assert(t.accept?('a'))
|
@@ -240,12 +254,27 @@ class TestTiddlywikiCp < Test::Unit::TestCase
|
|
240
254
|
end
|
241
255
|
end
|
242
256
|
|
257
|
+
def test_uri2tiddler
|
258
|
+
t = TiddlyWikiCp.new
|
259
|
+
assert('Rationale', t.uri2tiddler("#{this_dir(__FILE__)}/content/universe.html#Rationale").name)
|
260
|
+
end
|
261
|
+
|
243
262
|
def test_uri2tiddlywiki
|
244
263
|
t = TiddlyWikiCp.new
|
245
264
|
uri = "#{this_dir(__FILE__)}/content/universe.html"
|
265
|
+
#
|
266
|
+
# read
|
267
|
+
#
|
246
268
|
tw = t.uri2tiddlywiki("#{uri}#f")
|
247
269
|
assert_equal('Implementation', tw.get_tiddler('Implementation').name)
|
248
270
|
assert_equal(t.tiddlywiki_cache[uri], tw)
|
271
|
+
#
|
272
|
+
# check that content is verbatim (not decodeHTML)
|
273
|
+
#
|
274
|
+
assert_match(/< > \" &/, tw.get_tiddler('Rationale').text)
|
275
|
+
#
|
276
|
+
# check cache is reused
|
277
|
+
#
|
249
278
|
tw.get_tiddler('Implementation').rename('Other Implementation')
|
250
279
|
tw = t.uri2tiddlywiki("#{uri}#f")
|
251
280
|
assert_equal(nil, tw.get_tiddler('Implementation'))
|
@@ -298,17 +327,37 @@ class TestTiddlywikiCp < Test::Unit::TestCase
|
|
298
327
|
end
|
299
328
|
|
300
329
|
def test_file2tiddler
|
330
|
+
#
|
331
|
+
# Write to file
|
332
|
+
#
|
301
333
|
t = TiddlyWikiCp.new
|
302
334
|
a = "#{this_dir(__FILE__)}/content/universe.html#Implementation"
|
303
|
-
tiddler = t.
|
335
|
+
tiddler = t.uri2tiddler(a)
|
304
336
|
original_modified = tiddler.modified
|
305
337
|
t.tiddler2file(a, "spit/a")
|
338
|
+
#
|
339
|
+
# Read back
|
340
|
+
#
|
306
341
|
t = TiddlyWikiCp.new
|
307
342
|
t.options.times = true
|
308
343
|
t.file2tiddler("spit/a", a)
|
309
|
-
tiddler = t.
|
344
|
+
tiddler = t.uri2tiddler(a)
|
310
345
|
assert(original_modified != tiddler.modified)
|
311
346
|
assert(Time.convertFromYYYYMMDDHHMM(tiddler.modified), File.mtime("spit/a"))
|
347
|
+
#
|
348
|
+
# Write and read a JS file
|
349
|
+
#
|
350
|
+
j = "#{this_dir(__FILE__)}/content/universe.html#TiddlyLightBoxPlugin"
|
351
|
+
original = t.uri2tiddler(j).text
|
352
|
+
t.tiddler2file(j, "spit/b")
|
353
|
+
t.file2tiddler("spit/b", j)
|
354
|
+
t.tiddler2file(j, "spit/c")
|
355
|
+
t.uri2tiddler(j).fields['text'] = 'NONE'
|
356
|
+
t.file2tiddler("spit/c", j)
|
357
|
+
assert_match(/lightBoxTitle {padding:0px/, original)
|
358
|
+
transformed = t.uri2tiddler(j).text
|
359
|
+
assert_match(/TiddlyLightBoxStyles=\"/, original)
|
360
|
+
assert_equal(original, transformed)
|
312
361
|
end
|
313
362
|
|
314
363
|
def test_tiddler2directory
|
data/website/index.html
CHANGED
@@ -496,6 +496,151 @@ Also see AdvancedOptions</pre>
|
|
496
496
|
</div>
|
497
497
|
<!--POST-SHADOWAREA-->
|
498
498
|
<div id="storeArea">
|
499
|
+
<div title="ChangeLog" modifier="loic" modified="200707221919" created="200707211630" changecount="1">
|
500
|
+
<pre>{{{
|
501
|
+
changeset: 27:4fe4a301fdfb
|
502
|
+
tag: tip
|
503
|
+
user: root@dachary.org
|
504
|
+
date: Sun Jul 22 21:18:22 2007 +0200
|
505
|
+
summary: fix major HTML escaping logic problem
|
506
|
+
|
507
|
+
changeset: 26:fdcd8116f513
|
508
|
+
user: root@dachary.org
|
509
|
+
date: Sat Jul 21 19:31:23 2007 +0200
|
510
|
+
summary: first package published
|
511
|
+
|
512
|
+
changeset: 25:6225c5fb1bf2
|
513
|
+
user: root@dachary.org
|
514
|
+
date: Sat Jul 21 18:39:21 2007 +0200
|
515
|
+
summary: Introduction
|
516
|
+
|
517
|
+
changeset: 24:ae6e7e676ca3
|
518
|
+
user: root@dachary.org
|
519
|
+
date: Sat Jul 21 18:33:02 2007 +0200
|
520
|
+
summary: stub site
|
521
|
+
|
522
|
+
changeset: 23:c20e9a96ebaa
|
523
|
+
user: root@dachary.org
|
524
|
+
date: Sat Jul 21 18:32:46 2007 +0200
|
525
|
+
summary: implement ignore backupfiles and SCM files
|
526
|
+
|
527
|
+
changeset: 22:f97c46f9b77a
|
528
|
+
user: root@dachary.org
|
529
|
+
date: Sat Jul 21 18:13:53 2007 +0200
|
530
|
+
summary: tiddler2tiddlywiki implementation and tests
|
531
|
+
|
532
|
+
changeset: 21:409f079da1eb
|
533
|
+
user: root@dachary.org
|
534
|
+
date: Sat Jul 21 18:13:37 2007 +0200
|
535
|
+
summary: tiddlywiki website
|
536
|
+
|
537
|
+
changeset: 20:a23a9405c616
|
538
|
+
user: root@dachary.org
|
539
|
+
date: Sat Jul 21 17:21:19 2007 +0200
|
540
|
+
summary: complete usage and aliases for tiddler type to file
|
541
|
+
|
542
|
+
changeset: 19:293b94b6c938
|
543
|
+
user: root@dachary.org
|
544
|
+
date: Sat Jul 21 16:22:01 2007 +0200
|
545
|
+
summary: implement --all
|
546
|
+
|
547
|
+
changeset: 18:f6063aa4247c
|
548
|
+
user: root@dachary.org
|
549
|
+
date: Sat Jul 21 16:17:38 2007 +0200
|
550
|
+
summary: implement time preservation
|
551
|
+
|
552
|
+
changeset: 17:1a95e161bde8
|
553
|
+
user: root@dachary.org
|
554
|
+
date: Sat Jul 21 15:43:46 2007 +0200
|
555
|
+
summary: do not clear the cache each time read_uri is called
|
556
|
+
|
557
|
+
changeset: 16:78cbb71abc07
|
558
|
+
user: root@dachary.org
|
559
|
+
date: Sat Jul 21 15:31:47 2007 +0200
|
560
|
+
summary: test against argv > 2 is done after expansion
|
561
|
+
|
562
|
+
changeset: 15:c4a68e334122
|
563
|
+
user: root@dachary.org
|
564
|
+
date: Sat Jul 21 15:07:23 2007 +0200
|
565
|
+
summary: use string functions to split url fragments
|
566
|
+
|
567
|
+
changeset: 14:4a67be41486a
|
568
|
+
user: root@dachary.org
|
569
|
+
date: Sat Jul 21 14:06:11 2007 +0200
|
570
|
+
summary: first implementation 100% tested
|
571
|
+
|
572
|
+
changeset: 13:36dfc330051c
|
573
|
+
user: root@dachary.org
|
574
|
+
date: Sat Jul 21 12:25:18 2007 +0200
|
575
|
+
summary: implement args2from with tests
|
576
|
+
|
577
|
+
changeset: 12:9fdd8158d09e
|
578
|
+
user: root@dachary.org
|
579
|
+
date: Sat Jul 21 11:00:14 2007 +0200
|
580
|
+
summary: test helpers are included instead of inherited
|
581
|
+
|
582
|
+
changeset: 11:3e6d6b581c56
|
583
|
+
user: root@dachary.org
|
584
|
+
date: Sat Jul 21 10:36:41 2007 +0200
|
585
|
+
summary: test helpers are included instead of inherited
|
586
|
+
|
587
|
+
changeset: 10:c34230f8508b
|
588
|
+
user: root@dachary.org
|
589
|
+
date: Sat Jul 21 02:56:45 2007 +0200
|
590
|
+
summary: 75% tests
|
591
|
+
|
592
|
+
changeset: 9:671418aee5c3
|
593
|
+
user: root@dachary.org
|
594
|
+
date: Fri Jul 20 22:59:00 2007 +0200
|
595
|
+
summary: fix to compile and run test stubs
|
596
|
+
|
597
|
+
changeset: 8:e7130c15d293
|
598
|
+
user: root@dachary.org
|
599
|
+
date: Thu Jul 19 23:06:01 2007 +0200
|
600
|
+
summary: draft implementation
|
601
|
+
|
602
|
+
changeset: 7:76bfb609451a
|
603
|
+
user: root@dachary.org
|
604
|
+
date: Thu Jul 19 11:54:58 2007 +0200
|
605
|
+
summary: test puts action
|
606
|
+
|
607
|
+
changeset: 6:7ba8ec638385
|
608
|
+
user: root@dachary.org
|
609
|
+
date: Thu Jul 19 11:35:29 2007 +0200
|
610
|
+
summary: test puts action
|
611
|
+
|
612
|
+
changeset: 5:6b2ca1329232
|
613
|
+
user: root@dachary.org
|
614
|
+
date: Thu Jul 19 10:37:28 2007 +0200
|
615
|
+
summary: upgrade to GPLv3
|
616
|
+
|
617
|
+
changeset: 4:508ab2e4b392
|
618
|
+
user: root@dachary.org
|
619
|
+
date: Thu Jul 19 01:31:17 2007 +0200
|
620
|
+
summary: options parsing and tiddlywiki predicate
|
621
|
+
|
622
|
+
changeset: 3:68dd181ffa42
|
623
|
+
user: root@dachary.org
|
624
|
+
date: Wed Jul 18 21:27:52 2007 +0200
|
625
|
+
summary: import http://simonbaird.com/r4tw/
|
626
|
+
|
627
|
+
changeset: 2:3171d10560d3
|
628
|
+
user: root@dachary.org
|
629
|
+
date: Wed Jul 18 21:27:23 2007 +0200
|
630
|
+
summary: define project tiddlywiki_cp
|
631
|
+
|
632
|
+
changeset: 1:f7bb93667109
|
633
|
+
user: root@dachary.org
|
634
|
+
date: Wed Jul 18 19:28:02 2007 +0200
|
635
|
+
summary: import http://simonbaird.com/r4tw/
|
636
|
+
|
637
|
+
changeset: 0:5bc877af0761
|
638
|
+
user: root@dachary.org
|
639
|
+
date: Wed Jul 18 18:21:06 2007 +0200
|
640
|
+
summary: ruby /var/lib/gems/1.8/gems/newgem-0.11.0/bin/newgem -t test::unit tiddlywiki_cp
|
641
|
+
|
642
|
+
}}}</pre>
|
643
|
+
</div>
|
499
644
|
<div title="DefaultTiddlers" modifier="loic" modified="200707211643" created="200707211620" changecount="2">
|
500
645
|
<pre>Introduction
|
501
646
|
Usage</pre>
|
@@ -515,8 +660,11 @@ tiddlywiki_cp -a website/files website/index.html
|
|
515
660
|
Loic Dachary <mailto:loic@dachary.org>
|
516
661
|
</pre>
|
517
662
|
</div>
|
518
|
-
<div title="MainMenu" modifier="loic" modified="
|
519
|
-
<pre>[[
|
663
|
+
<div title="MainMenu" modifier="loic" modified="200707221924" created="200707211619" changecount="2">
|
664
|
+
<pre>[[Introduction]]
|
665
|
+
[[Usage]]
|
666
|
+
[[ChangeLog]]
|
667
|
+
</pre>
|
520
668
|
</div>
|
521
669
|
<div title="SiteSubtitle" modifier="loic" modified="200707211623" created="200707211618" changecount="1">
|
522
670
|
<pre>copy tiddlers to files and vice versa</pre>
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: tiddlywiki_cp
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0
|
7
|
-
date: 2007-07-
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2007-07-22 00:00:00 +02:00
|
8
8
|
summary: copy tiddlers to files and vice versa
|
9
9
|
require_paths:
|
10
10
|
- lib
|