From d4981e4d3216066abf249895fb196c8e81ea1b23 Mon Sep 17 00:00:00 2001 From: Ben Sheldon Date: Tue, 24 Jul 2012 15:02:16 -0700 Subject: [PATCH] Page through all repos (not just first 30); added spinner.gif for initial repo/member API loading. --- assets/spinner.gif | Bin 0 -> 1849 bytes index.html | 106 +++++++++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 46 deletions(-) create mode 100644 assets/spinner.gif diff --git a/assets/spinner.gif b/assets/spinner.gif new file mode 100644 index 0000000000000000000000000000000000000000..5b33f7e54f4e55b6b8774d86d96895db9af044b4 GIT binary patch literal 1849 zcma*odr(tX9tZI2z31lM+(&YVk%mZ}5P~KlG2s=WSbGzm0!x7^P##Mnh7t-jP!X0Q zk_SQ}Po-L1tlDK;6l?(>v)e5ZBQx4|Y-Q?nr@Px3?9h(3ZWr3^tj=`TP57gKr87N$ zp2wWee1GRRCwo_xahnw)5cxNPJbCg2L6DV|6`#+yw6v6!mDS$f9-JvFD^n;GQ&UrZ zzh5jCkByB101O60U0q#p_1BM>Cv-vP?&s4@g_((4_1L=L$(a91)0=J91Gas#R{McE znYG^9*0A5YZ>#;~+Wkn(W5B0^yELIYLP!K}mB~<)AM@1&nqekynuaEGqPrzoH|KodRXJy)%+w_fu3nE5>@Bd_b zqC$EQ;{c`T&?EsNO|igL9gC7Ygxv?aQUEXMq?~>wg{EyW;VcJ37CUF#HjrT=KQO_* zS>M9yydXk18D(+QDJ1>r);Lav_uYKp$T?4vr{Q$lTo&pKv^?(>L-)G2*lwH!Ah7k? z7oH<8h-(KTKt5V6$8gF)C7Io&P5=SjTh)=zV=E2EUhQZP##L8S{d%UK>>+y82>+FV+#^BzW7u3F)Bb>=lYQ%%j`F>ASe zo*cw@V#u6T`A2He;70mR(V&iV&-7{qP~=SRf&jm9-T{*ZeZ}$rd0#6c&fLG^xJcf5 z+p<`wJYgW+_s*V{uI$nMB;%8`S_3>PfGOj3Rq}@Cx^+j?rk92fANSFDBYnOqQ>Vdj z)(|$AhP4t&Lb=Gvo2#3Gl%9<=Gv`Mz?Po@P4iLF!x}GUWJICDlFk-hS^Whyh7x~VH z@0vD1>HYD4&e+~yzS*-sFR{9`{QEEZO1zg7>R&7cHts-6j!xHVdA8eI+ZlVzd%`es zJT@$#GX(gvCJ1oJN%yLBK}{V=V;seo;!w|Yte!W1%5qLNFWqvZW>h&IiH+oPT=b@E zPhGzv5=(Un*X>v`>%8h_nj^NdYcE6NHS_ifkCV$*D)Tqrbu`s;<=t<4 zAHNqNV?6(g<1PY-w@#I-WYFViz?9TrkMr)u0g`O`u|>T;k|2sV*YF^punvT;$SuTy{j3Gv)yqD!R_CF>yR)MzmmYS5v+~R zXAdD%ng9?df;wd8GxR#%3O+gz};Vo;)sK%Bj-q>Oq%R7JU-KD?vYu>#2UjaDo z&8$>5xW~?KPD_#XFToU1hIb*VOMidUr6iYiO0N|i-7s`T8!cFT`rN!^1Pt78J93i6 z5HI1wIM$94m{3SLDvISDe6$ZG1;eq_D9RTaaC>=cO{@Bs>$IlPCPJJ$h$)-3vzNUQ6OsN#_zWxey!_9%hxwH2_dEJi=yY|1c7nDm2_Lm!Cof8-R_+9UkS zcBE(o47yE)oMR(Q=dp1a2wTX5KvvGyLqlWTa7V&!A*|w|)ax~1_~aJ0=_Lilg*0iQk7#ZD EAHN$8j{pDw literal 0 HcmV?d00001 diff --git a/index.html b/index.html index ca5ca5911..f3e53dee5 100644 --- a/index.html +++ b/index.html @@ -63,51 +63,65 @@ $item.appendTo("#repos"); } - $.getJSON("https://api.github.com/orgs/twitter/repos?callback=?", function (result) { - var repos = result.data; - - $(function () { - $("#num-repos").text(repos.length); - - // Convert pushed_at to Date. - $.each(repos, function (i, repo) { - repo.pushed_at = new Date(repo.pushed_at); - - var weekHalfLife = 1.146 * Math.pow(10, -9); - - var pushDelta = (new Date) - Date.parse(repo.pushed_at); - var createdDelta = (new Date) - Date.parse(repo.created_at); - - var weightForPush = 1; - var weightForWatchers = 1.314 * Math.pow(10, 7); - - repo.hotness = weightForPush * Math.pow(Math.E, -1 * weekHalfLife * pushDelta); - repo.hotness += weightForWatchers * repo.watchers / createdDelta; - }); - - // Sort by highest # of watchers. - repos.sort(function (a, b) { - if (a.hotness < b.hotness) return 1; - if (b.hotness < a.hotness) return -1; - return 0; - }); - - $.each(repos, function (i, repo) { - addRepo(repo); - }); - - // Sort by most-recently pushed to. - 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); - }); + function addRepos(repos, page) { + repos = repos || []; + page = page || 1; + + var uri = "https://api.github.com/orgs/twitter/repos?callback=?" + + "&per_page=100" + + "&page="+page; + + $.getJSON(uri, function (result) { + if (result.data && result.data.length > 0) { + repos = repos.concat(result.data); + addRepos(repos, page + 1); + } + else { + $(function () { + $("#num-repos").text(repos.length); + + // Convert pushed_at to Date. + $.each(repos, function (i, repo) { + repo.pushed_at = new Date(repo.pushed_at); + + var weekHalfLife = 1.146 * Math.pow(10, -9); + + var pushDelta = (new Date) - Date.parse(repo.pushed_at); + var createdDelta = (new Date) - Date.parse(repo.created_at); + + var weightForPush = 1; + var weightForWatchers = 1.314 * Math.pow(10, 7); + + repo.hotness = weightForPush * Math.pow(Math.E, -1 * weekHalfLife * pushDelta); + repo.hotness += weightForWatchers * repo.watchers / createdDelta; + }); + + // Sort by highest # of watchers. + repos.sort(function (a, b) { + if (a.hotness < b.hotness) return 1; + if (b.hotness < a.hotness) return -1; + return 0; + }); + + $.each(repos, function (i, repo) { + addRepo(repo); + }); + + // Sort by most-recently pushed to. + 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); + }); + }); + } }); - }); + } + addRepos(); $.getJSON("https://api.github.com/orgs/twitter/members?callback=?", function (result) { var members = result.data; @@ -220,9 +234,9 @@

Twitter is built on open source software.