Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.upstream.oldstuff.uploadMultipleFiles
on uploadMultipleFiles (filelist) { <<Changes <<Wednesday, September 20, 2000 at 3:32:33 PM by DW <<Delete temporary debugging code. <<On Macintosh, replace colons with backslashes in relativePath elements. <<Thursday, September 21, 2000 at 2:28:39 PM by JES <<Replace the path character with forward slashes, not backslashes, since the server is expecting a forward-slash-delimited relative path. <<The reason why it was working on windows, even without this is that the server is a windows computer, so the delimiter was already correct. If the server had been a Macintosh, then Mac users would have been fine, and the bug would have been reported by Windows users. <<Sunday, September 24, 2000 at 7:23:04 PM by JES <<Cosmetic change to msg text. <<10/17/00; 6:07:34 PM by PBS <<If the password or username are empty, don't attempt to upstream, generate a scriptError. <<Friday, December 29, 2000 at 9:10:16 AM by DW <<Added logging code. <<12/30/00; 7:36:46 PM by DW <<Move the logging code into radio.log.add, call it. <<12/30/00; 9:30:46 PM by DW <<Pass startticks to radio.log.add. <<1/3/01; 8:04:43 PM by DW <<Added callback support. <<1/22/01; 11:04:06 AM by DW <<Set user.radio.settings.wwwUpstreamFolderUrl after every upstream event. <<2/10/01; 9:54:06 PM by DW <<Raise the timeout to sixty seconds. Some people have slow connections or might be far away from the cloud. Let's give this a try. <<2/12/01; 1:27:52 PM by DW <<Make timeout a pref. <<bundle //debugging code <<if not defined (system.temp.radio.upstream) <<new (tabletype, @system.temp.radio.upstream) <<system.temp.radio.upstream.lastfilelist = filelist local (startticks = clock.ticks ()); local (timeout = user.radio.prefs.upstream.timeoutSeconds * 60); local (f, relativePathList = {}, fileTextList = {}, s, pc = file.getPathChar ()); for f in filelist { s = string.delete (string (f), 1, sizeof (user.radio.prefs.upstream.folder)); s = string.replaceAll (s, pc, '/'); relativePathList = relativePathList + {s}; fileTextList = fileTextList + radio.upstream.getUpstreamText (f)}; local (useremail, userpassword); with user.radio.prefs.upstream.account { bundle { //error checking if email == "" { scriptError ("Can't upstream because your email address has not been specified.")}; if password == "" { scriptError ("Can't upstream because your password has not been specified.")}; useremail = email; userpassword = password}}; local (flerror, message, urllist, logdata); new (tabletype, @logdata); logdata.filelist = filelist; bundle { //make the xml-rpc call if sizeof (filelist) == 1 { msg ("Upstreaming " + filelist [1] + ".")} else { msg ("Upstreaming " + sizeof (filelist) + " files.")}; try { xmlStorageSystem.writeMultipleFiles (useremail, userpassword, relativepathlist, filetextlist, @response, adrdata:@user.radio.prefs.upstream.xmlStorageSystem); <<response = betty.rpc.client (server, port, saveMultipleProcedure, @params, flShowMessages:false, ticksToTimeOut:timeout) flerror = response.flerror; message = response.message; urllist = response.urllist; user.radio.settings.wwwUpstreamFolderUrl = response.yourUpstreamFolderUrl; logdata.response = response} else { flerror = true; message = tryerror; urllist = {}}; msg ("")}; bundle { //logging if user.radio.prefs.upstream.logging { local (htmltext = ""); if flerror { htmltext = "Error: " + message} else { local (url); for url in urllist { htmltext = htmltext + "<a href=\"" + url + "\">" + string.nthfield (url, "/", string.countfields (url, "/")) + "</a>, "}; htmltext = string.delete (htmltext, sizeof (htmltext) - 1, 2) + " copied to the cloud."}; radio.log.add ("Upstream", htmltext, startticks, @logdata)}}; bundle { //call the callbacks, if present local (adr, adrcallbacks = @user.radio.callbacks.upstream); if defined (adrcallbacks^) { for adr in adrcallbacks { while typeof (adr^) == addresstype { adr = adr^}; try {adr^ (filelist)}}}}; return (urllist)}; bundle { //test code local (filelist = {"C:\\Program Files\\Radio UserLand\\www\\stories\\2001\\05\\13\\thisIsAlsoATestStory.opml", "C:\\Program Files\\Radio UserLand\\www\\stories\\2001\\05\\13\\testStory.opml"}); dialog.alert (uploadMultipleFiles (filelist))}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.