Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.weblog.view
on view () {
<<Changes:
<<10/26/01; 9:42:52 PM by DW
<<Generate the empty string if not static rendering.
<<8/31/01; 8:40:43 PM by JES
<<Get the date from pta^.radioResponder.getArgs.d, instead of re-parsing the URL here.
local (pta = html.getpagetableaddress ());
if not pta^.radioResponder.flStaticRendering {
return ("")};
local (daytemplate = string (file.readwholefile (pta^.radioResponder.atts.dayTemplate)));
local (itemtemplate = string (file.readwholefile (pta^.radioResponder.atts.itemTemplate)));
local (mindate, maxdate);
bundle { //parse args
if defined (pta^.radioResponder.getArgs.d) {
local (d = pta^.radioResponder.getArgs.d);
local (yr = string.nthField (d, '/', 1));
local (mo = string.nthField (d, '/', 2));
local (dy = string.nthField (d, '/', 3));
mindate = date.set (dy, mo, yr, 0, 0, 0);
maxdate = date (number (date.set (dy, mo, yr, 0, 0, 0)) + 3600 * 24)}};
local (adrblog = radio.weblog.init ());
pta^.title = adrblog^.prefs.title;
return (radio.weblog.render (adrblog, dayTemplate, itemTemplate, catname:nil, flSameMachine:pta^.radioresponder.flsamemachine, flIEditLinks:true, minDate:mindate, maxDate:maxdate))}
<<on view (maxdays=nil)
<<local (pta = html.getpagetableaddress ())
<<local (daytemplate = string (file.readwholefile (pta^.radioResponder.atts.dayTemplate)))
<<local (daylist = {}, textlist = {})
<<local (itemtemplate = string (file.readwholefile (pta^.radioResponder.atts.itemTemplate)))
<<local (editbuttonimg = radio.images.systemImageRef ("icons/editbutton"))
<<local (adrblog = radio.weblog.init (), catname = nil, flArchivePage = false)
<<if maxdays == nil
<<maxdays = adrblog^.prefs.ctDaysToDisplay
<<local (bodytext)
<<bundle //set bodytext
<<local (minDate = date.set (1, 1, 1904, 0, 0, 0), maxDate = date.set (1, 1, 2040, 0, 0, 0))
<<local (ctdays = 0, lastday = -1, itemstext = "", lastitemdate)
<<on addDay ()
<<if adrblog^.prefs.manila.enabled //01/25/01 JES: build homepage text for sending to a Manila site
<<dateList = dateList + lastitemdate
<<if system.environment.isMac //02/22/2001 JES: convert to Latin text
<<textList = textList + latinToMac.macToLatin (itemstext)
<<else
<<textList = textList + itemstext
<<local (s = daytemplate)
<<s = string.replaceall (s, "{longDate}", date.longstring (lastitemdate), false)
<<s = string.replaceall (s, "{shortDate}", date.shortstring (lastitemdate), false)
<<s = string.replaceall (s, "{dayOfWeek}", date.dayOfWeekToString (date.dayOfWeek (lastitemdate)), false)
<<s = string.replaceall (s, "{items}", itemstext, false); itemstext = ""
<<bundle //PBS 02/22/01: archive link
<<local (day, month, year, hour, minute, second)
<<date.get (lastitemdate, @day, @month, @year, @hour, @minute, @second)
<<local (dateString = string.mid (year, 3, 2) + "/" + string.padWithZeros (month, 2) + "/" + string.padWithZeros (day, 2))
<<local (imgTag = "<img src=\"http://scripting.com/images/dailyLinkIcon.gif\" height=\"19\" width=\"13\" alt=\"Permanent link to archive for " + dateString + ".\" border=\"0\">")
<<local (archiveUrl = "")
<<if not flArchivePage
<<archiveUrl = year + "/" + string.padWithZeros (month, 2) + "/" + string.padWithZeros (day, 2) + ".html"
<<if catName != nil //PBS 03/18/01: the archive URL for category pages needs to pop up a level
<<archiveUrl = "../" + archiveUrl
<<local (archiveLink = html.getLink (imgTag, archiveUrl))
<<s = string.replaceAll (s, "{archiveLink}", archiveLink, false)
<<bodytext = bodytext + s + "\r\n"
<<bodytext = "\r\n"
<<local (i, adrpost, s, enclosurelink, editbuttonlink)
<<for i = sizeof (adrblog^.posts) downto 1
<<adrpost = @adrblog^.posts [i]
<<bundle //PBS 02/22/01: check min and max dates
<<if adrpost^.when < minDate
<<break
<<if adrpost^.when > maxDate
<<continue
<<bundle //only include if in category, if catname was specified
<<if catname != nil
<<local (flskip = true)
<<if defined (adrpost^.categories)
<<local (adrthiscat = @adrpost^.categories.[catname])
<<if defined (adrthiscat^)
<<if adrthiscat^
<<flskip = false
<<if flskip
<<continue
<<bundle //check date rollover
<<local (when = adrpost^.when, day, month, year, hour, minute, second)
<<date.get (when, @day, @month, @year, @hour, @minute, @second)
<<if lastday == -1 //first time through loop
<<lastday = day
<<else
<<if day != lastday
<<ctdays++
<<if ctdays == maxdays
<<break
<<lastday = day
<<addDay ()
<<bundle //set enclosurelink
<<if defined (adrpost^.enclosure)
<<enclosurelink = "<a href=\"" + adrpost^.enclosure.url + "\">" + radio.data.strings.enclosureImg + "</a>"
<<else
<<enclosurelink = ""
<<bundle //set editbuttonlink
<<local (url = radio.data.systemUrls.weblogEditor + "?itemtoedit=" + number (nameof (adrpost^)))
<<editbuttonlink = "<a href=\"" + url + "\">" + editbuttonimg + "</a>"
<<local (sourcelink = "")
<<bundle //set sourcelink
<<if defined (adrpost^.sourceUrl)
<<local (adrdata = xml.aggregator.init ())
<<local (adrsource = @adrdata^.services.[adrpost^.sourceUrl])
<<if defined (adrsource^)
<<sourcelink = "<a href=\"" + adrsource^.compilation.channellink + "\" title=\"Source: " + adrsource^.compilation.channeltitle + ".\">" + radio.data.strings.sourceImg + "</a>"
<<s = itemtemplate
<<s = string.replaceall (s, "{text}", string (adrpost^.text), false)
<<s = string.replaceall (s, "{enclosure}", enclosurelink, false)
<<s = string.replaceall (s, "{editButton}", editbuttonlink, false)
<<s = string.replaceall (s, "{source}", sourcelink, false)
<<s = string.replaceall (s, "{when}", date.timestring (adrpost^.when), false)
<<itemstext = itemstext + s + "\r\n"
<<lastitemdate = adrpost^.when
<<if itemstext != "" //there was some text left over when loop finished
<<addDay ()
<<return (bodytext)
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.