diff --git a/.themes/classic/sass/partials/_navigation.scss b/.themes/classic/sass/partials/_navigation.scss index 781d2f7..b0bf3e4 100644 --- a/.themes/classic/sass/partials/_navigation.scss +++ b/.themes/classic/sass/partials/_navigation.scss @@ -117,7 +117,7 @@ body > nav { } &:hover:after { background-color: lighten($nav-color, 20); } } -.cssmask { +.maskimage { body > nav { @media only screen and (min-width: 550px) { ul[data-subscription$=email] + form { diff --git a/.themes/classic/source/_includes/after_footer.html b/.themes/classic/source/_includes/after_footer.html index 88c0de3..0324a32 100644 --- a/.themes/classic/source/_includes/after_footer.html +++ b/.themes/classic/source/_includes/after_footer.html @@ -5,9 +5,3 @@ {% include twitter_sharing.html %} {% endunless %} {% include custom/after_footer.html %} -{% if site.github_user %} - -{% endif %} -{% if site.twitter_user %} - -{% endif %} diff --git a/.themes/classic/source/_includes/asides/delicious.html b/.themes/classic/source/_includes/asides/delicious.html index 115cdcb..6f656a2 100644 --- a/.themes/classic/source/_includes/asides/delicious.html +++ b/.themes/classic/source/_includes/asides/delicious.html @@ -2,7 +2,7 @@

On Delicious

- +

My Delicious Bookmarks »

-{% endif %} \ No newline at end of file +{% endif %} diff --git a/.themes/classic/source/javascripts/github.js b/.themes/classic/source/javascripts/github.js deleted file mode 100644 index 988986c..0000000 --- a/.themes/classic/source/javascripts/github.js +++ /dev/null @@ -1,48 +0,0 @@ -var 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(options){ - $.ajax({ - url: "https://api.github.com/users/"+options.user+"/repos?callback=?" - , dataType: 'jsonp' - , error: function (err) { options.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 (options.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 (options.count) { repos.splice(options.count); } - render(options.target, repos); - } - }); - } - }; -})(); - -$(document).ready(function(){ - g = $('#gh_repos'); - - github.showRepos({ - user: g.attr('data-user') - , count: parseInt(g.attr('data-count')) - , skip_forks: g.attr('data-skip') == 'true' - , target: g - }); -}); diff --git a/.themes/classic/source/javascripts/modernizr-2.0.js b/.themes/classic/source/javascripts/modernizr-2.0.js index f610af7..195001a 100644 --- a/.themes/classic/source/javascripts/modernizr-2.0.js +++ b/.themes/classic/source/javascripts/modernizr-2.0.js @@ -1,4 +1,4 @@ /* Modernizr 2.5.3 (Custom Build) | MIT & BSD - * Build: http://www.modernizr.com/download/#-video-shiv-cssclasses-addtest-testprop-testallprops-domprefixes-css_mask-forms_placeholder-load + * Build: http://www.modernizr.com/download/#-video-shiv-cssclasses-addtest-testprop-testallprops-domprefixes-forms_placeholder-load */ -;window.Modernizr=function(a,b,c){function x(a){j.cssText=a}function y(a,b){return x(prefixes.join(a+";")+(b||""))}function z(a,b){return typeof a===b}function A(a,b){return!!~(""+a).indexOf(b)}function B(a,b){for(var d in a)if(j[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function C(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:z(f,"function")?f.bind(d||b):f}return!1}function D(a,b,c){var d=a.charAt(0).toUpperCase()+a.substr(1),e=(a+" "+n.join(d+" ")+d).split(" ");return z(b,"string")||z(b,"undefined")?B(e,b):(e=(a+" "+o.join(d+" ")+d).split(" "),C(e,b,c))}var d="2.5.3",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m="Webkit Moz O ms",n=m.split(" "),o=m.toLowerCase().split(" "),p={},q={},r={},s=[],t=s.slice,u,v={}.hasOwnProperty,w;!z(v,"undefined")&&!z(v.call,"undefined")?w=function(a,b){return v.call(a,b)}:w=function(a,b){return b in a&&z(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=t.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(t.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(t.call(arguments)))};return e}),p.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c};for(var E in p)w(p,E)&&(u=E.toLowerCase(),e[u]=p[E](),s.push((e[u]?"":"no-")+u));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)w(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,g.className+=" "+(b?"":"no-")+a,e[a]=b}return e},x(""),i=k=null,function(a,b){function g(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function h(){var a=k.elements;return typeof a=="string"?a.split(" "):a}function i(a){var b={},c=a.createElement,e=a.createDocumentFragment,f=e();a.createElement=function(a){var e=(b[a]||(b[a]=c(a))).cloneNode();return k.shivMethods&&e.canHaveChildren&&!d.test(a)?f.appendChild(e):e},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+h().join().replace(/\w+/g,function(a){return b[a]=c(a),f.createElement(a),'c("'+a+'")'})+");return n}")(k,f)}function j(a){var b;return a.documentShived?a:(k.shivCSS&&!e&&(b=!!g(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),f||(b=!i(a)),b&&(a.documentShived=b),a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea)$/i,e,f;(function(){var a=b.createElement("a");a.innerHTML="",e="hidden"in a,f=a.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var k={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:j};a.html5=k,j(b)}(this,b),e._version=d,e._domPrefixes=o,e._cssomPrefixes=n,e.testProp=function(a){return B([a])},e.testAllProps=D,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+s.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return o.call(a)=="[object Function]"}function e(a){return typeof a=="string"}function f(){}function g(a){return!a||a=="loaded"||a=="complete"||a=="uninitialized"}function h(){var a=p.shift();q=1,a?a.t?m(function(){(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){a!="img"&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l={},o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return o.call(a)=="[object Array]"},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f",d.insertBefore(c.lastChild,d.firstChild)}function h(){var a=k.elements;return typeof a=="string"?a.split(" "):a}function i(a){var b={},c=a.createElement,e=a.createDocumentFragment,f=e();a.createElement=function(a){var e=(b[a]||(b[a]=c(a))).cloneNode();return k.shivMethods&&e.canHaveChildren&&!d.test(a)?f.appendChild(e):e},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+h().join().replace(/\w+/g,function(a){return b[a]=c(a),f.createElement(a),'c("'+a+'")'})+");return n}")(k,f)}function j(a){var b;return a.documentShived?a:(k.shivCSS&&!e&&(b=!!g(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),f||(b=!i(a)),b&&(a.documentShived=b),a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea)$/i,e,f;(function(){var a=b.createElement("a");a.innerHTML="",e="hidden"in a,f=a.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var k={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:j};a.html5=k,j(b)}(this,b),e._version=d,e._domPrefixes=o,e._cssomPrefixes=n,e.testProp=function(a){return B([a])},e.testAllProps=D,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+s.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return o.call(a)=="[object Function]"}function e(a){return typeof a=="string"}function f(){}function g(a){return!a||a=="loaded"||a=="complete"||a=="uninitialized"}function h(){var a=p.shift();q=1,a?a.t?m(function(){(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){a!="img"&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l={},o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return o.call(a)=="[object Array]"},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f') - var mobileNav = $('fieldset.mobile-nav').append(''); + mobileNav.find('select').append(''); + mainNav.find('a').each(function() { + mobileNav.find('select').append(''); + }); + $('ul.subscription a').each(function() { + mobileNav.find('select').append(''); + }); + mobileNav.find('select').bind('change', function(event) { + if (event.target.value) { window.location.href = event.target.value; } }); - video.remove(); } - }); -} -function wrapFlashVideos() { - $('object').each(function(object) { - object = $(object); - if ( $('param[name=movie]', object).length ) { - var wrapper = object.before('
    ').previous(); - $(wrapper).children().append(object); + , addSidebarToggler: function () { + if(!$('body').hasClass('sidebar-footer')) { + $('#content').append(''); + $('.toggle-sidebar').bind('click', function(e) { + e.preventDefault(); + if ($('body').hasClass('collapse-sidebar')) { + $('body').removeClass('collapse-sidebar'); + } else { + $('body').addClass('collapse-sidebar'); + } + }); + } + var sections = $('.sidebar section'); + if (sections.length > 1) { + sections.each(function(index){ + if ((sections.length >= 3) && index % 3 === 0) { + $(this).addClass("first"); + } + var count = ((index +1) % 2) ? "odd" : "even"; + $(this).addClass(count); + }); + } + if (sections.length >= 3){ $('aside.sidebar').addClass('thirds'); } + } + , addCodeLineNumbers: function () { + if (navigator.appName === 'Microsoft Internet Explorer') { return; } + $('div.gist-highlight').each(function(index) { + var tableStart = '
    ', + lineNumbers = '
    ',
    +            tableMiddle = '
    ', + tableEnd = '
    ', + count = $('.line', this).length; + for (var i=1;i<=count; i++) { + lineNumbers += ''+i+'\n'; + } + var table = tableStart + lineNumbers + tableMiddle + '
    '+$('pre', this).html()+'
    ' + tableEnd; + $(this).html(table); + }); } - }); - $('iframe[src*=vimeo],iframe[src*=youtube]').each(function(iframe) { - iframe = $(iframe); - var wrapper = iframe.before('
    ').previous(); - $(wrapper).children().append(iframe); - }); -} -function renderDeliciousLinks(items) { - var output = "
      "; - for (var i=0,l=items.length; i' + items[i].d + ''; + , testFeatures: function () { + if (Modernizr.testAllProps('maskImage')) { + $('html').addClass('maskimage') + } else { + $('html').addClass('no-maskimage') + } + } + + , flashVideoFallback: function (){ + var flashplayerlocation = "/assets/jwplayer/player.swf", + flashplayerskin = "/assets/jwplayer/glow/glow.xml"; + $('video').each(function(video){ + video = $(video); + if (!Modernizr.video.h264 && swfobject.getFlashPlayerVersion() || window.location.hash.indexOf("flash-test") !== -1){ + video.children('source[src$=mp4]').first().map(function(source){ + var src = $(source).attr('src'), + id = 'video_'+Math.round(1 + Math.random()*(100000)), + width = video.attr('width'), + height = parseInt(video.attr('height'), 10) + 30; + video.after('
      '); + swfobject.embedSWF(flashplayerlocation, id, width, height + 30, "9.0.0", + { file : src, image : video.attr('poster'), skin : flashplayerskin } , + { movie : src, wmode : "opaque", allowfullscreen : "true" } + ); + }); + video.remove(); + } + }); + } + + , wrapFlashVideos: function () { + $('object').each(function(object) { + object = $(object); + if ( $('param[name=movie]', object).length ) { + var wrapper = object.before('
      ').previous(); + $(wrapper).children().append(object); + } + }); + $('iframe[src*=vimeo],iframe[src*=youtube]').each(function(iframe) { + iframe = $(iframe); + var wrapper = iframe.before('
      ').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 = "
        "; + for (var i=0,l=items.length; i' + items[i].d + ''; + } + 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' - }); -});