-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathscript.js
More file actions
325 lines (282 loc) · 8.87 KB
/
script.js
File metadata and controls
325 lines (282 loc) · 8.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
(function ($, undefined) {
// NOTE: featured repos currently not used (commented out- why?)
var featured = ['lua-nginx-module', 'stapxx', 'redoctober'];
// See https://wiki.cfops.it/display/PS/Open+Source for deprecation information
var exclude = [
// These first few sections were already excluded.
// deleted? renamed?
'jas',
'CloudFlare-UI',
// forks
'circus',
'fpm',
'phantomjs',
'zendesk',
'raven-php',
'go-raft',
'twemcache',
// forked and deprecated
'cfapp-canopy',
// empty repo (one-line README only)
'cloudflarejs',
// active, but excluded as not of interest
'cloudflare.github.io',
// deprecated, already excluded
'instaflare',
'dnschanger_detector',
'cfapp_sample',
// The rest are newly tagged as deprecated
// Partnerships
'Cloudflare-CNAME-flattener',
'ModCloudFlareIIS',
'Cloudflare-Tools',
// This is being removed from GitHub entirely
'Cloudflare-Plesk',
// Talks and demos
'cf-dnssec-demo-domain-1',
'cf-dnssec-demo-domain-2',
'gosession2',
// External site
'origin-pull',
// App Store (the old one)
'cf-app',
// Security
'keyless',
// KyotoTycoon
'kyototycoon',
'kyotocabinet',
'kt_fdw',
'gokabinet',
'SortaSQL',
// NGINX & Lua
'lua-upstream-cache-nginx-module',
'lua-resty-kyototycoon',
'lua-resty-limit', // just a README
'ljmm',
'luajit-mm',
// JavaScript
'babel-preset-cf',
'generator-cf-module',
'redox',
'transifex-client',
'deadorbit',
'collapsify',
// Miscellaneous
'spdget',
'vpnc-scripts'];
var includeForks = [
'python-cloudflare',
'zlib',
'lua-cmsgpack'
];
var customRepos = [{
name : 'stapxx',
html_url : 'https://github.com/agentzh/stapxx',
language : 'Perl',
description : 'Simple macro language extentions to systemtap'
},{
name : 'nginx-systemtap-toolkit',
html_url : 'https://github.com/agentzh/nginx-systemtap-toolkit',
language : 'Perl',
description : 'Real-time analyzing and diagnosing tools for Nginx based on SystemTap'
},{
name : 'lua-nginx-module',
html_url : 'https://github.com/chaoslawful/lua-nginx-module',
language : 'C',
description : 'Embed the Power of Lua into NginX'
},{
name : 'ngx_cache_purge',
html_url : 'https://github.com/FRiCKLE/ngx_cache_purge',
language : 'C',
description : 'nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches.'
}];
var categories = {
'Integrate': {
'claire': null,
'Cloudflare-CPanel': null,
'Cloudflare-Magento': null,
'Cloudflare-Pivotal-Cloud-Foundry': null,
'Cloudflare-WordPress': null,
'mod_cloudflare': null,
'cloudflare-plugin-frontend': null,
'cloudflare-plugin-backend': null
},
'Automate': {
'cloudflare-go': null,
'node-cloudflare': null,
'python-cloudflare': null,
'cloudflare-php': null,
'salt-cloudflare': null,
'logsclient': null,
'logshare': null,
'wafanalyzer': null,
'json-schema-tools': null,
'doca': null,
'doca-bootstrap-theme': null
},
'Secure': {
'cfssl': null,
'sslconfig': null,
'redoctober': null,
'bpftools': null,
'fourq': null,
'gokeyless': null,
'cfssl_trust': null,
'certmgr': null,
'tls-tris': null
},
'JavaScript': {
'backgridjs.com': null
},
'Go': {
'golibs' : null,
'hellogopher': null,
'goser': null,
'golz4': null
},
'Other': {}
};
var num = 0;
function addRecentlyUpdatedRepo(repo) {
var $item = $('<li>');
var $name = $('<a>').attr('href', repo.html_url).text(repo.name);
$item.append($('<span>').addClass('name').append($name));
$item.append('<span class="bullet">⋅</span>');
var $time = $('<a>').attr('href', repo.html_url + '/commits').text( repo.pushed_at.toDateString() );
$item.append($('<span>').addClass('time').append($time));
$item.append('<span class="bullet">⋅</span>');
var $watchers = $('<a>').attr('href', repo.html_url + '/watchers').text(repo.watchers + (repo.watchers === 1 ? ' stargazer' : ' stargazers'));
$item.append($('<span>').addClass('watchers').append($watchers));
$item.append('<span class="bullet">⋅</span>');
var $forks = $('<a>').attr('href', repo.html_url + '/network').text(repo.forks + (repo.forks === 1 ? ' fork' : ' forks'));
$item.append($('<span>').addClass('forks').append($forks));
$('#recently-updated').removeClass('loading').append($item);
}
function addRepo(repo, $container) {
var $item = $('<div>').addClass('column');
var $link = $('<a>').attr('href', repo.html_url).appendTo($item);
$link.addClass('repo lang-'+ (repo.language || '').toLowerCase().replace(/[\+#]/gi, '') );
$link.append($('<h4 class="repo-name">').text(repo.name || 'Unknown'));
$link.append($('<h5 class="repo-lang">').text(repo.language || ''));
$link.append($('<p class="repo-desc">').text(repo.description || ''));
/*if( featured.indexOf(repo.name) > -1 ){
$link.addClass('featured'+(++num));
$item.prependTo('#repos');
}else{*/
$item.appendTo($container);
//}
}
function addCategory(cat, repos){
var $section = $('<section id="cat-'+cat+'" />').appendTo('#repos'), $container;
$section.append($('<h2 />',{'class': 'subheadline', 'text': cat}));
$container = $('<div class="repos section columns three" />').appendTo($section);
// The .append(' ') enures a space between the links which allows them
// to wrap on a narrow screen. Previously this sort of worked with breaks
// possible within "Nginx and Lua" but nowhere else. This provides a more
// natural behavior. Given tha larger number of headings, using both
// the space and the existing between-link margin works well.
$('#category-shortcuts').append($('<a />', {
href: '#cat-'+cat,
text: cat
})).append(' ')
$.each(repos, function(i, repo){
if( repo !== null ){
addRepo(repo, $container);
}
});
}
function addRepos(repos, page) {
repos = repos || [];
page = page || 1;
var uri = 'https://api.github.com/orgs/cloudflare/repos?callback=?' + '&per_page=100' + '&page='+page;
$.getJSON(uri, function (result) {
// API Rate limiting catch
if( result.data && result.data.message ){
$('<p class="text-error">')
.text('Your IP has hit github\'s rate limit per hour.')
.appendTo('.hero-block');
return;
}
repos = repos.concat(result.data);
if( result.data && result.data.length == 100 ){
addRepos(repos, page + 1);
}else{
//
repos = $.grep(repos, function(value) {
var keep = exclude.indexOf(value.name) === -1,
found = false;
if( value.fork && (includeForks.indexOf(value.name) === -1) ){
// ignore most forks.
keep = false;
}
// Build up the categories while we're looping through
if( keep ){
$.each(categories, function(key, items){
if( value.name in items ){
found = true;
items[value.name] = value;
return false;
}else if( value.language == key || (key === 'Nginx' && value.language === 'Lua') ){
found = true;
categories[key][value.name] = value;
}
});
if( !found ){
categories.Other[value.name] = value;
}
}
return keep;
});
$('#repo-headline').hide();//text(repos.length).removeClass('loading');
// Convert pushed_at to Date.
$.each(repos, function (i, repo) {
repo.pushed_at = new Date(repo.pushed_at || null);
});
// Sort by most-recently pushed to.
// or is featured
repos.sort(function (a, b) {
if (a.pushed_at < b.pushed_at) return 1;
if (b.pushed_at < a.pushed_at) return -1;
return 0;
});
$.each(repos.slice(0, 3), function (i, repo) {
addRecentlyUpdatedRepo(repo);
});
$.each(categories, function (cat, repos){
addCategory(cat, repos);
});
}
});
}
function addMember( member ){
var $item = $('<div>').addClass('column');
var $link = $('<a>').attr('href', member.html_url).appendTo($item);
var $deets = $('<div>').addClass('member-info').appendTo($link);
$link.addClass('member');
$link.prepend($('<img height="90" width="90">').attr('src', member.avatar_url).addClass('member-avatar'));
$deets.append( $('<h4 class="user-name">').text(member.login));
$item.appendTo('#members');
}
function addMembers( count, url ){
$.getJSON(url + '&callback=?', function (result) {
// API Rate limiting catch
if( result.data && result.data.message ){ return; }
var members = result.data;
count += members.length;
$('#member-count').text(count).removeClass('loading');
$.each( members, function(idx, member){ addMember( member ); });
$.each(result.meta.Link, function (idx, link) {
if (link[1].rel === 'next') {
addMembers( count, link[0] )
return false; // short-circuit $.each
}
});
});
}
addRepos(customRepos);
addMembers(0, 'https://api.github.com/orgs/cloudflare/members?page=1');
$('#activate-mobile-menu').on('click', function( evt ){
evt.preventDefault();
$('#header').toggleClass('mobile-menu-active');
})
})(jQuery);