diff --git a/.travis.yml b/.travis.yml index d913cc55..9b4749a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,12 @@ install: - composer install --ignore-platform-reqs php: - - 7.4 - nightly script: - mkdir -p build/logs - php vendor/bin/phpunit -c build -matrix: - allow_failures: - - php: nightly +#matrix: +# allow_failures: +# - php: nightly diff --git a/Jenkinsfile b/Jenkinsfile index c94da53f..48232ea7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,10 +10,10 @@ pipeline { sh 'php composer.phar install --ignore-platform-reqs' } } - stage('PHP 7.4') { + stage('PHP 8') { agent { docker { - image 'php:7.4-alpine' + image 'php:8-cli-alpine' args '-u root --privileged' } } @@ -25,7 +25,7 @@ pipeline { stage('Latest PHP') { agent { docker { - image 'php:alpine' + image 'php:cli-alpine' args '-u root --privileged' } } diff --git a/RoboFile.php b/RoboFile.php index 59003dfb..26749f7e 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -30,7 +30,7 @@ class RoboFile extends Tasks { * * @var array */ - protected $taskDirs = [ + protected array $taskDirs = [ 'build/logs', 'build/pdepend', 'build/phpdox', @@ -41,7 +41,7 @@ class RoboFile extends Tasks { * * @var array */ - protected $cleanDirs = [ + protected array $cleanDirs = [ 'coverage', 'docs', 'phpdoc', diff --git a/app/appConf/base_config.php b/app/appConf/base_config.php index 18a96c66..612592ca 100644 --- a/app/appConf/base_config.php +++ b/app/appConf/base_config.php @@ -14,7 +14,7 @@ * @link https://github.com/timw4mail/HummingBirdAnimeClient */ -use function Aviat\AnimeClient\loadToml; +use function Aviat\AnimeClient\loadConfig; // ---------------------------------------------------------------------------- // Lower level configuration @@ -24,7 +24,7 @@ use function Aviat\AnimeClient\loadToml; $APP_DIR = realpath(__DIR__ . '/../'); $ROOT_DIR = realpath("{$APP_DIR}/../"); -$tomlConfig = loadToml(__DIR__); +$tomlConfig = loadConfig(__DIR__); return array_merge($tomlConfig, [ 'asset_dir' => "{$ROOT_DIR}/public", diff --git a/app/appConf/routes.php b/app/appConf/routes.php index 48f3a357..e5d5de3a 100644 --- a/app/appConf/routes.php +++ b/app/appConf/routes.php @@ -51,6 +51,10 @@ $routes = [ 'action' => 'add', 'verb' => 'post', ], + 'anime.random' => [ + 'path' => '/anime/details/random', + 'action' => 'random', + ], 'anime.details' => [ 'path' => '/anime/details/{id}', 'action' => 'details', @@ -84,6 +88,10 @@ $routes = [ 'action' => 'delete', 'verb' => 'post', ], + 'manga.random' => [ + 'path' => '/manga/details/random', + 'action' => 'random', + ], 'manga.details' => [ 'path' => '/manga/details/{id}', 'action' => 'details', @@ -247,6 +255,13 @@ $routes = [ 'path' => '/logout', 'action' => 'logout', ], + 'history' => [ + 'controller' => 'history', + 'path' => '/history/{type}', + 'tokens' => [ + 'type' => SLUG_PATTERN + ] + ], 'increment' => [ 'path' => '/{controller}/increment', 'action' => 'increment', @@ -280,19 +295,12 @@ $routes = [ ], ], 'list' => [ - 'path' => '/{controller}/{type}{/view}', + 'path' => '/{controller}/{status}{/view}', 'tokens' => [ - 'type' => ALPHA_SLUG_PATTERN, + 'status' => ALPHA_SLUG_PATTERN, 'view' => ALPHA_SLUG_PATTERN, ], ], - 'history' => [ - 'controller' => 'history', - 'path' => '/history/{type}', - 'tokens' => [ - 'type' => SLUG_PATTERN - ] - ], 'index_redirect' => [ 'path' => '/', 'action' => 'redirectToDefaultRoute', diff --git a/app/bootstrap.php b/app/bootstrap.php index 149c1c2a..41ec2e38 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -4,13 +4,13 @@ * * An API client for Kitsu to manage anime and manga watch lists * - * PHP version 7.4 + * PHP version 7.4+ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright 2015 - 2020 Timothy J. Warren + * @copyright 2015 - 2021 Timothy J. Warren * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @version 5.1 + * @version 5.2 * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient */ @@ -32,10 +32,13 @@ use Monolog\Handler\RotatingFileHandler; use Monolog\Logger; use Psr\SimpleCache\CacheInterface; +use function Aviat\Ion\_dir; + if ( ! defined('APP_DIR')) { define('APP_DIR', __DIR__); - define('TEMPLATE_DIR', APP_DIR . '/templates'); + define('ROOT_DIR', dirname(APP_DIR)); + define('TEMPLATE_DIR', _dir(APP_DIR, 'templates')); } // ----------------------------------------------------------------------------- @@ -47,15 +50,16 @@ return static function (array $configArray = []): Container { // ------------------------------------------------------------------------- // Logging // ------------------------------------------------------------------------- + $LOG_DIR = _dir(APP_DIR, 'logs'); $appLogger = new Logger('animeclient'); - $appLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/app.log', 2, Logger::WARNING)); + $appLogger->pushHandler(new RotatingFileHandler(_dir($LOG_DIR, 'app.log'), 2, Logger::WARNING)); $container->setLogger($appLogger); foreach (['anilist-request', 'kitsu-request', 'kitsu-graphql'] as $channel) { $logger = new Logger($channel); - $handler = new RotatingFileHandler(__DIR__ . "/logs/{$channel}.log", 2, Logger::WARNING); + $handler = new RotatingFileHandler(_dir($LOG_DIR, "{$channel}.log"), 2, Logger::WARNING); $handler->setFormatter(new JsonFormatter()); $logger->pushHandler($handler); @@ -67,7 +71,7 @@ return static function (array $configArray = []): Container { // ------------------------------------------------------------------------- // Create Config Object - $container->set('config', fn () => new Config($configArray)); + $container->set('config', static fn () => new Config($configArray)); // Create Cache Object $container->set('cache', static function(ContainerInterface $container): CacheInterface { @@ -77,7 +81,7 @@ return static function (array $configArray = []): Container { }); // Create Aura Router Object - $container->set('aura-router', fn() => new RouterContainer); + $container->set('aura-router', static fn() => new RouterContainer); // Create Html helpers $container->set('html-helper', static function(ContainerInterface $container) { @@ -125,8 +129,8 @@ return static function (array $configArray = []): Container { }); // Create Request Object - $container->set('request', fn () => ServerRequestFactory::fromGlobals( - $_SERVER, + $container->set('request', static fn () => ServerRequestFactory::fromGlobals( + $GLOBALS['_SERVER'], $_GET, $_POST, $_COOKIE, @@ -134,10 +138,10 @@ return static function (array $configArray = []): Container { )); // Create session Object - $container->set('session', fn () => (new SessionFactory())->newInstance($_COOKIE)); + $container->set('session', static fn () => (new SessionFactory())->newInstance($_COOKIE)); // Miscellaneous helper methods - $container->set('util', fn ($container) => new Util($container)); + $container->set('util', static fn ($container) => new Util($container)); // Models $container->set('kitsu-model', static function(ContainerInterface $container): Kitsu\Model { @@ -170,10 +174,10 @@ return static function (array $configArray = []): Container { return $model; }); - $container->set('anime-model', fn ($container) => new Model\Anime($container)); - $container->set('manga-model', fn ($container) => new Model\Manga($container)); - $container->set('anime-collection-model', fn ($container) => new Model\AnimeCollection($container)); - $container->set('manga-collection-model', fn ($container) => new Model\MangaCollection($container)); + $container->set('anime-model', static fn ($container) => new Model\Anime($container)); + $container->set('manga-model', static fn ($container) => new Model\Manga($container)); + $container->set('anime-collection-model', static fn ($container) => new Model\AnimeCollection($container)); + $container->set('manga-collection-model', static fn ($container) => new Model\MangaCollection($container)); $container->set('settings-model', static function($container) { $model = new Model\Settings($container->get('config')); $model->setContainer($container); @@ -181,13 +185,13 @@ return static function (array $configArray = []): Container { }); // Miscellaneous Classes - $container->set('auth', fn ($container) => new Kitsu\Auth($container)); - $container->set('url-generator', fn ($container) => new UrlGenerator($container)); + $container->set('auth', static fn ($container) => new Kitsu\Auth($container)); + $container->set('url-generator', static fn ($container) => new UrlGenerator($container)); // ------------------------------------------------------------------------- // Dispatcher // ------------------------------------------------------------------------- - $container->set('dispatcher', fn ($container) => new Dispatcher($container)); + $container->set('dispatcher', static fn ($container) => new Dispatcher($container)); return $container; }; diff --git a/app/templates/anime-cover.php b/app/templates/anime-cover.php index aef5ec2b..5715d0d2 100644 --- a/app/templates/anime-cover.php +++ b/app/templates/anime-cover.php @@ -18,7 +18,7 @@
- +
diff --git a/app/views/main-menu.php b/app/views/main-menu.php index 39d68032..c6b45276 100644 --- a/app/views/main-menu.php +++ b/app/views/main-menu.php @@ -5,8 +5,8 @@ namespace Aviat\AnimeClient; $whose = $config->get('whose_list') . "'s "; $lastSegment = $urlGenerator->lastSegment(); $extraSegment = $lastSegment === 'list' ? '/list' : ''; -$hasAnime = stripos($_SERVER['REQUEST_URI'], 'anime') !== FALSE; -$hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') !== FALSE; +$hasAnime = stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'anime') !== FALSE; +$hasManga = stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'manga') !== FALSE; ?>