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

system.verbs.apps.trackback.changedPost

on changedPost (adrpost, flnew, posttext) {
	<<Changes
		<<7/14/03; 12:02:34 AM by JES
			<<Factored the code that adds an outbound ping URL to the trackback sub-table for a post.
		<<4/22/03; 6:57:13 PM by DW
			<<Created. The post is either new or changed. We scan the text looking for URLs, and accumulate them in a trackback sub-table.
	
	<<bundle //debugging
		<<local (oldtarget = target.set (@scratchpad.trackbacks))
		<<op.firstsummit ()
		<<local (s)
		<<if flnew
			<<s = "New"
		<<else
			<<s = "Edit"
		<<op.insert (s + ": " + nameof (adrpost^) + " " + date.timestring (), up)
		<<target.set (oldtarget)
	
	local (adrtrackback);
	trackback.initPost (adrpost);
	<<edit (adrpost) //debugging
	adrtrackback = @adrpost^.trackback;
	
	bundle { //add to the urls table
		local (s = string.lower (posttext));
		local (ix, ixsingle, ixdouble, chclose, fladd);
		loop {
			bundle { //set ix
				ixsingle = string.patternmatch ("'http://", s);
				ixdouble = string.patternmatch ("\"http://", s);
				if (ixsingle == 0) and (ixdouble == 0) {
					break};
				if ixsingle == 0 {
					ixsingle = infinity};
				if ixdouble == 0 {
					ixdouble = infinity};
				if ixsingle < ixdouble {
					ix = ixsingle;
					chclose = "'"}
				else {
					ix = ixdouble;
					chclose = "\""}};
			s = string.delete (s, 1, ix);
			posttext = string.delete (posttext, 1, ix);
			ix = string.patternmatch (chclose, s);
			if ix == 0 {
				break};
			url = string.mid (posttext, 1, ix - 1);
			bundle { //init fladd
				case string.nthfield (url, ".", string.countfields (url, ".")) {
					"jpg";
					"jpeg";
					"gif";
					"dtd";
					"js" {
						fladd = false}}
				else {
					fladd = true}};
			if not ((url - "http://") contains "/") {
				fladd = true;
				url = url + "/"};
			if url beginswith "http://127.0.0.1" { //2/19/03 by DW
				fladd = false};
			if fladd {
				trackback.initOutboundUrl (adrpost, url)};
				<<bundle //factored code
					<<local (adrurl = @adrtrackback^.outbound.urls.[url])
					<<if not defined (adrurl^)
						<<new (tabletype, adrurl)
						<<adrurl^.flPinged = false
						<<adrurl^.flChecked = false
						<<adrurl^.flSupportsTrackback = false
			s = string.delete (s, 1, sizeof (url) + 1);
			posttext = string.delete (posttext, 1, sizeof (url) + 1)}};
	bundle { //loop over urls and find out if there's trackback support on the other end
		local (adrurls = @adrtrackback^.outbound.urls, adrurl);
		for adrurl in adrurls {
			if not adrurl^.flChecked {
				trackback.discoverPingInfo (adrurl);
				adrurl^.flChecked = true}}}}
<<bundle //test code
	<<local (adrpost = @newssiteManilaWebsite.["#discussionGroup"].messages.["0000005"])
	<<changedPost (adrpost, false, string (adrpost^.newsItem.description))



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.