Make application work with new packages
This commit is contained in:
parent
cb4fd4347d
commit
4e35440ac0
8 changed files with 39 additions and 38 deletions
|
@ -9,6 +9,7 @@
|
||||||
namespace helpers;
|
namespace helpers;
|
||||||
|
|
||||||
use Cache\Adapter\Filesystem\FilesystemCachePool;
|
use Cache\Adapter\Filesystem\FilesystemCachePool;
|
||||||
|
use Github\AuthMethod;
|
||||||
use Github\Client;
|
use Github\Client;
|
||||||
use Github\ResultPager;
|
use Github\ResultPager;
|
||||||
use League\Flysystem\Adapter\Local;
|
use League\Flysystem\Adapter\Local;
|
||||||
|
@ -57,7 +58,7 @@ class GithubImporter {
|
||||||
$client->addCache($pool);
|
$client->addCache($pool);
|
||||||
|
|
||||||
if (!empty($clientId)) {
|
if (!empty($clientId)) {
|
||||||
$client->authenticate($clientId, null, Client::AUTH_HTTP_TOKEN);
|
$client->authenticate($clientId, null, AuthMethod::ACCESS_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $client;
|
return $client;
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Issue {
|
||||||
* Upfront you should check whether the issue actually exists by calling exists().
|
* Upfront you should check whether the issue actually exists by calling exists().
|
||||||
*
|
*
|
||||||
* @param int $issueNumber
|
* @param int $issueNumber
|
||||||
* @return bool
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getIssue($issueNumber)
|
public function getIssue($issueNumber)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Page
|
||||||
* Upfront you should check whether the page actually exists by calling exists().
|
* Upfront you should check whether the page actually exists by calling exists().
|
||||||
*
|
*
|
||||||
* @param int $pageNumber
|
* @param int $pageNumber
|
||||||
* @return bool
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getPage($pageNumber) {
|
public function getPage($pageNumber) {
|
||||||
$path = $this->getPathToFile($pageNumber);
|
$path = $this->getPathToFile($pageNumber);
|
||||||
|
|
|
@ -11,25 +11,25 @@ namespace helpers;
|
||||||
class Twig
|
class Twig
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function setDateFormat(\Twig_Environment $environment) {
|
public static function setDateFormat(\Twig\Environment $environment) {
|
||||||
$environment->getExtension("Twig_Extension_Core")->setDateFormat('F jS Y');
|
$environment->getExtension("Twig\Extension\CoreExtension")->setDateFormat('F jS Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function registerFilter(\Twig_Environment $environment) {
|
public static function registerFilter(\Twig\Environment $environment) {
|
||||||
$environment->addFilter(static::getMarkdownFilter());
|
$environment->addFilter(static::getMarkdownFilter());
|
||||||
$environment->addFilter(static::getColorFilter());
|
$environment->addFilter(static::getColorFilter());
|
||||||
$environment->addFunction(static::getPaginationFunction());
|
$environment->addFunction(static::getPaginationFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getMarkdownFilter() {
|
private static function getMarkdownFilter() {
|
||||||
return new \Twig_SimpleFilter('markdown', function ($text) {
|
return new \Twig\TwigFilter('markdown', function ($text) {
|
||||||
$parser = new Markdown();
|
$parser = new Markdown();
|
||||||
return $parser->text($text);
|
return $parser->text($text);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getColorFilter() {
|
private static function getColorFilter() {
|
||||||
return new \Twig_SimpleFilter(
|
return new \Twig\TwigFilter(
|
||||||
/**
|
/**
|
||||||
* modified from https://24ways.org/2010/calculating-color-contrast/
|
* modified from https://24ways.org/2010/calculating-color-contrast/
|
||||||
* @param $colorstring "#ffffff"
|
* @param $colorstring "#ffffff"
|
||||||
|
@ -45,7 +45,7 @@ class Twig
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getPaginationFunction() {
|
private static function getPaginationFunction() {
|
||||||
return new \Twig_Function('paginationFunction', function ($numPages, $page) {
|
return new \Twig\TwigFunction('paginationFunction', function ($numPages, $page) {
|
||||||
$padding = PAGINATION_PADDING;
|
$padding = PAGINATION_PADDING;
|
||||||
$pages = [1];
|
$pages = [1];
|
||||||
$i = 2;
|
$i = 2;
|
||||||
|
|
|
@ -10,28 +10,19 @@ require '../vendor/autoload.php';
|
||||||
require '../config/config.php';
|
require '../config/config.php';
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
$config = [
|
|
||||||
'settings' => [
|
|
||||||
'displayErrorDetails' => DEBUG_ENABLED,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$app = new \Slim\App($config);
|
$container = new \DI\Container();
|
||||||
|
\Slim\Factory\AppFactory::setContainer($container);
|
||||||
// Get container
|
|
||||||
$container = $app->getContainer();
|
|
||||||
|
|
||||||
// Register component on container
|
// Register component on container
|
||||||
$container['view'] = function ($container) {
|
$container->set('view', function () {
|
||||||
$view = new \Slim\Views\Twig(realpath("../templates/"), [
|
$view = \Slim\Views\Twig::create(realpath("../templates/"), [
|
||||||
'cache' => realpath('../tmp/templates_cache'),
|
'cache' => realpath('../tmp/templates_cache'),
|
||||||
'debug' => DEBUG_ENABLED,
|
'debug' => DEBUG_ENABLED,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Instantiate and add Slim specific extension
|
// Instantiate and add Slim specific extension
|
||||||
$basePath = rtrim(str_ireplace('index.php', '', $container['request']->getUri()->getBasePath()), '/');
|
$view->addExtension(new \Twig\Extension\DebugExtension());
|
||||||
$view->addExtension(new Slim\Views\TwigExtension($container['router'], $basePath));
|
|
||||||
$view->addExtension(new \Twig_Extension_Debug());
|
|
||||||
$twig = $view->getEnvironment();
|
$twig = $view->getEnvironment();
|
||||||
helpers\Twig::setDateFormat($twig);
|
helpers\Twig::setDateFormat($twig);
|
||||||
helpers\Twig::registerFilter($twig);
|
helpers\Twig::registerFilter($twig);
|
||||||
|
@ -44,7 +35,15 @@ $container['view'] = function ($container) {
|
||||||
$view->getEnvironment()->addGlobal('privacyPolicyURL', PRIVACY_POLICY_URL);
|
$view->getEnvironment()->addGlobal('privacyPolicyURL', PRIVACY_POLICY_URL);
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
};
|
});
|
||||||
|
|
||||||
|
// Create App
|
||||||
|
$app = \Slim\Factory\AppFactory::create();
|
||||||
|
|
||||||
|
// Add Twig-View Middleware
|
||||||
|
$app->add(\Slim\Views\TwigMiddleware::createFromContainer($app));
|
||||||
|
|
||||||
|
$app->addErrorMiddleware(DEBUG_ENABLED, true, true);
|
||||||
|
|
||||||
require '../routes/page.php';
|
require '../routes/page.php';
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
$app->get(
|
$app->get(
|
||||||
'/{number:[0-9]+}', function ($request, $response, $args) {
|
'/{number:[0-9]+}', function ($request, $response, $args) {
|
||||||
|
|
||||||
|
@ -15,24 +14,26 @@ $app->get(
|
||||||
$issue = new helpers\Issue();
|
$issue = new helpers\Issue();
|
||||||
|
|
||||||
if (!$issue->exists($number)) {
|
if (!$issue->exists($number)) {
|
||||||
throw new \Slim\Exception\NotFoundException($request, $response);
|
throw new \Slim\Exception\HttpNotFoundException($request, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
$details = $issue->getIssue($number);
|
$details = $issue->getIssue($number);
|
||||||
return $this->view->render($response, 'issue.twig', $details);
|
|
||||||
|
return $this->get('view')->render($response, 'issue.twig', $details);
|
||||||
})->setName("issue");
|
})->setName("issue");
|
||||||
|
|
||||||
$app->get('/', function ($request, $response, $args) {
|
$app->get('/', function ($request, $response, $args) {
|
||||||
/** @var \Slim\Http\Request $request */
|
/** @var \GuzzleHttp\Psr7\ServerRequest $request */
|
||||||
$pageNumber = (int)$request->getQueryParam('page', 1);
|
$params = $request->getQueryParams();
|
||||||
|
$pageNumber = $params['page'] ?? 1;
|
||||||
|
|
||||||
$page = new helpers\Page();
|
$page = new helpers\Page();
|
||||||
|
|
||||||
if (!$page->exists($pageNumber)) {
|
if (!$page->exists($pageNumber)) {
|
||||||
throw new \Slim\Exception\NotFoundException($request, $response);
|
throw new \Slim\Exception\HttpNotFoundException($request, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
$details = $page->getPage($pageNumber);
|
$details = $page->getPage($pageNumber);
|
||||||
|
|
||||||
return $this->view->render($response, 'page.twig', $details);
|
return $this->get('view')->render($response, 'page.twig', $details);
|
||||||
})->setName("page");
|
})->setName("page");
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
{% if page > 1 %}
|
{% if page > 1 %}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
<a rel="prev" href="{{ path_for('page', [], { 'page': page - 1 }) }}" class="page-link">
|
<a rel="prev" href="{{ url_for('page', [], { 'page': page - 1 }) }}" class="page-link">
|
||||||
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
|
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M1203 544q0 13-10 23l-393 393 393 393q10 10 10 23t-10 23l-50 50q-10 10-23 10t-23-10l-466-466q-10-10-10-23t10-23l466-466q10-10 23-10t23 10l50 50q10 10 10 23z"></path>
|
<path d="M1203 544q0 13-10 23l-393 393 393 393q10 10 10 23t-10 23l-50 50q-10 10-23 10t-23-10l-466-466q-10-10-10-23t10-23l466-466q10-10 23-10t23 10l50 50q10 10 10 23z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
{% if page < num_pages %}
|
{% if page < num_pages %}
|
||||||
<a rel="next" href="{{ path_for('page', [], { 'page': page + 1 }) }}" class="page-link">
|
<a rel="next" href="{{ url_for('page', [], { 'page': page + 1 }) }}" class="page-link">
|
||||||
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
|
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M1171 960q0 13-10 23l-466 466q-10 10-23 10t-23-10l-50-50q-10-10-10-23t10-23l393-393-393-393q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l466 466q10 10 10 23z"></path>
|
<path d="M1171 960q0 13-10 23l-466 466q-10 10-23 10t-23-10l-50-50q-10-10-10-23t10-23l393-393-393-393q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l466 466q10 10 10 23z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
{% macro printpage(i,active) %}
|
{% macro printpage(i,active) %}
|
||||||
<li class="page-item {{ i == active ? "active" : "other" }}">
|
<li class="page-item {{ i == active ? "active" : "other" }}">
|
||||||
<a href="{{ path_for('page', [], { 'page': i }) }}"
|
<a href="{{ url_for('page', [], { 'page': i }) }}"
|
||||||
class="page-link">{{ i }}</a>
|
class="page-link">{{ i }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{% if currentPage > 1 %}
|
{% if currentPage > 1 %}
|
||||||
<link rel="prev" href="{{ path_for('page', [] , { 'page': previousPage }) }}"/>
|
<link rel="prev" href="{{ url_for('page', [] , { 'page': previousPage }) }}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if currentPage != numPages %}
|
{% if currentPage != numPages %}
|
||||||
<link rel="next" href="{{ path_for('page', [], { 'page': nextPage }) }}"/>
|
<link rel="next" href="{{ url_for('page', [], { 'page': nextPage }) }}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<link rel="canonical" href="https://github.com/matomo-org/matomo/issues/" />
|
<link rel="canonical" href="https://github.com/matomo-org/matomo/issues/" />
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
<div class="card-deck"><div class="row">
|
<div class="card-deck"><div class="row">
|
||||||
{% for issue in issues %}
|
{% for issue in issues %}
|
||||||
<div class="col-lg-3 col-md-4">
|
<div class="col-lg-3 col-md-4">
|
||||||
<a href="{{ path_for('issue', { 'number': issue.number }) }}" class="card overviewCard">
|
<a href="{{ url_for('issue', { 'number': issue.number }) }}" class="card overviewCard">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">{{ issue.title }}
|
<h4 class="card-title">{{ issue.title }}
|
||||||
<small>#{{ issue.number }}</small>
|
<small>#{{ issue.number }}</small>
|
||||||
|
|
Reference in a new issue