2009-10-30 01:31:02 -04:00
|
|
|
|
//
|
|
|
|
|
// The Octopress Twitter Feed is based on the following work:
|
|
|
|
|
// Valerio's javascript framework Mootools: Mootools.net
|
|
|
|
|
// David Walsh's Twitter Gitter plugin: http://davidwalsh.name/mootools-twitter-plugin
|
|
|
|
|
// Aaron Newton’s JSONP plugin: http://clientcide.com/js
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
var username = 'imathis';
|
|
|
|
|
var filter_mentions = true;
|
|
|
|
|
var tweet_count = 5;
|
|
|
|
|
var tweet_tag = 'p';
|
|
|
|
|
var twitter_div = 'twitter_status';
|
2009-11-06 12:04:12 -05:00
|
|
|
|
var tweet_cookie = 'the_tweets_' + username;
|
2009-10-30 01:31:02 -04:00
|
|
|
|
|
|
|
|
|
window.addEvent('domready',function() {
|
|
|
|
|
getTwitterStatus();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function showTweets(the_tweets, from_cookie){
|
|
|
|
|
if(from_cookie){
|
|
|
|
|
the_tweets = the_tweets.split('^!^!^!^!^');
|
|
|
|
|
}
|
|
|
|
|
$(twitter_div).set('html', '');
|
|
|
|
|
the_tweets.each(function(tweet){
|
|
|
|
|
new Element(tweet_tag,{
|
|
|
|
|
html: tweet
|
|
|
|
|
}).inject(twitter_div);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getTwitterStatus(){
|
|
|
|
|
$(twitter_div).set('html', 'Fetching tweets...');
|
2009-11-06 12:04:12 -05:00
|
|
|
|
if(!Cookie.read(tweet_cookie)) {
|
2009-10-30 01:31:02 -04:00
|
|
|
|
var myTwitterGitter = new TwitterGitter(username,{
|
|
|
|
|
count: ((!filter_mentions) ? tweet_count : 15 + tweet_count),
|
|
|
|
|
onComplete: function(tweets,user) {
|
|
|
|
|
the_tweets = Array();
|
|
|
|
|
tweets.each(function(tweet,i) {
|
|
|
|
|
if((tweet.in_reply_to_status_id && !filter_mentions) || !tweet.in_reply_to_status_id){
|
|
|
|
|
if(the_tweets.length == tweet_count) return;
|
2009-11-06 12:04:12 -05:00
|
|
|
|
tweet.text = tweet.text.replace(/\n/gi, '<br/>');
|
2009-10-30 01:31:02 -04:00
|
|
|
|
the_tweets.push(tweet.text);
|
|
|
|
|
}
|
|
|
|
|
});
|
2009-11-06 12:04:12 -05:00
|
|
|
|
Cookie.write(tweet_cookie,the_tweets.join('^!^!^!^!^'), { duration: 1 });
|
2009-10-30 01:31:02 -04:00
|
|
|
|
showTweets(the_tweets);
|
|
|
|
|
}
|
|
|
|
|
}).retrieve();
|
|
|
|
|
} else {
|
2009-11-06 12:04:12 -05:00
|
|
|
|
showTweets(Cookie.read(tweet_cookie),true);
|
2009-10-30 01:31:02 -04:00
|
|
|
|
}
|
2009-11-06 12:04:12 -05:00
|
|
|
|
}
|