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

scripting2Suite.server.buildRecentStories

on buildRecentStories (username, ctstories=15) {
	<<Changes
		<<6/26/10; 5:46:16 PM by DW
			<<Save the url of the recent stories JS file in the stats table.
		<<6/25/10; 8:25:31 PM by DW
			<<Use our visitReverseChronologic routine to exclude stories that aren't in the chronology.
		<<5/22/10; 8:27:11 PM by DW
			<<Use string.addPeriodToSentence to add the period -- it won't add one if the title ends with a ! or ?.
		<<5/21/10; 10:28:18 AM by DW
			<<Use CSS to style the list.
		<<11/3/08; 8:35:34 AM by DW
			<<Don't skip the first story. 
		<<10/2/08; 11:31:26 AM by DW
			<<Created. A macro that returns a table linking to the most recent xxx stories.
	local (adrdata = scripting2suite.inituser (username));
	local (htmltext = "", indentlevel = 0, adrstory, ct = 0, maxtitlechars = 255);
	local (divnumber = "<div class=\"storyListNumber\">"); //5/21/10 by DW
	local (divtitle = "<div class=\"storyListTitle\">"); //5/21/10 by DW
	bundle { //build htmltext
		on add (s) {
			htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r"};
		add ("<table cellpadding=\"0\" cellspacing=\"0\">"); indentlevel++;
		on visit (adrstory) {
			if ct >= ctstories {
				return (false)};
			local (title, url);
			bundle { //set title
				title = string.addPeriodToSentence (adrstory^.title); //5/22/10 by DW
				if sizeof (title) > maxtitlechars {
					title = string.mid (title, 1, maxtitlechars) + "..."}};
			add ("<tr><td align=\"right\" valign=\"top\">" + divnumber+ ++ct + ".</div></td><td>" + divtitle + "<a href=\"" + adrstory^.url + "\">" + title + "</a></div></td></tr>");
			return (true)};
		scripting2Suite.server.visitReverseChronologic (@adrdata^.calendar, @visit);
		add ("</table>"); indentlevel--};
	bundle { //upload the file, return the url
		local (url);
		url = scripting2Suite.writeStaticFile (username, scripting2Suite.data.paths.recentStories, html.buildJavascriptInclude (htmltext));
		adrdata^.stats.urlRecentStories = url; //6/26/10 by DW
		return (url)}};
bundle { //test code
	webbrowser.openurl (buildRecentStories ("davewiner"))}



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.