update knplabs/github-api
This commit is contained in:
parent
69ffeebd1b
commit
3d8c967d3f
6 changed files with 1199 additions and 131 deletions
|
@ -1,11 +1,13 @@
|
|||
{
|
||||
"require": {
|
||||
"slim/slim": "^3.0",
|
||||
"knplabs/github-api": "1.2.*",
|
||||
"ezyang/htmlpurifier": "^4.9",
|
||||
"phpmailer/phpmailer": "^6.0",
|
||||
"erusev/parsedown": "^1.6",
|
||||
"slim/twig-view": "^2.2"
|
||||
"slim/twig-view": "^2.2",
|
||||
"knplabs/github-api": "^2.5",
|
||||
"php-http/guzzle6-adapter": "^1.1",
|
||||
"cache/filesystem-adapter": "^1.0"
|
||||
},
|
||||
"autoload":{
|
||||
"psr-0":{
|
||||
|
|
1272
src/composer.lock
generated
1272
src/composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,10 +8,11 @@
|
|||
|
||||
namespace helpers;
|
||||
|
||||
use Cache\Adapter\Filesystem\FilesystemCachePool;
|
||||
use Github\Client;
|
||||
use Github\HttpClient\CachedHttpClient;
|
||||
use Github\ResultPager;
|
||||
|
||||
use League\Flysystem\Adapter\Local;
|
||||
use League\Flysystem\Filesystem;
|
||||
class GithubImporter {
|
||||
|
||||
private $client;
|
||||
|
@ -38,8 +39,12 @@ class GithubImporter {
|
|||
|
||||
public static function buildClient($clientId, $clientSecret)
|
||||
{
|
||||
$httpClient = new CachedHttpClient(array('cache_dir' => realpath('../tmp/github_api_cache')));
|
||||
$client = new Client($httpClient);
|
||||
$filesystemAdapter = new Local(realpath('../tmp/github_api_cache'));
|
||||
$filesystem = new Filesystem($filesystemAdapter);
|
||||
|
||||
$pool = new FilesystemCachePool($filesystem);
|
||||
$client = new Client();
|
||||
$client->addCache($pool);
|
||||
|
||||
if (!empty($clientId) && !empty($clientSecret)) {
|
||||
$client->authenticate($clientId, $clientSecret, Client::AUTH_URL_CLIENT_ID);
|
||||
|
|
|
@ -18,8 +18,6 @@ class Twig {
|
|||
public static function registerFilter(\Twig_Environment $environment)
|
||||
{
|
||||
$environment->addFilter(static::getMarkdownFilter());
|
||||
$environment->addFilter(static::getLinkToPageFilter());
|
||||
$environment->addFilter(static::getLinkToIssueFilter());
|
||||
}
|
||||
|
||||
private static function getMarkdownFilter()
|
||||
|
@ -29,23 +27,4 @@ class Twig {
|
|||
return $parser->text($text);
|
||||
});
|
||||
}
|
||||
|
||||
private static function getLinkToPageFilter()
|
||||
{
|
||||
return new \Twig_SimpleFilter('pageLink', function ($page) {
|
||||
if (1 === (int) $page) {
|
||||
return '/';
|
||||
}
|
||||
|
||||
return '/?page=' . (int) $page;
|
||||
}, array('is_safe' => array('all')));
|
||||
}
|
||||
|
||||
private static function getLinkToIssueFilter()
|
||||
{
|
||||
return new \Twig_SimpleFilter('issueLink', function ($number) {
|
||||
|
||||
return '/' . (int) $number;
|
||||
}, array('is_safe' => array('all')));
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ $app->get(
|
|||
|
||||
$details = $issue->getIssue($number);
|
||||
return $this->view->render($response, 'issue.twig', $details);
|
||||
});
|
||||
})->setName("issue");
|
||||
|
||||
$app->get('/', function ($request, $response, $args) {
|
||||
/** @var \Slim\Http\Request $request */
|
||||
|
@ -37,4 +37,4 @@ $app->get('/', function ($request, $response, $args) {
|
|||
$details = $page->getPage($pageNumber);
|
||||
|
||||
return $this->view->render($response, 'page.twig', $details);
|
||||
});
|
||||
})->setName("page");
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
{% block head %}
|
||||
{% if currentPage > 1 %}
|
||||
<link rel="prev" href="{{ previousPage|pageLink }}" />
|
||||
<link rel="prev" href="{{ path_for('page', [] , { 'page': previousPage }) }}" />
|
||||
{% endif %}
|
||||
|
||||
{% if currentPage != numPages %}
|
||||
<link rel="next" href="{{ nextPage|pageLink }}" />
|
||||
<link rel="next" href="{{ path_for('page', [], { 'page': nextPage }) }}" />
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
|||
{% if currentPage == 1 %}
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>Read-only mirror of all <a href="http://github.com/{{ githubOrganization|e('url') }}/{{ githubRepository|e('url') }}/issues" target="_blank">{{ projectName }} issues</a>.</h1>
|
||||
<h1>Read-only mirror of all <a href="https://github.com/{{ githubOrganization|e('url') }}/{{ githubRepository|e('url') }}/issues" target="_blank">{{ projectName }} issues</a>.</h1>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
{% for issue in issues %}
|
||||
<div class="list-group">
|
||||
<a href="{{ issue.number|issueLink }}" class="list-group-item">
|
||||
<a href="{{ path_for('issue', { 'number': issue.number }) }}" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">{{ issue.title }} <small>#{{ issue.number }}</small></h4>
|
||||
<p class="list-group-item-text">
|
||||
<small>
|
||||
|
@ -45,17 +45,17 @@
|
|||
|
||||
<ul class="pagination">
|
||||
{% if currentPage > 1 %}
|
||||
<li><a href="{{ previousPage|pageLink }}" title="Previous page">«</a></li>
|
||||
<li><a href="{{ path_for('page', [], { 'page': previousPage }) }}" title="Previous page">«</a></li>
|
||||
{% endif %}
|
||||
|
||||
{% for pageEntry in 1..numPages %}
|
||||
<li {% if pageEntry == currentPage %}class="active"{% endif %}>
|
||||
<a href="{{ pageEntry|pageLink }}" title="Page {{ pageEntry }}">{{ pageEntry }}</a>
|
||||
<a href="{{ path_for('page', [], { 'page': pageEntry }) }}" title="Page {{ pageEntry }}">{{ pageEntry }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
{% if currentPage != numPages %}
|
||||
<li><a href="{{ nextPage|pageLink }}" title="Next page">»</a></li>
|
||||
<li><a href="{{ path_for('page', [], { 'page': nextPage }) }}" title="Next page">»</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
|
|
Reference in a new issue