Monday, November 08, 2010 at 12:05 AM.

system.verbs.builtins.radio.macros.previousDayLink

on previousDayLink (linetext="Previous", flAlwaysLinkToPrevDay=false) {
	<<Changes
		<<8/7/02; 2:05:00 PM by LL
			<<Created. Generate a link to the previous day's archive page, if any.
	local (adrblog = radio.weblog.init (), adrPost, catname="");
	local (d, year, month, day, minute, second, maxdate);
	if defined (categoryName) {
		catname = categoryName};
	if flArchivePage {
		year = string.nthField (archiveDate, "/", 1);
		month = string.nthField (archiveDate, "/", 2);
		day = string.nthField (archiveDate, "/", 3);
		maxdate = date.set (day, month, year, 0, 0, 0)}
	else { //home page
		local (ctposts = sizeOf (adrblog^.posts));
		local (maxdays = adrblog^.prefs.ctDaysToDisplay -1 );
		local (i, ctdays = 0, lastday = -1, itemstext = "", lastitemdate, adrpost);
		for i = sizeOf (adrblog^.posts) downto 1 {
			adrpost = @adrblog^.posts [i];
			bundle { //only include if in category, if catname was specified
				if catname != nil {
					if radio.weblog.isPostInCategory (adrpost, catname) {
						continue}}};
			bundle { //if rendering the home page, or a non-category archive page, skip posts with flNotOnHomePage == true
				if catname == nil {
					if defined (adrpost^.flNotOnHomePage) {
						if adrpost^.flNotOnHomePage {
							continue}}}};
			bundle { //check date rollover
				if flAlwaysLinkToPrevDay {
					break};
				local (day, month, year, hour, minute, second);
				date.get (adrpost^.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}}}};
		local (theDay, theMonth, theYear, theHour, theMinute, theSecond);
		date.get (adrpost^.when, @theDay, @theMonth, @theYear, @theHour, @theMinute, @theSecond);
		maxdate = date.set (theDay, theMonth, theYear, 0, 0, 0)};
	if catname == nil { //check that the post is included on the home page
		loop {
			radio.weblog.getLastPostBeforeDate (adrblog, maxdate, adrAdrPost:@adrpost);
			if (adrpost == nil) or (adrpost^.flNotOnHomePage == false) {
				break}
			else {
				local (theDay, theMonth, theYear, theHour, theMinute, theSecond);
				date.get (adrpost^.when, @theDay, @theMonth, @theYear, @theHour, @theMinute, @theSecond);
				maxdate = date.set (theDay, theMonth, theYear, 0, 0, 0)}}}
	else {
		radio.weblog.getLastPostBeforeDate (adrblog, maxdate, adrAdrPost:@adrpost, catname:catname)};
	if adrPost != nil { //only return a link if we actually have a post
		local (url);
		if radio.weblog.getUrlForPost (adrpost, @url, catname) {
			url = string.nthField (url, "#", 1);
			return ("<a href=\"" + url + "\" title=\"Click to view the previous archive page.\">" + linetext + "</a>")}};
	return (linetext)}



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.