Monday, April 04, 2011 at 1:08 AM.
radio2Suite.viewHistory
on viewHistory (adruser, adrfeed, idHistoryHIghlight=0) { <<Changes <<3/16/11; 1:11:26 PM by DW <<Confirmation dialog for deleting posts. <<3/15/11; 6:35:30 PM by DW <<Call radio2Suite.viewPost to get the text of main column. <<3/12/11; 11:03:57 PM by DW <<New optional parameter, idHistoryHIghlight, the id of the post that is highlighted. Default value is 0, which means nothing is highlighted. <<3/12/11; 9:25:18 AM by DW <<If an item has an enclosure, link to it from an icon in the right margin. <<3/6/11; 6:20:52 PM by DW <<Links to delete items were broken, fixed. <<3/5/11; 9:35:17 AM by DW <<Factored from of river2suite.main. local (historytext = "", indentlevel = 0, ctitems = 0, maxitems = 25); local (imgXmlMini, imgEdit, imgDelete, imgEnclosure, now = clock.now ()); bundle { //set images html imgXmlMini = string (radio2Suite.data.html.xml); imgEdit = string (radio2Suite.data.html.editIcon); imgDelete = string (radio2Suite.data.html.deleteIcon); imgEnclosure = string (radio2Suite.data.html.podcastIcon)}; on add (s) { historytext = historytext + string.filledstring ("\t", indentlevel) + s + "\r"}; on visit (adritem) { local (class = "history"); if idHistoryHIghlight > 0 { //3/12/11 by DW if number (nameof (adritem^)) == idHistoryHIghlight { class = "historyHighlighted"}}; add ("<tr>"); indentlevel++; add ("<td class=\"" + class + "\" align=\"right\" valign=\"top\">" + ++ctitems + ". </td>"); bundle { //add the main text column <<local (title = string.trimwhitespace (adritem^.title), s = "") <<local (link = string.trimwhitespace (adritem^.link)) <<local (description = string.trimwhitespace (adritem^.description)) <<if sizeof (title) > 0 <<if sizeof (link) > 0 <<s = "<a href=\"" + link + "\">" + title + "</a>" <<else <<s = title <<if sizeof (description) > 0 <<s = s + ". " + description <<else //title is empty <<if sizeof (description) > 0 <<if sizeof (link) > 0 <<s = "<a href=\"" + link + "\">" + description + "</a>" <<s = twitter.hotUpText (description) + " <a href=\"" + link + "\">#</a>" <<else <<s = description <<else //title and description are empty <<if sizeof (link) > 0 //just plop down the link <<s = "<a href=\"" + link + "\">" + link + "</a>" <<add ("<td class=\"" + class + "\" valign=\"top\">" + s + "</td>") add ("<td class=\"" + class + "\" valign=\"top\">" + radio2Suite.viewPost (adritem) + "</td>")}; bundle { //add the short code, 2/22/11 by DW local (shortcode = " "); if defined (adritem^.linkShortened) { local (shortlink = adritem^.linkShortened); shortCode = "<a href=\"" + shortlink + "\">" + string.lastfield (shortlink, "/") + "</a>"}; add ("<td class=\"" + class + "\" align=\"right\" valign=\"top\" nowrap>" + shortcode + "</td>")}; bundle { //add the read count local (readcount = " "); if defined (adritem^.stats.ctReads) { readcount = adritem^.stats.ctReads}; add ("<td class=\"" + class + "\" align=\"right\" valign=\"top\" nowrap>" + readcount + "</td>")}; bundle { //add the post time/date add ("<td class=\"" + class + "\" align=\"right\" valign=\"top\" nowrap>" + date.viewDate (adritem^.when) + "</td>")}; bundle { //add the Edit & Delete links local (url = "?idPost=" + number (nameof (adritem^)) + "&feed=" + nameof (adrfeed^)); local (editlink = "<a href=\"index" + url + "\">" + imgEdit + "</a>"); local (confirmation = "Are you sure you want to delete the post? (There is no undo.)"); local (deletelink = "<a href=\"delete" + url + "\" onclick=\"return confirm('" + confirmation + "')\">" + imgDelete + "</a>", enclosurelink); bundle { //set enclosurelink, 3/12/11 by DW if defined (adritem^.enclosure) { enclosurelink = " <a href=\"" + adritem^.enclosure + "\">" + imgEnclosure + "</a>"} else { enclosurelink = ""}}; add ("<td valign=\"top\" nowrap>" + editlink + " " + deletelink + enclosurelink + "</td>")}; add ("</tr>"); indentlevel--; return (ctitems < maxitems)}; add ("<table width=\"650\" cellspacing=\"2\" cellpadding=\"5\" border=\"0\">"); indentlevel++; mainresponder.calendar.visitReverseChronologic (@adrfeed^.calendar, @visit); add ("</table>"); indentlevel--; return (historytext)}; bundle { //test code viewHistory (@config.radio2.users.dave, @config.radio2.users.dave.feeds.["linkblog.xml"])}
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.