Monday, November 08, 2010 at 12:00 AM.
scripting2Suite.server.getOutlineFromUrl
on getOutlineFromUrl (username, url) { <<Changes <<7/14/10; 7:04:33 PM by DW <<Add new outline -- "instantOutline" <<6/27/10; 9:30:16 AM by DW <<This url business was a mistake, but I don't want to unwind it all the way right now (getting ready for a hand-off). <<So... if it begins with http:// treat it as a url and assume it points to a story, get the story and return its opml text. <<If it doesn't begin with http://, it's blogroll, hometemplate or one of the other special outlines. <<6/11/10; 10:26:02 PM by DW <<Factored into urlToStory so we could share code with the save routine. <<on getOutlineFromUrl (username, url) <<Changes <<6/10/10; 1:53:02 PM by DW <<Added special cases for blogroll, hometemplate and storytemplate. <<6/10/10; 11:29:23 AM by DW <<Get the OPML text for stories. Later we'll add special cases for the other outlines we work with, like templates and the blogroll. <<http://scripting.com/stories/2010/06/10/myScripting2Todo.html <<local (adrdata = scripting2suite.inituser (username), adrsystemdata = scripting2suite.init (), baseurl) <<bundle //get baseurl <<if adrdata^.prefs.ftp.enabled <<baseurl = adrdata^.prefs.ftp.url <<else <<baseurl = adrsystemdata^.prefs.baseurl + username + "/" <<local (s = string.delete (url, 1, sizeof (baseurl)), type) //now it's stories/2010/06/10/myScripting2Todo.html <<type = string.nthfield (s, "/", 1) <<s = string.delete (s, 1, sizeof (type) + 1) <<case string.lower (type) <<"stories" <<local (year, month, day, adrday, adrstory) <<year = string.nthfield (s, "/", 1) <<month = string.nthfield (s, "/", 2) <<day = string.nthfield (s, "/", 3) <<adrday = @adrdata^.calendar.[year].[month].[day] <<for adrstory in adrday <<if string.lower (adrstory^.url) == string.lower (url) <<return (adrstory^.opmltext) <<"blogroll" <<return (op.outlinetoxml (@adrdata^.prefs.blogroll)) <<"hometemplate" <<return (op.outlinetoxml (@adrdata^.prefs.homeTemplate)) <<"storytemplate" <<return (op.outlinetoxml (@adrdata^.prefs.storyTemplate)) <<scripterror ("Can't get the outline identified by the url \"" + url + "\" because it doesn't exist.") <<6/10/10; 1:53:02 PM by DW <<Added special cases for blogroll, hometemplate and storytemplate. <<6/10/10; 11:29:23 AM by DW <<Get the OPML text for stories. Later we'll add special cases for the other outlines we work with, like templates and the blogroll. <<http://scripting.com/stories/2010/06/10/myScripting2Todo.html local (adrdata = scripting2suite.inituser (username), type, adrstory, lowerurl = string.lower (url)); if lowerurl beginswith "http://" { scripting2Suite.server.urlToStory (username, url, @type, @adrstory); return (adrstory^.opmltext)} else { case lowerurl { <<"stories" <<return (adrstory^.opmltext) "blogroll" { return (op.outlinetoxml (@adrdata^.prefs.blogroll))}; "hometemplate" { return (op.outlinetoxml (@adrdata^.prefs.homeTemplate))}; "storytemplate" { return (op.outlinetoxml (@adrdata^.prefs.storyTemplate))}; "stylesheet" { return (op.outlinetoxml (@adrdata^.prefs.stylesheet))}; //6/11/10 by DW "instantoutline" { local (s = adrdata^.prefs.instantOutline.opmltext); if sizeof (s) == 0 { local (instantOutline); new (outlinetype, @instantOutline); s = op.outlinetoxml (@instantOutline)}; return (s)}}}}; //7/14/10 by DW bundle { //test code local (tc = clock.ticks (), opmltext); for i = 1 to 1 { opmltext = getOutlineFromUrl ("davewiner", "http://scripting.com/stories/2010/06/10/myScripting2Todo.html")}; dialog.alert (clock.ticks () - tc)} <<op.xmltooutline (opmltext, @scratchpad.storyoutline)
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.