From e70d1759589a9edfdea4f65b9e83770fe234ca1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Evandro=20Leopoldino=20Gon=C3=A7alves?= Date: Mon, 6 Jan 2014 19:28:32 -0200 Subject: [PATCH 01/31] Update jquery.github.js --- dist/jquery.github.js | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/dist/jquery.github.js b/dist/jquery.github.js index 220967d..adfb1f7 100644 --- a/dist/jquery.github.js +++ b/dist/jquery.github.js @@ -102,24 +102,11 @@ Github.prototype.displayIcons = function () { $iconStars = $( ".repo-stars" ); $iconForks = $( ".repo-forks" ); $iconIssues = $( ".repo-issues" ); + var options = this.options; - if ( this.options.iconStars ) { - $iconStars.css( "display", "inline-block" ); - } else { - $iconStars.css( "display", "none" ); - } - - if ( this.options.iconForks ) { - $iconForks.css( "display", "inline-block" ); - } else { - $iconForks.css( "display", "none" ); - } - - if ( this.options.iconIssues ) { - $iconIssues.css( "display", "inline-block" ); - } else { - $iconIssues.css( "display", "none" ); - } + $iconStars.css( "display", options.iconStars ? "inline-block" : "none" ); + $iconForks.css( "display", options.iconForks ? "inline-block" : "none" ); + $iconIssues.css( "display", options.iconIssues ? "inline-block" : none ); }; // Request repositories from Github From 6496f505eb352547db7214b8ede4ed6f2c998016 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Thu, 9 Jan 2014 19:04:22 -0200 Subject: [PATCH 02/31] Source formatting #29 --- src/jquery.github.js | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/jquery.github.js b/src/jquery.github.js index a63805e..c6b070b 100644 --- a/src/jquery.github.js +++ b/src/jquery.github.js @@ -91,27 +91,14 @@ Github.prototype.init = function () { // Display or hide icons Github.prototype.displayIcons = function () { - $iconStars = $( ".repo-stars" ); - $iconForks = $( ".repo-forks" ); - $iconIssues = $( ".repo-issues" ); - - if ( this.options.iconStars ) { - $iconStars.css( "display", "inline-block" ); - } else { - $iconStars.css( "display", "none" ); - } - - if ( this.options.iconForks ) { - $iconForks.css( "display", "inline-block" ); - } else { - $iconForks.css( "display", "none" ); - } - - if ( this.options.iconIssues ) { - $iconIssues.css( "display", "inline-block" ); - } else { - $iconIssues.css( "display", "none" ); - } + var options = this.options, + $iconStars = $( ".repo-stars" ), + $iconForks = $( ".repo-forks" ), + $iconIssues = $( ".repo-issues" ); + + $iconStars.css( "display", options.iconStars ? "inline-block" : "none" ); + $iconForks.css( "display", options.iconForks ? "inline-block" : "none" ); + $iconIssues.css( "display", options.iconIssues ? "inline-block" : "none" ); }; // Request repositories from Github From 489b47356836096d34ef95635529259de0cd48b2 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Thu, 9 Jan 2014 19:22:11 -0200 Subject: [PATCH 03/31] Add bump/release tasks --- Gruntfile.js | 18 ++++++++++++++++++ package.json | 1 + 2 files changed, 19 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index 9331687..ac19fb3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,6 +3,7 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), + meta: { banner: '/*\n' + ' * <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n' + @@ -13,6 +14,21 @@ module.exports = function(grunt) { ' * MIT License\n' + ' */\n' }, + + bump: { + options: { + files: ['bower.json', 'package.json'], + commit: true, + commitMessage: 'Release v%VERSION%', + commitFiles: ['bower.json', 'package.json'], + createTag: true, + tagName: '%VERSION%', + tagMessage: '', + push: true, + pushTo: 'origin' + } + }, + concat: { options: { banner: '<%= meta.banner %>' @@ -70,6 +86,7 @@ module.exports = function(grunt) { }); + grunt.loadNpmTasks('grunt-bump'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-jasmine'); grunt.loadNpmTasks('grunt-contrib-jshint'); @@ -78,6 +95,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-lintspaces'); grunt.registerTask('default', ['lintspaces', 'jshint', 'concat', 'uglify']); + grunt.registerTask('release', ['bump-only:patch', 'default', 'bump-commit']); grunt.registerTask('test', ['lintspaces', 'jshint', 'jasmine']); }; diff --git a/package.json b/package.json index 8308446..db5dab3 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "devDependencies": { "grunt": "~0.4.1", + "grunt-bump": "~0.0.13", "grunt-cli": "~0.1.7", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-jasmine": "~0.5.1", From 8c94816a500d05f0c8305a9a57ac9cd223c1e205 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Thu, 9 Jan 2014 19:29:51 -0200 Subject: [PATCH 04/31] Regenerate distribution files --- dist/jquery.github.js | 14 +++++++------- dist/jquery.github.min.js | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/jquery.github.js b/dist/jquery.github.js index adfb1f7..d861b3c 100644 --- a/dist/jquery.github.js +++ b/dist/jquery.github.js @@ -1,9 +1,9 @@ /* - * jQuery Github - v0.3.2 + * jQuery Github - v0.3.3 * A jQuery plugin to display your Github Repositories. * https://github.com/zenorocha/jquery-github/ * - * Copyright (c) 2013 + * Copyright (c) 2014 * MIT License */ // -- Github Repository -------------------------------------------------------- @@ -99,14 +99,14 @@ Github.prototype.init = function () { // Display or hide icons Github.prototype.displayIcons = function () { - $iconStars = $( ".repo-stars" ); - $iconForks = $( ".repo-forks" ); - $iconIssues = $( ".repo-issues" ); - var options = this.options; + var options = this.options, + $iconStars = $( ".repo-stars" ), + $iconForks = $( ".repo-forks" ), + $iconIssues = $( ".repo-issues" ); $iconStars.css( "display", options.iconStars ? "inline-block" : "none" ); $iconForks.css( "display", options.iconForks ? "inline-block" : "none" ); - $iconIssues.css( "display", options.iconIssues ? "inline-block" : none ); + $iconIssues.css( "display", options.iconIssues ? "inline-block" : "none" ); }; // Request repositories from Github diff --git a/dist/jquery.github.min.js b/dist/jquery.github.min.js index 87920e9..394d6bd 100644 --- a/dist/jquery.github.min.js +++ b/dist/jquery.github.min.js @@ -1,9 +1,9 @@ /* - * jQuery Github - v0.3.2 + * jQuery Github - v0.3.3 * A jQuery plugin to display your Github Repositories. * https://github.com/zenorocha/jquery-github/ * - * Copyright (c) 2013 + * Copyright (c) 2014 * MIT License */ -function GithubRepo(s){this.description=s.description,this.forks=s.forks,this.name=s.name,this.open_issues=s.open_issues,this.pushed_at=s.pushed_at,this.url=s.url,this.watchers=s.watchers}function Github(s,t){var e=this,o={iconStars:!0,iconForks:!0,iconIssues:!1};e.element=s,e.$container=$(s),e.repo=e.$container.attr("data-repo"),e.options=$.extend({},o,t),e._defaults=o,e.init(),e.displayIcons()}GithubRepo.prototype.toHTML=function(){var s=this;return s.pushed_at=s._parsePushedDate(s.pushed_at),s.url=s._parseURL(s.url),$("
"+"
"+"

