From 5fab45d7bf8d6203fed25d1173e97dd0737787cd Mon Sep 17 00:00:00 2001
From: Zeno Rocha
Date: Sun, 13 Jan 2013 22:20:07 -0300
Subject: [PATCH 01/11] moving demo to root
---
{demo/css => css}/style.css | 2 +-
{demo/font => font}/Museo_Slab_500-webfont.eot | Bin
{demo/font => font}/Museo_Slab_500-webfont.svg | 0
{demo/font => font}/Museo_Slab_500-webfont.ttf | Bin
{demo/font => font}/Museo_Slab_500-webfont.woff | Bin
{demo/img => img}/bg-noise.png | Bin
{demo/img => img}/github-cat.png | Bin
{demo/img => img}/github-ribbon.png | Bin
demo/index.html => index.html | 4 ++--
{assets => js/assets}/base.css | 0
{assets => js/assets}/btn-sprite.png | Bin
jquery.github.repos.js => js/jquery.github.repos.js | 0
.../jquery.github.repos.min.js | 0
13 files changed, 3 insertions(+), 3 deletions(-)
rename {demo/css => css}/style.css (95%)
rename {demo/font => font}/Museo_Slab_500-webfont.eot (100%)
rename {demo/font => font}/Museo_Slab_500-webfont.svg (100%)
rename {demo/font => font}/Museo_Slab_500-webfont.ttf (100%)
rename {demo/font => font}/Museo_Slab_500-webfont.woff (100%)
rename {demo/img => img}/bg-noise.png (100%)
rename {demo/img => img}/github-cat.png (100%)
rename {demo/img => img}/github-ribbon.png (100%)
rename demo/index.html => index.html (92%)
rename {assets => js/assets}/base.css (100%)
rename {assets => js/assets}/btn-sprite.png (100%)
rename jquery.github.repos.js => js/jquery.github.repos.js (100%)
rename jquery.github.repos.min.js => js/jquery.github.repos.min.js (100%)
diff --git a/demo/css/style.css b/css/style.css
similarity index 95%
rename from demo/css/style.css
rename to css/style.css
index 8ebc404..d55c9b8 100644
--- a/demo/css/style.css
+++ b/css/style.css
@@ -1,5 +1,5 @@
body {
- background: #Ffffff;
+ background:#F8F8F8 url('../img/noise.png') top left;
}
a {
diff --git a/demo/font/Museo_Slab_500-webfont.eot b/font/Museo_Slab_500-webfont.eot
similarity index 100%
rename from demo/font/Museo_Slab_500-webfont.eot
rename to font/Museo_Slab_500-webfont.eot
diff --git a/demo/font/Museo_Slab_500-webfont.svg b/font/Museo_Slab_500-webfont.svg
similarity index 100%
rename from demo/font/Museo_Slab_500-webfont.svg
rename to font/Museo_Slab_500-webfont.svg
diff --git a/demo/font/Museo_Slab_500-webfont.ttf b/font/Museo_Slab_500-webfont.ttf
similarity index 100%
rename from demo/font/Museo_Slab_500-webfont.ttf
rename to font/Museo_Slab_500-webfont.ttf
diff --git a/demo/font/Museo_Slab_500-webfont.woff b/font/Museo_Slab_500-webfont.woff
similarity index 100%
rename from demo/font/Museo_Slab_500-webfont.woff
rename to font/Museo_Slab_500-webfont.woff
diff --git a/demo/img/bg-noise.png b/img/bg-noise.png
similarity index 100%
rename from demo/img/bg-noise.png
rename to img/bg-noise.png
diff --git a/demo/img/github-cat.png b/img/github-cat.png
similarity index 100%
rename from demo/img/github-cat.png
rename to img/github-cat.png
diff --git a/demo/img/github-ribbon.png b/img/github-ribbon.png
similarity index 100%
rename from demo/img/github-ribbon.png
rename to img/github-ribbon.png
diff --git a/demo/index.html b/index.html
similarity index 92%
rename from demo/index.html
rename to index.html
index 074292c..d2b0712 100644
--- a/demo/index.html
+++ b/index.html
@@ -6,7 +6,7 @@
jQuery Github Repos
-
+
@@ -35,7 +35,7 @@
jQuery Github Repos
-
+
diff --git a/js/jquery.github.repos.js b/js/jquery.github.repos.js
index 7d12194..eec881e 100644
--- a/js/jquery.github.repos.js
+++ b/js/jquery.github.repos.js
@@ -1,8 +1,10 @@
/*
- * Project: jQuery Github Repos
- * Description: A jQuery plugin to display your Github Repositories.
- * Author: Zeno Rocha
- * License: MIT
+ * jQuery Github Repos v0.2.2
+ * A jQuery plugin to display your Github Repositories.
+ * http://git.io/3A1RMg
+ *
+ * Zeno Rocha
+ * MIT License
*/
// the semi-colon before function invocation is a safety net against concatenated
@@ -30,6 +32,7 @@
this.element = element;
this.$container = $(element);
this.repo = this.$container.attr("data-repo");
+ this.cached;
// jQuery has an extend method which merges the contents of two or
// more objects, storing the result in the first object. The first object
@@ -45,42 +48,80 @@
Plugin.prototype.init = function () {
- var self = this;
+ var self = this;
+ var cached;
+
+ // Attempt to get cached repo data
+ if (window.sessionStorage) {
+ cached = sessionStorage.getItem('gh-repos:' + this.repo);
+ }
+
+ if (cached != null) {
+ self.applyTemplate(JSON.parse(cached));
+ }
+ else {
$.ajax({
url: 'https://api.github.com/repos/' + this.repo,
dataType: 'jsonp',
success: function(results){
- var repo = results.data;
- var date = new Date(repo.pushed_at);
- var pushed_at = date.getMonth() + '/' + date.getDate() + '/' + date.getFullYear();
- var $widget = $(' \
-
');g.appendTo(b.$container)}})},a.fn[d]=function(b){return this.each(function(){a.data(this,"plugin_"+d)||a.data(this,"plugin_"+d,new g(this,b))})}})(jQuery,window)
\ No newline at end of file
+(function(a,b){function g(b,c){this.element=b,this.$container=a(b),this.repo=this.$container.attr("data-repo"),this.cached,this.options=a.extend({},f,c),this._defaults=f,this._name=d,this.init()}var d="githubRepos",f=(b.document,{propertyName:"value"});g.prototype.init=function(){var e,d=this;b.sessionStorage&&(e=sessionStorage.getItem("gh-repos:"+this.repo)),null!=e?d.applyTemplate(JSON.parse(e)):a.ajax({url:"https://api.github.com/repos/"+this.repo,dataType:"jsonp",success:function(a){return a.meta.status>=400&&a.data.message?(console.warn(a.data.message),c):(d.applyTemplate(a.data),b.sessionStorage&&sessionStorage.setItem("gh-repos:"+d.repo,JSON.stringify(a.data)),c)}})},g.prototype.applyTemplate=function(b){var c=this,d=new Date(b.pushed_at),e=d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear(),f=a('
'));c.appendTemplate(f)},g.prototype.appendTemplate=function(a){var b=this;a.appendTo(b.$container)},a.fn[d]=function(b){return this.each(function(){a.data(this,"plugin_"+d)||a.data(this,"plugin_"+d,new g(this,b))})}})(jQuery,window);
\ No newline at end of file
+(function(e,t,n){function o(t,n){this.element=t,this.$container=e(t),this.repo=this.$container.attr("data-repo"),this.options=e.extend({},s,n),this._defaults=s,this._name=r,this.init()}var r="github",i=t.document,s={propertyName:"value"};o.prototype.init=function(){var n=this,r;t.sessionStorage&&(r=sessionStorage.getItem("gh-repos:"+this.repo)),r!==null?n.applyTemplate(JSON.parse(r)):e.ajax({url:"https://api.github.com/repos/"+this.repo,dataType:"jsonp",success:function(e){if(e.meta.status>=400&&e.data.message){console.warn(e.data.message);return}n.applyTemplate(e.data),t.sessionStorage&&sessionStorage.setItem("gh-repos:"+n.repo,JSON.stringify(e.data))}})},o.prototype.applyTemplate=function(t){var n=this,r=new Date(t.pushed_at),i=r.getDate()+"/"+(r.getMonth()+1)+"/"+r.getFullYear(),s=e(e.parseHTML('
-
+
diff --git a/js/jquery.github.js b/js/jquery.github.js
index 5f2ea58..a3e88a1 100644
--- a/js/jquery.github.js
+++ b/js/jquery.github.js
@@ -1,136 +1,176 @@
/*
- * jQuery Github - v0.2.5
+ * jquery-github - v0.3.4
* A jQuery plugin to display your Github Repositories.
- * https://github.com/zenorocha/jquery-github/
-
- * Copyright (c) 2013
+ * https://github.com/zenorocha/jquery-github
+ *
+ * Copyright (c) 2014
* MIT License
*/
-
-// the semi-colon before function invocation is a safety net against concatenated
-// scripts and/or other plugins which may not be closed properly.
-;(function ( $, window, undefined ) {
-
- // undefined is used here as the undefined global variable in ECMAScript 3 is
- // mutable (ie. it can be changed by someone else). undefined isn't really being
- // passed in so we can ensure the value of it is truly undefined. In ES5, undefined
- // can no longer be modified.
-
- // window is passed through as local variable rather than global
- // as this (slightly) quickens the resolution process and can be more efficiently
- // minified (especially when both are regularly referenced in your plugin).
-
- // Create the defaults once
- var pluginName = 'github',
- document = window.document,
- defaults = {
- propertyName: "value"
- };
-
- // The actual plugin constructor
- function Plugin( element, options ) {
- this.element = element;
- this.$container = $(element);
- this.repo = this.$container.attr("data-repo");
-
- // jQuery has an extend method which merges the contents of two or
- // more objects, storing the result in the first object. The first object
- // is generally empty as we don't want to alter the default options for
- // future instances of the plugin
- this.options = $.extend( {}, defaults, options) ;
-
- this._defaults = defaults;
- this._name = pluginName;
-
- this.init();
- }
-
- Plugin.prototype.init = function () {
-
- var self = this;
- var cached;
-
- // Attempt to get cached repo data
- if (window.sessionStorage) {
- cached = sessionStorage.getItem('gh-repos:' + this.repo);
- }
-
- if (cached !== null) {
- self.applyTemplate(JSON.parse(cached));
- }
- else {
-
- $.ajax({
- url: 'https://api.github.com/repos/' + this.repo,
- dataType: 'jsonp',
- success: function(results){
-
- // Handle API failures
- if (results.meta.status >= 400 && results.data.message){
- console.warn(results.data.message);
- return;
- }
- else {
-
- self.applyTemplate(results.data);
-
- // Cache data
- if (window.sessionStorage) {
- sessionStorage.setItem('gh-repos:' + self.repo, JSON.stringify(results.data));
- }
-
- }
- }
- });
-
- }
-
- };
-
- Plugin.prototype.applyTemplate = function (repo) {
-
- var self = this;
- var date = new Date(repo.pushed_at);
- var pushed_at = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear();
-
- var $widget = $($.parseHTML(' \
-
'));n.appendTemplate(s)},o.prototype.appendTemplate=function(e){var t=this;e.appendTo(t.$container)},e.fn[r]=function(t){return this.each(function(){e.data(this,"plugin_"+r)||e.data(this,"plugin_"+r,new o(this,t))})}})(jQuery,window);
\ No newline at end of file
+function GithubRepo(a){this.description=a.description,this.forks=a.forks_count,this.name=a.name,this.open_issues=a.open_issues,this.pushed_at=a.pushed_at,this.url=a.url,this.stargazers=a.stargazers_count}function Github(a,b){var c={iconStars:!0,iconForks:!0,iconIssues:!1};this.element=a,this.$container=$(a),this.repo=this.$container.attr("data-repo"),this.options=$.extend({},c,b),this._defaults=c,this.init(),this.displayIcons()}GithubRepo.prototype.toHTML=function(){return this.pushed_at=this._parsePushedDate(this.pushed_at),this.url=this._parseURL(this.url),$("