').previous();
+ $(wrapper).children().append(iframe);
+ });
+ }
+
+ /* Sky Slavin, Ludopoli. MIT license. * based on JavaScript Pretty Date * Copyright (c) 2008 John Resig (jquery.com) * Licensed under the MIT license. */
+ /* Updated considerably by Brandon Mathis */
+
+ , prettyDate: function (time) {
+ if (navigator.appName === 'Microsoft Internet Explorer') {
+ return "
∞"; // because IE date parsing isn't fun.
+ }
+ var say = {
+ just_now: " now",
+ minute_ago: "1m",
+ minutes_ago: "m",
+ hour_ago: "1h",
+ hours_ago: "h",
+ yesterday: "1d",
+ days_ago: "d",
+ last_week: "1w",
+ weeks_ago: "w"
+ };
+
+ var current_date = new Date(),
+ current_date_time = current_date.getTime(),
+ current_date_full = current_date_time + (1 * 60000),
+ date = new Date(time),
+ diff = ((current_date_full - date.getTime()) / 1000),
+ day_diff = Math.floor(diff / 86400);
+
+ if (isNaN(day_diff) || day_diff < 0) { return "
∞"; }
+
+ return day_diff === 0 && (
+ diff < 60 && say.just_now ||
+ diff < 120 && say.minute_ago ||
+ diff < 3600 && Math.floor(diff / 60) + say.minutes_ago ||
+ diff < 7200 && say.hour_ago ||
+ diff < 86400 && Math.floor(diff / 3600) + say.hours_ago) ||
+ day_diff === 1 && say.yesterday ||
+ day_diff < 7 && day_diff + say.days_ago ||
+ day_diff === 7 && say.last_week ||
+ day_diff > 7 && Math.ceil(day_diff / 7) + say.weeks_ago;
+ }
+
+ , renderDeliciousLinks: function (items) {
+ var output = "
";
+ $('#delicious').html(output);
+ }
+
+ // Twitter fetcher for Octopress (c) Brandon Mathis // MIT License
+ , twitter: (function(){
+
+ function linkifyTweet(text, url) {
+ // Linkify urls, usernames, hashtags
+ text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '
$2')
+ .replace(/(^|\W)@(\w+)/g, '$1
@$2')
+ .replace(/(^|\W)#(\w+)/g, '$1
#$2');
+
+ // Use twitter's api to replace t.co shortened urls with expanded ones.
+ for (var u in url) {
+ if(url[u].expanded_url != null){
+ var shortUrl = new RegExp(url[u].url, 'g');
+ text = text.replace(shortUrl, url[u].expanded_url);
+ var shortUrl = new RegExp(">"+(url[u].url.replace(/https?:\/\//, '')), 'g');
+ text = text.replace(shortUrl, ">"+url[u].display_url);
+ }
+ }
+ return text
+ }
+
+ function render(tweets, twitter_user) {
+ var timeline = document.getElementById('tweets'),
+ content = '';
+
+ for (var t in tweets) {
+ content += '
'+''+''+octopress.prettyDate(tweets[t].created_at)+''+linkifyTweet(tweets[t].text.replace(/\n/g, '
'), tweets[t].entities.urls)+'
'+'';
+ }
+ timeline.innerHTML = content;
+ }
+
+ return {
+ getFeed: function(target){
+ target = $(target);
+ if (target.length == 0) return;
+ var user = target.attr('data-user');
+ var count = parseInt(target.attr('data-count'), 10);
+ var replies = target.attr('data-replies') == 'true';
+ $.ajax({
+ url: "http://api.twitter.com/1/statuses/user_timeline/" + user + ".json?trim_user=true&count=" + (count + 20) + "&include_entities=1&exclude_replies=" + (replies ? "0" : "1") + "&callback=?"
+ , dataType: 'jsonp'
+ , error: function (err) { $('#tweets li.loading').addClass('error').text("Twitter's busted"); }
+ , success: function(data) { render(data.slice(0, count), user); }
+ });
+ }
+ }
+ })()
+
+ , github: (function(){
+ function render(target, data){
+ var i = 0, repos = '';
+
+ for(i = 0; i < data.length; i++) {
+ repos += '
'+data[i].name+''+data[i].description+'
';
+ }
+ target.html(repos);
+ }
+ return {
+ showRepos: function(target){
+ target = $(target);
+ if (target.length == 0) return;
+ var user = target.attr('data-user')
+ var count = parseInt(target.attr('data-count'))
+ var skip_forks = target.attr('data-skip') == 'true'
+ $.ajax({
+ url: "https://api.github.com/users/"+user+"/repos?callback=?"
+ , dataType: 'jsonp'
+ , error: function (err) { target.find('.loading').addClass('error').text("Error loading feed"); }
+ , success: function(data) {
+ var repos = [];
+ if (!data.data) { return; }
+ for (var i = 0; i < data.data.length; i++) {
+ if (skip_forks && data.data[i].fork) { continue; }
+ repos.push(data.data[i]);
+ }
+ repos.sort(function(a, b) {
+ var aDate = new Date(a.pushed_at).valueOf(),
+ bDate = new Date(b.pushed_at).valueOf();
+
+ if (aDate === bDate) { return 0; }
+ return aDate > bDate ? -1 : 1;
+ });
+
+ if (count) { repos.splice(count); }
+ render(target, repos);
+ }
+ });
+ }
+ };
+ })()
}
- output += "";
- $('#delicious').html(output);
-}
+})();
+
$(document).ready(function() {
- wrapFlashVideos();
- flashVideoFallback();
- addCodeLineNumbers();
- getNav();
- addSidebarToggler();
+ octopress.wrapFlashVideos();
+ octopress.testFeatures();
+ octopress.flashVideoFallback();
+ octopress.addCodeLineNumbers();
+ octopress.getNav();
+ octopress.addSidebarToggler();
+ octopress.twitter.getFeed('#tweets')
+ octopress.github.showRepos('#gh_repos');
});
// iOS scaling bug fix
diff --git a/.themes/classic/source/javascripts/twitter.js b/.themes/classic/source/javascripts/twitter.js
deleted file mode 100644
index 4f85e20..0000000
--- a/.themes/classic/source/javascripts/twitter.js
+++ /dev/null
@@ -1,94 +0,0 @@
-// JSON-P Twitter fetcher for Octopress
-// (c) Brandon Mathis // MIT License
-
-/* Sky Slavin, Ludopoli. MIT license. * based on JavaScript Pretty Date * Copyright (c) 2008 John Resig (jquery.com) * Licensed under the MIT license. */
-/* Updated considerably by Brandon Mathis */
-function prettyDate(time) {
- if (navigator.appName === 'Microsoft Internet Explorer') {
- return "
∞"; // because IE date parsing isn't fun.
- }
- var say = {
- just_now: " now",
- minute_ago: "1m",
- minutes_ago: "m",
- hour_ago: "1h",
- hours_ago: "h",
- yesterday: "1d",
- days_ago: "d",
- last_week: "1w",
- weeks_ago: "w"
- };
-
- var current_date = new Date(),
- current_date_time = current_date.getTime(),
- current_date_full = current_date_time + (1 * 60000),
- date = new Date(time),
- diff = ((current_date_full - date.getTime()) / 1000),
- day_diff = Math.floor(diff / 86400);
-
- if (isNaN(day_diff) || day_diff < 0) { return "
∞"; }
-
- return day_diff === 0 && (
- diff < 60 && say.just_now ||
- diff < 120 && say.minute_ago ||
- diff < 3600 && Math.floor(diff / 60) + say.minutes_ago ||
- diff < 7200 && say.hour_ago ||
- diff < 86400 && Math.floor(diff / 3600) + say.hours_ago) ||
- day_diff === 1 && say.yesterday ||
- day_diff < 7 && day_diff + say.days_ago ||
- day_diff === 7 && say.last_week ||
- day_diff > 7 && Math.ceil(day_diff / 7) + say.weeks_ago;
-}
-
-var twitter = (function(){
-
- function linkifyTweet(text, url) {
- // Linkify urls, usernames, hashtags
- text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '
$2')
- .replace(/(^|\W)@(\w+)/g, '$1
@$2')
- .replace(/(^|\W)#(\w+)/g, '$1
#$2');
-
- // Use twitter's api to replace t.co shortened urls with expanded ones.
- for (var u in url) {
- if(url[u].expanded_url != null){
- var shortUrl = new RegExp(url[u].url, 'g');
- text = text.replace(shortUrl, url[u].expanded_url);
- var shortUrl = new RegExp(">"+(url[u].url.replace(/https?:\/\//, '')), 'g');
- text = text.replace(shortUrl, ">"+url[u].display_url);
- }
- }
- return text
- }
-
- function render(tweets, twitter_user) {
- var timeline = document.getElementById('tweets'),
- content = '';
-
- for (var t in tweets) {
- content += '
'+''+''+prettyDate(tweets[t].created_at)+''+linkifyTweet(tweets[t].text.replace(/\n/g, '
'), tweets[t].entities.urls)+'
'+'';
- }
- timeline.innerHTML = content;
- }
-
- return {
- getFeed: function(options){
- count = options.count;
- console.log(options);
- $.ajax({
- url: "http://api.twitter.com/1/statuses/user_timeline/" + options.user + ".json?trim_user=true&count=" + (count + 20) + "&include_entities=1&exclude_replies=" + (options.replies ? "0" : "1") + "&callback=?"
- , dataType: 'jsonp'
- , error: function (err) { $('#tweets li.loading').addClass('error').text("Twitter's busted"); }
- , success: function(data) { render(data.slice(0, count), options.user); }
- });
- }
- }
-})();
-
-$(document).ready(function(){
- t = $('#tweets');
- twitter.getFeed({
- user: t.attr('data-user')
- , count: parseInt(t.attr('data-count'), 10)
- , replies: t.attr('data-replies') == 'true'
- });
-});