var local = structNew(); var cacheKey = ''; //first some business -- if being called remotely (ajax), jsonService and urlService will be blank! :( if (isSimpleValue(variables.urlService)){variables.urlService = createObject("component", "shrinkURL").init();} if (isSimpleValue(variables.jsonService)){variables.jsonService = createObject("component", "JSONUtil").init();} //strip any bookmarks from the url arguments.uri = listFirst(arguments.uri,'##'); //setup cache cacheKey = hash(arguments.uri); setupCache(cacheKey); //check tweetback cache, updates every 5 minutes at most if (not tweetCacheExpired(cacheKey)){ local.tweets = getTweetCache(cacheKey); }else{ local.thisSearch = getTweetSearchUrl(arguments.uri); local.shortened = getShortUrls(arguments.uri); local.tweets = makeTwitterSearchRequest(local.thisSearch).results; local.tweets = killImpostors(local.tweets,local.shortened); local.tweets = cleanup(local.tweets); //cache tweets for 5 minutes setTweetCache(cacheKey, local.tweets, 5); } return local.tweets; var local = structNew(); var cacheKey = ''; //strip any bookmarks from the url arguments.uri = listFirst(arguments.uri,'##'); //setup cache cacheKey = hash(arguments.uri); setupCache(cacheKey); //use services local.thisSearch = getTweetSearchUrl(arguments.uri); local.shortened = getShortUrls(arguments.uri); local.tweets = makeTwitterSearchRequest(local.thisSearch).results; local.tweets = killImpostors(local.tweets,local.shortened); local.tweets = cleanup(local.tweets); dump(local,true); var local = structNew(); local.dsp = structNew(); local.tweets = getTweetbacks(arguments.uri); local.searchUrl = replace(getTweetSearchUrl(arguments.uri), ".json", "");//instead of linking to json, link to search results page local.tweetCount = arrayLen(local.tweets); local.limit = min(arguments.limit, local.tweetcount); if (local.limit eq 0){local.limit=local.tweetcount;} //define header if (local.tweetcount eq 0){ local.dsp.header = "

No Tweetbacks

"; }else{ local.dsp.header = "

#arrayLen(local.tweets)# Tweetbacks

