From 5d9619c81b1ccccf71340aae544a66f62c103f64 Mon Sep 17 00:00:00 2001 From: Daan Debie Date: Fri, 23 Aug 2013 00:44:51 +0200 Subject: Added pelican-bootstrap3 theme --- pelican-bootstrap3/static/js/github.js | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 pelican-bootstrap3/static/js/github.js (limited to 'pelican-bootstrap3/static/js/github.js') diff --git a/pelican-bootstrap3/static/js/github.js b/pelican-bootstrap3/static/js/github.js new file mode 100644 index 0000000..7bdb6a4 --- /dev/null +++ b/pelican-bootstrap3/static/js/github.js @@ -0,0 +1,40 @@ +var github = (function(){ + function escapeHtml(str) { + return $('
').text(str).html(); + } + function render(target, repos){ + var i = 0, fragment = '', t = $(target)[0]; + + for(i = 0; i < repos.length; i++) { + fragment += '
  • '+repos[i].name+'

    '+escapeHtml(repos[i].description||'')+'

  • '; + } + t.innerHTML = fragment; + } + return { + showRepos: function(options){ + $.ajax({ + url: "https://api.github.com/users/"+options.user+"/repos?callback=?" + , dataType: 'jsonp' + , error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); } + , success: function(data) { + var repos = []; + if (!data || !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); + } + }); + } + }; +})(); -- cgit