show contributors and add GitHub and Stash service
parent
10aa559703
commit
530b9de718
@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AAAQ,0BAAe;AACf,yBAAc;AAGd,uBAAY;AAGZ,6IAAqI;AACrI,6GAAqG;ACR7G,SAAS;EACP,eAAe,EAAE,IAAI;EACrB,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EACV,QAAQ,EAAE,MAAM;;AAElB,YAAY;EACV,KAAK,EAAE,IAAI;;AAEb,cAAc;EACZ,OAAO,EAAE,YAAY;EACrB,OAAO,EAAE,SAAS;EAClB,eAAe,EAAE,IAAI;EACrB,SAAS,EAAE,IAAI;EACf,gBAAgB,EAAE,IAAI;EACtB,MAAM,EAAE,eAAe;EACvB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,OAAO;;AAEhB,oBAAoB;EAClB,gBAAgB,EAAE,OAAO;EACzB,eAAe,EAAE,IAAI;;AAEvB,iBAAiB;EACf,OAAO,EAAE,IAAI;;AAEf,oCAAmC;EACjC,8BAA8B;IAC5B,OAAO,EAAE,IAAI;;EACf,iBAAiB;IACf,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,YAAY;AAEzB,oCAAmC;EACjC,oBAAoB;IAClB,QAAQ,EAAE,QAAQ;;EAEpB,4BAA4B;IAC1B,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;;EAER,uBAAuB;IACrB,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,MAAM;;EAEjB,yBAAyB;IACvB,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,IAAI;AChDpB,KAAK;EACH,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,UAAU;EACtB,MAAM,EAAE,iBAAiB;EACzB,aAAa,EAAE,GAAG;EAClB,SAAS,EAAE,KAAK;EAChB,WAAW,EAAE,YAAY;;AAE3B,WAAW;EACT,MAAM,EAAE,cAAc;;AAExB,MAAM;EACJ,gBAAg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YAAY,EAAE,iBAAiB;EAC/B,WAAW,EAAE,CAAC;;AAGhB,WAAY;EACV,UAAU,EAAE,iCAAiC;EAAE,qBAAqB;EACpE,OAAO,EAAE,IAAI;EACb,cAAc,EAAE,MAAM;EACtB,eAAe,EAAE,MAAM;EACvB,WAAW,EAAE,MAAM",
|
||||
"sources": ["main.scss","navigation.sass","forms.sass"],
|
||||
"names": [],
|
||||
"file": "main.css"
|
||||
|
@ -0,0 +1,17 @@
|
||||
Zerooo.whenReady(function() {
|
||||
Zerooo.getJSON('https://api.github.com/repos/EaterOfCode/zer.ooo/contributors', function (err, data) {
|
||||
if (err) return;
|
||||
|
||||
var contributors = data.filter(function (data) {
|
||||
// It's me!
|
||||
return data.id !== 1922630;
|
||||
});
|
||||
|
||||
var html = Zerooo.joinHumanReadable(contributors.map(function (contributor) {
|
||||
return '<a href="' + contributor.html_url + '">' + contributor.login + '</a>';
|
||||
}));
|
||||
|
||||
Zerooo.select('#contributors').innerHTML = html;
|
||||
Zerooo.select('#contributors-container').style.display = 'block';
|
||||
});
|
||||
});
|
@ -0,0 +1,81 @@
|
||||
Zerooo = {};
|
||||
|
||||
Zerooo.getJSON = function (url, callback) {
|
||||
var x = new XMLHttpRequest();
|
||||
var callbackSent = false;
|
||||
|
||||
x.open("GET", url, true);
|
||||
x.onerror = function (message, source, lineno, colno, error) {
|
||||
if (!callbackSent) {
|
||||
sendCallback(error);
|
||||
}
|
||||
};
|
||||
|
||||
x.onreadystatechange = function () {
|
||||
if (x.readyState != 4) return;
|
||||
|
||||
if (x.status !== 200) {
|
||||
sendCallback(new Error(url + " responded with status code " + x.status));
|
||||
return;
|
||||
}
|
||||
|
||||
var data = x.responseText;
|
||||
var json = null;
|
||||
|
||||
try {
|
||||
json = JSON.parse(data);
|
||||
} catch (e) {
|
||||
sendCallback(e)
|
||||
}
|
||||
|
||||
sendCallback(null, json);
|
||||
};
|
||||
x.send();
|
||||
|
||||
function sendCallback(err, data)
|
||||
{
|
||||
if (!callbackSent) {
|
||||
callbackSent = true;
|
||||
callback(err, data || null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Zerooo.whenReady = function (callback) {
|
||||
if (document.readyState == "complete") {
|
||||
setTimeout(callback, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
document.onreadystatechange = function () {
|
||||
if (document.readyState == "complete") {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Zerooo.select = function (sel) {
|
||||
return document.querySelector(sel);
|
||||
};
|
||||
|
||||
Zerooo.selectAll = function (sel) {
|
||||
return document.querySelectorAll(sel);
|
||||
};
|
||||
|
||||
Zerooo.joinHumanReadable = function (arr) {
|
||||
if (arr.length === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (arr.length === 1) {
|
||||
return arr.shift();
|
||||
}
|
||||
|
||||
var str = arr.shift();
|
||||
|
||||
while (arr.length > 1) {
|
||||
str += ', ' + arr.shift();
|
||||
}
|
||||
|
||||
return str + " and " + arr.shift();
|
||||
};
|
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Eater\Glim\Service;
|
||||
|
||||
use Stash\Pool;
|
||||
|
||||
class GitHub extends Main
|
||||
{
|
||||
public function getContributors() {
|
||||
|
||||
/** @var Pool $pool */
|
||||
$pool = $this->get('stash');
|
||||
|
||||
$contributors = $pool->getItem('github/contributors');
|
||||
|
||||
if ($contributors->isMiss()) {
|
||||
$contributorsData = [];
|
||||
|
||||
try {
|
||||
$contributorsJson = @$this->fetch('/repos/' . $this->get('github-repo') . '/contributors');
|
||||
$contributorsNewData = json_decode($contributorsJson, true);
|
||||
if ($contributorsNewData !== null) {
|
||||
$contributorsData = $contributorsNewData;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
$info = $this->getRepoInfo();
|
||||
|
||||
if ($info !== false) {
|
||||
|
||||
$ownerId = $info['owner']['id'];
|
||||
|
||||
$contributorsNewData = [];
|
||||
|
||||
foreach ($contributorsData as $contributor) {
|
||||
if ($contributor['id'] !== $ownerId) {
|
||||
$contributorsNewData[] = $contributor;
|
||||
}
|
||||
}
|
||||
|
||||
$contributorsData = $contributorsNewData;
|
||||
}
|
||||
|
||||
$contributors->expiresAfter(3600);
|
||||
$contributors->set($contributorsData);
|
||||
$contributors->save();
|
||||
}
|
||||
|
||||
return $contributors->get();
|
||||
}
|
||||
|
||||
public function getRepoInfo() {
|
||||
/** @var Pool $pool */
|
||||
$pool = $this->get('stash');
|
||||
|
||||
$info = $pool->getItem('github/info');
|
||||
|
||||
if ($info->isMiss()) {
|
||||
$infoData = false;
|
||||
|
||||
try {
|
||||
$infoJson = @$this->fetch('/repos/' . $this->get('github-repo'));
|
||||
$infoNewData = json_decode($infoJson, true);
|
||||
if ($infoNewData !== null) {
|
||||
$infoData = $infoNewData;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
$info->expiresAfter(3600);
|
||||
$info->set($infoData);
|
||||
$info->save();
|
||||
}
|
||||
|
||||
return $info->get();
|
||||
}
|
||||
|
||||
private function fetch($path)
|
||||
{
|
||||
$options = array('http' => array('user_agent'=> $_SERVER['HTTP_USER_AGENT']));
|
||||
$context = stream_context_create($options);
|
||||
return file_get_contents('https://api.github.com' . $path, false, $context);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Eater\Glim\Service;
|
||||
use Stash\Pool;
|
||||
use Stash\Driver\FileSystem;
|
||||
|
||||
class Stash
|
||||
{
|
||||
static public function init() {
|
||||
$driver = new FileSystem();
|
||||
$pool = new Pool($driver);
|
||||
|
||||
return $pool;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue