tiddlywiki_cp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/COPYING +674 -0
  2. data/History.txt +4 -0
  3. data/Manifest.txt +68 -0
  4. data/README.txt +3 -0
  5. data/Rakefile +123 -0
  6. data/bin/tiddlywiki_cp +13 -0
  7. data/lib/tiddlywiki_cp/converters.rb +36 -0
  8. data/lib/tiddlywiki_cp/file2file.rb +32 -0
  9. data/lib/tiddlywiki_cp/file2tiddler.rb +42 -0
  10. data/lib/tiddlywiki_cp/r4tw.rb +763 -0
  11. data/lib/tiddlywiki_cp/tiddler2directory.rb +27 -0
  12. data/lib/tiddlywiki_cp/tiddler2file.rb +41 -0
  13. data/lib/tiddlywiki_cp/tiddler2tiddlywiki.rb +29 -0
  14. data/lib/tiddlywiki_cp/tiddler_css.rb +39 -0
  15. data/lib/tiddlywiki_cp/tiddler_html.rb +39 -0
  16. data/lib/tiddlywiki_cp/tiddler_js.rb +39 -0
  17. data/lib/tiddlywiki_cp/tiddlywiki2file.rb +29 -0
  18. data/lib/tiddlywiki_cp/version.rb +24 -0
  19. data/lib/tiddlywiki_cp.rb +378 -0
  20. data/scripts/txt2html +67 -0
  21. data/setup.rb +1585 -0
  22. data/test/content/a +0 -0
  23. data/test/content/a.div +0 -0
  24. data/test/content/b +0 -0
  25. data/test/content/e +3 -0
  26. data/test/content/e.div +1 -0
  27. data/test/content/html_entities.html +6 -0
  28. data/test/content/test_fetch.html +6 -0
  29. data/test/content/universe.html +10522 -0
  30. data/test/r4tw/addtag.rb +93 -0
  31. data/test/r4tw/all.rb +29 -0
  32. data/test/r4tw/createfrom.rb +62 -0
  33. data/test/r4tw/empties/2.1.3.html +7087 -0
  34. data/test/r4tw/empties/2.2.0.beta5.html +8726 -0
  35. data/test/r4tw/fromremote.rb +19 -0
  36. data/test/r4tw/fromurl.rb +28 -0
  37. data/test/r4tw/shadows.rb +27 -0
  38. data/test/r4tw/tiddler.rb +70 -0
  39. data/test/r4tw/tiddlerfromurl.rb +23 -0
  40. data/test/r4tw/tiddlywiki.rb +66 -0
  41. data/test/r4tw/utils.rb +55 -0
  42. data/test/r4tw/withcontent/2.2.0.beta5.html +8739 -0
  43. data/test/r4tw/withcontent/22b5index.html +13523 -0
  44. data/test/r4tw/withcontent/empty2.html +7084 -0
  45. data/test/r4tw/withcontent/nothing.js +1 -0
  46. data/test/r4tw/write_all_tiddlers_to.rb +62 -0
  47. data/test/test_all.rb +8 -0
  48. data/test/test_helper.rb +36 -0
  49. data/test/test_tiddler_css.rb +55 -0
  50. data/test/test_tiddler_html.rb +54 -0
  51. data/test/test_tiddler_js.rb +56 -0
  52. data/test/test_tiddlywiki_cp.rb +341 -0
  53. data/website/files/DefaultTiddlers.tiddler +2 -0
  54. data/website/files/DefaultTiddlers.tiddler.div +1 -0
  55. data/website/files/Introduction.tiddler +12 -0
  56. data/website/files/Introduction.tiddler.div +1 -0
  57. data/website/files/MainMenu.tiddler +1 -0
  58. data/website/files/MainMenu.tiddler.div +1 -0
  59. data/website/files/SiteSubtitle.tiddler +1 -0
  60. data/website/files/SiteSubtitle.tiddler.div +1 -0
  61. data/website/files/SiteTitle.tiddler +1 -0
  62. data/website/files/SiteTitle.tiddler.div +1 -0
  63. data/website/files/Usage.tiddler +55 -0
  64. data/website/files/Usage.tiddler.div +1 -0
  65. data/website/files/WebDAVSavingPlugin.js +234 -0
  66. data/website/files/WebDAVSavingPlugin.js.div +1 -0
  67. data/website/index.html +9144 -0
  68. data/website/index.xml +336 -0
  69. metadata +116 -0