"+s.description+" — Read More

"+"
"+"
"+"

Latest commit to master on "+s.pushed_at+"

"+""+"
"+"
")},GithubRepo.prototype._parsePushedDate=function(s){var t=new Date(s);return t.getDate()+"/"+(t.getMonth()+1)+"/"+t.getFullYear()},GithubRepo.prototype._parseURL=function(s){return s.replace("api.","").replace("repos/","")},Github.prototype.init=function(){var s=this,t=s.getCache();null!==t?s.applyTemplate(JSON.parse(t)):s.requestData(s.repo)},Github.prototype.displayIcons=function(){$iconStars=$(".repo-stars"),$iconForks=$(".repo-forks"),$iconIssues=$(".repo-issues"),this.options.iconStars?$iconStars.css("display","inline-block"):$iconStars.css("display","none"),this.options.iconForks?$iconForks.css("display","inline-block"):$iconForks.css("display","none"),this.options.iconIssues?$iconIssues.css("display","inline-block"):$iconIssues.css("display","none")},Github.prototype.requestData=function(s){var t=this;$.ajax({url:"https://api.github.com/repos/"+s,dataType:"jsonp",success:function(s){var e=s.data;s.meta.status>=400&&e.message?t.handleErrorRequest(e):t.handleSuccessfulRequest(e)}})},Github.prototype.handleErrorRequest=function(s){console.warn(s.message)},Github.prototype.handleSuccessfulRequest=function(s){var t=this;t.applyTemplate(s),t.setCache(s)},Github.prototype.setCache=function(s){var t=this;window.sessionStorage&&window.sessionStorage.setItem("gh-repos:"+t.repo,JSON.stringify(s))},Github.prototype.getCache=function(){var s=this;return window.sessionStorage?window.sessionStorage.getItem("gh-repos:"+s.repo):!1},Github.prototype.applyTemplate=function(s){var t=this,e=new GithubRepo(s),o=e.toHTML();o.appendTo(t.$container)},function(s){s.fn.github=function(t){return this.each(function(){s(this).data("plugin_github")||s(this).data("plugin_github",new Github(this,t))})}}(window.jQuery||window.Zepto,window); \ No newline at end of file +function GithubRepo(a){this.description=a.description,this.forks=a.forks,this.name=a.name,this.open_issues=a.open_issues,this.pushed_at=a.pushed_at,this.url=a.url,this.watchers=a.watchers}function Github(a,b){var c=this,d={iconStars:!0,iconForks:!0,iconIssues:!1};c.element=a,c.$container=$(a),c.repo=c.$container.attr("data-repo"),c.options=$.extend({},d,b),c._defaults=d,c.init(),c.displayIcons()}GithubRepo.prototype.toHTML=function(){var a=this;return a.pushed_at=a._parsePushedDate(a.pushed_at),a.url=a._parseURL(a.url),$("

"+a.description+" — Read More

Latest commit to master on "+a.pushed_at+"

")},GithubRepo.prototype._parsePushedDate=function(a){var b=new Date(a);return b.getDate()+"/"+(b.getMonth()+1)+"/"+b.getFullYear()},GithubRepo.prototype._parseURL=function(a){return a.replace("api.","").replace("repos/","")},Github.prototype.init=function(){var a=this,b=a.getCache();null!==b?a.applyTemplate(JSON.parse(b)):a.requestData(a.repo)},Github.prototype.displayIcons=function(){var a=this.options,b=$(".repo-stars"),c=$(".repo-forks"),d=$(".repo-issues");b.css("display",a.iconStars?"inline-block":"none"),c.css("display",a.iconForks?"inline-block":"none"),d.css("display",a.iconIssues?"inline-block":"none")},Github.prototype.requestData=function(a){var b=this;$.ajax({url:"https://api.github.com/repos/"+a,dataType:"jsonp",success:function(a){var c=a.data;a.meta.status>=400&&c.message?b.handleErrorRequest(c):b.handleSuccessfulRequest(c)}})},Github.prototype.handleErrorRequest=function(a){console.warn(a.message)},Github.prototype.handleSuccessfulRequest=function(a){var b=this;b.applyTemplate(a),b.setCache(a)},Github.prototype.setCache=function(a){var b=this;window.sessionStorage&&window.sessionStorage.setItem("gh-repos:"+b.repo,JSON.stringify(a))},Github.prototype.getCache=function(){var a=this;return window.sessionStorage?window.sessionStorage.getItem("gh-repos:"+a.repo):!1},Github.prototype.applyTemplate=function(a){var b=this,c=new GithubRepo(a),d=c.toHTML();d.appendTo(b.$container)},function(a){a.fn.github=function(b){return this.each(function(){a(this).data("plugin_github")||a(this).data("plugin_github",new Github(this,b))})}}(window.jQuery||window.Zepto,window); \ No newline at end of file From 742ca0ad601c17f82bba4997b04259f1e8d3aa26 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Thu, 9 Jan 2014 19:37:02 -0200 Subject: [PATCH 05/31] Browser icon's repository moved to @alrra --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d71da0..a944a38 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ We do care about it. -![IE](https://raw.github.com/paulirish/browser-logos/master/ie/ie_48x48.png) | ![Chrome](https://raw.github.com/paulirish/browser-logos/master/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/paulirish/browser-logos/master/firefox/firefox_48x48.png) | ![Opera](https://raw.github.com/paulirish/browser-logos/master/opera/opera_48x48.png) | ![Safari](https://raw.github.com/paulirish/browser-logos/master/safari/safari_48x48.png) +![IE](https://raw.github.com/alrra/browser-logos/master/internet-explorer/internet-explorer_48x48.png) | ![Chrome](https://raw.github.com/alrra/browser-logos/master/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/firefox/firefox_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/opera/opera_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/safari/safari_48x48.png) --- | --- | --- | --- | --- | IE 8+ ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | From 8cf9370cd0282a4c4c754c469ad3edcfbfb19adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Evandro=20Leopoldino=20Gon=C3=A7alves?= Date: Thu, 9 Jan 2014 23:52:55 -0200 Subject: [PATCH 06/31] Refactoring the code --- src/jquery.github.js | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/src/jquery.github.js b/src/jquery.github.js index c6b070b..516bfc5 100644 --- a/src/jquery.github.js +++ b/src/jquery.github.js @@ -83,10 +83,10 @@ Github.prototype.init = function () { if ( cached !== null ) { self.applyTemplate( JSON.parse( cached ) ); + return; } - else { - self.requestData( self.repo ); - } + + self.requestData( self.repo ); }; // Display or hide icons @@ -109,51 +109,43 @@ Github.prototype.requestData = function ( repo ) { url: "https://api.github.com/repos/" + repo, dataType: "jsonp", success: function( results ) { - var result_data = results.data; - - // Handle API failures - if ( results.meta.status >= 400 && result_data.message ) { + var result_data = results.data, + isFailling = results.meta.status >= 400 && result_data.message; + + if ( isFailling ) { self.handleErrorRequest( result_data ); + return; } - else { - self.handleSuccessfulRequest( result_data ); - } + + self.handleSuccessfulRequest( result_data ); } }); }; // Handle Errors requests Github.prototype.handleErrorRequest = function ( result_data ) { - var self = this; - console.warn( result_data.message ); return; }; // Handle Successful request Github.prototype.handleSuccessfulRequest = function ( result_data ) { - var self = this; - - self.applyTemplate( result_data ); - self.setCache( result_data ); + this.applyTemplate( result_data ); + this.setCache( result_data ); }; // Stores repostories in sessionStorage if available Github.prototype.setCache = function ( result_data ) { - var self = this; - // Cache data if ( window.sessionStorage ) { - window.sessionStorage.setItem( "gh-repos:" + self.repo, JSON.stringify( result_data ) ); + window.sessionStorage.setItem( "gh-repos:" + this.repo, JSON.stringify( result_data ) ); } }; // Grab cached results Github.prototype.getCache = function() { - var self = this; - if ( window.sessionStorage ) { - return window.sessionStorage.getItem( "gh-repos:" + self.repo ); + return window.sessionStorage.getItem( "gh-repos:" + this.repo ); } else { return false; @@ -162,11 +154,10 @@ Github.prototype.getCache = function() { // Apply results to HTML template Github.prototype.applyTemplate = function ( repo ) { - var self = this, - githubRepo = new GithubRepo( repo ), - $widget = githubRepo.toHTML(); + var githubRepo = new GithubRepo( repo ), + $widget = githubRepo.toHTML(); - $widget.appendTo( self.$container ); + $widget.appendTo( this.$container ); }; // -- Attach plugin to jQuery's prototype -------------------------------------- From c947cc0d02e81893ea8c81134f228a9141051c3a Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Sat, 25 Jan 2014 13:59:05 -0300 Subject: [PATCH 07/31] Source formatting #30 --- src/jquery.github.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jquery.github.js b/src/jquery.github.js index 516bfc5..7e1fffa 100644 --- a/src/jquery.github.js +++ b/src/jquery.github.js @@ -85,7 +85,7 @@ Github.prototype.init = function () { self.applyTemplate( JSON.parse( cached ) ); return; } - + self.requestData( self.repo ); }; @@ -110,13 +110,13 @@ Github.prototype.requestData = function ( repo ) { dataType: "jsonp", success: function( results ) { var result_data = results.data, - isFailling = results.meta.status >= 400 && result_data.message; - + isFailling = results.meta.status >= 400 && result_data.message; + if ( isFailling ) { self.handleErrorRequest( result_data ); return; } - + self.handleSuccessfulRequest( result_data ); } }); @@ -155,7 +155,7 @@ Github.prototype.getCache = function() { // Apply results to HTML template Github.prototype.applyTemplate = function ( repo ) { var githubRepo = new GithubRepo( repo ), - $widget = githubRepo.toHTML(); + $widget = githubRepo.toHTML(); $widget.appendTo( this.$container ); }; From a876dfcefd40c31a282538243c0c6e63e38b423a Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Sat, 25 Jan 2014 14:18:40 -0300 Subject: [PATCH 08/31] Removing unnecessary reference to the original `this` --- src/jquery.github.js | 55 +++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/src/jquery.github.js b/src/jquery.github.js index 7e1fffa..03f8e97 100644 --- a/src/jquery.github.js +++ b/src/jquery.github.js @@ -12,81 +12,74 @@ function GithubRepo( repo ) { // Parses HTML template GithubRepo.prototype.toHTML = function () { - var self = this; - - self.pushed_at = self._parsePushedDate( self.pushed_at ), - self.url = self._parseURL( self.url ); + this.pushed_at = this._parsePushedDate( this.pushed_at ), + this.url = this._parseURL( this.url ); return $( "
" + "" + "
" + - "

