Saturday, April 09, 2011 at 1:08 AM.
radio2Suite.buildCommunityOpml
on buildCommunityOpml () { <<Changes <<4/8/11; 4:36:52 PM by DW <<The River2 user we were creating had static rendering turned on. I don't see the point (or a comment) so I'm turning it off. <<3/6/11; 10:17:00 AM by DW <<Create a River2 user for Radio2, subscribed to the community OPML. <<3/5/11; 12:31:23 PM by DW <<Automatically subscribe to the community list in River2 if enabled. <<3/3/11; 10:29:20 AM by DW <<Add logging code. <<3/2/11; 8:58:33 PM by DW <<Created. local (adrdata = radio2suite.init (), now = clock.now (), adruser, adrfeed, startticks = clock.ticks ()); local (xmltext = "", indentlevel = 0, title = radio2Suite.data.strings.communityReadingListTitle, urlReadingList); on add (s) { xmltext = xmltext + string.filledstring ("\t", indentlevel) + s + "\r"}; on encode (s) { if system.environment.isMac { return (xml.entityEncode (latinToMac.macToLatin (s), true))} else { return (xml.entityEncode (s, true))}}; add ("<opml version=\"2.0\">"); indentlevel++; bundle { //<head> section add ("<head>"); indentlevel++; add ("<title>" + encode (title) + "</title>"); <<add ("<dateCreated>" + date.netstandardstring (now) + "</dateCreated>") add ("</head>"); indentlevel--}; bundle { //<body> section add ("<body>"); indentlevel++; for adruser in @adrdata^.users { for adrfeed in @adruser^.feeds { if defined (adrfeed^.stats.feedurl) { add ("<outline text=\"" + encode (adrfeed^.prefs.title) + "\" description=\"" + encode (adrfeed^.prefs.description) + "\" htmlUrl=\"" + encode (adrfeed^.prefs.link) + "\" language=\"" + adrfeed^.prefs.language + "\" title=\"" + encode (adrfeed^.prefs.title) + "\" type=\"rss\" version=\"RSS2\" xmlUrl=\"" + encode (adrfeed^.stats.feedurl) + "\" />")}}}; add ("</body>"); indentlevel--}; add ("</opml>"); indentlevel--; bundle { //save the file local (fname = "communityReadingList.opml"); s3.newobject (adrdata^.prefs.s3path + fname, xmltext, "text/plain"); urlReadingList = adrdata^.prefs.s3url + fname; adrdata^.stats.urlCommunityReadingList = urlReadingList; adrdata^.stats.ctCommunityOpmlBuilds++; adrdata^.stats.whenLastCommunityOpmlBuild = now}; bundle { //log it local (s = "Rebuilt community OPML <a href=\"" + urlReadingList + "\">reading list</a>."); log2.add (radio2Suite.data.strings.logname, "OPML", s, startticks)}; bundle { //subscribe in River2 if pref is set, 3/5/11 by DW if adrdata^.prefs.flRiver2SubscribeCommunityOPML { local (adrdata = river2suite.init ()); local (adrlist =@adrdata^.lists.[urlReadingList]); if not defined (adrlist^) { local (startticks = clock.ticks ()); try { river2Suite.subscribeList (urlReadingList); local (s = "Subscribed to the community <a href=\"" + urlReadingList + "\">readling list</a> in River2."); log2.add (radio2Suite.data.strings.logname, "OPML", s, startticks)} else { local (s = "Error subscribing to the community <a href=\"" + urlReadingList + "\">readling list</a> in River2:" + tryerror); log2.add (radio2Suite.data.strings.logname, "OPML", s, startticks)}}; local (adruser = @adrdata^.users.radio2); if not defined (adruser^) { river2suite.inituser (adruser); adruser^.prefs.password = string.getrandompassword (8); adruser^.prefs.urlReadingList = urlReadingList; adruser^.prefs.static.enabled = false; //4/8/11 by DW adruser^.prefs.beautifulRiver.flBeautifulIsIndex = true}}}; return (xmltext)}; bundle { //test code local (ctticks = clock.ticks ()); buildCommunityOpml (); dialog.alert (clock.ticks () - ctticks)}
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.