"; if (local.tweetcount eq 1){local.dsp.header=replace(local.dsp.header,"Tweetbacks","Tweetback");} } //define view-all link if (local.tweetcount lte local.limit or local.limit eq 0){ local.dsp.allLink = ""; }else{ local.dsp.allLink = "Showing #local.limit# most recent - View All Tweetbacks"; }
#local.dsp.header##local.dsp.allLink#
var local = StructNew(); local.shortened = structNew(); //cligs local.cligsParams = StructNew(); local.cligsParams['appid'] = urlEncodedFormat('http://sweettweetscfc.riaforge.org'); local.shortened.cligs = urlService.shrink('cligs',arguments.uri,local.cligsParams); if (len(trim(local.shortened.cligs)) eq 0){ structDelete(local.shortened, "cligs"); } //simple services local.shortened.isgd = urlService.shrink('isgd',arguments.uri); local.shortened.tinyurl = urlService.shrink('tinyurl', arguments.uri); local.shortened.hexio = urlService.shrink('hexio', arguments.uri); return local.shortened; var local = structNew(); var cacheKey = hash(arguments.uri); //shortened url cache never expires if (urlCacheExists(cacheKey)){ local.shortened = getUrlCache(cacheKey); }else{ //get shortened versions of the url local.shortened = getShortUrls(arguments.uri); //and cache the result setUrlCache(cacheKey, local.shortened); } //compile twitter search url local.api = 'http://search.twitter.com/search.json?rpp=100&q=&ors='; local.thisSearch = local.api & urlEncodedFormat(local.shortened.isgd) & '+' & urlEncodedFormat(local.shortened.cligs) & '+' & urlEncodedFormat(local.shortened.tinyurl) & '+' & urlEncodedFormat(local.shortened.hexio); return local.thisSearch; var local = structNew(); var i = 0; local.linkRegex = "((https?|s?ftp|ssh)\:\/\/[^""\s\<\>]*[^.,;'"">\:\s\<\>\)\]\!])"; local.atRegex = "@([_a-z0-9]+)"; local.hashRegex = "##([_a-z0-9]+)"; for (i=1;i lte arrayLen(arguments.tweets);i=i+1){ //fix links arguments.tweets[i].text = REReplaceNoCase(arguments.tweets[i].text,local.linkRegex,"\1","all"); arguments.tweets[i].text = REReplaceNoCase(arguments.tweets[i].text,local.atRegex,"@\1","all"); arguments.tweets[i].text = REReplaceNoCase(arguments.tweets[i].text,local.hashRegex,"##\1"); //remove ugly stuff from timestamp arguments.tweets[i].created_at = Replace(arguments.tweets[i].created_at, "+0000", ""); } return arguments.tweets; //this function removes false positives returned because search is case-INsensitive, but shortened url's are case-sensitive var i = 0; var j = 0; var keyNames = structKeyList(shorties); var impostor = true; for (i=1;i lte arrayLen(data);i=i+1){ impostor = true; for (j=1;j lte listLen(keyNames);j=j+1){ if (find(shorties[listGetAt(keyNames,j)],data[i].text)){ impostor = false; break; } } if (impostor){ arrayDeleteAt(data,i); i=i-1; } } return data; if (variables.cacheLocation eq "application"){ if (not structKeyExists(application, "SweetTweetCache")){application.SweetTweetCache=StructNew();} if (not structKeyExists(application.sweetTweetCache, "urls")){application.sweetTweetCache.urls=StructNew();} if (not structKeyExists(application.sweetTweetCache, "tweetbacks")){application.sweetTweetCache.tweetbacks=StructNew();} if (not structKeyExists(application.sweetTweetCache.tweetbacks, arguments.cacheKey)){application.sweetTweetCache.tweetbacks[arguments.cacheKey]=StructNew();} }else{ if (not structKeyExists(variables, "SweetTweetCache")){variables.SweetTweetCache=StructNew();} if (not structKeyExists(variables.sweetTweetCache, "urls")){variables.sweetTweetCache.urls=StructNew();} if (not structKeyExists(variables.sweetTweetCache, "tweetbacks")){variables.sweetTweetCache.tweetbacks=StructNew();} if (not structKeyExists(variables.sweetTweetCache.tweetbacks, arguments.cacheKey)){variables.sweetTweetCache.tweetbacks[arguments.cacheKey]=StructNew();} } if (variables.cacheLocation eq "application"){ return (not structKeyExists(application.sweetTweetCache.tweetbacks[arguments.cacheKey], "timeout") or dateCompare(now(), application.sweetTweetCache.tweetbacks[arguments.cacheKey].timeout) eq 1); }else{ return (not structKeyExists(variables.sweetTweetCache.tweetbacks[arguments.cacheKey], "timeout") or dateCompare(now(), variables.sweetTweetCache.tweetbacks[arguments.cacheKey].timeout) eq 1); } if (variables.cacheLocation eq "application"){ return application.sweetTweetCache.tweetbacks[arguments.cacheKey].tweets; }else{ //dump(variables.sweetTweetCache,true); return variables.sweetTweetCache.tweetbacks[arguments.cacheKey].tweets; } if (variables.cacheLocation eq "application"){ application.sweetTweetCache.tweetbacks[arguments.cacheKey].tweets = arguments.data; application.sweetTweetCache.tweetbacks[arguments.cacheKey].timeout = dateAdd("n",arguments.timeout,now()); }else{ variables.sweetTweetCache.tweetbacks[arguments.cacheKey].tweets = arguments.data; variables.sweetTweetCache.tweetbacks[arguments.cacheKey].timeout = dateAdd("n",arguments.timeout,now()); } if (variables.cacheLocation eq "application"){ return (structKeyExists(application.SweetTweetCache.urls, arguments.cacheKey)); }else{ return (structKeyExists(variables.SweetTweetCache.urls, arguments.cacheKey)); } if (variables.cacheLocation eq "application"){ return application.sweetTweetCache.urls[arguments.cacheKey]; }else{ return variables.sweetTweetCache.urls[arguments.cacheKey]; } if (variables.cacheLocation eq "application"){ application.sweetTweetCache.urls[arguments.cacheKey] = arguments.data; }else{ variables.sweetTweetCache.urls[arguments.cacheKey] = arguments.data; }