updated source to latest

This commit is contained in:
Brandon Mathis 2012-05-24 23:05:33 -05:00
parent 4efb88c72a
commit a15cecf323
10 changed files with 150 additions and 150 deletions

View File

@ -8,23 +8,23 @@
<a href="https://github.com/{{site.github_user}}">@{{site.github_user}}</a> on GitHub <a href="https://github.com/{{site.github_user}}">@{{site.github_user}}</a> on GitHub
{% endif %} {% endif %}
<script type="text/javascript"> <script type="text/javascript">
$.domReady(function(){ $(document).ready(function(){
if (!window.jXHR){ if (!window.jXHR){
var jxhr = document.createElement('script'); var jxhr = document.createElement('script');
jxhr.type = 'text/javascript'; jxhr.type = 'text/javascript';
jxhr.src = '{{ root_url}}/javascripts/libs/jXHR.js'; jxhr.src = '{{ root_url}}/javascripts/libs/jXHR.js';
var s = document.getElementsByTagName('script')[0]; var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(jxhr, s); s.parentNode.insertBefore(jxhr, s);
} }
github.showRepos({ github.showRepos({
user: '{{site.github_user}}', user: '{{site.github_user}}'
count: {{site.github_repo_count}}, , count: {{site.github_repo_count}}
skip_forks: {{site.github_skip_forks}}, , skip_forks: {{site.github_skip_forks}}
target: '#gh_repos' , target: '#gh_repos'
}); });
}); });
</script> </script>
<script src="{{ root_url }}/javascripts/github.js" type="text/javascript"> </script> <script src="{{ root_url }}/javascripts/github.js" type="text/javascript"></script>
</section> </section>
{% endif %} {% endif %}

View File

@ -5,15 +5,13 @@
<p><a href="http://pinboard.in/u:{{ site.pinboard_user }}">My Pinboard Bookmarks &raquo;</a></p> <p><a href="http://pinboard.in/u:{{ site.pinboard_user }}">My Pinboard Bookmarks &raquo;</a></p>
</section> </section>
<script type="text/javascript"> <script type="text/javascript">
var linkroll = 'pinboard_linkroll'; //id target for pinboard list $(document).ready(function(){
var pinboard_user = "{{ site.pinboard_user }}"; //id target for pinboard list pinboard.getFeed({
var pinboard_count = {{ site.pinboard_count }}; //id target for pinboard list target: 'pinboard_linkroll' //id target for pinboard list
(function(){ , user: "{{ site.pinboard_user }}"
var pinboardInit = document.createElement('script'); , count: {{ site.pinboard_count }}
pinboardInit.type = 'text/javascript'; });
pinboardInit.async = true; });
pinboardInit.src = '{{ root_url }}/javascripts/pinboard.js';
document.getElementsByTagName('head')[0].appendChild(pinboardInit);
})();
</script> </script>
<script src="{{ root_url }}/javascripts/pinboard.js" type="text/javascript"></script>
{% endif %} {% endif %}

View File

@ -5,8 +5,12 @@
<li class="loading">Status updating...</li> <li class="loading">Status updating...</li>
</ul> </ul>
<script type="text/javascript"> <script type="text/javascript">
$.domReady(function(){ $(document).ready(function(){
getTwitterFeed("{{site.twitter_user}}", {{site.twitter_tweet_count}}, {{site.twitter_show_replies}}); twitter.getFeed({
user: "{{site.twitter_user}}"
, count: {{site.twitter_tweet_count}}
, replies: {{site.twitter_show_replies}}
});
}); });
</script> </script>
<script src="{{ root_url }}/javascripts/twitter.js" type="text/javascript"> </script> <script src="{{ root_url }}/javascripts/twitter.js" type="text/javascript"> </script>

View File

