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


on newPost (adrfeed, title, link, linkShortened, description, enclosure="", adrextradata=nil) {
		<<3/15/11; 11:52:49 PM by DW
			<<Drop quotes around username in logging code.
		<<3/15/11; 6:49:39 PM by DW
			<<Log new posts, so you can see what members of your community are linking to in the Log command.
		<<3/13/11; 1:15:22 AM by DW
			<<Optional adrextradata param, allows the caller to add any data they want to the post table.
		<<3/2/11; 9:29:11 AM by DW
			<< When you post an item with an enclosure, if it doesn't have a link, set the link to point to the enclosure and shorten it as if it were added via the bookmarklet or manually.
		<<3/2/11; 8:14:24 AM by DW
			<<If the enclosure is "" don't bother allocating it.
		<<2/24/11; 1:00:21 PM by DW
			<<Include the guid in the table. It's the shortened link, if one is available, otherwise it's the link. The idea is that the guid and the link in the feed should always be the same. 
		<<2/22/11; 11:57:57 AM by DW
			<<if linkShortened equals link, or if it's empty, then don't add it to the database. The lack of presence of linkShortened indicates that the URL hasn't been shortened. Add call to initPost. 
		<<2/21/11; 11:54:34 AM by DW
			<<Add new linkShortened parameter.
		<<1/10/11; 5:49:39 PM by DW
			<<Add optional enclosure param.
		<<12/14/10; 8:38:56 PM by DW
	local (now = (), startticks = clock.ticks ());
	local (adruser = parentof (parentof (adrfeed^)^));
	local (adrday = mainresponder.calendar.getdayaddress (@adrfeed^.calendar, now));
	local (adrpost = @adrday^.[string.padwithzeros (++adrfeed^.stats.serialnum, 5)]);
	new (tabletype, adrpost);
	radio2Suite.initPost (adrpost); //2/21/11 by DW
	adrpost^.title = title;
	adrpost^.link = link;
	adrpost^.guid = link; //2/24/11 by DW
	if linkShortened != link { //2/22/11 by DW
		if sizeof (linkShortened) > 0 {
			adrpost^.linkShortened = linkShortened; //2/21/11 by DW
			adrpost^.guid = linkShortened}}; //2/24/11 by DW
	adrpost^.description = description;
	if enclosure != "" {
		adrpost^.enclosure = enclosure;
		if sizeof (adrpost^.link) == 0 { //3/2/11 by DW
			adrpost^.link = enclosure;
			if adruser^.prefs.shortener.enabled {
				adrpost^.linkShortened = radio2suite.shortener.create (adrpost^.link, adruser);
				adrpost^.guid = adrpost^.linkShortened}}};
	adrpost^.when = now;
	if adrextradata != nil {
		local (adr);
		for adr in adrextradata {
			adrpost^.[nameof (adr^)] = adr^}};
	bundle { //log it
		local (s = "New post by " + nameof (adruser^) + " -- " + radio2Suite.viewPost (adrpost));
		log2.add (, "New", s, startticks)};
	return (adrpost)}
<<bundle //test code
	<<s = states.nthstate (random (1, 50))
	<<edit (newTweet (s))

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.