" + self.description + " — Read More

" + + "

" + this.description + " — Read More

" + "
" + "
" + - "

Latest commit to master on " + self.pushed_at + "

" + - "" + + "

Latest commit to master on " + this.pushed_at + "

" + + "" + "
" + "
"); }; // Parses pushed_at with date format GithubRepo.prototype._parsePushedDate = function ( pushed_at ) { - var self = this, - date = new Date( pushed_at ); + var date = new Date( pushed_at ); return date.getDate() + "/" + ( date.getMonth() + 1 ) + "/" + date.getFullYear(); }; // Parses URL to be friendly GithubRepo.prototype._parseURL = function ( url ) { - var self = this; - return url.replace( "api.", "" ).replace( "repos/", "" ); }; // -- Github Plugin ------------------------------------------------------------ function Github( element, options ) { - var self = this, - defaults = { + var defaults = { iconStars: true, iconForks: true, iconIssues: false }; - self.element = element; - self.$container = $( element ); - self.repo = self.$container.attr( "data-repo" ); + this.element = element; + this.$container = $( element ); + this.repo = this.$container.attr( "data-repo" ); - self.options = $.extend( {}, defaults, options ) ; + this.options = $.extend( {}, defaults, options ) ; - self._defaults = defaults; + this._defaults = defaults; - self.init(); - self.displayIcons(); + this.init(); + this.displayIcons(); } // Initializer Github.prototype.init = function () { - var self = this, - cached = self.getCache(); + var cached = this.getCache(); if ( cached !== null ) { - self.applyTemplate( JSON.parse( cached ) ); + this.applyTemplate( JSON.parse( cached ) ); return; } - self.requestData( self.repo ); + this.requestData( this.repo ); }; // Display or hide icons @@ -103,7 +96,7 @@ Github.prototype.displayIcons = function () { // Request repositories from Github Github.prototype.requestData = function ( repo ) { - var self = this; + var that = this; $.ajax({ url: "https://api.github.com/repos/" + repo, @@ -113,11 +106,11 @@ Github.prototype.requestData = function ( repo ) { isFailling = results.meta.status >= 400 && result_data.message; if ( isFailling ) { - self.handleErrorRequest( result_data ); + that.handleErrorRequest( result_data ); return; } - self.handleSuccessfulRequest( result_data ); + that.handleSuccessfulRequest( result_data ); } }); }; From f09d5e19420c82cfb2e4e61d4ebd23e80b9263e2 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Thu, 3 Apr 2014 14:33:28 -0300 Subject: [PATCH 09/31] Use SVG badge for Travis + Add SVG badge for Bower --- README.md | 2 +- dist/jquery.github.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a944a38..2d95733 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# jQuery Github [![Build Status](https://secure.travis-ci.org/zenorocha/jquery-github.png?branch=master)](https://travis-ci.org/zenorocha/jquery-github) +# jQuery Github [![Build Status](https://secure.travis-ci.org/zenorocha/jquery-github.svg?branch=master)](https://travis-ci.org/zenorocha/jquery-github) ![Bower Version](https://badge.fury.io/bo/jquery-github.svg) [![Github Repo Demonstration](http://f.cl.ly/items/2I3u29002A1g2w1R1I0X/Screen%20Shot%202013-01-17%20at%202.16.36%20PM.png)](http://zenorocha.github.com/jquery-github/) diff --git a/dist/jquery.github.js b/dist/jquery.github.js index d861b3c..08bffce 100644 --- a/dist/jquery.github.js +++ b/dist/jquery.github.js @@ -1,5 +1,5 @@ /* - * jQuery Github - v0.3.3 + * jQuery Github - v0.3.2 * A jQuery plugin to display your Github Repositories. * https://github.com/zenorocha/jquery-github/ * From 0f92c44825a2935d585dc1c404d5327d98f65cbd Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Sat, 19 Apr 2014 18:33:26 -0300 Subject: [PATCH 10/31] Display options in table format --- README.md | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 2d95733..cf57e8a 100644 --- a/README.md +++ b/README.md @@ -73,23 +73,11 @@ $("[data-repo]").github({ }); ``` -#### iconStars - -*Type: `Boolean` Default: `true`* - -Display the number of stars in a repository. - -#### iconForks - -*Type: `Boolean` Default: `true`* - -Display the number of forks in a repository. - -#### iconIssues - -*Type: `Boolean` Default: `false`* - -Display the number of issues in a repository. +Attribute | Type | Default | Description +--- | --- | --- | --- +`iconStars` | *Boolean* | `true` | Displays the number of stars in a repository. +`iconForks` | *Boolean* | `true` | Displays the number of forks in a repository. +`iconIssues` | *Boolean* | `false` | Displays the number of issues in a repository. ## Structure @@ -203,7 +191,7 @@ Check [CONTRIBUTING.md](https://github.com/zenorocha/jquery-github/blob/master/C ## History -Check [Release](https://github.com/zenorocha/jquery-github/releases) list. +Check [Releases](https://github.com/zenorocha/jquery-github/releases) for detailed changelog. ## Credits From ccf923d2fc8625c58a8e5ead426b690e68196bf8 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Sat, 19 Apr 2014 18:33:38 -0300 Subject: [PATCH 11/31] Clean up package.json --- package.json | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/package.json b/package.json index db5dab3..6915421 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,5 @@ { - "name": "jquery-github", - "title": "jQuery Github", - "description": "A jQuery plugin to display your Github Repositories.", - "author": "Zeno Rocha", - "homepage": "https://github.com/zenorocha/jquery-github/", - "version": "0.3.3", - "repository": { - "type": "git", - "url": "https://github.com/zenorocha/jquery-github.git" - }, + "private": true, "devDependencies": { "grunt": "~0.4.1", "grunt-bump": "~0.0.13", From 8700b43c3ff3709a49b6092e5c5c3bc7e392e638 Mon Sep 17 00:00:00 2001 From: niuzhist Date: Thu, 22 May 2014 16:52:59 -0700 Subject: [PATCH 12/31] fix api --- src/jquery.github.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jquery.github.js b/src/jquery.github.js index 03f8e97..1fadfa9 100644 --- a/src/jquery.github.js +++ b/src/jquery.github.js @@ -2,12 +2,12 @@ function GithubRepo( repo ) { this.description = repo.description; - this.forks = repo.forks; + this.forks = repo.forks_count; this.name = repo.name; this.open_issues = repo.open_issues; this.pushed_at = repo.pushed_at; this.url = repo.url; - this.watchers = repo.watchers; + this.stargazers = repo.stargazers_count; } // Parses HTML template @@ -22,7 +22,7 @@ GithubRepo.prototype.toHTML = function () { "" + this.name + "" + "" + "" + From 351903bc17d0939fb3b350ec3e158d91340ad492 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Mon, 2 Jun 2014 23:25:51 -0300 Subject: [PATCH 13/31] Rename "watchers" to "stargazers" in the spec --- spec/jquery.github.repo-spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/jquery.github.repo-spec.js b/spec/jquery.github.repo-spec.js index afbb34e..0169e4e 100644 --- a/spec/jquery.github.repo-spec.js +++ b/spec/jquery.github.repo-spec.js @@ -9,7 +9,7 @@ describe("jquery.github.repo", function() { forks: 33, pushed_at: "2013-07-02T12:08:36Z", url: "https://api.github.com/repos/zenorocha/jquery-github", - watchers: 131 + stargazers: 131 }); }); @@ -39,8 +39,8 @@ describe("jquery.github.repo", function() { .toEqual("https://api.github.com/repos/zenorocha/jquery-github"); }); - it("should be repository's number of watchers", function() { - expect(instance.watchers) + it("should be repository's number of stargazers", function() { + expect(instance.stargazers) .toEqual(131); }); }); From e0900e9514fdeba3b1588322d9c45bff5ebb6ac1 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Mon, 2 Jun 2014 23:27:02 -0300 Subject: [PATCH 14/31] Fetch banner data from bower.json instead of package.json --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index ac19fb3..b5786a7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,7 +2,7 @@ module.exports = function(grunt) { grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), + pkg: grunt.file.readJSON('bower.json'), meta: { banner: '/*\n' + From c457a2eb83854e2e058d2e1f8b9d20bbc87af7bc Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Mon, 2 Jun 2014 23:28:13 -0300 Subject: [PATCH 15/31] Remove package.json bumping --- Gruntfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index b5786a7..e949a61 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -17,10 +17,10 @@ module.exports = function(grunt) { bump: { options: { - files: ['bower.json', 'package.json'], + files: ['bower.json'], commit: true, commitMessage: 'Release v%VERSION%', - commitFiles: ['bower.json', 'package.json'], + commitFiles: ['bower.json'], createTag: true, tagName: '%VERSION%', tagMessage: '', From 93f0fd96a952469f25d255089bd6cf59145372a9 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Mon, 2 Jun 2014 23:29:00 -0300 Subject: [PATCH 16/31] Release v0.3.4 --- bower.json | 2 +- dist/jquery.github.js | 100 ++++++++++++++++---------------------- dist/jquery.github.min.js | 6 +-- 3 files changed, 46 insertions(+), 62 deletions(-) diff --git a/bower.json b/bower.json index 874fcca..3ca05f1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-github", - "version": "0.3.3", + "version": "0.3.4", "homepage": "https://github.com/zenorocha/jquery-github", "authors": [ "Zeno Rocha " diff --git a/dist/jquery.github.js b/dist/jquery.github.js index 08bffce..a3e88a1 100644 --- a/dist/jquery.github.js +++ b/dist/jquery.github.js @@ -1,7 +1,7 @@ /* - * jQuery Github - v0.3.2 + * jquery-github - v0.3.4 * A jQuery plugin to display your Github Repositories. - * https://github.com/zenorocha/jquery-github/ + * https://github.com/zenorocha/jquery-github * * Copyright (c) 2014 * MIT License @@ -10,91 +10,84 @@ function GithubRepo( repo ) { this.description = repo.description; - this.forks = repo.forks; + this.forks = repo.forks_count; this.name = repo.name; this.open_issues = repo.open_issues; this.pushed_at = repo.pushed_at; this.url = repo.url; - this.watchers = repo.watchers; + this.stargazers = repo.stargazers_count; } // Parses HTML template GithubRepo.prototype.toHTML = function () { - var self = this; - - self.pushed_at = self._parsePushedDate( self.pushed_at ), - self.url = self._parseURL( self.url ); + this.pushed_at = this._parsePushedDate( this.pushed_at ), + this.url = this._parseURL( this.url ); return $( "
" + "" + "
" + - "

