Monday, April 04, 2011 at 1:06 AM.

radio2Suite.viewRiver

on viewRiver (adruser) {
	<<Changes
		<<3/5/11; 12:09:56 PM by DW
			<<A start on a Radio2-resident River2 displayer. Not sure if this will ever make it to the UI. 
	local (adrdata = radio2suite.init (), adrriverdata = river2suite.init (), ourfeeds, currentfeedname = "", now = clock.now ());
	local (htmltext = "", indentlevel = 0, ctitems = 0, maxitems = 125, imgXmlMini, imgEdit, imgDelete);
	bundle { //set images html
		imgXmlMini = string (radio2Suite.data.html.xml);
		imgEdit = string (radio2Suite.data.html.editIcon);
		imgDelete = string (radio2Suite.data.html.deleteIcon)};
	on add (s) {
		htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r"};
	add ("<table width=\"650\" cellspacing=\"3\" cellpadding=\"5\" border=\"0\">"); indentlevel++;
	bundle { //fill ourfeeds
		local (adruser, adrfeed);
		new (tabletype, @ourfeeds);
		for adruser in @adrdata^.users {
			for adrfeed in @adruser^.feeds {
				if defined (adrfeed^.stats.feedurl) {
					ourfeeds.[adrfeed^.stats.feedurl] = nameof (adruser^)}}}};
		<<scratchpad.ourfeeds = ourfeeds
	on visit (adrriveritem) {
		if not defined (ourfeeds.[adrriveritem^.feedurl]) { //not one of our feeds
			return (true)};
		bundle { //output feedname if it changed
			local (adrfeed = @adrriverdata^.feeds.[adrriveritem^.feedurl]);
			local (namefeed = adrfeed^.feedinfo.title, linebreak = "");
			local (favicon = radio2Suite.utilities.getFavIconHtml (adrfeed^.feedinfo.link));
			if namefeed != currentfeedname {
				if currentfeedname != "" {
					linebreak = "<br>"};
				add ("<tr><td colspan=\"3\">" + linebreak + " " + namefeed + "</td></tr>");
				currentfeedname = namefeed}};
		add ("<tr>"); indentlevel++;
		bundle { //add count
			<<add ("<td align=\"right\" valign=\"top\">" + ++ctitems + ". </td>")
			++ctitems};
		bundle { //add the main text column
			local (title = string.trimwhitespace (adrriveritem^.title), s = "");
			local (link = string.trimwhitespace (adrriveritem^.link));
			local (description = string.trimwhitespace (adrriveritem^.description));
			if sizeof (title) > 0 {
				if sizeof (link) > 0 {
					s = "<a href=\"" + link + "\">" + title + "</a>"}
				else {
					s = title};
				if sizeof (description) > 0 {
					s = s + ". " + description}}
			else { //title is empty
				if sizeof (description) > 0 {
					if sizeof (link) > 0 {
						s = "<a href=\"" + link + "\">" + description + "</a>"}
						<<s = twitter.hotUpText (description) + " <a href=\"" + link + "\">#</a>"
					else {
						s = description}}
				else { //title and description are empty
					if sizeof (link) > 0 { //just plop down the link
						s = "<a href=\"" + link + "\">" + link + "</a>"}}};
			add ("<td class=\"history\" valign=\"top\">" + s + "</td>")};
		bundle { //add the post time/date
			add ("<td class=\"history\" align=\"right\" valign=\"top\" nowrap>" + (date.viewDate (timecreated (adrriveritem)) - " ") + "</td>")};
		bundle { //name of author if one of our community
			local (adr = @ourfeeds.[adrriveritem^.feedurl], nameuser = " ");
			if defined (adr^) {
				nameuser = adr^};
			<<else
				<<local (adrfeed = @adrriverdata^.feeds.[adrriveritem^.feedurl])
				<<nameuser = adrfeed^.feedinfo.title
				<<if sizeof (nameuser) > 15
					<<nameuser = string.mid (nameuser, 1, 15) + "..."
			add ("<td class=\"history\" valign=\"top\">" + nameuser + "</td>")};
		bundle { //add the Edit & Delete links
			<<local (url = "?idPost=" + number (nameof (adritem^)) + "&feed=" + nameof (adrfeed^))
			local (url = "?hello=12");
			local (editlink = "<a href=\"index" + url + "\">" + imgEdit + "</a>");
			local (deletelink = "<a href=\"delete" + url + "\">" + imgDelete + "</a>");
			add ("<td valign=\"top\" nowrap>" + editlink + " " + deletelink + "</td>")};
		add ("</tr>"); indentlevel--;
		return (ctitems < maxitems)};
	mainresponder.calendar.visitReverseChronologic (@config.river2.river, @visit);
	add ("</table>"); indentlevel--;
	return (htmltext)};
bundle { //test code
	viewRiver ()}



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.