Permalink
Browse files

new GitHub Widget

  • Loading branch information...
1 parent ec03db4 commit 65056f2fc34289a53afb6e8dbc68ed9a217bd05f @flyerhzm committed Aug 5, 2012
@@ -6,9 +6,10 @@
<meta name="author" content="Richard Huang" />
<meta name="google-site-verification" content="KDVRO6hdZ0Vww31dac2Yomyd7xjmMMFEZw2Fzq5acuY" />
<link rel="stylesheet" type="text/css" href="/stylesheets/screen.css">
+ <link rel="stylesheet" type="text/css" href="/stylesheets/GitHubWidget.css">
<link href="http://feeds.feedburner.com/richard-huang" rel="alternate" title="RSS" type="application/rss+xml" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
- <script type="text/javascript" src="/javascripts/jquery.github_v2.js"></script>
+ <script type="text/javascript" src="/javascripts/GitHubWidget.js"></script>
</head>
<body>
@@ -54,6 +55,9 @@ <h2 class="widget-title">About</h2>
<img src="/images/railsconf2012.png" alt="speaker at railsconf2012" title="to be added">
</a>
</div>
+ <div id="carrington-github" class="widget">
+ <iframe src="http://githubbadge.appspot.com/badge/flyerhzm" style="border: 0;height: 142px;width: 200px;overflow: hidden;" frameBorder=0></iframe>
+ </div>
<div id="primary-sidebar">
<div class="widget">
<h2 class="widget-title">Categories</h2>
View
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Richard Huang - {{ page.title }}</title>
+ <meta name="author" content="Richard Huang" />
+ <meta name="google-site-verification" content="KDVRO6hdZ0Vww31dac2Yomyd7xjmMMFEZw2Fzq5acuY" />
+ <link rel="stylesheet" type="text/css" href="/stylesheets/screen.css">
+ <link rel="stylesheet" type="text/css" href="/stylesheets/GitHubWidget.css">
+ <link href="http://feeds.feedburner.com/richard-huang" rel="alternate" title="RSS" type="application/rss+xml" />
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+ <script type="text/javascript" src="/javascripts/GitHubWidget.js"></script>
+ </head>
+
+ <body>
+ <div id="header" class="section">
+ <div class="wrapper">
+ <strong id="blog-title">
+ <a href="/" rel="home">Richard Huang's Website</a>
+ </strong>
+ <p id="blog-description"></p>
+ <div id="navigation">
+ <ul class="nav clearfix">
+ <li class="first-child"><a href="/blog.html">Blog</a></li>
+ <li><a href="/projects.html">Projects</a></li>
+ <li><a href="/about.html">About</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ <div id="main" class="section">
+ <div class="wrapper">
+ {{ content }}
+ </div>
+ </div>
+ <div id="footer" class="section">
+ <div class="wrapper">
+ <a id="generator-link">
+ Proudly powered by
+ <a href="https://github.com/mojombo/jekyll" rel="generator">Jekyll</a>
+ and
+ <a href="http://carringtontheme.com" title="Carrington theme for WordPress">Carrington</a>
+ </div>
+ <div id="developer-link">
+ </div>
+ </div>
+ <a href="https://github.com/flyerhzm"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
+ <script type="text/javascript">
+ var disqus_shortname = 'richard-huang';
+
+ (function () {
+ var s = document.createElement('script'); s.async = true;
+ s.type = 'text/javascript';
+ s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
+ (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
+ }());
+ </script>
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-8561975-1");
+ pageTracker._trackPageview();
+ } catch(err) {}
+ </script>
+ </body>
+</html>
@@ -0,0 +1,81 @@
+/*
+ GitHubWidget v1.0
+
+ Kelp http://kelp.phate.org/
+ MIT License
+
+*/
+
+var GitHubWidget = GitHubWidget || {
+ init: function () {
+ $('.githubwidget').each(function () {
+ // github account
+ var username = $(this).attr('user');
+ var $panel = $(this);
+ $.ajax({ url: 'https://api.github.com/users/' + username + '/repos?sort=pushed',
+ type: 'get',
+ dataType: 'jsonp',
+ cache: false,
+ async: false,
+ beforeSend: function () { },
+ error: function (xhr) { },
+ success: function (result) {
+ if (result.meta.status == 200) {
+ // jsonp OK
+ result.data = GitHubWidget.Sort(result.data, 'pushed_at');
+ $(result.data).sort(function(a, b) {
+ return a.watchers < b.watchers ? 1 : -1;
+ }).each(function (index) {
+ var date = new Date(this.pushed_at);
+ var dateForm = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
+ this.language = this.language || '';
+ this.homepage = this.homepage || '';
+ var division = $('<div class="repos"></div>');
+ division.append($('<div class="reposname">' +
+ '<span class="mini-icon public-repo"></span> <a href="' + this.html_url + '" target="_blank">' +
+ this.name + '</a>' +
+ '<div class="reposstate">' +
+ this.language +
+ ' &nbsp;<a href="' + this.html_url + '/watchers" target="_blank" title="Watchers"><span class="mini-icon watchers"></span> ' +
+ this.watchers +
+ ' <a href="' + this.html_url + '/network" target="_blank" title="Forks"><span class="mini-icon fork"></span>' +
+ this.forks +
+ '</a>' +
+ '</div>' +
+ '</div>'));
+ division.append($('<div class="reposbody">' +
+ '<a href="' + this.html_url + '/zipball/master" class="minibutton btn-download" title="Download this repository as a zip file" target="_blank">' +
+ '<span class="icon"></span>ZIP' +
+ '</a>' +
+
+ this.description +
+ '<div class="lastupdated">Last updated on ' + dateForm + '</div>' +
+ '<a href="' + this.homepage + '" target="_blank">' + this.homepage + '</a>' +
+ '</div>'));
+ $panel.append(division);
+ });
+ }
+ }
+ });
+ });
+ },
+ Sort: function (array, target) {
+ var result = [];
+
+ while (result.length < array.length) {
+ var pushitem = null;
+ for (var index in array) {
+ if (array[index].__sorted != true && (pushitem == null || pushitem[target] < array[index][target])) {
+ pushitem = array[index];
+ }
+ }
+ pushitem.__sorted = true;
+ result.push(pushitem);
+ }
+ return result;
+ }
+};
+
+$(document).ready(function(){
+ GitHubWidget.init();
+});
View
@@ -1,54 +1,13 @@
---
-layout: default
+layout: simple
title: Projects
---
<h1 class="page-title">Open Source Projects</h1>
-<div id="github-projects">
- <div class="full">
- <h1 class="repo-title"><a href="https://github.com/flyerhzm/bullet">bullet</a></h1>
- <div class="repo-content full-content">A rails plugin/gem to kill N+1 queries and unused eager loading</div>
- <div class="clear"></div>
- </div>
- <div class="rule"><hr></div>
-
- <div class="full">
- <h1 class="repo-title"><a href="https://github.com/flyerhzm/rails_best_practices">rails_best_practices</a></h1>
- <div class="repo-content full-content">a code metric tool for rails projects</div>
- <div class="clear"></div>
- </div>
- <div class="rule"><hr></div>
-
- <div class="full">
- <h1 class="repo-title"><a href="https://github.com/flyerhzm/css_sprite">css_sprite</a></h1>
- <div class="repo-content full-content">automatically css sprite</div>
- <div class="clear"></div>
- </div>
- <div class="rule"><hr></div>
+<div style="float: left; width: 48%;">
+ <div class="githubwidget" user='flyerhzm'></div>
+</div>
+<div style="float: right; width: 48%;">
+ <div class="githubwidget" user='railsbp'></div>
</div>
-
-<script type="text/javascript" charset="utf-8">
- $('#github-projects').html('');
- $.githubUser(['flyerhzm', 'railsbp'], function(data) {
- var repos = data.user.repositories;
- repos.sort(function(a,b) {
- return b.watchers - a.watchers;
- });
-
- $(repos).each(function() {
- $('#github-projects').append("\
-<div class='full'>\
- <p class='repostats-link'>\
- <a class='watchers' href='"+ this.url +"'>"+this.watchers+" watchers</a>\
- <a class='forks' href='"+ this.url +"'>"+this.forks+" forks</a>\
- </p>\
- <h1 class='repo-title'><a href='" + this.url + "'>" + this.name + "</a></h1>\
- <div class='repo-content full-content'>"+this.description+"</div>\
- <div class='clear'></div>\
-</div>\
-<div class='rule'><hr/></div>");
- });
- });
-</script>
-
Oops, something went wrong.

0 comments on commit 65056f2

Please sign in to comment.