@@ -0,0 +1,55 @@
1
+ {{{
2
+ Usage: tiddlywiki_cp [options] FROM [FROM ...] TO|-
3
+
4
+ -r, --[no-]recursive recurse into directories and tiddlywikies
5
+ -t, --[no-]times preserve modification time
6
+ -a, --all implies -rt
7
+ -i, --include REGEX all files,directories or tiddlers must match regex.
8
+ If specified multiple times,
9
+ must match at least one of the regex.
10
+ Includes are tested after excludes.
11
+ --exclude REGEX all files,directories or tiddlers must NOT match regex.
12
+ If specified multiple times,
13
+ exclude if matches at least one of the regex.
14
+ Includes are tested after excludes.
15
+ -v, --[no-]verbose run verbosely
16
+ -n, --[no-]dry-run show what would have been transferred
17
+ --version show version
18
+ --help show command usage
19
+
20
+ Examples:
21
+
22
+ mkdir /tmp/a ; tiddlywiki_cp -a http://tiddlywiki.com/index.html /tmp/a
23
+ copies index.html tiddlers in separate files and preserve times.
24
+ For each tiddler, a .div file contains the meta information.
25
+ The files are named after their content:
26
+ /tmp/a/HelloThere.tiddler
27
+ /tmp/a/HelloThere.tiddler.div
28
+ /tmp/a/Plugin.js
29
+ /tmp/a/Plugin.js.div
30
+ /tmp/a/OwnStyle.css
31
+ /tmp/a/OwnStyle.css.div
32
+ ...
33
+
34
+ tiddlywiki_cp 'http://tiddlylab.bidix.info/#WebDAVSavingPlugin' tiddlywiki.html
35
+ copies the WebDAVSavingPlugin tiddler in the existing tiddlywiki.html
36
+
37
+ tiddlywiki_cp http://tiddlywiki.com/index.html /tmp/i.html
38
+ copies to a local file
39
+
40
+ tiddlywiki_cp -t myplugin.js tiddlywiki.html
41
+ copies the tiddler in the existing tiddlywiki.html tiddlywiki
42
+ and use file system modification time
43
+
44
+ tiddlywiki_cp 'http://tiddlylab.bidix.info/#WebDAVSavingPlugin' WebDAVSavingPlugin.js
45
+ get a local copy of the WebDAVSavingPlugin tiddler
46
+
47
+ mkdir A ; tiddlywiki_cp -a --include 'WebDAV' --include 'RSS' 'http://tiddlylab.bidix.info/' A
48
+ copy all tiddlers with WebDAV or RSS in the url
49
+
50
+ mkdir A ; tiddlywiki_cp -a --exclude 'SEX' 'http://tiddlylab.bidix.info/' A
51
+ copy all tiddlers except those with SEX in the url
52
+
53
+ tiddlywiki_cp -a A B C tiddlywiki.html
54
+ copy all tiddlers found in the A B and C directories to tiddlywiki.html
55
+ }}}
@@ -0,0 +1 @@
1
+ title="Usage" modifier="loic" modified="200707211623" created="200707211620" changecount="1"
@@ -0,0 +1,234 @@
1
+ /***
2
+ |''Name:''|WebDAVSavingPlugin|
3
+ |''Description:''|Saves on a WebDAV server without the need of any ServerSide script.<br>When TiddlyWiki is accessed over http, this plugin permits to save back to the server, using http PUT.|
4
+ |''Version:''|0.2.1|
5
+ |''Date:''|Apr 21, 2007|
6
+ |''Source:''|http://tiddlywiki.bidix.info/#WebDAVSavingPlugin|
7
+ |''Author:''|BidiX (BidiX (at) bidix (dot) info)|
8
+ |''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
9
+ |''~CoreVersion:''|2.2.0 (Beta 5)|
10
+ ***/
11
+ //{{{
12
+ version.extensions.WebDAVSavingPlugin = {
13
+ major: 0, minor: 2, revision: 1,
14
+ date: new Date("Apr 21, 2007"),
15
+ source: 'http://tiddlywiki.bidix.info/#WebDAVSavingPlugin',
16
+ author: 'BidiX (BidiX (at) bidix (dot) info',
17
+ license: '[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D]]',
18
+ coreVersion: '2.2.0 (Beta 5)'
19
+ };
20
+
21
+ if (!window.bidix) window.bidix = {};
22
+ bidix.WebDAVSaving = {
23
+ orig_saveChanges: saveChanges,
24
+ defaultFilename: 'index.html',
25
+ messages: {
26
+ loadOriginalHttpDavError: "Original file can't be loaded",
27
+ optionsMethodError: "The OPTIONS method can't be used on this ressource : %0",
28
+ webDavNotEnabled: "WebDAV is not enabled on this ressource : %0",
29
+ notHTTPUrlError: "WebDAV saving can be used for http viewed TiddlyWiki only",
30
+ aboutToSaveOnHttpDav: 'About to save on %0 ...' ,
31
+ folderCreated: "Remote folder '%0' created"
32
+ }
33
+ };
34
+
35
+ // Save this tiddlywiki with the pending changes
36
+ saveChanges = function(onlyIfDirty,tiddlers)
37
+ {
38
+ var originalPath = document.location.toString();
39
+ if (originalPath.substr(0,5) == "file:")
40
+ return bidix.WebDAVSaving.orig_saveChanges(onlyIfDirty,tiddlers);
41
+ else
42
+ return bidix.WebDAVSaving.saveChanges(onlyIfDirty,tiddlers);
43
+ }
44
+
45
+ bidix.WebDAVSaving.saveChanges = function(onlyIfDirty,tiddlers)
46
+ {
47
+ var callback = function(status,params,original,url,xhr) {
48
+ url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
49
+ if (!status)
50
+ displayMessage(bidix.WebDAVSaving.messages.optionsMethodError.format([url]));
51
+ else {
52
+ if (!xhr.getResponseHeader("DAV"))
53
+ alert(bidix.WebDAVSaving.messages.webDavNotEnabled.format([url]));
54
+ else
55
+ bidix.WebDAVSaving.doSaveChanges();
56
+ }
57
+ }
58
+ if(onlyIfDirty && !store.isDirty())
59
+ return;
60
+ clearMessage();
61
+ var originalPath = document.location.toString();
62
+ // Check we were loaded from a HTTP or HTTPS URL
63
+ if(originalPath.substr(0,4) != "http") {
64
+ alert(bidix.WebDAVSaving.messages.notHTTPUrlError);
65
+ return;
66
+ }
67
+ // is the server WebDAV enabled ?
68
+ var r = doHttp("OPTIONS",originalPath,null,null,null,null,callback,null,null);
69
+ if (typeof r == "string")
70
+ alert(r);
71
+ }
72
+
73
+ bidix.WebDAVSaving.doSaveChanges = function()
74
+ {
75
+ var callback = function(status,params,original,url,xhr) {
76
+ if (!status) {
77
+ alert(config.messages.loadOriginalHttpDavError);
78
+ return;
79
+ }
80
+ url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
81
+ // Locate the storeArea div's
82
+ var posDiv = locateStoreArea(original);
83
+ if((posDiv[0] == -1) || (posDiv[1] == -1)) {
84
+ alert(config.messages.invalidFileError.format([localPath]));
85
+ return;
86
+ }
87
+ bidix.WebDAVSaving.mkbackupfolder(null,null,params,original,posDiv);
88
+ };
89
+ // get original
90
+ var originalPath = document.location.toString();
91
+ if (originalPath.charAt(originalPath.length-1) == "/")
92
+ originalPath = originalPath + bidix.WebDAVSaving.defaultFilename;
93
+ displayMessage(bidix.WebDAVSaving.messages.aboutToSaveOnHttpDav.format([originalPath]));
94
+ doHttp("GET",originalPath,null,null,null,null,callback,originalPath,null);
95
+ };
96
+
97
+ bidix.WebDAVSaving.mkbackupfolder = function(root,dirs,url,original,posDiv) {
98
+ if (!root || !dirs) {
99
+ root = bidix.dirname(url);
100
+ if (config.options.txtBackupFolder == "")
101
+ dirs = null;
102
+ else
103
+ dirs = config.options.txtBackupFolder.split('/');
104
+ }
105
+ if (config.options.chkSaveBackups && dirs && (dirs.length > 0))
106
+ bidix.WebDAVSaving.mkdir(root,dirs.shift(),dirs,url,original,posDiv);
107
+ else
108
+ bidix.WebDAVSaving.saveBackup(url,original,posDiv);
109
+ };
110
+
111
+ bidix.WebDAVSaving.saveBackup = function(url,original,posDiv)
112
+ {
113
+ var callback = function(status,params,responseText,url,xhr) {
114
+ if (!status) {
115
+ alert(config.messages.backupFailed);
116
+ return;
117
+ }
118
+ url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
119
+ displayMessage(config.messages.backupSaved,url);
120
+ bidix.WebDAVSaving.saveRss(params[0],params[1],params[2]);
121
+ };
122
+ if(config.options.chkSaveBackups) {
123
+ var backupPath = getBackupPath(url);
124
+ bidix.httpPut(backupPath,original,callback,Array(url,original,posDiv));
125
+ } else {
126
+ bidix.WebDAVSaving.saveRss(url,original,posDiv);
127
+ }
128
+ }
129
+
130
+ bidix.WebDAVSaving.saveRss = function(url,original,posDiv)
131
+ {
132
+ var callback = function(status,params,responseText,url,xhr) {
133
+ if (!status) {
134
+ alert(config.messages.rssFailed);
135
+ return;
136
+ }
137
+ url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
138
+ displayMessage(config.messages.rssSaved,url);
139
+ bidix.WebDAVSaving.saveEmpty(params[0],params[1],params[2]);
140
+ };
141
+ if(config.options.chkGenerateAnRssFeed) {
142
+ var rssPath = url.substr(0,url.lastIndexOf(".")) + ".xml";
143
+ bidix.httpPut(rssPath,convertUnicodeToUTF8(generateRss()),callback,Array(url,original,posDiv));
144
+ } else {
145
+ bidix.WebDAVSaving.saveEmpty(url,original,posDiv);
146
+ }
147
+ }
148
+
149
+ bidix.WebDAVSaving.saveEmpty = function(url,original,posDiv)
150
+ {
151
+ var callback = function(status,params,responseText,url,xhr) {
152
+ if (!status) {
153
+ alert(config.messages.emptyFailed);
154
+ return;
155
+ }
156
+ url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
157
+ displayMessage(config.messages.emptySaved,url);
158
+ bidix.WebDAVSaving.saveMain(params[0],params[1],params[2]);
159
+ };
160
+ if(config.options.chkSaveEmptyTemplate) {
161
+ var emptyPath,p;
162
+ if((p = url.lastIndexOf("/")) != -1)
163
+ emptyPath = url.substr(0,p) + "/empty.html";
164
+ else
165
+ emptyPath = url + ".empty.html";
166
+ var empty = original.substr(0,posDiv[0] + startSaveArea.length) + original.substr(posDiv[1]);
167
+ bidix.httpPut(emptyPath,empty,callback,Array(url,original,posDiv));
168
+ } else {
169
+ bidix.WebDAVSaving.saveMain(url,original,posDiv);
170
+ }
171
+ }
172
+
173
+ bidix.WebDAVSaving.saveMain = function(url,original,posDiv)
174
+ {
175
+ var callback = function(status,params,responseText,url,xhr) {
176
+ if(status) {
177
+ url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
178
+ displayMessage(config.messages.mainSaved,url);
179
+ store.setDirty(false);
180
+ } else
181
+ alert(config.messages.mainFailed);
182
+ };
183
+ // Save new file
184
+ var revised = updateOriginal(original,posDiv);
185
+ bidix.httpPut(url,revised,callback,null);
186
+ }
187
+
188
+ // asynchronous mkdir
189
+ bidix.WebDAVSaving.mkdir = function(root,dir,dirs,url,original,posDiv) {
190
+ var callback = function(status,params,responseText,url,xhr) {
191
+ url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
192
+ if (status == null) {
193
+ alert("Error in mkdir");
194
+ return;
195
+ }
196
+ if (xhr.status == httpStatus.ContentCreated) {
197
+ displayMessage(bidix.WebDAVSaving.messages.folderCreated.format([url]),url);
198
+ bidix.WebDAVSaving.mkbackupfolder(url,params[1],params[2],params[3],params[4]);
199
+ } else {
200
+ if (xhr.status == httpStatus.NotFound)
201
+ bidix.http('MKCOL',url,null,callback,params);
202
+ else
203
+ bidix.WebDAVSaving.mkbackupfolder(url,params[1],params[2],params[3],params[4]);
204
+ }
205
+ };
206
+ if (root.charAt(root.length) != '/')
207
+ root = root +'/';
208
+ bidix.http('HEAD',root+dir,null,callback,Array(root,dirs,url,original,posDiv));
209
+ }
210
+
211
+ bidix.httpPut = function(url,data,callback,params)
212
+ {
213
+ return bidix.http("PUT",url,data,callback,params);
214
+ }
215
+
216
+ bidix.http = function(type,url,data,callback,params)
217
+ {
218
+ var r = doHttp(type,url,data,null,null,null,callback,params,null);
219
+ if (typeof r == "string")
220
+ alert(r);
221
+ return r;
222
+ }
223
+
224
+ bidix.dirname = function (filePath) {
225
+ if (!filePath)
226
+ return;
227
+ var lastpos;
228
+ if ((lastpos = filePath.lastIndexOf("/")) != -1) {
229
+ return filePath.substring(0, lastpos);
230
+ } else {
231
+ return filePath.substring(0, filePath.lastIndexOf("\\"));
232
+ }
233
+ };
234
+ //}}}
@@ -0,0 +1 @@
1
+ title="WebDAVSavingPlugin" modifier="BidiX" modified="200704212208" created="200702221114" tags="systemConfig" changecount="4"