1
0
Fork 0

Merge pull request #12 from Findus23/more-improvements

More improvements
This commit is contained in:
Thomas Steur 2018-02-12 07:20:07 +13:00 committed by GitHub
commit 286225eb1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 417 additions and 427 deletions

5
.gitignore vendored
View file

@ -1,12 +1,11 @@
.idea
src/data/issues/*/*.json
src/data/pages/*.json
src/tmp/templates_cache/*
src/tmp/github_api_cache/*
src/tmp/
!src/tmp/templates_cache/.gitkeep
!src/tmp/github_api_cache/.gitkeep
src/vendor
src/composer.phar
src/config/config.php
src/node_modules/
src/public/css/style.*
src/public/css/style.css.map

View file

@ -8,7 +8,8 @@
"knplabs/github-api": "^2.5",
"php-http/guzzle6-adapter": "^1.1",
"cache/filesystem-adapter": "^1.0",
"monolog/monolog": "^1.23"
"monolog/monolog": "^1.23",
"evert/sitemap-php": "^1.2"
},
"autoload":{
"psr-0":{

163
src/composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "14a0b7b897b18b882ea252fcf4b478bd",
"content-hash": "173d5101b6c7ef41ef8167acc05029fc",
"packages": [
{
"name": "cache/adapter-common",
@ -275,21 +275,24 @@
},
{
"name": "erusev/parsedown",
"version": "1.6.3",
"version": "1.6.4",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "728952b90a333b5c6f77f06ea9422b94b585878d"
"reference": "fbe3fe878f4fe69048bb8a52783a09802004f548"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/728952b90a333b5c6f77f06ea9422b94b585878d",
"reference": "728952b90a333b5c6f77f06ea9422b94b585878d",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/fbe3fe878f4fe69048bb8a52783a09802004f548",
"reference": "fbe3fe878f4fe69048bb8a52783a09802004f548",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"type": "library",
"autoload": {
"psr-0": {
@ -313,7 +316,51 @@
"markdown",
"parser"
],
"time": "2017-05-14T14:47:48+00:00"
"time": "2017-11-14T20:44:03+00:00"
},
{
"name": "evert/sitemap-php",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/evert/sitemap-php.git",
"reference": "be07a062943401067bf0ba62710ca733c838bc24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/evert/sitemap-php/zipball/be07a062943401067bf0ba62710ca733c838bc24",
"reference": "be07a062943401067bf0ba62710ca733c838bc24",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-0": {
"SitemapPHP": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Osman Ungur",
"email": "osmanungur@gmail.com"
},
{
"name": "Evert Pot",
"email": "evert@rooftopsolutions.nl"
}
],
"description": "Lightweight library for generating Google sitemap XML files",
"homepage": "http://code.google.com/p/sabredav/",
"keywords": [
"Sitemap"
],
"time": "2015-04-17T21:45:50+00:00"
},
{
"name": "ezyang/htmlpurifier",
@ -545,16 +592,16 @@
},
{
"name": "knplabs/github-api",
"version": "2.5.0",
"version": "2.6.0",
"source": {
"type": "git",
"url": "https://github.com/KnpLabs/php-github-api.git",
"reference": "05b24ed592a61ea947b45d8d14cde25f9795fb2f"
"reference": "cacf6f38bf9e6c5242e2b6dc26a67c4791bc7751"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/KnpLabs/php-github-api/zipball/05b24ed592a61ea947b45d8d14cde25f9795fb2f",
"reference": "05b24ed592a61ea947b45d8d14cde25f9795fb2f",
"url": "https://api.github.com/repos/KnpLabs/php-github-api/zipball/cacf6f38bf9e6c5242e2b6dc26a67c4791bc7751",
"reference": "cacf6f38bf9e6c5242e2b6dc26a67c4791bc7751",
"shasum": ""
},
"require": {
@ -578,7 +625,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5.x-dev"
"dev-master": "2.6.x-dev"
}
},
"autoload": {
@ -609,7 +656,7 @@
"gist",
"github"
],
"time": "2017-06-26T07:29:00+00:00"
"time": "2017-09-30T20:00:06+00:00"
},
{
"name": "league/flysystem",
@ -817,16 +864,16 @@
},
{
"name": "php-http/cache-plugin",
"version": "v1.4.0",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/php-http/cache-plugin.git",
"reference": "fe2730638f254934529006eb38aad8b5d427f475"
"reference": "c573ac6ea9b4e33fad567f875b844229d18000b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/cache-plugin/zipball/fe2730638f254934529006eb38aad8b5d427f475",
"reference": "fe2730638f254934529006eb38aad8b5d427f475",
"url": "https://api.github.com/repos/php-http/cache-plugin/zipball/c573ac6ea9b4e33fad567f875b844229d18000b9",
"reference": "c573ac6ea9b4e33fad567f875b844229d18000b9",
"shasum": ""
},
"require": {
@ -834,7 +881,7 @@
"php-http/client-common": "^1.1",
"php-http/message-factory": "^1.0",
"psr/cache": "^1.0",
"symfony/options-resolver": "^2.6 || ^3.0"
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0"
},
"require-dev": {
"henrikbjorn/phpspec-code-coverage": "^1.0",
@ -843,7 +890,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
"dev-master": "1.5-dev"
}
},
"autoload": {
@ -869,32 +916,32 @@
"httplug",
"plugin"
],
"time": "2017-04-05T20:09:01+00:00"
"time": "2017-11-29T20:45:41+00:00"
},
{
"name": "php-http/client-common",
"version": "1.5.0",
"version": "1.7.0",
"source": {
"type": "git",
"url": "https://github.com/php-http/client-common.git",
"reference": "154d36542eb96ee95daa504591eab78af2484baa"
"reference": "9accb4a082eb06403747c0ffd444112eda41a0fd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/client-common/zipball/154d36542eb96ee95daa504591eab78af2484baa",
"reference": "154d36542eb96ee95daa504591eab78af2484baa",
"url": "https://api.github.com/repos/php-http/client-common/zipball/9accb4a082eb06403747c0ffd444112eda41a0fd",
"reference": "9accb4a082eb06403747c0ffd444112eda41a0fd",
"shasum": ""
},
"require": {
"php": ">=5.4",
"php": "^5.4 || ^7.0",
"php-http/httplug": "^1.1",
"php-http/message": "^1.2",
"php-http/message": "^1.6",
"php-http/message-factory": "^1.0",
"symfony/options-resolver": "^2.6 || ^3.0"
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0"
},
"require-dev": {
"henrikbjorn/phpspec-code-coverage": "^1.0",
"phpspec/phpspec": "^2.4"
"guzzlehttp/psr7": "^1.4",
"phpspec/phpspec": "^2.5 || ^3.4 || ^4.2"
},
"suggest": {
"php-http/cache-plugin": "PSR-6 Cache plugin",
@ -904,7 +951,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.5-dev"
"dev-master": "1.7-dev"
}
},
"autoload": {
@ -930,7 +977,7 @@
"http",
"httplug"
],
"time": "2017-03-30T12:50:04+00:00"
"time": "2017-11-30T11:06:59+00:00"
},
{
"name": "php-http/discovery",
@ -1284,16 +1331,16 @@
},
{
"name": "phpmailer/phpmailer",
"version": "v6.0.1",
"version": "v6.0.2",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "992392437c2e2784e0dc41446024fe411d293c96"
"reference": "7a4459cff6abeb86b63cdbad760f567252f3f39c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/992392437c2e2784e0dc41446024fe411d293c96",
"reference": "992392437c2e2784e0dc41446024fe411d293c96",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/7a4459cff6abeb86b63cdbad760f567252f3f39c",
"reference": "7a4459cff6abeb86b63cdbad760f567252f3f39c",
"shasum": ""
},
"require": {
@ -1345,7 +1392,7 @@
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"time": "2017-09-14T16:47:12+00:00"
"time": "2017-11-30T17:20:24+00:00"
},
{
"name": "pimple/pimple",
@ -1639,16 +1686,16 @@
},
{
"name": "slim/slim",
"version": "3.8.1",
"version": "3.9.2",
"source": {
"type": "git",
"url": "https://github.com/slimphp/Slim.git",
"reference": "5385302707530b2bccee1769613ad769859b826d"
"reference": "4086d0106cf5a7135c69fce4161fe355a8feb118"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/5385302707530b2bccee1769613ad769859b826d",
"reference": "5385302707530b2bccee1769613ad769859b826d",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/4086d0106cf5a7135c69fce4161fe355a8feb118",
"reference": "4086d0106cf5a7135c69fce4161fe355a8feb118",
"shasum": ""
},
"require": {
@ -1706,7 +1753,7 @@
"micro",
"router"
],
"time": "2017-03-19T17:55:20+00:00"
"time": "2017-11-26T19:13:09+00:00"
},
{
"name": "slim/twig-view",
@ -1760,25 +1807,25 @@
},
{
"name": "symfony/options-resolver",
"version": "v3.3.9",
"version": "v4.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "ee4e22978fe885b54ee5da8c7964f0a5301abfb6"
"reference": "ef617a2867c7d889d4ecee3c29595698d87474a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/ee4e22978fe885b54ee5da8c7964f0a5301abfb6",
"reference": "ee4e22978fe885b54ee5da8c7964f0a5301abfb6",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/ef617a2867c7d889d4ecee3c29595698d87474a4",
"reference": "ef617a2867c7d889d4ecee3c29595698d87474a4",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
"php": "^7.1.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
"dev-master": "4.0-dev"
}
},
"autoload": {
@ -1810,20 +1857,20 @@
"configuration",
"options"
],
"time": "2017-07-29T21:54:42+00:00"
"time": "2017-11-07T14:45:01+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.5.0",
"version": "v1.6.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803"
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7c8fae0ac1d216eb54349e6a8baa57d515fe8803",
"reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
"shasum": ""
},
"require": {
@ -1835,7 +1882,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.5-dev"
"dev-master": "1.6-dev"
}
},
"autoload": {
@ -1869,20 +1916,20 @@
"portable",
"shim"
],
"time": "2017-06-14T15:44:48+00:00"
"time": "2017-10-11T12:05:26+00:00"
},
{
"name": "twig/twig",
"version": "v2.4.3",
"version": "v2.4.4",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "eab7c3288ae6603d7d6f92b531626af2b162d1f2"
"reference": "eddb97148ad779f27e670e1e3f19fb323aedafeb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/eab7c3288ae6603d7d6f92b531626af2b162d1f2",
"reference": "eab7c3288ae6603d7d6f92b531626af2b162d1f2",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/eddb97148ad779f27e670e1e3f19fb323aedafeb",
"reference": "eddb97148ad779f27e670e1e3f19fb323aedafeb",
"shasum": ""
},
"require": {
@ -1935,7 +1982,7 @@
"keywords": [
"templating"
],
"time": "2017-06-07T18:47:58+00:00"
"time": "2017-09-27T18:10:31+00:00"
}
],
"packages-dev": [],

View file

@ -44,3 +44,19 @@ define('FORBIDDEN_EXTENSIONS', ['swf', 'js', 'html', 'htm']);
*/
define('MATOMO_URL', false);
define('MATOMO_ID', false);
/**
* Number of pages to show before and after the current page in the pagination. e.g. default (5) on page 37:
* < 1 ... 32 33 34 35 36 *37** 38 39 40 40 42 ... 115 >
*/
define("PAGINATION_PADDING", 5);
/**
* used in sitemap (without trailing slash)
*/
define("BASE_DOMAIN", "https://issues.matomo.org");
/**
* URL to privacy policy (linked in footer)
*/
define("PRIVACY_POLICY_URL", "https://matomo.org/privacy-policy/");