" + self.description + " — Read More

" + + "

" + this.description + " — Read More

" + "
" + "
" + - "

Latest commit to master on " + self.pushed_at + "

" + - "" + + "

Latest commit to master on " + this.pushed_at + "

" + + "" + "
" + "
"); }; // Parses pushed_at with date format GithubRepo.prototype._parsePushedDate = function ( pushed_at ) { - var self = this, - date = new Date( pushed_at ); + var date = new Date( pushed_at ); return date.getDate() + "/" + ( date.getMonth() + 1 ) + "/" + date.getFullYear(); }; // Parses URL to be friendly GithubRepo.prototype._parseURL = function ( url ) { - var self = this; - return url.replace( "api.", "" ).replace( "repos/", "" ); }; // -- Github Plugin ------------------------------------------------------------ function Github( element, options ) { - var self = this, - defaults = { + var defaults = { iconStars: true, iconForks: true, iconIssues: false }; - self.element = element; - self.$container = $( element ); - self.repo = self.$container.attr( "data-repo" ); + this.element = element; + this.$container = $( element ); + this.repo = this.$container.attr( "data-repo" ); - self.options = $.extend( {}, defaults, options ) ; + this.options = $.extend( {}, defaults, options ) ; - self._defaults = defaults; + this._defaults = defaults; - self.init(); - self.displayIcons(); + this.init(); + this.displayIcons(); } // Initializer Github.prototype.init = function () { - var self = this, - cached = self.getCache(); + var cached = this.getCache(); if ( cached !== null ) { - self.applyTemplate( JSON.parse( cached ) ); - } - else { - self.requestData( self.repo ); + this.applyTemplate( JSON.parse( cached ) ); + return; } + + this.requestData( this.repo ); }; // Display or hide icons @@ -111,57 +104,49 @@ Github.prototype.displayIcons = function () { // Request repositories from Github Github.prototype.requestData = function ( repo ) { - var self = this; + var that = this; $.ajax({ url: "https://api.github.com/repos/" + repo, dataType: "jsonp", success: function( results ) { - var result_data = results.data; + var result_data = results.data, + isFailling = results.meta.status >= 400 && result_data.message; - // Handle API failures - if ( results.meta.status >= 400 && result_data.message ) { - self.handleErrorRequest( result_data ); - } - else { - self.handleSuccessfulRequest( result_data ); + if ( isFailling ) { + that.handleErrorRequest( result_data ); + return; } + + that.handleSuccessfulRequest( result_data ); } }); }; // Handle Errors requests Github.prototype.handleErrorRequest = function ( result_data ) { - var self = this; - console.warn( result_data.message ); return; }; // Handle Successful request Github.prototype.handleSuccessfulRequest = function ( result_data ) { - var self = this; - - self.applyTemplate( result_data ); - self.setCache( result_data ); + this.applyTemplate( result_data ); + this.setCache( result_data ); }; // Stores repostories in sessionStorage if available Github.prototype.setCache = function ( result_data ) { - var self = this; - // Cache data if ( window.sessionStorage ) { - window.sessionStorage.setItem( "gh-repos:" + self.repo, JSON.stringify( result_data ) ); + window.sessionStorage.setItem( "gh-repos:" + this.repo, JSON.stringify( result_data ) ); } }; // Grab cached results Github.prototype.getCache = function() { - var self = this; - if ( window.sessionStorage ) { - return window.sessionStorage.getItem( "gh-repos:" + self.repo ); + return window.sessionStorage.getItem( "gh-repos:" + this.repo ); } else { return false; @@ -170,11 +155,10 @@ Github.prototype.getCache = function() { // Apply results to HTML template Github.prototype.applyTemplate = function ( repo ) { - var self = this, - githubRepo = new GithubRepo( repo ), - $widget = githubRepo.toHTML(); + var githubRepo = new GithubRepo( repo ), + $widget = githubRepo.toHTML(); - $widget.appendTo( self.$container ); + $widget.appendTo( this.$container ); }; // -- Attach plugin to jQuery's prototype -------------------------------------- diff --git a/dist/jquery.github.min.js b/dist/jquery.github.min.js index 394d6bd..5a9707a 100644 --- a/dist/jquery.github.min.js +++ b/dist/jquery.github.min.js @@ -1,9 +1,9 @@ /* - * jQuery Github - v0.3.3 + * jquery-github - v0.3.4 * A jQuery plugin to display your Github Repositories. - * https://github.com/zenorocha/jquery-github/ + * https://github.com/zenorocha/jquery-github * * Copyright (c) 2014 * MIT License */ -function GithubRepo(a){this.description=a.description,this.forks=a.forks,this.name=a.name,this.open_issues=a.open_issues,this.pushed_at=a.pushed_at,this.url=a.url,this.watchers=a.watchers}function Github(a,b){var c=this,d={iconStars:!0,iconForks:!0,iconIssues:!1};c.element=a,c.$container=$(a),c.repo=c.$container.attr("data-repo"),c.options=$.extend({},d,b),c._defaults=d,c.init(),c.displayIcons()}GithubRepo.prototype.toHTML=function(){var a=this;return a.pushed_at=a._parsePushedDate(a.pushed_at),a.url=a._parseURL(a.url),$("

