tiddlywiki_cp 0.4.1 → 0.5.1

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.
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.4.1
7
- date: 2008-03-30 00:00:00 +00:00
6
+ version: 0.5.1
7
+ date: 2008-04-06 00:00:00 +00:00
8
8
  summary: copy tiddlers to files and vice versa
9
9
  require_paths:
10
10
  - lib
@@ -61,6 +61,7 @@ files:
61
61
  - test/content/test_fetch.html
62
62
  - test/content/tiddly_version_2_1.txt
63
63
  - test/content/tiddly_version_2_2.txt
64
+ - test/content/tiddly_version_2_3.txt
64
65
  - test/content/universe.html
65
66
  - test/r4tw/addtag.rb
66
67
  - test/r4tw/all.rb
@@ -99,8 +100,8 @@ files:
99
100
  - website/files/SiteTitle.tiddler.div
100
101
  - website/files/Usage.tiddler
101
102
  - website/files/Usage.tiddler.div
102
- - website/files/WebDAVSavingPlugin.js
103
- - website/files/WebDAVSavingPlugin.js.div
103
+ - website/files/WebDavPlugin.js
104
+ - website/files/WebDavPlugin.js.div
104
105
  - website/index.html
105
106
  - website/index.xml
106
107
  test_files:
@@ -114,6 +115,7 @@ extra_rdoc_files:
114
115
  - README.txt
115
116
  - test/content/tiddly_version_2_1.txt
116
117
  - test/content/tiddly_version_2_2.txt
118
+ - test/content/tiddly_version_2_3.txt
117
119
  executables:
118
120
  - tiddlywiki_cp
119
121
  extensions: []
@@ -1,234 +0,0 @@
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
- //}}}
@@ -1 +0,0 @@
1
- title="WebDAVSavingPlugin" modifier="BidiX" modified="200704212208" created="200702221114" tags="systemConfig" changecount="4"