View file

@ -25,6 +25,17 @@ class Issue {
return json_decode($serialized, true);
}
public static function getAllIssues() {
$Directory = new \RecursiveDirectoryIterator(dirname(__FILE__) . "/../data/issues/");
$Iterator = new \RecursiveIteratorIterator($Directory);
$issues = [];
foreach ($Iterator as $name => $object) {
$filename = $object->getFilename();
$issues[] = str_replace(".json", "", $filename);
}
return $issues;
}
/**
* Verify whether the given issue exists.
* @param int $issueNumber

View file

@ -25,6 +25,11 @@ class Page
return json_decode($content, true);
}
public static function getAllPages() {
$files = scandir(dirname(__FILE__) . "/../data/pages/");
return str_replace(".json", "", array_diff($files, array('..', '.', '.gitkeep')));
}
/**
* Verify whether the given page number exists.
* @param int $pageNumber

View file

@ -0,0 +1,46 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace helpers;
use Monolog\Logger;
use SitemapPHP\Sitemap;
use Slim\App;
class SitemapHelper
{
public static function createSitemap(Logger $logger) {
$app = new App();
require "../routes/page.php";
$sitemap = new Sitemap(BASE_DOMAIN);
$sitemap->setPath('../tmp/');
$logger->info("fetching all pages for sitemap");
$pages = Page::getAllPages();
natsort($pages);
foreach ($pages as $pageNumber) {
$url = $app->getContainer()->get('router')->pathFor('page', [], [
'page' => $pageNumber
]);
$sitemap->addItem($url, 0.2);
}
$logger->info("fetching all issues for sitemap");
$issues = Issue::getAllIssues();
natsort($issues);
foreach ($issues as $issueNumber) {
$url = $app->getContainer()->get('router')->pathFor('issue', [
'number' => $issueNumber
]);
$sitemap->addItem($url, 0.5);
}
$logger->info("generating sitemap");
$sitemap->createSitemapIndex(BASE_DOMAIN . "/", 'Today');
}
}

View file

@ -45,7 +45,8 @@ class Twig
}
private static function getPaginationFunction() {
return new \Twig_Function('paginationFunction', function ($numPages, $page, $padding = 2) {
return new \Twig_Function('paginationFunction', function ($numPages, $page) {
$padding = PAGINATION_PADDING;
$pages = [1];
$i = 2;
while ($i <= $numPages) {

561
src/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,17 @@
{
"name": "src",
"name": "github-issue-mirror",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"bootstrap": "^4.0.0-beta",
"node-sass": "^4.5.3"
"bootstrap": "^4.0.0",
"node-sass": "^4.7.2"
},
"devDependencies": {},
"scripts": {
"compileCSS": "node-sass --recursive --output-style compressed --output public/css --source-map true --source-map-contents scss",
"watchSCSS": "node-sass --watch --recursive --output-style compressed --output public/css --source-map true --source-map-contents scss"
},
"author": "",
"license": "ISC"
"author": "Piwik Team",
"license": "GPL3"
}

8
src/public/css/style.css Normal file

File diff suppressed because one or more lines are too long

View file

@ -12,7 +12,7 @@ require '../config/config.php';
date_default_timezone_set('UTC');
$config = [
'settings' => [
'displayErrorDetails' => true,
'displayErrorDetails' => DEBUG_ENABLED,
],
];
@ -41,6 +41,7 @@ $container['view'] = function ($container) {
$view->getEnvironment()->addGlobal('githubRepository', GITHUB_REPOSITORY);
$view->getEnvironment()->addGlobal('matomoURL', MATOMO_URL);
$view->getEnvironment()->addGlobal('matomoID', MATOMO_ID);
$view->getEnvironment()->addGlobal('privacyPolicyURL', PRIVACY_POLICY_URL);
return $view;
};

View file

@ -0,0 +1 @@
../tmp/sitemap-index.xml

1
src/public/sitemap.xml Symbolic link
View file

@ -0,0 +1 @@
../tmp/sitemap.xml

View file

@ -29,6 +29,7 @@ $importer = new helpers\GithubImporter($client, $logger);
try {
$logger->info("starting import");
$importer->import(GITHUB_ORGANIZATION, GITHUB_REPOSITORY, NUMBER_OF_ISSUES_PER_PAGE);
helpers\SitemapHelper::createSitemap($logger);
} catch (Exception $e) {
helpers\Mail::sendEmail('Import error', $e->getMessage(), PROJECT_EMAIL, PROJECT_EMAIL);

View file

@ -22,6 +22,11 @@
<div class="col-md-6">
Powered by <a target="_blank" href="https://github.com/matomo-org/github-issues-mirror">GitHub Issue Mirror</a>
</div>
{% if privacyPolicyURL %}
<div class="col-md-6 text-right">
<a href="{{privacyPolicyURL}}">Privacy Policy</a>
</div>
{% endif %}
</div>
</div>

View file

@ -16,7 +16,7 @@
{% macro pagination(num_pages, page) %}
{% import _self as m %}
{% set pagearray = paginationFunction(num_pages, page,5) %}
{% set pagearray = paginationFunction(num_pages, page) %}
<!-- License of svg icons - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) -->
<ul class="pagination">
{% if page > 1 %}