@ -22,7 +22,7 @@
<link href="{{ root_url }}/favicon.png" rel="icon"> <link href="{{ root_url }}/favicon.png" rel="icon">
<link href="{{ root_url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css"> <link href="{{ root_url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="{{ root_url }}/javascripts/modernizr-2.0.js"></script> <script src="{{ root_url }}/javascripts/modernizr-2.0.js"></script>
<script src="{{ root_url }}/javascripts/ender.js"></script> <script src="{{ root_url }}/javascripts/jquery.min.js"></script>
<script src="{{ root_url }}/javascripts/octopress.js" type="text/javascript"></script> <script src="{{ root_url }}/javascripts/octopress.js" type="text/javascript"></script>
<link href="{{ site.subscribe_rss }}" rel="alternate" title="{{site.title}}" type="application/atom+xml"> <link href="{{ site.subscribe_rss }}" rel="alternate" title="{{site.title}}" type="application/atom+xml">
{% include custom/head.html %} {% include custom/head.html %}

View File

@ -3,22 +3,22 @@ var github = (function(){
var i = 0, fragment = '', t = $(target)[0]; var i = 0, fragment = '', t = $(target)[0];
for(i = 0; i < repos.length; i++) { for(i = 0; i < repos.length; i++) {
fragment += '<li><a href="'+repos[i].url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>'; fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';
} }
t.innerHTML = fragment; t.innerHTML = fragment;
} }
return { return {
showRepos: function(options){ showRepos: function(options){
$.ajax({ $.ajax({
url: "http://github.com/api/v2/json/repos/show/"+options.user+"?callback=?" url: "https://api.github.com/users/"+options.user+"/repos?callback=?"
, type: 'jsonp' , dataType: 'jsonp'
, error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); } , error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); }
, success: function(data) { , success: function(data) {
var repos = []; var repos = [];
if (!data || !data.repositories) { return; } if (!data.data) { return; }
for (var i = 0; i < data.repositories.length; i++) { for (var i = 0; i < data.data.length; i++) {
if (options.skip_forks && data.repositories[i].fork) { continue; } if (options.skip_forks && data.data[i].fork) { continue; }
repos.push(data.repositories[i]); repos.push(data.data[i]);
} }
repos.sort(function(a, b) { repos.sort(function(a, b) {
var aDate = new Date(a.pushed_at).valueOf(), var aDate = new Date(a.pushed_at).valueOf(),

4
source/javascripts/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,14 @@
function getNav() { function getNav() {
var mobileNav = $('nav[role=navigation] ul.main-navigation').before('<fieldset class="mobile-nav"></fieldset>').next().append('<select></select>'); var mainNav = $('ul.main-navigation, ul[role=main-navigation]').before('<fieldset class="mobile-nav">')
mobileNav.children('select').append('<option value="">Navigate&hellip;</option>'); var mobileNav = $('fieldset.mobile-nav').append('<select>');
$('ul[role=main-navigation]').addClass('main-navigation'); mobileNav.find('select').append('<option value="">Navigate&hellip;</option>');
$('ul.main-navigation a').each(function(link) { mainNav.find('a').each(function() {
mobileNav.children('select').append('<option value="'+link.href+'">&raquo; '+link.text+'</option>'); mobileNav.find('select').append('<option value="'+this.href+'">&raquo; '+this.text+'</option>');
}); });
$('ul.subscription a').each(function(link) { $('ul.subscription a').each(function() {
mobileNav.children('select').append('<option value="'+link.href+'">&raquo; '+link.text+'</option>'); mobileNav.find('select').append('<option value="'+this.href+'">&raquo; '+this.text+'</option>');
}); });
mobileNav.children('select').bind('change', function(event) { mobileNav.find('select').bind('change', function(event) {
if (event.target.value) { window.location.href = event.target.value; } if (event.target.value) { window.location.href = event.target.value; }
}); });
} }
@ -25,35 +25,19 @@ function addSidebarToggler() {
} }
}); });
} }
var sections = $('aside.sidebar > section'); var sections = $('.sidebar section');
if (sections.length > 1) { if (sections.length > 1) {
sections.each(function(section, index){ sections.each(function(index){
if ((sections.length >= 3) && index % 3 === 0) { if ((sections.length >= 3) && index % 3 === 0) {
$(section).addClass("first"); $(this).addClass("first");
} }
var count = ((index +1) % 2) ? "odd" : "even"; var count = ((index +1) % 2) ? "odd" : "even";
$(section).addClass(count); $(this).addClass(count);
}); });
} }
if (sections.length >= 3){ $('aside.sidebar').addClass('thirds'); } if (sections.length >= 3){ $('aside.sidebar').addClass('thirds'); }
} }
function testFeatures() {
var features = ['maskImage'];
$(features).map(function(feature) {
if (Modernizr.testAllProps(feature)) {
$('html').addClass(feature);
} else {
$('html').addClass('no-'+feature);
}
});
if ("placeholder" in document.createElement("input")) {
$('html').addClass('placeholder');
} else {
$('html').addClass('no-placeholder');
}
}
function addCodeLineNumbers() { function addCodeLineNumbers() {
if (navigator.appName === 'Microsoft Internet Explorer') { return; } if (navigator.appName === 'Microsoft Internet Explorer') { return; }
$('div.gist-highlight').each(function(code) { $('div.gist-highlight').each(function(code) {
@ -116,8 +100,7 @@ function renderDeliciousLinks(items) {
$('#delicious').html(output); $('#delicious').html(output);
} }
$.domReady(function() { $(document).ready(function() {
testFeatures();
wrapFlashVideos(); wrapFlashVideos();
flashVideoFallback(); flashVideoFallback();
addCodeLineNumbers(); addCodeLineNumbers();

View File

@ -1,56 +1,62 @@
function pinboardNS_fetch_script(url) { var pinboard = (function(){
//document.writeln('<s'+'cript type="text/javascript" src="' + url + '"></s'+'cript>'); function fetch(url) {
(function(){ (function(){
var pinboardLinkroll = document.createElement('script'); var pinboardLinkroll = document.createElement('script');
pinboardLinkroll.type = 'text/javascript'; pinboardLinkroll.type = 'text/javascript';
pinboardLinkroll.async = true; pinboardLinkroll.async = true;
pinboardLinkroll.src = url; pinboardLinkroll.src = url;
document.getElementsByTagName('head')[0].appendChild(pinboardLinkroll); document.getElementsByTagName('head')[0].appendChild(pinboardLinkroll);
})(); })();
}
function pinboardNS_show_bmarks(r) {
var lr = new Pinboard_Linkroll();
lr.set_items(r);
lr.show_bmarks();
}
function Pinboard_Linkroll() {
var items;
this.set_items = function(i) {
this.items = i;
} }
this.show_bmarks = function() {
var lines = [];
for (var i = 0; i < this.items.length; i++) { function linkroll(element) {
var item = this.items[i]; var items;
var str = this.format_item(item);
lines.push(str); this.set_items = function(i) {
this.items = i;
} }
document.getElementById(linkroll).innerHTML = lines.join("\n"); this.show_bmarks = function() {
} var lines = [];
this.cook = function(v) { for (var i = 0; i < this.items.length; i++) {
return v.replace('<', '&lt;').replace('>', '&gt>'); var item = this.items[i];
} var str = this.format_item(item);
lines.push(str);
this.format_item = function(it) {
var str = "<li class=\"pin-item\">";
if (!it.d) { return; }
str += "<p><a class=\"pin-title\" href=\"" + this.cook(it.u) + "\">" + this.cook(it.d) + "</a>";
if (it.n) {
str += "<span class=\"pin-description\">" + this.cook(it.n) + "</span>\n";
}
if (it.t.length > 0) {
for (var i = 0; i < it.t.length; i++) {
var tag = it.t[i];
str += " <a class=\"pin-tag\" href=\"http://pinboard.in/u:"+ this.cook(it.a) + "/t:" + this.cook(tag) + "\">" + this.cook(tag).replace(/^\s+|\s+$/g, '') + "</a> ";
} }
document.getElementById(element).innerHTML = lines.join("\n");
}
this.cook = function(v) {
return v.replace('<', '&lt;').replace('>', '&gt>');
} }
str += "</p></li>\n";
return str;
}
}
Pinboard_Linkroll.prototype = new Pinboard_Linkroll();
pinboardNS_fetch_script("http://feeds.pinboard.in/json/v1/u:"+pinboard_user+"/?cb=pinboardNS_show_bmarks\&count="+pinboard_count);
this.format_item = function(it) {
var str = "<li class=\"pin-item\">";
if (!it.d) { return; }
str += "<p><a class=\"pin-title\" href=\"" + this.cook(it.u) + "\">" + this.cook(it.d) + "</a>";
if (it.n) {
str += "<span class=\"pin-description\">" + this.cook(it.n) + "</span>\n";
}
if (it.t.length > 0) {
for (var i = 0; i < it.t.length; i++) {
var tag = it.t[i];
str += " <a class=\"pin-tag\" href=\"http://pinboard.in/u:"+ this.cook(it.a) + "/t:" + this.cook(tag) + "\">" + this.cook(tag).replace(/^\s+|\s+$/g, '') + "</a> ";
}
}
str += "</p></li>\n";
return str;
}
}
return {
getFeed: function(options) {
this.element = options.target;
fetch("http://feeds.pinboard.in/json/v1/u:"+options.user+"/?cb=pinboard.render\&count="+options.count);
},
render: function(data) {
var lr = new linkroll(this.element);
lr.set_items(data);
lr.show_bmarks();
}
}
})();

View File

@ -2,6 +2,7 @@
// (c) Brandon Mathis // MIT License // (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. */ /* 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) { function prettyDate(time) {
if (navigator.appName === 'Microsoft Internet Explorer') { if (navigator.appName === 'Microsoft Internet Explorer') {
return "<span>&infin;</span>"; // because IE date parsing isn't fun. return "<span>&infin;</span>"; // because IE date parsing isn't fun.
@ -39,40 +40,45 @@ function prettyDate(time) {
day_diff > 7 && Math.ceil(day_diff / 7) + say.weeks_ago; day_diff > 7 && Math.ceil(day_diff / 7) + say.weeks_ago;
} }
function linkifyTweet(text, url) { var twitter = (function(){
// Linkify urls, usernames, hashtags
text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$1$2">$2</a>')
.replace(/(^|\W)@(\w+)/g, '$1<a href="http://twitter.com/$2">@$2</a>')
.replace(/(^|\W)#(\w+)/g, '$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>');
// Use twitter's api to replace t.co shortened urls with expanded ones. function linkifyTweet(text, url) {
for (var u in url) { // Linkify urls, usernames, hashtags
if(url[u].expanded_url != null){ text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$1$2">$2</a>')
var shortUrl = new RegExp(url[u].url, 'g'); .replace(/(^|\W)@(\w+)/g, '$1<a href="http://twitter.com/$2">@$2</a>')
text = text.replace(shortUrl, url[u].expanded_url); .replace(/(^|\W)#(\w+)/g, '$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>');
var shortUrl = new RegExp(">"+(url[u].url.replace(/https?:\/\//, '')), 'g');
text = text.replace(shortUrl, ">"+url[u].display_url); // 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 += '<li>'+'<p>'+'<a href="http://twitter.com/'+twitter_user+'/status/'+tweets[t].id_str+'">'+prettyDate(tweets[t].created_at)+'</a>'+linkifyTweet(tweets[t].text.replace(/\n/g, '<br>'), tweets[t].entities.urls)+'</p>'+'</li>';
}
timeline.innerHTML = content;
}
return {
getFeed: function(options){
count = parseInt(options.count, 10);
$.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); }
});
} }
} }
return text })();
}
function showTwitterFeed(tweets, twitter_user) {
var timeline = document.getElementById('tweets'),
content = '';
for (var t in tweets) {
content += '<li>'+'<p>'+'<a href="http://twitter.com/'+twitter_user+'/status/'+tweets[t].id_str+'">'+prettyDate(tweets[t].created_at)+'</a>'+linkifyTweet(tweets[t].text.replace(/\n/g, '<br>'), tweets[t].entities.urls)+'</p>'+'</li>';
}
timeline.innerHTML = content;
}
function getTwitterFeed(user, count, replies) {
count = parseInt(count, 10);
$.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=?"
, type: 'jsonp'
, error: function (err) { $('#tweets li.loading').addClass('error').text("Twitter's busted"); }
, success: function(data) { showTwitterFeed(data.slice(0, count), user); }
})
}