Changeset 4953
- Timestamp:
- 14/05/08 18:53:47 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Trunk/contributors/MartinBudden/adaptors/ImportWorkspacePlugin.js
r4951 r4953 4 4 |''Author:''|Martin Budden (mjbudden (at) gmail (dot) com)| 5 5 |''CodeRepository:''|http://svn.tiddlywiki.org/Trunk/contributors/MartinBudden/adaptors/ImportWorkspacePlugin.js | 6 |''Version:''|0.0. 8|6 |''Version:''|0.0.9| 7 7 |''Date:''|Aug 23, 2007| 8 8 |''Comments:''|Please make comments at http://groups.google.co.uk/group/TiddlyWikiDev | … … 142 142 if(context) { 143 143 context.adaptor.openHost(context.host,context); 144 context.adaptor.getWorkspaceList(context,null,config.macros.importWorkspace.getWorkspaceListCallback);145 //context.adaptor.openWorkspace(context.workspace,context);144 //context.adaptor.getWorkspaceList(context,null,config.macros.importWorkspace.getWorkspaceListCallback); 145 context.adaptor.openWorkspace(context.workspace,context,null,config.macros.importWorkspace.openWorkspaceCallback); 146 146 //context.adaptor.getTiddlerList(context); 147 147 return true; … … 150 150 }; 151 151 152 config.macros.importWorkspace. getWorkspaceListCallback = function(context,userParams)152 config.macros.importWorkspace.openWorkspaceCallback = function(context,userParams) 153 153 { 154 154 if(context.status) { Trunk/contributors/MartinBudden/adaptors/WikispacesSoapAdaptorPlugin.js
r4952 r4953 8 8 |''Date:''|Feb 15, 2008| 9 9 |''Comments:''|Please make comments at http://groups.google.co.uk/group/TiddlyWikiDev | 10 |''License:''|[[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]] |10 |''License:''|[[Creative Commons Attribution-ShareAlike 3.0 License|http://creativecommons.org/licenses/by-sa/3.0/]] | 11 11 |''~CoreVersion:''|2.3.0| 12 12 … … 128 128 WikispacesSoapAdaptor.loginCallback = function(r,x,context)//status,context,responseText,url,xhr) 129 129 { 130 varstatus = r instanceof Error ? false : true;130 context.status = r instanceof Error ? false : true; 131 131 fnLog('loginCallback:'+status); 132 132 console.log(r); 133 133 console.log(x); 134 if(r instanceof Error) { 135 context.status = false; 136 context.statusText = "Error at login"; 137 } else { 138 context.status = true; 134 if(context.status) { 139 135 context.sessionToken = r; 140 136 context.adaptor.sessionToken = r; 141 } 142 if(context.complete) 143 context.complete(context,context.userParams); 137 if(context.complete) 138 context.complete(context,context.userParams); 139 } else { 140 context.statusText = "Error at login"; 141 if(context.callback) 142 context.callback(context,context.userParams); 143 } 144 144 }; 145 145 … … 161 161 this.workspace = workspace; 162 162 context = this.setContext(context,userParams,callback); 163 if(context.callback) {164 context.status = true;165 window.setTimeout(function() {callback(context,userParams);},0);166 }167 return true;168 };169 170 WikispacesSoapAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)171 {172 fnLog('getWorkspaceList');173 context = this.setContext(context,userParams,callback);174 var workspace = userParams ? userParams.getValue("feedWorkspace") : context.workspace;//!! kludge until core fixed175 var list = [];176 list.push({title:workspace,name:workspace});177 163 context.workspace = workspace; 178 context.workspaces = list; 179 return this.complete(context,WikispacesSoapAdaptor.getWorkspaceListComplete); 180 }; 181 182 WikispacesSoapAdaptor.getWorkspaceListComplete = function(context,userParams) 183 { 184 fnLog('getWorkspaceListComplete'); 164 return this.complete(context,WikispacesSoapAdaptor.openWorkspaceComplete); 165 }; 166 167 WikispacesSoapAdaptor.openWorkspaceComplete = function(context,userParams) 168 { 169 fnLog('opentWorkspaceComplete'); 185 170 //# http://www.wikispaces.com/space/api?wsdl 186 171 var uri = WikispacesSoapAdaptor.SoapUri(context,'%0space/api'); … … 188 173 var pl = new SOAPClientParameters(); 189 174 pl.add('session',context.sessionToken); 190 pl.add('name',context.workspace s[0].name);191 SOAPClient.invoke(uri,'getSpace',pl,true,WikispacesSoapAdaptor. getWorkspaceListCallback,context);192 return true; 193 }; 194 195 WikispacesSoapAdaptor. getWorkspaceListCallback = function(r,x,context)//(status,context,responseText,uri,xhr)175 pl.add('name',context.workspace); 176 SOAPClient.invoke(uri,'getSpace',pl,true,WikispacesSoapAdaptor.openWorkspaceCallback,context); 177 return true; 178 }; 179 180 WikispacesSoapAdaptor.openWorkspaceCallback = function(r,x,context)//(status,context,responseText,uri,xhr) 196 181 { 197 182 var status = r instanceof Error ? false : true; 198 fnLog(' getWorkspaceListCallback:'+status);183 fnLog('openWorkspaceCallback:'+status); 199 184 context.status = false; 200 185 function gev(p,i,n) { … … 203 188 } catch(ex) { 204 189 } 190 return null; 205 191 } 206 192 if(status) { … … 218 204 context.status = true; 219 205 } else { 206 context.statusText = WikispacesSoapAdaptor.errorInFunctionMessage.format(['openWorkspaceCallback']); 207 } 208 if(context.callback) 209 context.callback(context,context.userParams); 210 }; 211 212 WikispacesSoapAdaptor.prototype.getWorkspaceList = function(context,userParams,callback) 213 { 214 fnLog('getWorkspaceList'); 215 context = this.setContext(context,userParams,callback); 216 var workspace = userParams ? userParams.getValue("feedWorkspace") : context.workspace;//!! kludge until core fixed 217 var list = []; 218 list.push({title:workspace,name:workspace}); 219 context.workspace = workspace; 220 context.workspaces = list; 221 return this.complete(context,WikispacesSoapAdaptor.getWorkspaceListComplete); 222 }; 223 224 WikispacesSoapAdaptor.getWorkspaceListComplete = function(context,userParams) 225 { 226 fnLog('getWorkspaceListComplete'); 227 //# http://www.wikispaces.com/space/api?wsdl 228 var uri = WikispacesSoapAdaptor.SoapUri(context,'%0space/api'); 229 //#console.log('uri:'+uri); 230 var pl = new SOAPClientParameters(); 231 pl.add('session',context.sessionToken); 232 pl.add('name',context.workspaces[0].name); 233 SOAPClient.invoke(uri,'getSpace',pl,true,WikispacesSoapAdaptor.getWorkspaceListCallback,context); 234 return true; 235 }; 236 237 WikispacesSoapAdaptor.getWorkspaceListCallback = function(r,x,context)//(status,context,responseText,uri,xhr) 238 { 239 var status = r instanceof Error ? false : true; 240 fnLog('getWorkspaceListCallback:'+status); 241 context.status = false; 242 function gev(p,i,n) { 243 try { 244 return p[i].getElementsByTagName(n)[0].childNodes[0].nodeValue; 245 } catch(ex) { 246 } 247 return null; 248 } 249 if(status) { 250 try { 251 var p = x.getElementsByTagName('space'); 252 context.workspaceId = gev(p,0,'id'); 253 context.adaptor.workspaceId = context.workspaceId; 254 //#console.log("workspaceId:"+context.workspaceId); 255 } catch (ex) { 256 context.statusText = exceptionText(ex,WikispacesSoapAdaptor.serverParsingErrorMessage); 257 if(context.callback) 258 context.callback(context,context.userParams); 259 return; 260 } 261 context.status = true; 262 } else { 220 263 context.statusText = WikispacesSoapAdaptor.errorInFunctionMessage.format(['getWorkspaceListCallback']); 221 //context.statusText = xhr.statusText;222 264 } 223 265 if(context.callback) … … 387 429 } catch(ex) { 388 430 } 431 return null; 389 432 } 390 433 if(status) { … … 565 608 { 566 609 var status = r instanceof Error ? false : true; 567 //#fnLog('getTopicListCallback:'+status);610 fnLog('getTopicListCallback:'+status); 568 611 context.status = false; 569 612 context.statusText = WikispacesSoapAdaptor.errorInFunctionMessage.format(['getTopicListCallback']); Trunk/contributors/MartinBudden/plugins/ImportWikispacesMessagesPlugin.js
r4944 r4953 4 4 |''Author:''|Martin Budden (mjbudden (at) gmail (dot) com)| 5 5 |''CodeRepository:''|http://svn.tiddlywiki.org/Trunk/contributors/MartinBudden/plugins/ImportWikispacesMessagesPlugin.js | 6 |''Version:''|0.0. 2|6 |''Version:''|0.0.3| 7 7 |''Date:''|May 13, 2008| 8 8 |''Comments:''|Please make comments at http://groups.google.co.uk/group/TiddlyWikiDev | … … 91 91 { 92 92 if(context) { 93 context.title = title; 93 94 context.adaptor.openHost(context.host,context); 94 context.adaptor.openWorkspace(context.workspace,context); 95 context.adaptor.getTopicList(title,context,null,config.macros.importWikispacesMessages.getTopicListCallback); 95 context.adaptor.openWorkspace(context.workspace,context,null,config.macros.importWikispacesMessages.openWorkspaceCallback); 96 return true; 97 } 98 return false; 99 }; 100 101 config.macros.importWikispacesMessages.openWorkspaceCallback = function(context,userParams) 102 { 103 if(context.status) { 104 context.adaptor.getTopicList(context.title,context,null,config.macros.importWikispacesMessages.getTopicListCallback); 96 105 return true; 97 106 } … … 101 110 config.macros.importWikispacesMessages.getTopicListCallback = function(context,userParams) 102 111 { 103 //#console.log("config.macros.importW orkspace.getTopicListCallback:"+context.status);112 //#console.log("config.macros.importWikispacesMessages.getTopicListCallback:"+context.status); 104 113 if(context.status) { 105 114 var tiddlers = context.topics; … … 116 125 config.macros.importWikispacesMessages.getMessageListCallback = function(context,userParams) 117 126 { 118 //#console.log("config.macros.importW orkspace.getMessageListCallback:"+context.status);127 //#console.log("config.macros.importWikispacesMessages.getMessageListCallback:"+context.status); 119 128 if(context.status) { 120 129 var tiddlers = context.messages;