<commit_before>//
// The Octopress Twitter Feed is based on the following work:
// Valerio's javascript framework Mootools: Mootools.net
// <NAME>sh's Twitter Gitter plugin: http://davidwalsh.name/mootools-twitter-plugin
// <NAME>ton’s JSONP plugin: http://clientcide.com/js
// PrettyDate by <NAME> at http://ejohn.org/files/pretty.js
//

/*
	Plugin:   	Octopress Twitter Feed
	Author:   	<NAME>
	Website:    http://brandonmathis.com
	Date:     	11/07/2009
*/

var tweet_container = 'li';
var twitter_container = 'twitter_status';
var key = '-!-!-';
var show_source = false;

window.addEvent('domready',function() {
	getTwitterStatus(twitter_user);
});

function showTweets(the_tweets, from_cookie){
  if(from_cookie){
    the_tweets = the_tweets.split('^!^!^');
  }
  $(twitter_container).set('html', '');
  the_tweets.each(function(tweet){
    tweet = parseTweetMeta(tweet)
    tweet = '<p>' + tweet.replace(/\n\n/gi,'</p><p>') + '</p>';
    new Element(tweet_container,{
  		html: tweet
  	}).inject(twitter_container);
  });
}

function parseTweetMeta(tweet_data){
  var tweet_data = tweet_data.split(key);
  var tweet = tweet_data[0];
  var date = tweet_data[1];
  var tweet_id = tweet_data[2];
  var source = tweet_data[3];
  
  date = prettyDate(new Date().parse(date));
  return tweet + '<span class="meta"><a href="http://twitter.com/'+twitter_user + '/status/' + tweet_id + '">' + date + '</a>' + (show_source ? ' from '+source : '') + '</span>';
}

function prettyDate(time){
	var date = time;
	var diff = (((new Date()).getTime() - date.getTime()) / 1000)
	var day_diff = Math.floor(diff / 86400);
			
	if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
		return;
			
	return day_diff == 0 && (
			diff < 60 && "just now" ||
			diff < 120 && "1 minute ago" ||
			diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
			diff < 7200 && "1 hour ago" ||
			diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
		day_diff == 1 && "1 day ago" ||
		day_diff < 7 && day_diff + " days ago" ||
		day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago";
}

function getTwitterStatus(twitter_name){
  var container = $(twitter_container);
  if(!container) return;<commit_msg>Return months when > 31 days.<commit_after>//
// The Octopress Twitter Feed is based on the following work:
// Valerio's javascript framework Mootools: Mootools.net
// <NAME>'s Twitter Gitter plugin: http://davidwalsh.name/mootools-twitter-plugin
// <NAME>’s JSONP plugin: http://clientcide.com/js
// PrettyDate by <NAME> at http://ejohn.org/files/pretty.js
//

/*
	Plugin:   	Octopress Twitter Feed
	Author:   	<NAME>
	Website:    http://brandonmathis.com
	Date:     	11/07/2009
*/

var tweet_container = 'li';
var twitter_container = 'twitter_status';
var key = '-!-!-';
var show_source = false;

window.addEvent('domready',function() {
	getTwitterStatus(twitter_user);
});

function showTweets(the_tweets, from_cookie){
  if(from_cookie){
    the_tweets = the_tweets.split('^!^!^');
  }
  $(twitter_container).set('html', '');
  the_tweets.each(function(tweet){
    tweet = parseTweetMeta(tweet)
    tweet = '<p>' + tweet.replace(/\n\n/gi,'</p><p>') + '</p>';
    new Element(tweet_container,{
  		html: tweet
  	}).inject(twitter_container);
  });
}

function parseTweetMeta(tweet_data){
  var tweet_data = tweet_data.split(key);
  var tweet = tweet_data[0];
  var date = tweet_data[1];
  var tweet_id = tweet_data[2];
  var source = tweet_data[3];
  
  date = prettyDate(new Date().parse(date));
  return tweet + '<span class="meta"><a href="http://twitter.com/'+twitter_user + '/status/' + tweet_id + '">' + date + '</a>' + (show_source ? ' from '+source : '') + '</span>';
}

function prettyDate(time){
	var date = time;
	var diff = (((new Date()).getTime() - date.getTime()) / 1000)
	var day_diff = Math.floor(diff / 86400);
			
	if ( isNaN(day_diff) || day_diff < 0)
		return;
			
	return day_diff == 0 && (
			diff < 60 && "just now" ||
			diff < 120 && "1 minute ago" ||
			diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
			diff < 7200 && "1 hour ago" ||
			diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
		day_diff == 1 && "1 day ago" ||
		day_diff < 7 && day_diff + " days ago" ||
		day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago" ||
		true && Math.ceil( day_diff / 30 ) + " months ago";
}

function getTwitterStatus(twitter_name){
  var container = $(twitter_container);
  if(!container) return;
{'fraction_non_alphanumeric': 0.18122467357046376, 'fraction_numerical': 0.026114362899594776, 'mean_word_length': 3.637787056367432, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '218212', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1594, 'n_words': 371}