Wednesday, April 06, 2011 at 1:06 AM.
radio2Suite.buildMiniLinkBlogJS
on buildMiniLinkBlogJS (adruser, adrfeed, maxct=20) { <<Changes <<4/5/11; 11:56:17 AM by DW <<If an item doesn't have a linkshortened element use the link in its place. This can happen when servers startup and don't have a URL shortener connected. <<3/31/11; 8:47:58 AM by DW <<Pop the http:// off the url when displaying it. Save a few characters, visually. <<3/30/11; 12:31:22 PM by DW <<Created. Builds the mini-linkblog Javascript for a feed. local (htmltext = "", indentlevel = 0, ct = 0); on add (s) { htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r"}; on cleanupfilename (fname) { local (i, ch); for i = sizeof (fname) downto 1 { ch = fname [i]; if (not string.isalpha (ch)) and (not string.isnumeric (ch)) and (ch != ' ') { fname = string.delete (fname, i, 1)}}; fname = string.innerCaseName (fname); return (fname); }; on visit (adritem) { local (url, urlfordisplay); bundle { //set url if defined (adritem^.linkshortened) { url = adritem^.linkshortened} else { url = adritem^.link}}; bundle { //set urlfordisplay urlfordisplay = url; if string.lower (urlfordisplay) beginswith "http://" { urlfordisplay = string.delete (urlfordisplay, 1, 7)}}; add ("<li class=\"miniLinkBlogItem\">" + adritem^.description + " " + "<a href=\"" + url + "\">" + urlfordisplay + "</a>"); return (++ct < maxct)}; add ("<ul class=\"miniLinkBlog\">"); indentlevel++; mainresponder.calendar.visitReverseChronologic (@adrfeed^.calendar, @visit); add ("</ul>"); indentlevel--; local (jstext = html.buildJavascriptInclude (htmltext), now = clock.now ()); local (foldername = cleanupfilename (nameof (adrfeed^))); adrfeed^.stats.urlMiniLinkBlogJs = radio2Suite.writeStaticFile (adruser, foldername + "/miniLinkBlog.js", jstext)}; bundle { //test code buildMiniLinkBlogJS (@user.radio2.users.dave, @user.radio2.users.dave.feeds [1])}
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.