Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.outliner.macros.subscribe
on subscribe () { <<Changes <<9/1/02; 9:00:32 PM by JES <<Only add the IM notification request info to the subscription sub-table if the sub-table exists. <<8/27/02; 1:06:58 AM by JES <<Get IM-based notification request info out of the URL, store it, and request notification if we're set up for it. <<4/3/02; 4:48:09 PM by JES <<If the user clicks the Cancel button in the confirmation dialog, or there's an error reading the outline, delete the subscription table. Prevents "author hasn't been defined" errors. <<3/26/02; 1:43:29 PM by JES <<If pta^.requestHeaders.Referer is not defined, return some text to the browser. Avoids an error message about Referer not being defined. <<3/12/02; 6:48:35 PM by DW <<Created. local (adrdata = radio.outliner.init ()); local (pta = html.getpagetableaddress ()); <<workspace.pt = pta^; edit (@workspace.pt) local (url = pta^.radioResponder.getArgs.url); local (author = pta^.radioResponder.getArgs.author); local (imProtocol, imUsername, imRegisterProcedure); on setImRegisterProcedure (adrsubscription) { local (adrim = @adrsubscription^.imRegisterProcedure); if not defined (adrim^) { new (tableType, adrim)}; adrim^.protocol = imProtocol; adrim^.username = imUsername; adrim^.procedure = imRegisterProcedure}; if adrdata^.prefs.messaging.flEnabled { //register for im-based notifications if defined (pta^.radioResponder.getArgs.imProtocol) { imProtocol = pta^.radioResponder.getArgs.imProtocol}; if defined (pta^.radioResponder.getArgs.imUsername) { imUsername = pta^.radioResponder.getArgs.imUsername}; if defined (pta^.radioResponder.getArgs.imRegisterProcedure) { imRegisterProcedure = pta^.radioResponder.getArgs.imRegisterProcedure}; on register (protocol, screenname, procedure, myname) { local (adrdriver); try { //RPI is asynch -- no error messages if tcp.im.findDriver (protocol, @adrdriver) { //make sure the protocol is handled tcp.im.rpi.client (protocol, screenname, procedure, {protocol, myname})}} else { msg (tryError)}}; case imProtocol { "aim" { if adrdata^.prefs.messaging.flAimEnabled { local (myscreenname = user.im.aim.username); register (imProtocol, imUsername, imRegisterProcedure, myscreenname)}}; "jabber" { if adrdata^.prefs.messaging.flJabberEnabled { local (myscreenname = user.im.jabber.username); register (imProtocol, imUsername, imRegisterProcedure, myscreenname)}}}}; local (adrsubscription = @adrdata^.subscriptions.[url]); if defined (adrsubscription^) { frontier.bringtofront (); radio.outliner.openBuddies (true, true); if adrdata^.prefs.messaging.flEnabled { //record im registration info setImRegisterProcedure (adrsubscription)}; if defined (pta^.requestHeaders.Referer) { radio.webserver.redirect (pta^.requestHeaders.Referer); return} else { pta^.title = "Subscribe to Outline"; local (s); if string.lower (author) endsWith "s" { s = author + "'"} else { s = author + "'s"}; return ("Already subscribed to " + s + " Instant Outline.")}}; local (localoutline); try { radio.outliner.read (url, @localoutline); if defined (adrsubscription^) { if adrdata^.prefs.messaging.flEnabled { //record im registration info setImRegisterProcedure (adrsubscription)}}} else { if defined (adrsubscription^) { delete (adrsubscription)}; return ("Can't subscribe to the outline because there was an error reading it. \"" + tryerror + "\".")}; frontier.bringtofront (); local (flSubscribed = false); if dialog.confirm ("Subscribe to " + author + "'s Instant Outline?") { new (tabletype, adrsubscription); adrsubscription^.author = author; <<adrsubscription^.outline = localoutline adrsubscription^.whenCreated = clock.now (); adrsubscription^.whenLastPoll = date (0); radio.outliner.openBuddies (true); if adrdata^.prefs.messaging.flEnabled { //record im registration info setImRegisterProcedure (adrsubscription)}; flSubscribed = true} else { //delete the subscription table if defined (adrsubscription^) { delete (adrsubscription)}}; if defined (pta^.requestHeaders.Referer) { radio.webserver.redirect (pta^.requestHeaders.Referer); if not flSubscribed { webBrowser.bringToFront ()}} else { pta^.title = "Subscribe to Outline"; local (s); if string.lower (author) endsWith "s" { s = author + "'"} else { s = author + "'s"}; if flSubscribed { return ("Congratulations, you have successfully subscribed to " + s + " Instant Outline. " + author + " now appears in your Buddies window.")} else { return ("Subscribe to outline cancelled.")}}} <<bundle //test code <<html.setPageTableAddress (@workspace.pt) <<subscribe ()
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.