«Changes «11/9/02; 9:44:41 AM by DW «Designed to run every minute, prepare a static HTML file with the latest headlines, every hour, just after the Radio aggregator runs. Basically a demo for Radio-Dev'ers. local (adrdata = @user.aggyBaby); if not defined (adrdata^) { new (tabletype, adrdata); adrdata^.whenLastBuild = date (0); new (tabletype, @adrdata^.items); adrdata^.template = aggybaby.data.virginTemplate; adrdata^.htmlfile = "c:\\program files\\radio userland\\www\\userland\\aggyBaby.html"; adrdata^.ctChecks = 0; adrdata^.ctBuilds = 0}; adrdata^.lastScanInfo = aggregator.getLastScanInfo (); adrdata^.ctChecks++; if adrdata^.whenLastBuild < adrdata^.lastScanInfo.whenComplete { //needs a rebuild if not adrdata^.lastScanInfo.flScanRunningNow { //wait for the scan to complete local (newitems = aggregator.getRecentItems (adrdata^.lastScanInfo.ctNewItems), adr); for adr in @newitems { adrdata^.items.[nameof (adr^)] = adr^}; bundle { //delete any that are older than 24 hours local (i, onedayago = clock.now () - (60 * 60 * 24)); for i = sizeof (adrdata^.items) downto 1 { adr = @adrdata^.items [i]; if adr^.when <= onedayago { delete (adr)}}}; bundle { //build the static page local (htmltext = "", indentlevel = 0); on add (s) { htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r"}; local (i, lasttitle = ""); for i = sizeof (adrdata^.items) downto 1 { adr = @adrdata^.items [i]; if adr^.channelTitle != lasttitle { add ("<h4>" + adr^.channelTitle + " (" + date.timestring (adr^.when, true) + ")</h4>"); lasttitle = adr^.channelTitle}; add ("<p>" + adr^.itemText + "</p>")}; htmltext = string.replace (string (adrdata^.template), "<%bodytext%>", htmltext); file.surefilepath (adrdata^.htmlfile); file.writeWholeFile (adrdata^.htmlfile, htmltext); adrdata^.whenLastBuild = adrdata^.lastScanInfo.whenComplete}; adrdata^.ctBuilds++ bundle { //send an email tcp.sendmail (user.prefs.mailaddress, this, "Rebuilt the aggyBaby page, here's the URL:\r\r" + user.aggyBaby.htmlurl + "\r\rPretty fast, eh?\r\r" + clock.now ())}}}