Tuesday, August 18, 2009 at 7:34 PM.
newsRiverSuite.viewLog
on viewLog () { <<Changes <<1/15/06; 7:48:53 AM by DW <<Created. local (adroutline = @user.log.outlines.default); local (pta = html.getpagetableaddress ()); pta^.title = "Event log"; bundle { //see if we can get it from the cache if defined (system.temp.newsRiver.logHtmlCache) { if timemodified (adroutline) <= system.temp.newsRiver.logHtmlCache.when { return (system.temp.newsRiver.logHtmlCache.htmltext)}}}; local (htmltext = "", indentlevel = 0); on add (s) { htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r\n"}; add ("<table class=\"dwsFrameTable\" cellspacing=\"0\" cellpadding=\"0\" width=\"55%\"><tr bgcolor=\"" + newsRiverData.htmlColors.framecolor + "\"><td>"); indentlevel++; add ("<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\">"); indentlevel++; bundle { //add header add ("<tr bgcolor=\"" + newsRiverData.htmlColors.cellbgcolor + "\"><td class=\"dwsTableCell\"><b>" + newsRiverSuite.getString ("eventsLog.eventHeader") + "</b></td><td class=\"dwsTableCell\"><b>" + newsRiverSuite.getString ("eventsLog.whatHappenedHeader") + "</b></td><td class=\"dwsTableCell\" align=\"right\"><b>" + newsRiverSuite.getString ("eventsLog.timeHeader") + "</b></td><td class=\"dwsTableCell\" align=\"right\"><b>" + newsRiverSuite.getString ("eventsLog.secsHeader") + "</b></td></tr>")}; local (xstruct); xml.compile (op.outlinetoxml (adroutline), @xstruct); scratchpad.xstruct = xstruct; local (adropml = xml.getaddress (@xstruct, "opml")); local (adrbody = xml.getaddress (adropml, "body"), adrhour, adritem, adratts); for adrhour in adrbody { if nameof (adrhour^) contains "outline" { for adritem in adrhour { if nameof (adritem^) contains "outline" { adratts = @adritem^.["/atts"]; local (text = adratts^.text); local (eventType = string.nthfield (text, ":", 1)); text = string.delete (text, 1, sizeof (eventType + 2)); local (what); bundle { //set what local (ix = string.patternmatch (" at ", text)); what = string.mid (text, 1, ix); text = string.delete (text, 1, ix + 3); if string.trimwhitespace (what) endswith ")" { //remove substring " (xxx)" for ix = sizeof (what) downto 1 { if what [ix] == "(" { what = string.mid (what, 1, ix-1)}}}; if defined (adratts^.url) { what = "<a href=\"" + adratts^.url + "\">" + what + "</a>"}}; local (when = string.nthfield (text, ",", 1)); local (secs = string.nthfield (text, ",", 2) - " secs."); local (s); s = s + "<tr bgcolor=\"" + newsRiverData.htmlColors.cellbgcolor + "\">"; s = s + "<td class=\"dwsTableCell\" valign=\"top\" nowrap>" + eventType + "</td>"; s = s + "<td class=\"dwsTableCell\" valign=\"top\">" + what + "</td>"; s = s + "<td class=\"dwsTableCell\" valign=\"top\" align=\"right\" nowrap>" + when + "</td>"; s = s + "<td class=\"dwsTableCell\" valign=\"top\" align=\"right\" nowrap>" + secs + "</td>"; s = s + "</tr>"; add (s)}}}}; add ("</table>"); indentlevel--; add ("</table>"); indentlevel--; bundle { //cache if not defined (system.temp.newsRiver.logHtmlCache) { new (tabletype, @system.temp.newsRiver.logHtmlCache)}; system.temp.newsRiver.logHtmlCache.htmltext = htmltext; system.temp.newsRiver.logHtmlCache.when = clock.now ()}; return (htmltext)}; bundle { //test code local (pt); new (tabletype, @pt); html.setpagetableaddress (@pt); webbrowser.displaytext (viewLog ())}
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.