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

radio2Suite.shortener.create

on create (url, adruser) {
	<<Changes
		<<3/6/11; 5:25:18 PM by DW
			<<Rewrite, now if the user doesn't have a shortener defined, we use the global one. 
		<<2/20/11; 11:26:51 AM by DW
			<<We now get a pointer to the user's table as a parameter. If the user has his or her shortener enabled, use those prefs instead of the global ones.
		<<2/17/11; 6:20:49 PM by DW
			<<Give me a url and I return a shortened url.
	local (adrdata = radio2suite.init (), now = clock.now (), customDomain = nil, partnerEmail = nil);
	if adruser^.prefs.shortener.enabled {
		if adruser^.prefs.shortener.email != "" {
			partnerEmail = adruser^.prefs.shortener.email};
		if adruser^.prefs.shortener.customDomain != "" {
			customDomain = adruser^.prefs.shortener.customDomain};
		url = adjix.create (url, partnerEmail, adruser^.prefs.shortener.partnerID, customDomain);
		adruser^.stats.ctShortenedUrls++;
		adruser^.stats.whenLastShortenedUrl = now}
	else {
		if adrdata^.prefs.shortener.enabled {
			if adrdata^.prefs.shortener.email != "" {
				partnerEmail = adrdata^.prefs.shortener.email};
			if adrdata^.prefs.shortener.customDomain != "" {
				customDomain = adrdata^.prefs.shortener.customDomain};
			url = adjix.create (url, partnerEmail, adrdata^.prefs.shortener.partnerID, customDomain);
			adrdata^.stats.ctShortenedUrls++;
			adrdata^.stats.whenLastShortenedUrl = now}};
	return (url)};
	<<bundle //old code, 3/6/11 by DW
		<<if adruser^.prefs.shortener.enabled
			<<pid = adruser^.prefs.shortener.partnerID
		<<url = adjix.create (url, partnerId:pid)
		<<adruser^.stats.ctShortenedUrls++
		<<adruser^.stats.whenLastShortenedUrl = now
		<<return (url)
bundle { //test code
	create ("http://static.reallysimple.org/users/dave/linkblog.xml")}



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.