Created
March 29, 2011 05:28
-
-
Save jmoyers/891854 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tweet_li_template = _.template( | |
"<li><div class='tweet'>{content}</div>" + | |
"<div class='details'>{time} via {source}</div></li>" | |
); | |
$.getJSON("http://twitter.com/statuses/user_timeline/so_co_co.json?count=3&callback=?", function(data){ | |
var fragments = []; | |
_.each( data, function(tweet){ | |
// Linkify urls, @'s | |
var status = tweet.text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) { | |
return '<a href="'+url+'">'+url+'</a>'; | |
}).replace(/\B@([_a-z0-9]+)/ig, function(reply) { | |
return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>'; | |
}); | |
var time = relative_time(parse_date(tweet.created_at)); | |
var new_li = tweet_li_template({ | |
content: status, | |
time: time, | |
source: tweet.source | |
}); | |
fragments.push( new_li ); | |
}); | |
$('#tweet-list').append( fragments.join('') ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment