Skip to content

Commit 0362570

Browse files
committed
Regenerate v0.2.7
1 parent 643b627 commit 0362570

File tree

2 files changed

+160
-189
lines changed

2 files changed

+160
-189
lines changed

dist/jquery.github.js

Lines changed: 157 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -1,192 +1,163 @@
11
/*
2-
* jQuery Github - v0.2.6
2+
* jQuery Github - v0.2.7
33
* A jQuery plugin to display your Github Repositories.
44
* https://github.com/zenorocha/jquery-github/
5-
5+
*
66
* Copyright (c) 2013
77
* MIT License
88
*/
9-
10-
;(function ( $, window, undefined ) {
11-
var pluginName = 'github',
12-
document = window.document,
13-
defaults = {
14-
propertyName: "value"
15-
};
16-
17-
function Plugin( element, options ) {
18-
var self = this;
19-
20-
self.element = element;
21-
self.$container = $(element);
22-
self.repo = self.$container.attr("data-repo");
23-
24-
self.options = $.extend( {}, defaults, options) ;
25-
26-
self._defaults = defaults;
27-
self._name = pluginName;
28-
29-
self.init();
30-
}
31-
32-
/**
33-
* Initializer
34-
*
35-
*/
36-
Plugin.prototype.init = function () {
37-
var self = this,
38-
cached = self.getCache();
39-
40-
if (cached !== null) {
41-
self.applyTemplate(JSON.parse(cached));
42-
}
43-
else {
44-
self.requestData(self.repo);
45-
}
46-
};
47-
48-
/**
49-
* Apply results to HTML template
50-
*
51-
*/
52-
Plugin.prototype.applyTemplate = function (repo) {
53-
var self = this,
54-
$widget = self.parseTemplate(repo);
55-
56-
$widget.appendTo(self.$container);
57-
};
58-
59-
/**
60-
* Stores repostories in sessionStorage if available
61-
*
62-
*/
63-
Plugin.prototype.cacheResults = function (result_data) {
64-
var self = this;
65-
66-
// Cache data
67-
if (window.sessionStorage) {
68-
sessionStorage.setItem('gh-repos:' + self.repo, JSON.stringify(result_data));
69-
}
70-
};
71-
72-
/**
73-
* Grab cached results
74-
*
75-
*/
76-
Plugin.prototype.getCache = function () {
77-
var self = this;
78-
79-
if (window.sessionStorage) {
80-
return sessionStorage.getItem('gh-repos:' + self.repo);
81-
}
82-
else {
83-
return false;
84-
}
85-
};
86-
87-
/**
88-
* Handle Errors requests
89-
*
90-
*/
91-
Plugin.prototype.handlerErrorRequests = function (result_data) {
92-
var self = this;
93-
94-
console.warn(result_data.message);
95-
return;
96-
};
97-
98-
/**
99-
* Handle Successful request
100-
*
101-
*/
102-
Plugin.prototype.handlerSuccessfulRequest = function (result_data) {
103-
var self = this;
104-
105-
self.applyTemplate(result_data);
106-
self.cacheResults(result_data);
107-
};
108-
109-
/**
110-
* Parses Pushed date with date format
111-
*
112-
*/
113-
Plugin.prototype.parsePushedDate = function (pushed_at) {
114-
var self = this,
115-
date = new Date(pushed_at);
116-
117-
return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear()
118-
};
119-
120-
/**
121-
* Parses repository URL to be friendly
122-
*
123-
*/
124-
Plugin.prototype.parseRepositoryURL = function (url) {
125-
var self = this;
126-
127-
return url.replace('api.','').replace('repos/','');
128-
};
129-
130-
/**
131-
* Parses HTML template
132-
*
133-
*/
134-
Plugin.prototype.parseTemplate = function (repo) {
135-
var self = this,
136-
pushed_at = self.parsePushedDate(repo.pushed_at),
137-
repo_url = self.parseRepositoryURL(repo.url);
138-
139-
return $($.parseHTML(' \
140-
<div class="github-box"> \
141-
<div class="github-box-header"> \
142-
<h3> \
143-
<a href="' + repo_url + '">' + repo.name + '</a> \
144-
</h3> \
145-
<div class="github-stats"> \
146-
<a class="repo-watchers" href="' + repo_url + '/watchers">' + repo.watchers + '</a> \
147-
<a class="repo-forks" href="' + repo_url + '/forks">' + repo.forks + '</a> \
148-
</div> \
149-
</div> \
150-
<div class="github-box-content"> \
151-
<p>' + repo.description + ' &mdash; <a href="' + repo_url + '#readme">Read More</a></p> \
152-
</div> \
153-
<div class="github-box-download"> \
154-
<p class="repo-update">Latest commit to <strong>master</strong> on ' + pushed_at + '</p> \
155-
<a class="repo-download" href="' + repo_url + '/zipball/master">Download as zip</a> \
156-
</div> \
157-
</div> \
158-
'));
159-
};
160-
161-
/**
162-
* Request repositories from Github
163-
*
164-
*/
165-
Plugin.prototype.requestData = function (repo) {
166-
var self = this;
167-
168-
$.ajax({
169-
url: 'https://api.github.com/repos/' + repo,
170-
dataType: 'jsonp',
171-
success: function(results) {
172-
var result_data = results.data;
173-
174-
// Handle API failures
175-
if (results.meta.status >= 400 && result_data.message) {
176-
self.handlerErrorRequest();
177-
}
178-
else {
179-
self.handlerSuccessfulRequest(result_data);
180-
}
181-
}
182-
});
183-
};
184-
185-
$.fn[pluginName] = function ( options ) {
186-
return this.each(function () {
187-
if (!$.data(this, 'plugin_' + pluginName)) {
188-
$.data(this, 'plugin_' + pluginName, new Plugin( this, options ));
189-
}
190-
});
191-
};
192-
}(jQuery, window));
9+
;( function ( $, window, undefined ) {
10+
11+
var pluginName = "github",
12+
document = window.document,
13+
defaults = {
14+
propertyName: "value"
15+
};
16+
17+
function Plugin( element, options ) {
18+
var self = this;
19+
20+
self.element = element;
21+
self.$container = $(element);
22+
self.repo = self.$container.attr("data-repo");
23+
24+
self.options = $.extend( {}, defaults, options) ;
25+
26+
self._defaults = defaults;
27+
self._name = pluginName;
28+
29+
self.init();
30+
}
31+
32+
// Initializer
33+
Plugin.prototype.init = function () {
34+
var self = this,
35+
cached = self.getCache();
36+
37+
if (cached !== null) {
38+
self.applyTemplate(JSON.parse(cached));
39+
}
40+
else {
41+
self.requestData(self.repo);
42+
}
43+
};
44+
45+
// Apply results to HTML template
46+
Plugin.prototype.applyTemplate = function (repo) {
47+
var self = this,
48+
$widget = self.parseTemplate(repo);
49+
50+
$widget.appendTo(self.$container);
51+
};
52+
53+
// Stores repostories in sessionStorage if available
54+
Plugin.prototype.cacheResults = function (result_data) {
55+
var self = this;
56+
57+
// Cache data
58+
if (window.sessionStorage) {
59+
window.sessionStorage.setItem("gh-repos:" + self.repo, JSON.stringify(result_data));
60+
}
61+
};
62+
63+
// Grab cached results
64+
Plugin.prototype.getCache = function () {
65+
var self = this;
66+
67+
if (window.sessionStorage) {
68+
return window.sessionStorage.getItem("gh-repos:" + self.repo);
69+
}
70+
else {
71+
return false;
72+
}
73+
};
74+
75+
// Handle Errors requests
76+
Plugin.prototype.handlerErrorRequests = function (result_data) {
77+
var self = this;
78+
79+
console.warn(result_data.message);
80+
return;
81+
};
82+
83+
// Handle Successful request
84+
Plugin.prototype.handlerSuccessfulRequest = function (result_data) {
85+
var self = this;
86+
87+
self.applyTemplate(result_data);
88+
self.cacheResults(result_data);
89+
};
90+
91+
// Parses Pushed date with date format
92+
Plugin.prototype.parsePushedDate = function (pushed_at) {
93+
var self = this,
94+
date = new Date(pushed_at);
95+
96+
return date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear();
97+
};
98+
99+
// Parses repository URL to be friendly
100+
Plugin.prototype.parseRepositoryURL = function (url) {
101+
var self = this;
102+
103+
return url.replace("api.","").replace("repos/","");
104+
};
105+
106+
// Parses HTML template
107+
Plugin.prototype.parseTemplate = function (repo) {
108+
var self = this,
109+
pushed_at = self.parsePushedDate(repo.pushed_at),
110+
repo_url = self.parseRepositoryURL(repo.url);
111+
112+
return $($.parseHTML(" \
113+
<div class='github-box'> \
114+
<div class='github-box-header'> \
115+
<h3> \
116+
<a href='" + repo_url + "'>" + repo.name + "</a> \
117+
</h3> \
118+
<div class='github-stats'> \
119+
<a class='repo-watchers' href='" + repo_url + "'/watchers'>" + repo.watchers + "</a> \
120+
<a class='repo-forks' href='" + repo_url + "'/forks'>" + repo.forks + "</a> \
121+
</div> \
122+
</div> \
123+
<div class='github-box-content'> \
124+
<p>" + repo.description + " &mdash; <a href='" + repo_url + "'#readme'>Read More</a></p> \
125+
</div> \
126+
<div class='github-box-download'> \
127+
<p class='repo-update'>Latest commit to <strong>master</strong> on " + pushed_at + "</p> \
128+
<a class='repo-download' href='" + repo_url + "'/zipball/master'>Download as zip</a> \
129+
</div> \
130+
</div> \
131+
"));
132+
};
133+
134+
// Request repositories from Github
135+
Plugin.prototype.requestData = function (repo) {
136+
var self = this;
137+
138+
$.ajax({
139+
url: "https://api.github.com/repos/" + repo,
140+
dataType: "jsonp",
141+
success: function(results) {
142+
var result_data = results.data;
143+
144+
// Handle API failures
145+
if (results.meta.status >= 400 && result_data.message) {
146+
self.handlerErrorRequest();
147+
}
148+
else {
149+
self.handlerSuccessfulRequest(result_data);
150+
}
151+
}
152+
});
153+
};
154+
155+
$.fn[pluginName] = function ( options ) {
156+
return this.each(function () {
157+
if (!$.data(this, "plugin_" + pluginName)) {
158+
$.data(this, "plugin_" + pluginName, new Plugin( this, options ));
159+
}
160+
});
161+
};
162+
163+
}(jQuery, window));

dist/jquery.github.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)