"+a.description+" — Read More

Latest commit to master on "+a.pushed_at+"

")},GithubRepo.prototype._parsePushedDate=function(a){var b=new Date(a);return b.getDate()+"/"+(b.getMonth()+1)+"/"+b.getFullYear()},GithubRepo.prototype._parseURL=function(a){return a.replace("api.","").replace("repos/","")},Github.prototype.init=function(){var a=this,b=a.getCache();null!==b?a.applyTemplate(JSON.parse(b)):a.requestData(a.repo)},Github.prototype.displayIcons=function(){var a=this.options,b=$(".repo-stars"),c=$(".repo-forks"),d=$(".repo-issues");b.css("display",a.iconStars?"inline-block":"none"),c.css("display",a.iconForks?"inline-block":"none"),d.css("display",a.iconIssues?"inline-block":"none")},Github.prototype.requestData=function(a){var b=this;$.ajax({url:"https://api.github.com/repos/"+a,dataType:"jsonp",success:function(a){var c=a.data;a.meta.status>=400&&c.message?b.handleErrorRequest(c):b.handleSuccessfulRequest(c)}})},Github.prototype.handleErrorRequest=function(a){console.warn(a.message)},Github.prototype.handleSuccessfulRequest=function(a){var b=this;b.applyTemplate(a),b.setCache(a)},Github.prototype.setCache=function(a){var b=this;window.sessionStorage&&window.sessionStorage.setItem("gh-repos:"+b.repo,JSON.stringify(a))},Github.prototype.getCache=function(){var a=this;return window.sessionStorage?window.sessionStorage.getItem("gh-repos:"+a.repo):!1},Github.prototype.applyTemplate=function(a){var b=this,c=new GithubRepo(a),d=c.toHTML();d.appendTo(b.$container)},function(a){a.fn.github=function(b){return this.each(function(){a(this).data("plugin_github")||a(this).data("plugin_github",new Github(this,b))})}}(window.jQuery||window.Zepto,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),$("

"+this.description+" — Read More

Latest commit to master on "+this.pushed_at+"

