├── LICENSE
├── README.md
├── bower.json
├── index.html
├── package.json
└── src
├── github-feed.css
└── github-feed.js
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Bachors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | jQuery-Github-Feed
2 | ==================
3 |
This is a small and simple jQuery plugin to make github repositories, activity and gists widget from multiple accounts.
4 | USAGE
5 | <!-- Include Octicons -->
6 | <link href="//cdnjs.cloudflare.com/ajax/libs/octicons/2.0.2/octicons.min.css" rel="stylesheet">
7 |
8 | <!-- Custom Github Feed style -->
9 | <link type="text/css" rel="stylesheet" href="src/github-feed.css" />
10 |
11 | <!-- by ClassName -->
12 | <div class="anu" data-username="bachors"></div>
13 | <div class="anu" data-username="facebook"></div>
14 |
15 | <!-- by ID -->
16 | <div id="unix" data-username="primer"></div>
17 |
18 | <!-- Include jQuery -->
19 | <script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
20 |
21 | <!-- Include jQuery Github Feed-->
22 | <script src="src/github-feed.js"></script>
23 |
24 | <script>
25 | $(document).ready(function(){
26 |
27 | $(".anu").githubfeed(
28 | sort = "updated", // Can be one of created, updated, pushed, full_name.
29 | width = '100%', // width widget
30 | height = '400px' // height post
31 | );
32 |
33 | $("#unix").githubfeed(
34 | sort = "updated", // Can be one of created, updated, pushed, full_name.
35 | width = '350px', // width widget
36 | height = '400px' // height post
37 | );
38 | });
39 | </script>
40 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jQuery-Github-Feed",
3 | "main": "src/github-feed.js",
4 | "homepage": "https://github.com/bachors/jQuery-Github-Feed",
5 | "description": "This is a small and simple jQuery plugin to make github repositories, activity and gists widget from multiple accounts.",
6 | "keywords": [
7 | "github",
8 | "feed",
9 | "repositories",
10 | "git"
11 | ],
12 | "license": "MIT",
13 | "ignore": [
14 | "**/.*"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | jQuery Github Feed - iBacor.com
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
31 |
32 |
33 |
34 |
35 |
38 |
39 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jQuery-Github-Feed",
3 | "version": "1.0.0",
4 | "description": "This is a small and simple jQuery plugin to make github repositories, activity and gists widget from multiple accounts.",
5 | "repository": "bachors/jQuery-Github-Feed",
6 | "author": "Ican Bachors",
7 | "license": "MIT",
8 | "bugs": {
9 | "url": "https://github.com/bachors/jQuery-Github-Feed/issues"
10 | },
11 | "homepage": "https://github.com/bachors/jQuery-Github-Feed",
12 | "dependencies": {
13 | "jquery": "^2.1.3",
14 | "fontawesome": "^4.7.0"
15 | },
16 | "keywords": [
17 | "github",
18 | "feed",
19 | "repositories",
20 | "git"
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/src/github-feed.css:
--------------------------------------------------------------------------------
1 | /***********************************************************
2 | * #### jQuery-Github-Feed v3.0 ####
3 | * Coded by Ican Bachors 2014.
4 | * https://github.com/bachors/jQuery-Github-Feed
5 | * Updates will be posted to this site.
6 | ***********************************************************/
7 |
8 | .github-feed {
9 | font-family: Helvetica, arial, freesans, clean, sans-serif;
10 | height: 100%;
11 | font-weight: bold;
12 | line-height: 1.3;
13 | border: 1px solid #d8d8d8;
14 | color: #555;
15 | text-align: left
16 | }
17 |
18 | .github-feed a {
19 | color: #4183c4;
20 | text-decoration: none;
21 | font-weight: bold;
22 | }
23 |
24 | /* header */
25 | .github-feed .head {
26 | font-size: 1em;
27 | width: calc(100% - 20px);
28 | /* width: 100%; */
29 | padding: 10px;
30 | height: 70px;
31 | /* height: 90px; */
32 | background: #f5f5f5;
33 | border-bottom: 1px solid #d8d8d8;
34 | display: block;
35 | overflow: hidden;
36 | }
37 |
38 | .github-feed .head a {
39 | display: block;
40 | color: #555;
41 | overflow: hidden;
42 | white-space: nowrap;
43 | text-overflow: ellipsis;
44 | margin-bottom: 5px;
45 | }
46 |
47 | .github-feed .head p {
48 | margin: 0;
49 | padding: 0;
50 | margin-bottom: 7px;
51 | font-size: 0.8em;
52 | font-weight: normal;
53 | overflow: hidden;
54 | white-space: nowrap;
55 | text-overflow: ellipsis;
56 | }
57 |
58 | .github-feed .head span.user {
59 | margin-right: 15px
60 | }
61 |
62 | .github-feed .head span.user span {
63 | padding: 2px 5px;
64 | font-size: 12px;
65 | font-weight: 600;
66 | line-height: 1;
67 | color: #fff;
68 | background-color: #5cb85c;
69 | border-radius: 20px;
70 | }
71 |
72 | .github-feed .head .left {
73 | display: inline;
74 | float: left;
75 | width: auto;
76 | }
77 |
78 | .github-feed .head .left img {
79 | width: 60px;
80 | border: 1px solid #d8d8d8;
81 | padding: 0px 3px;
82 | margin: 0px !important
83 | }
84 |
85 | .github-feed .head .right {
86 | display: inline-block;
87 | width: 63%;
88 | margin-left: 10px
89 | }
90 |
91 | /* tabs */
92 | .github-feed .gftabs {
93 | display: block;
94 | width: 100%;
95 | background: #fafafa;
96 | }
97 |
98 | .github-feed .gftabs .gftab {
99 | font-size: 0.8em;
100 | background: #fafafa;
101 | color: #555;
102 | display: inline-block;
103 | padding: 0px;
104 | width: 33.33%;
105 | text-align: center;
106 | padding-top: 10px;
107 | padding-bottom: 10px;
108 | cursor: pointer;
109 | overflow: hidden;
110 | white-space: nowrap;
111 | text-overflow: ellipsis;
112 | }
113 |
114 | .github-feed .gftabs .gftab sup {
115 | padding: 2px 5px;
116 | font-size: 0.7em;
117 | font-weight: 600;
118 | line-height: 1;
119 | color: #fff;
120 | background-color: #666;
121 | border-radius: 20px;
122 | }
123 |
124 | .github-feed .gftabs .aktip, .github-feed .gftabs .gftab:hover {
125 | background: #fff;
126 | }
127 |
128 | /* body */
129 | .github-feed .bod {
130 | font-size: 1em;
131 | width: 100%;
132 | padding: 0;
133 | margin: 0;
134 | background: #fff;
135 | overflow: hidden;
136 | overflow-y: auto;
137 | }
138 |
139 | .github-feed .bod .result {
140 | display: block;
141 | padding: 10px;
142 | padding-right: 0;
143 | width: calc(100% - 10px);
144 | /* width: 100%; */
145 | border-bottom: 1px solid #d8d8d8;
146 | font-weight: normal;
147 | }
148 |
149 | .github-feed .bod .result .icon {
150 | display: inline-block;
151 | float: left;
152 | width: 35px;
153 | margin-right: 10px;
154 | }
155 |
156 | .github-feed .bod .result .icon .octicon {
157 | font-size: 40px;
158 | font-weight: normal;
159 | }
160 |
161 | .github-feed .bod .bachorsactiv .result .icon .octicon {
162 | font-size: 30px;
163 | color: #d8d8d8;
164 | }
165 |
166 | .github-feed .bod .bachorsactiv .result .gfpost {
167 | display: inline-block;
168 | width: calc(100% - 60px);
169 | overflow: hidden;
170 | text-overflow: ellipsis;
171 | font-size: 0.8em;
172 | color: #000;
173 | }
174 |
175 | .github-feed .bod .result .gfpost {
176 | display: inline-block;
177 | width: calc(100% - 120px);
178 | overflow: hidden;
179 | text-overflow: ellipsis;
180 | }
181 |
182 | .github-feed .bod .result .contributor {
183 | display: inline-block;
184 | margin-left: 10px;
185 | width: 50px;
186 | font-size: 0.8em;
187 | text-align: right;
188 | }
189 |
190 | .github-feed .bod .result .contributor .octicon {
191 | width: 10px;
192 | margin-bottom: 5px;
193 | margin-right: 5px;
194 | }
195 |
196 | .github-feed .bod .result .contributor a {
197 | color: #555;
198 | font-weight: normal;
199 | }
200 |
201 | .github-feed .bod .result .contributor a span {
202 | color: #aaa;
203 | }
204 |
205 | .github-feed .bod .result .gfpost p {
206 | margin: 0;
207 | padding: 0;
208 | font-size: 0.8em;
209 | color: #555;
210 | clear: both;
211 | }
212 |
213 | .github-feed .bod .result .gfpost p a {
214 | font-weight: normal;
215 | }
216 |
217 | .github-feed .bod .result .gfpost p img {
218 | margin-top: 5px;
219 | float: left;
220 | width: 30px;
221 | margin-right: 5px;
222 | }
223 |
224 | .github-feed .bod .result .gfpost p img.letik {
225 | width: 20px;
226 | }
227 |
228 | .github-feed .bod .result .gfpost .date {
229 | margin: 0;
230 | padding: 0;
231 | font-size: 0.8em;
232 | color: #999;
233 | }
234 |
235 | /* footer */
236 | .github-feed .foot {
237 | background: #f5f5f5;
238 | width: calc(100% - 20px);
239 | /* width: 100%; */
240 | padding: 5px 10px 5px 10px;
241 | border-top: 1px solid #d8d8d8;
242 | font-size: 0.8em;
243 | }
244 |
245 | .github-feed .foot a {
246 | float: right;
247 | color: #999;
248 | }
249 |
--------------------------------------------------------------------------------
/src/github-feed.js:
--------------------------------------------------------------------------------
1 | /***********************************************************
2 | * #### jQuery-Github-Feed v3.0 ####
3 | * Coded by Ican Bachors 2014.
4 | * https://github.com/bachors/jQuery-Github-Feed
5 | * Updates will be posted to this site.
6 | ***********************************************************/
7 |
8 | $.fn.githubfeed = function(h, width, height) {
9 |
10 | $(this).each(function(i, a) {
11 | var b = ($(this).attr('id') != null ? '#' + $(this).attr('id') : '.' + $(this).attr('class')),
12 | g = $(this).data('username'),
13 | j = '';
14 |
15 | j += '';
16 | j += '
';
17 | j += '
Repositories
Activity
Gists
';
18 | j += '
';
19 | j += '
';
20 | j += '
';
21 | j += '
';
22 | j += '
';
23 | j += '';
26 | j += '
';
27 | $(this).html(j);
28 |
29 | ibacor_profil(g, i, b);
30 | ibacor_repos(g, i, b);
31 | ibacor_gists(g, i, b);
32 | ibacor_activs(g, i, b);
33 | });
34 |
35 | function ibacor_profil(d, x, z) {
36 | $.ajax({
37 | url: 'https://api.github.com/users/' + d,
38 | crossDomain: true,
39 | dataType: 'json'
40 | }).done(function(b) {
41 | var c = '',
42 | ibacor = $('.jgf').attr('href').split("/");
43 | c += '
';
44 | c += '
';
45 | c += ' ';
46 | c += '
' + b.name + ' ';
47 | if(b.type != 'User'){
48 | c += '
' + (b.bio != null ? b.bio : '') + '
';
49 | }
50 | c += '
' + (b.location != null ? b.location : '') + '
';
51 | if(b.type == 'User'){
52 | c += '
Followers '+ b.followers + ' Following '+ b.following + '
';
53 | }
54 | c += '
';
55 | $(z + ':eq(' + x + ') .github-feed .head').html(c);
56 | $(z + ':eq(' + x + ') .github-feed sup.repc').html(b.public_repos);
57 | $(z + ':eq(' + x + ') .github-feed sup.gisc').html(b.public_gists);
58 | $(z + ':eq(' + x + ') .github-feed .gftab').click(function() {
59 | $(z + ':eq(' + x + ') .github-feed .gftab').removeClass('aktip');
60 | $(z + ':eq(' + x + ') .github-feed .feed').css('display', 'none');
61 | var a = $(this).data('dip');
62 | $(this).addClass('aktip');
63 | $(z + ':eq(' + x + ') .' + ibacor[3] + a).css('display', 'block');
64 | return false
65 | })
66 | })
67 | }
68 |
69 | function ibacor_repos(d, x, z) {
70 | $.ajax({
71 | url: 'https://api.github.com/users/' + d + '/repos?type=all&sort=' + h,
72 | crossDomain: true,
73 | dataType: 'json'
74 | }).done(function(b) {
75 | var c = '',
76 | ibacor = $('.jgf').attr('href').split("/");
77 | $.each(b, function(i, a) {
78 | c += '';
79 | c += '
';
80 | c += ' ';
81 | c += '
';
82 | c += '
';
83 | c += '
' + b[i].name + ' ';
84 | c += '
' + b[i].description + '
';
85 | c += '
' + relative_time(b[i].created_at) + ' ago - update ' + relative_time(b[i].updated_at) + ' ago
';
86 | c += '
';
87 | c += '
';
92 | c += '
'
93 | });
94 | $(z + ':eq(' + x + ') .' + ibacor[3] + 'repos').html(c)
95 | })
96 | }
97 |
98 | function ibacor_gists(d, x, z) {
99 | $.ajax({
100 | url: 'https://api.github.com/users/' + d + '/gists',
101 | crossDomain: true,
102 | dataType: 'json'
103 | }).done(function(b) {
104 | var c = '',
105 | ibacor = $('.jgf').attr('href').split("/");
106 | $.each(b, function(i, a) {
107 | var keys = Object.keys(b[i].files);
108 | c += '';
109 | c += '
';
110 | c += ' ';
111 | c += '
';
112 | c += '
';
113 | c += '
' + keys[0] + ' ';
114 | c += '
' + (b[i].description != null ? b[i].description : '') + '
';
115 | c += '
' + relative_time(b[i].created_at) + ' ago - update ' + relative_time(b[i].updated_at) + ' ago
';
116 | c += '
';
117 | c += '
';
120 | c += '
'
121 | });
122 | $(z + ':eq(' + x + ') .' + ibacor[3] + 'gists').html(c)
123 | })
124 | }
125 |
126 | function ibacor_activs(f, x, z) {
127 | $.ajax({
128 | url: 'https://api.github.com/users/' + f + '/events',
129 | crossDomain: true,
130 | dataType: 'json'
131 | }).done(function(d) {
132 | var e = '',
133 | ibacor = $('.jgf').attr('href').split("/");
134 | $.each(d, function(i, a) {
135 | if (d[i].type == "WatchEvent") {
136 | e += '';
137 | e += '
';
138 | e += ' ';
139 | e += '
';
140 | e += '
';
141 | e += '
' + d[i].actor.login + ' ';
142 | e += d[i].payload.action + ' ';
143 | e += '
' + d[i].repo.name + ' ';
144 | e += '
' + relative_time(d[i].created_at) + ' ago ';
145 | e += '
';
146 | e += '
'
147 | } else if (d[i].type == "ForkEvent") {
148 | e += ''
160 | } else if (d[i].type == "ReleaseEvent") {
161 | e += ''
175 | } else if (d[i].type == "IssueCommentEvent") {
176 | e += ''
188 | } else if (d[i].type == "IssuesEvent") {
189 | var b = "";
190 | if (d[i].payload.action == "closed") {
191 | b += "closed issue"
192 | } else if (d[i].payload.action == "opened") {
193 | b += "opened issue"
194 | }
195 | e += ''
207 | } else if (d[i].type == "PushEvent") {
208 | if (d[i].payload.ref.substring(0, 11) === 'refs/heads/') {
209 | rep = d[i].payload.ref.substring(11);
210 | } else {
211 | rep = d[i].payload.ref;
212 | }
213 | e += ''
237 | } else if (d[i].type == "CreateEvent") {
238 | if (d[i].payload.ref_type == "branch") {
239 | e += ''
251 | } else if (d[i].payload.ref_type == "repository") {
252 | e += '';
253 | e += '
';
254 | e += ' ';
255 | e += '
';
256 | e += '
';
257 | e += '
' + d[i].actor.login + ' ';
258 | e += ' created repository ';
259 | e += '
' + d[i].repo.name + ' ';
260 | e += '
' + relative_time(d[i].created_at) + ' ago ';
261 | e += '
';
262 | e += '
'
263 | } else if (d[i].payload.ref_type == "tag") {
264 | e += ''
276 | }
277 | }
278 | });
279 | $(z + ':eq(' + x + ') .' + ibacor[3] + 'activ').html(e)
280 | })
281 | }
282 |
283 | function relative_time(a) {
284 | if (!a) {
285 | return
286 | }
287 | a = $.trim(a);
288 | a = a.replace(/\.\d\d\d+/, "");
289 | a = a.replace(/-/, "/").replace(/-/, "/");
290 | a = a.replace(/T/, " ").replace(/Z/, " UTC");
291 | a = a.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2");
292 | var b = new Date(a);
293 | var c = (arguments.length > 1) ? arguments[1] : new Date();
294 | var d = parseInt((c.getTime() - b) / 1000);
295 | d = (d < 2) ? 2 : d;
296 | var r = '';
297 | if (d < 60) {
298 | r = 'jst now'
299 | } else if (d < 120) {
300 | r = 'a min'
301 | } else if (d < (45 * 60)) {
302 | r = (parseInt(d / 60, 10)).toString() + ' mins'
303 | } else if (d < (2 * 60 * 60)) {
304 | r = 'an hr'
305 | } else if (d < (24 * 60 * 60)) {
306 | r = (parseInt(d / 3600, 10)).toString() + ' hrs'
307 | } else if (d < (48 * 60 * 60)) {
308 | r = 'a day'
309 | } else {
310 | dd = (parseInt(d / 86400, 10)).toString();
311 | if (dd <= 30) {
312 | r = dd + ' dys'
313 | } else {
314 | mm = (parseInt(dd / 30, 10)).toString();
315 | if (mm <= 12) {
316 | r = mm + ' mon'
317 | } else {
318 | r = (parseInt(mm / 12, 10)).toString() + ' yrs'
319 | }
320 | }
321 | }
322 | return r
323 | }
324 |
325 | function addCommas(a) {
326 | var b = parseInt(a, 10);
327 | if (b === null) {
328 | return 0
329 | }
330 | if (b >= 1000000000) {
331 | return (b / 1000000000).toFixed(1).replace(/\.0$/, "") + "G"
332 | }
333 | if (b >= 1000000) {
334 | return (b / 1000000).toFixed(1).replace(/\.0$/, "") + "M"
335 | }
336 | if (b >= 1000) {
337 | return (b / 1000).toFixed(1).replace(/\.0$/, "") + "K"
338 | }
339 | return b
340 | }
341 | }
342 |
--------------------------------------------------------------------------------