Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

time to release

  • Loading branch information...
commit 920d8463ab722a89112ea20f1f3c4d222dd6a58e 0 parents
@briandoll authored
Showing with 114 additions and 0 deletions.
  1. +37 −0 README.md
  2. +73 −0 index.html
  3. +4 −0 jquery.twitter.min.js
37 README.md
@@ -0,0 +1,37 @@
+# influencer.tweets
+
+What are "influencers" saying about X on twitter, right now? influencer.tweets shows recent tweets by influencers that mention a given topic.
+
+## Why?
+
+Becasuse, surprisingly, no "social media" app solves for this yet. The current landscape of social media apps allow you to shout louder into multimple mouth pieces at once. They don't seem to (yet) help you actually have conversations with people.
+
+I didn't want to miss an "important" tweet about something I care about.
+
+## How to use it
+
+You can download this code and run it directly from your computer by opening ``index.html`` in your browser of choice. It's best if you can host this code on a server somewhere intead, since you'll probably want to view these tweets on your phone.
+
+To see tweets that mention ``coffee`` with more than 10,000 followers:
+
+* http://host.tld/influencer.tweets/?q=coffee&c=10000
+
+To see tweets that mention ``ruby`` with more than 5,000 followers:
+
+* http://host.tld/influencer.tweets/?q=ruby&c=5000
+
+
+**Note:** The Twitter API is rate limited to 150 queries per hour. Depending on the search terms, a single page view may make up to 11 queries. If the page goes blank, you're probably being rate limted. Be patient and try again later :)
+
+
+## TODO
+
+This is a silly hack of a project right now. I'd really prefer a company that builds social media tools solve for this in a better way. To name a few:
+
+* Let me specify a list of users to filter out (handy when searching for your company name, filter out employees)
+* Push notifications to me rather than make this something I have to remember to use all the time
+* Make the UI not horrible
+* Pull-to-refresh on mobile
+* Reply to tweets via a specified account
+* Any way to deal with rate limiting?
+* and on and on and on...
73 index.html
@@ -0,0 +1,73 @@
+<html>
+ <head>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+ <script src="jquery.twitter.min.js"></script>
+ <style type="text/css">
+ body {background: #333; font-size: 64px; color: #999}
+ .twitter-posts {padding: 10px; list-style-type:none; border-bottom: 1px solid #000;}
+ .twitter-posts a {text-decoration:none; color: #FFF;}
+ </style>
+ <script type="text/javascript">
+ // please tell me there is a builtin for this
+ var parseQuerystring = function(){
+ var nvpair = {};
+ var qs = window.location.search.replace('?', '');
+ var pairs = qs.split('&');
+ $.each(pairs, function(i, v){
+ var pair = v.split('=');
+ nvpair[pair[0]] = pair[1];
+ });
+ return nvpair;
+ }
+
+ $(function(){
+ var qs = parseQuerystring();
+ // pass q=query&c=count to override
+ var q = qs['q'] || '@github';
+ var c = qs['c'] || 2000;
+
+ $.twitter({limit: 1000, retweets: false, q: q}, function(tweets){
+ var musings = tweets.results;
+ var tweet_data = {};
+ $.each(musings, function(num, tweet) {
+ tweet_data[tweet.from_user] = tweet;
+ });
+
+ // we can get profile data on 100 people or less at a time
+ // so we need to break up our authors into chunks of 100
+ var authors = Object.keys(tweet_data).splice(0);
+ var batch_count = ((authors.size / 100) + 1)
+ var batches_of_authors = [];
+ while(authors.length){
+ batches_of_authors.push(authors.splice(0,100));
+ }
+
+ $.each(batches_of_authors, function(counter, author_batch){
+
+ var url = "http://api.twitter.com/1/users/lookup.json?callback=?&screen_name=";
+ $.getJSON(url + author_batch.join(), function(profiles){
+ $.each(profiles, function(count, author){
+ // naive approach to highlight 'influencers'
+ if (author.followers_count > c){
+ tweet = tweet_data[author.screen_name];
+ name = author.name;
+ // this should use mustache.js instead
+ $('#loud-tweets').append($("<li>", {
+ "class": "twitter-posts",
+ html: name + " <a href='http://twitter.com/" + tweet.from_user + "' class='profile'>@" + tweet.from_user + "</a> (" + author.followers_count + ") says...<div class='tweet'><a href='http://twitter.com/" + tweet.from_user + "/status/" + tweet.id_str + "'>" + tweet.text + "</a></div>"}));
+ };
+ });
+ });
+
+ });
+
+
+ });
+
+ });
+ </script>
+ </head>
+ <body>
+ <div id="loud-tweets"></div>
+ </body>
+</html>
4 jquery.twitter.min.js
@@ -0,0 +1,4 @@
+/*! jQuery Twitter Plugin - v0.2.0 - 2/13/2012
+* http://code.bocoup.com/jquery-twitter-plugin/
+* Copyright (c) 2012 Boaz Sender; Licensed MIT, GPL */
+window.linkify=function(){var a="[a-z\\d.-]+://",b="(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])",c="(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)+",d="(?:ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)",e="(?:"+c+d+"|"+b+")",f="(?:[;/][^#?<>\\s]*)?",g="(?:\\?[^#<>\\s]*)?(?:#[^<>\\s]*)?",h="\\b"+a+"[^<>\\s]+",i="\\b"+e+f+g+"(?!\\w)",j="mailto:",k="(?:"+j+")?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"+e+g+"(?!\\w)",l=new RegExp("(?:"+h+"|"+i+"|"+k+")","ig"),m=new RegExp("^"+a,"i"),n={"'":"`",">":"<",")":"(","]":"[","}":"{","»":"«","›":"‹"},o={callback:function(a,b){return b?'<a href="'+b+'" title="'+b+'">'+a+"</a>":a},punct_regexp:/(?:[!?.,:;'"]|(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)$/};return function(a,b){b=b||{};var c,d,e,f,g="",h=[],i,k,p,q,r,s,t,u;for(d in o)b[d]===undefined&&(b[d]=o[d]);while(c=l.exec(a)){e=c[0],k=l.lastIndex,p=k-e.length;if(/[\/:]/.test(a.charAt(p-1)))continue;do q=e,u=e.substr(-1),t=n[u],t&&(r=e.match(new RegExp("\\"+t+"(?!$)","g")),s=e.match(new RegExp("\\"+u,"g")),(r?r.length:0)<(s?s.length:0)&&(e=e.substr(0,e.length-1),k--)),b.punct_regexp&&(e=e.replace(b.punct_regexp,function(a){return k-=a.length,""}));while(e.length&&e!==q);f=e,m.test(f)||(f=(f.indexOf("@")!==-1?f.indexOf(j)?j:"":f.indexOf("irc.")?f.indexOf("ftp.")?"http://":"ftp://":"irc://")+f),i!=p&&(h.push([a.slice(i,p)]),i=k),h.push([e,f])}h.push([a.substr(i)]);for(d=0;d<h.length;d++)g+=b.callback.apply(window,h[d]);return g||a}}();var linkify=linkify||function(){};(function(a,b){var c=function(a){return a.replace("/[@]+[A-Za-z0-9-_]+/ig",function(a){return a.link("http://twitter.com/"+a.replace("@",""))})},d=function(a){return a.replace("/[#]+[A-Za-z0-9-_]+/ig",function(a){return a.link("http://search.twitter.com/search?q="+a.replace("#","%23"))})};a.twitter=function(b,c){if(!b)return!1;var d,e="",f=new RegExp(!1);typeof b=="string"?d=a.extend({},a.twitter.opts,{q:b}):(b.rpp=b.limit?b.limit:b.rpp,b.limit=b.limit?b.limit:b.rpp,e=b.exclusions?b.exclusions.replace(" ","|"):!1,f=e?new RegExp(e):!1,d=a.extend({},a.twitter.opts,b),d.rpp=d.exclusions||!d.replies||!d.retweets?d.rpp*10:d.rpp),a.getJSON("http://search.twitter.com/search.json?callback=?",d,function(a){c(a,d,f)})},a.fn.twitter=function(e){return e?this.each(function(){var f=a(this);a.twitter(e,function(e,g,h){var i=a("<ul>"),j=0,k;if(e.results&&e.results.length){for(k in e.results){var l=e.results[k],m=!g.replies&&l.to_user_id?!1:!0,n=!g.retweets&&l.text.slice(0,2)==="RT"?!1:!0;if(!m)continue;if(!n)continue;if(h&&h.test(l.text))continue;var o=a("<li/>",{"class":"tweet"});g.avatar===!0&&o.append(a("<a/>",{href:"http://twitter.com/"+l.from_user,html:"<img src='"+l.profile_image_url+"'/>"})),o.append(a("<span>",{"class":"content",html:"<a href='http://twitter.com/"+l.from_user+"'>@"+l.from_user+"</a>: "+c(d(b(l.text)))})).appendTo(i),j++;if(j===g.limit)break}f.html(i)}else f.html(a("<h3/>",{"class":"twitter-notFound",text:g.notFoundText}))})}):this},a.twitter.opts={limit:7,exclusions:"",notFoundText:"No results found on twitter",replies:!0,retweets:!0,ands:"",phrase:"",ors:"",nots:"",tag:"",lang:"",from:"",to:"",ref:"",near:"",within:"",units:"",since:"",until:"",tude:"",filter:"",include:"",rpp:5,q:"",avatar:!0}})(jQuery,linkify)
Please sign in to comment.
Something went wrong with that request. Please try again.