")},GithubRepo.prototype._parsePushedDate=function(a){var b=new Date(a);return b.getDate()+"/"+(b.getMonth()+1)+"/"+b.getFullYear()},GithubRepo.prototype._parseURL=function(a){return a.replace("api.","").replace("repos/","")},Github.prototype.init=function(){var a=this.getCache();return null!==a?(this.applyTemplate(JSON.parse(a)),void 0):(this.requestData(this.repo),void 0)},Github.prototype.displayIcons=function(){var a=this.options,b=$(".repo-stars"),c=$(".repo-forks"),d=$(".repo-issues");b.css("display",a.iconStars?"inline-block":"none"),c.css("display",a.iconForks?"inline-block":"none"),d.css("display",a.iconIssues?"inline-block":"none")},Github.prototype.requestData=function(a){var b=this;$.ajax({url:"https://api.github.com/repos/"+a,dataType:"jsonp",success:function(a){var c=a.data,d=a.meta.status>=400&&c.message;return d?(b.handleErrorRequest(c),void 0):(b.handleSuccessfulRequest(c),void 0)}})},Github.prototype.handleErrorRequest=function(a){console.warn(a.message)},Github.prototype.handleSuccessfulRequest=function(a){this.applyTemplate(a),this.setCache(a)},Github.prototype.setCache=function(a){window.sessionStorage&&window.sessionStorage.setItem("gh-repos:"+this.repo,JSON.stringify(a))},Github.prototype.getCache=function(){return window.sessionStorage?window.sessionStorage.getItem("gh-repos:"+this.repo):!1},Github.prototype.applyTemplate=function(a){var b=new GithubRepo(a),c=b.toHTML();c.appendTo(this.$container)},function(a){a.fn.github=function(b){return this.each(function(){a(this).data("plugin_github")||a(this).data("plugin_github",new Github(this,b))})}}(window.jQuery||window.Zepto,window); \ No newline at end of file From 80aed2d6135db0205449f9687136e555f257e6f2 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Wed, 9 Jul 2014 14:33:17 -0300 Subject: [PATCH 17/31] Upload images to GitHub In order to avoid broken URLs in the future --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cf57e8a..96b6028 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # jQuery Github [![Build Status](https://secure.travis-ci.org/zenorocha/jquery-github.svg?branch=master)](https://travis-ci.org/zenorocha/jquery-github) ![Bower Version](https://badge.fury.io/bo/jquery-github.svg) -[![Github Repo Demonstration](http://f.cl.ly/items/2I3u29002A1g2w1R1I0X/Screen%20Shot%202013-01-17%20at%202.16.36%20PM.png)](http://zenorocha.github.com/jquery-github/) +[![Github Repo Demonstration](https://cloud.githubusercontent.com/assets/398893/3528396/064b1fa4-078f-11e4-8460-2593d190c2fc.png)](http://zenorocha.github.io/jquery-github/) > A jQuery plugin to display your Github Repositories. @@ -8,7 +8,7 @@ We do care about it. -![IE](https://raw.github.com/alrra/browser-logos/master/internet-explorer/internet-explorer_48x48.png) | ![Chrome](https://raw.github.com/alrra/browser-logos/master/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/firefox/firefox_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/opera/opera_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/safari/safari_48x48.png) +![IE](https://cloud.githubusercontent.com/assets/398893/3528325/20373e76-078e-11e4-8e3a-1cb86cf506f0.png) | ![Chrome](https://cloud.githubusercontent.com/assets/398893/3528328/23bc7bc4-078e-11e4-8752-ba2809bf5cce.png) | ![Firefox](https://cloud.githubusercontent.com/assets/398893/3528329/26283ab0-078e-11e4-84d4-db2cf1009953.png) | ![Opera](https://cloud.githubusercontent.com/assets/398893/3528330/27ec9fa8-078e-11e4-95cb-709fd11dac16.png) | ![Safari](https://cloud.githubusercontent.com/assets/398893/3528331/29df8618-078e-11e4-8e3e-ed8ac738693f.png) --- | --- | --- | --- | --- | IE 8+ ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | From c170d82e78155984ef157126587f4af48925018b Mon Sep 17 00:00:00 2001 From: Lucas Constantino Silva Date: Sat, 20 Sep 2014 04:58:57 -0300 Subject: [PATCH 18/31] Fixed example repository reference --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 96b6028..4bf3430 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Now you're ready to go! Create an attribute called `data-repo`: ```html -
+
``` Include jQuery: From 490eda449576afd9b2c7c7e76b7fa2bc08c6e813 Mon Sep 17 00:00:00 2001 From: Lucas Constantino Date: Sat, 20 Sep 2014 20:49:39 -0300 Subject: [PATCH 19/31] Fixed bower command. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4bf3430..11340f2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Three quick start options are available: * [Download latest release](https://github.com/zenorocha/jquery-github/releases) * Clone the repo: `git@github.com:zenorocha/jquery-github.git` -* Install with [Bower](http://bower.io): `bower install bootstrap` +* Install with [Bower](http://bower.io): `bower install jquery-github` ## Setup From f795fd9ee97fd47061b2d38d4808921aa95f70fd Mon Sep 17 00:00:00 2001 From: Lucas Constantino Date: Sat, 20 Sep 2014 20:58:09 -0300 Subject: [PATCH 20/31] Add AngularJS alternative, made by Lucas. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 96b6028..2581fd3 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,10 @@ No problem, [@ricardobeat](https://github.com/ricardobeat) already did one. Chec No problem, [@igorlima](https://github.com/igorlima) already did that. Check [demo/index-zepto.html](https://github.com/zenorocha/jquery-github/tree/master/demo/index-zepto.html). +**Prefer AngularJS instead of jQuery?** + +No problem, [@lucasconstantino](https://github.com/lucasconstantino) already did that. Check [his fork](https://github.com/lucasconstantino/angular-github-repo)! + ## Contributing Check [CONTRIBUTING.md](https://github.com/zenorocha/jquery-github/blob/master/CONTRIBUTING.md). From 769c5a9324c76c36ef87cb8c1ecc1900543edfe7 Mon Sep 17 00:00:00 2001 From: Randson Oliveira Date: Wed, 22 Oct 2014 09:54:36 -0400 Subject: [PATCH 21/31] Update command to install bower --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 96b6028..19f972b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Three quick start options are available: * [Download latest release](https://github.com/zenorocha/jquery-github/releases) * Clone the repo: `git@github.com:zenorocha/jquery-github.git` -* Install with [Bower](http://bower.io): `bower install bootstrap` +* Install with [Bower](http://bower.io): `bower install jquery-github` ## Setup From 5da701c9a2ca142db5075cb5c51021f2c75ad604 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Tue, 4 Nov 2014 12:46:47 +0100 Subject: [PATCH 22/31] Include badges #33 --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60608e2..4e06be5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# jQuery Github [![Build Status](https://secure.travis-ci.org/zenorocha/jquery-github.svg?branch=master)](https://travis-ci.org/zenorocha/jquery-github) ![Bower Version](https://badge.fury.io/bo/jquery-github.svg) +# jQuery Github + +[![Bower version](http://img.shields.io/bower/v/jquery-github.svg?style=flat)](http://bower.io/search/?q=jquery-github) +[![Build Status](http://img.shields.io/travis/zenorocha/jquery-github/master.svg?style=flat)](https://travis-ci.org/zenorocha/jquery-github) +[![DevDependencies Status](http://img.shields.io/david/dev/zenorocha/jquery-github.svg?style=flat)](https://david-dm.org/zenorocha/jquery-github#info=devDependencies) [![Github Repo Demonstration](https://cloud.githubusercontent.com/assets/398893/3528396/064b1fa4-078f-11e4-8460-2593d190c2fc.png)](http://zenorocha.github.io/jquery-github/) From 5099dc41f8931aed3163f6758434895020ba75cb Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Tue, 4 Nov 2014 12:48:03 +0100 Subject: [PATCH 23/31] Update NodeJS version to be used on Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index baa0031..20fd86b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ language: node_js node_js: - - 0.8 + - 0.10 From 5930d8d59c6d5d1ce66ab6f02ce41b6c155ea4a7 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Tue, 4 Nov 2014 13:04:00 +0100 Subject: [PATCH 24/31] Update devDependencies #33 --- Gruntfile.js | 2 +- package.json | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index e949a61..558241f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -42,7 +42,7 @@ module.exports = function(grunt) { lintspaces: { all: { src: [ - '*', 'src/*', 'spec/*', 'demo/*', 'assets/base.css' + '*', 'src/*', 'spec/*', 'demo/*', 'assets/base.css', '!package.json' ], options: { newline: true, diff --git a/package.json b/package.json index 6915421..84bf932 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,17 @@ { - "private": true, - "devDependencies": { - "grunt": "~0.4.1", - "grunt-bump": "~0.0.13", - "grunt-cli": "~0.1.7", - "grunt-contrib-concat": "~0.3.0", - "grunt-contrib-jasmine": "~0.5.1", - "grunt-contrib-jshint": "~0.7.2", - "grunt-contrib-uglify": "~0.2.0", - "grunt-contrib-watch": "~0.5.3", - "grunt-lintspaces": "~0.2.301" - }, - "scripts": { - "test": "grunt test --verbose" - } + "private": true, + "devDependencies": { + "grunt": "~0.4.1", + "grunt-bump": "~0.0.13", + "grunt-cli": "~0.1.7", + "grunt-contrib-concat": "~0.5.0", + "grunt-contrib-jasmine": "~0.8.1", + "grunt-contrib-jshint": "~0.10.0", + "grunt-contrib-uglify": "~0.6.0", + "grunt-contrib-watch": "~0.6.1", + "grunt-lintspaces": "~0.6.0" + }, + "scripts": { + "test": "grunt test --verbose" + } } From d2df2cc3e96acd0a567239e046eff9f166940f77 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Tue, 4 Nov 2014 13:09:31 +0100 Subject: [PATCH 25/31] Update Zepto and jQuery - Closes #33 --- Gruntfile.js | 4 ++-- README.md | 2 +- bower.json | 4 ++-- demo/index.html | 2 +- github.jquery.json | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 558241f..5ccdd80 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -17,10 +17,10 @@ module.exports = function(grunt) { bump: { options: { - files: ['bower.json'], + files: ['bower.json', 'github.jquery.json'], commit: true, commitMessage: 'Release v%VERSION%', - commitFiles: ['bower.json'], + commitFiles: ['bower.json', 'github.jquery.json', 'dist'], createTag: true, tagName: '%VERSION%', tagMessage: '', diff --git a/README.md b/README.md index 4e06be5..2cb5712 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Create an attribute called `data-repo`: Include jQuery: ```html - + ``` Include plugin's CSS and JS: diff --git a/bower.json b/bower.json index 3ca05f1..4bcfc3d 100644 --- a/bower.json +++ b/bower.json @@ -13,7 +13,7 @@ ], "license": "MIT", "dependencies": { - "zepto": "~1.0.0", - "jquery": "~2.0.3" + "jquery": "^2.1.1", + "zepto": "^1.1.4" } } diff --git a/demo/index.html b/demo/index.html index a7dc9d2..265417e 100644 --- a/demo/index.html +++ b/demo/index.html @@ -34,7 +34,7 @@

jQuery Github

- + diff --git a/github.jquery.json b/github.jquery.json index 35f90ca..e7f7c1e 100644 --- a/github.jquery.json +++ b/github.jquery.json @@ -7,7 +7,7 @@ "repositories", "git" ], - "version": "0.3.3", + "version": "0.3.4", "author": { "name": "Zeno Rocha", "url": "https://github.com/zenorocha" From c20ad941e3b0aa037cb58193d39524c619c17ec0 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Tue, 4 Nov 2014 14:56:10 +0100 Subject: [PATCH 26/31] Release v0.4.0 --- bower.json | 2 +- dist/jquery.github.min.js | 2 +- github.jquery.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index 4bcfc3d..f804d76 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-github", - "version": "0.3.4", + "version": "0.4.0", "homepage": "https://github.com/zenorocha/jquery-github", "authors": [ "Zeno Rocha " diff --git a/dist/jquery.github.min.js b/dist/jquery.github.min.js index 5a9707a..3f350b3 100644 --- a/dist/jquery.github.min.js +++ b/dist/jquery.github.min.js @@ -6,4 +6,4 @@ * Copyright (c) 2014 * MIT License */ -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),$("

"+this.description+" — Read More

Latest commit to master on "+this.pushed_at+"

")},GithubRepo.prototype._parsePushedDate=function(a){var b=new Date(a);return b.getDate()+"/"+(b.getMonth()+1)+"/"+b.getFullYear()},GithubRepo.prototype._parseURL=function(a){return a.replace("api.","").replace("repos/","")},Github.prototype.init=function(){var a=this.getCache();return null!==a?(this.applyTemplate(JSON.parse(a)),void 0):(this.requestData(this.repo),void 0)},Github.prototype.displayIcons=function(){var a=this.options,b=$(".repo-stars"),c=$(".repo-forks"),d=$(".repo-issues");b.css("display",a.iconStars?"inline-block":"none"),c.css("display",a.iconForks?"inline-block":"none"),d.css("display",a.iconIssues?"inline-block":"none")},Github.prototype.requestData=function(a){var b=this;$.ajax({url:"https://api.github.com/repos/"+a,dataType:"jsonp",success:function(a){var c=a.data,d=a.meta.status>=400&&c.message;return d?(b.handleErrorRequest(c),void 0):(b.handleSuccessfulRequest(c),void 0)}})},Github.prototype.handleErrorRequest=function(a){console.warn(a.message)},Github.prototype.handleSuccessfulRequest=function(a){this.applyTemplate(a),this.setCache(a)},Github.prototype.setCache=function(a){window.sessionStorage&&window.sessionStorage.setItem("gh-repos:"+this.repo,JSON.stringify(a))},Github.prototype.getCache=function(){return window.sessionStorage?window.sessionStorage.getItem("gh-repos:"+this.repo):!1},Github.prototype.applyTemplate=function(a){var b=new GithubRepo(a),c=b.toHTML();c.appendTo(this.$container)},function(a){a.fn.github=function(b){return this.each(function(){a(this).data("plugin_github")||a(this).data("plugin_github",new Github(this,b))})}}(window.jQuery||window.Zepto,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),$("

"+this.description+" — Read More

Latest commit to master on "+this.pushed_at+"

")},GithubRepo.prototype._parsePushedDate=function(a){var b=new Date(a);return b.getDate()+"/"+(b.getMonth()+1)+"/"+b.getFullYear()},GithubRepo.prototype._parseURL=function(a){return a.replace("api.","").replace("repos/","")},Github.prototype.init=function(){var a=this.getCache();return null!==a?void this.applyTemplate(JSON.parse(a)):void this.requestData(this.repo)},Github.prototype.displayIcons=function(){var a=this.options,b=$(".repo-stars"),c=$(".repo-forks"),d=$(".repo-issues");b.css("display",a.iconStars?"inline-block":"none"),c.css("display",a.iconForks?"inline-block":"none"),d.css("display",a.iconIssues?"inline-block":"none")},Github.prototype.requestData=function(a){var b=this;$.ajax({url:"https://api.github.com/repos/"+a,dataType:"jsonp",success:function(a){var c=a.data,d=a.meta.status>=400&&c.message;return d?void b.handleErrorRequest(c):void b.handleSuccessfulRequest(c)}})},Github.prototype.handleErrorRequest=function(a){console.warn(a.message)},Github.prototype.handleSuccessfulRequest=function(a){this.applyTemplate(a),this.setCache(a)},Github.prototype.setCache=function(a){window.sessionStorage&&window.sessionStorage.setItem("gh-repos:"+this.repo,JSON.stringify(a))},Github.prototype.getCache=function(){return window.sessionStorage?window.sessionStorage.getItem("gh-repos:"+this.repo):!1},Github.prototype.applyTemplate=function(a){var b=new GithubRepo(a),c=b.toHTML();c.appendTo(this.$container)},function(a){a.fn.github=function(b){return this.each(function(){a(this).data("plugin_github")||a(this).data("plugin_github",new Github(this,b))})}}(window.jQuery||window.Zepto,window); \ No newline at end of file diff --git a/github.jquery.json b/github.jquery.json index e7f7c1e..4e3a30c 100644 --- a/github.jquery.json +++ b/github.jquery.json @@ -7,7 +7,7 @@ "repositories", "git" ], - "version": "0.3.4", + "version": "0.4.0", "author": { "name": "Zeno Rocha", "url": "https://github.com/zenorocha" From a3b997fc6907dcbffe0cf5ad75c3a2bcef4edb19 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Fri, 28 Nov 2014 14:10:20 -0800 Subject: [PATCH 27/31] Update attribute names - "stargazers" > "stargazers_count" & "forks" > "forks_count" --- spec/jquery.github.repo-spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/jquery.github.repo-spec.js b/spec/jquery.github.repo-spec.js index 0169e4e..88464bb 100644 --- a/spec/jquery.github.repo-spec.js +++ b/spec/jquery.github.repo-spec.js @@ -6,10 +6,10 @@ describe("jquery.github.repo", function() { instance = new GithubRepo({ name: "jquery-github", description: "A jQuery plugin to display your Github Repositories", - forks: 33, + forks_count: 33, pushed_at: "2013-07-02T12:08:36Z", url: "https://api.github.com/repos/zenorocha/jquery-github", - stargazers: 131 + stargazers_count: 131 }); }); From 3b135ab8ce96523fe33f07680d8fb06fa501feea Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Fri, 28 Nov 2014 14:11:16 -0800 Subject: [PATCH 28/31] Bump version in dist files --- dist/jquery.github.js | 2 +- dist/jquery.github.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/jquery.github.js b/dist/jquery.github.js index a3e88a1..27e6de9 100644 --- a/dist/jquery.github.js +++ b/dist/jquery.github.js @@ -1,5 +1,5 @@ /* - * jquery-github - v0.3.4 + * jquery-github - v0.4.0 * A jQuery plugin to display your Github Repositories. * https://github.com/zenorocha/jquery-github * diff --git a/dist/jquery.github.min.js b/dist/jquery.github.min.js index 3f350b3..4d06fc4 100644 --- a/dist/jquery.github.min.js +++ b/dist/jquery.github.min.js @@ -1,5 +1,5 @@ /* - * jquery-github - v0.3.4 + * jquery-github - v0.4.0 * A jQuery plugin to display your Github Repositories. * https://github.com/zenorocha/jquery-github * From 3c8c8c083a54c4466376369ec47bc497e77dd454 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Thu, 8 Jan 2015 01:31:23 -0200 Subject: [PATCH 29/31] Move displayIcons to be called inside applyTemplate --- src/jquery.github.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jquery.github.js b/src/jquery.github.js index 1fadfa9..197663b 100644 --- a/src/jquery.github.js +++ b/src/jquery.github.js @@ -67,7 +67,6 @@ function Github( element, options ) { this._defaults = defaults; this.init(); - this.displayIcons(); } // Initializer @@ -151,6 +150,8 @@ Github.prototype.applyTemplate = function ( repo ) { $widget = githubRepo.toHTML(); $widget.appendTo( this.$container ); + + this.displayIcons(); }; // -- Attach plugin to jQuery's prototype -------------------------------------- From 00710d66c0d4b36d09b802684c03663172efc649 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Thu, 10 Mar 2016 11:09:12 -0800 Subject: [PATCH 30/31] Uses parsed URL from API --- src/jquery.github.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/jquery.github.js b/src/jquery.github.js index 197663b..97f0871 100644 --- a/src/jquery.github.js +++ b/src/jquery.github.js @@ -6,14 +6,13 @@ function GithubRepo( repo ) { this.name = repo.name; this.open_issues = repo.open_issues; this.pushed_at = repo.pushed_at; - this.url = repo.url; + this.url = repo.html_url; this.stargazers = repo.stargazers_count; } // Parses HTML template GithubRepo.prototype.toHTML = function () { - this.pushed_at = this._parsePushedDate( this.pushed_at ), - this.url = this._parseURL( this.url ); + this.pushed_at = this._parsePushedDate( this.pushed_at ); return $( "
" + @@ -44,11 +43,6 @@ GithubRepo.prototype._parsePushedDate = function ( pushed_at ) { return date.getDate() + "/" + ( date.getMonth() + 1 ) + "/" + date.getFullYear(); }; -// Parses URL to be friendly -GithubRepo.prototype._parseURL = function ( url ) { - return url.replace( "api.", "" ).replace( "repos/", "" ); -}; - // -- Github Plugin ------------------------------------------------------------ function Github( element, options ) { From 98f752cf92ef99ff49df5c574c98b3753db55591 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Thu, 10 Mar 2016 11:13:26 -0800 Subject: [PATCH 31/31] Removes broken test --- spec/jquery.github.repo-spec.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/spec/jquery.github.repo-spec.js b/spec/jquery.github.repo-spec.js index 88464bb..28c4d12 100644 --- a/spec/jquery.github.repo-spec.js +++ b/spec/jquery.github.repo-spec.js @@ -34,11 +34,6 @@ describe("jquery.github.repo", function() { .toEqual("2013-07-02T12:08:36Z"); }); - it("should be repository's api url", function() { - expect(instance.url) - .toEqual("https://api.github.com/repos/zenorocha/jquery-github"); - }); - it("should be repository's number of stargazers", function() { expect(instance.stargazers) .toEqual(131); @@ -52,14 +47,4 @@ describe("jquery.github.repo", function() { }); }); - describe("execute _parseURL()", function() { - it("should parse repository's url attribute", function() { - expect(instance._parseURL(instance.url)) - .toEqual("https://github.com/zenorocha/jquery-github"); - }); - }); - - describe("execute toHTML()", function() { - // TODO - }); });