Various tweaking

This commit is contained in:
Timothy Warren 2017-02-17 08:25:19 -05:00
parent 856aaec7ca
commit 58549b7018
13 changed files with 138 additions and 81 deletions

View File

@ -1,4 +1,7 @@
<?php <?php declare(strict_types=1);
use Robo\Tasks;
if ( ! function_exists('glob_recursive')) if ( ! function_exists('glob_recursive'))
{ {
// Does not support flag GLOB_BRACE // Does not support flag GLOB_BRACE
@ -20,7 +23,7 @@ if ( ! function_exists('glob_recursive'))
* *
* @see http://robo.li/ * @see http://robo.li/
*/ */
class RoboFile extends \Robo\Tasks { class RoboFile extends Tasks {
/** /**
* Directories used by analysis tools * Directories used by analysis tools
@ -102,10 +105,11 @@ class RoboFile extends \Robo\Tasks {
*/ */
public function coverage() public function coverage()
{ {
$this->taskPhpUnit() $this->_run(['vendor/bin/phpunit -c build']);
/* $this->taskPhpUnit()
->configFile('build/phpunit.xml') ->configFile('build/phpunit.xml')
->printed(true) ->printed(true)
->run(); ->run(); */
} }
/** /**
@ -128,7 +132,7 @@ class RoboFile extends \Robo\Tasks {
{ {
$files = $this->getAllSourceFiles(); $files = $this->getAllSourceFiles();
$chunks = array_chunk($files, 6); $chunks = array_chunk($files, 12);
foreach($chunks as $chunk) foreach($chunks as $chunk)
{ {
@ -136,29 +140,6 @@ class RoboFile extends \Robo\Tasks {
} }
} }
/**
* Run mutation tests with humbug
*
* @param bool $stats - if true, generates stats rather than running mutation tests
*/
public function mutate($stats = FALSE)
{
$test_parts = [
'vendor/bin/humbug'
];
$stat_parts = [
'vendor/bin/humbug',
'--skip-killed=yes',
'-v',
'./build/humbug.json'
];
$cmd_parts = ($stats) ? $stat_parts : $test_parts;
$this->_run($cmd_parts);
}
/** /**
* Run the phpcs tool * Run the phpcs tool
* *
@ -226,10 +207,13 @@ class RoboFile extends \Robo\Tasks {
public function test() public function test()
{ {
$this->lint(); $this->lint();
$this->taskPHPUnit()
$this->_run(['phpunit']);
/*$this->taskPHPUnit()
->configFile('phpunit.xml') ->configFile('phpunit.xml')
->printed(true) ->printed(true)
->run(); ->run();*/
} }
/** /**
@ -275,7 +259,9 @@ class RoboFile extends \Robo\Tasks {
$files = array_merge( $files = array_merge(
glob_recursive('build/*.php'), glob_recursive('build/*.php'),
glob_recursive('src/*.php'), glob_recursive('src/*.php'),
glob_recursive('src/**/*.php'),
glob_recursive('tests/*.php'), glob_recursive('tests/*.php'),
glob_recursive('tests/**/*.php'),
glob('*.php') glob('*.php')
); );

View File

@ -28,7 +28,13 @@
<?php if ($auth->isAuthenticated()): ?> <?php if ($auth->isAuthenticated()): ?>
<div class="row"> <div class="row">
<span class="edit"> <span class="edit">
<a class="bracketed" title="Edit information about this anime" href="<?= $urlGenerator->url("anime/edit/{$item['id']}/{$item['watching_status']}") ?>">Edit</a> <a class="bracketed" title="Edit information about this anime" href="<?=
$url->generate('edit', [
'controller' => 'anime',
'id' => $item['id'],
'status' => $item['watching_status']
]);
?>">Edit</a>
</span> </span>
</div> </div>
<?php endif ?> <?php endif ?>

View File

@ -6,8 +6,8 @@
<meta http-equiv="cache-control" content="no-store" /> <meta http-equiv="cache-control" content="no-store" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self'" /> <meta http-equiv="Content-Security-Policy" content="script-src 'self'" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0" />
<link rel="icon" href="favicon.ico" /> <link rel="icon" href="<?= $urlGenerator->assetUrl('favicon.ico') ?>" />
<link rel="stylesheet" href="<?= $urlGenerator->assetUrl('css.php/g/base') ?>" /> <link rel="stylesheet" href="<?= $urlGenerator->assetUrl('css.php/g/base/debug') ?>" />
<script defer="defer" src="<?= $urlGenerator->assetUrl('js.php/g/base') ?>"></script> <script defer="defer" src="<?= $urlGenerator->assetUrl('js.php/g/base') ?>"></script>
</head> </head>
<body class="<?= $escape->attr($url_type) ?> list"> <body class="<?= $escape->attr($url_type) ?> list">
@ -16,7 +16,7 @@
<?php if(isset($message) && is_array($message)): <?php if(isset($message) && is_array($message)):
foreach($message as $m) foreach($message as $m)
{ {
extract($message); extract($m);
include 'message.php'; include 'message.php';
} }
endif ?> endif ?>

View File

@ -34,7 +34,7 @@
"require-dev": { "require-dev": {
"pdepend/pdepend": "^2.2", "pdepend/pdepend": "^2.2",
"sebastian/phpcpd": "^3.0", "sebastian/phpcpd": "^3.0",
"theseer/phpdox": "^0.9.0", "theseer/phpdox": "*",
"phploc/phploc": "^3.0", "phploc/phploc": "^3.0",
"phpmd/phpmd": "^2.4", "phpmd/phpmd": "^2.4",
"phpunit/phpunit": "^6.0", "phpunit/phpunit": "^6.0",
@ -46,6 +46,8 @@
}, },
"scripts": { "scripts": {
"build:css": "cd public && npm run build && cd ..", "build:css": "cd public && npm run build && cd ..",
"watch:css": "cd public && npm run watch" "coverage": "vendor/bin/phpunit -c build",
"watch:css": "cd public && npm run watch",
"test": "vendor/bin/phpunit"
} }
} }

View File

@ -1044,6 +1044,7 @@ a:hover, a:active {
.medium_metadata > div, .medium_metadata > div,
.row { .row {
text-shadow:1px 2px 1px rgba(0, 0, 0, .85); text-shadow:1px 2px 1px rgba(0, 0, 0, .85);
background:#000;
background:rgba(0, 0, 0, .45); background:rgba(0, 0, 0, .45);
color:#ffffff; color:#ffffff;
padding:0.25em 0.125em; padding:0.25em 0.125em;
@ -1127,6 +1128,7 @@ a:hover, a:active {
.anime .row, .manga .row { .anime .row, .manga .row {
width:100%; width:100%;
background:#000;
background:rgba(0, 0, 0, .45); background:rgba(0, 0, 0, .45);
display: -webkit-box; display: -webkit-box;
display: -ms-flexbox; display: -ms-flexbox;

View File

@ -4,6 +4,7 @@
--link-shadow: 1px 1px 1px #000; --link-shadow: 1px 1px 1px #000;
--shadow: 1px 2px 1px rgba(0, 0, 0, 0.85); --shadow: 1px 2px 1px rgba(0, 0, 0, 0.85);
--title-overlay: rgba(0, 0, 0, 0.45); --title-overlay: rgba(0, 0, 0, 0.45);
--title-overlay-fallback: #000;
--text-color: #ffffff; --text-color: #ffffff;
--normal-padding: 0.25em 0.125em; --normal-padding: 0.25em 0.125em;
--link-hover-color: #7d12db; --link-hover-color: #7d12db;
@ -315,6 +316,7 @@ a:hover, a:active {
.medium_metadata > div, .medium_metadata > div,
.row { .row {
text-shadow: var(--shadow); text-shadow: var(--shadow);
background: var(--title-overlay-fallback);
background: var(--title-overlay); background: var(--title-overlay);
color: var(--text-color); color: var(--text-color);
padding: var(--normal-padding); padding: var(--normal-padding);
@ -398,6 +400,7 @@ a:hover, a:active {
.anime .row, .manga .row { .anime .row, .manga .row {
width:100%; width:100%;
background: var(--title-overlay-fallback);
background: var(--title-overlay); background: var(--title-overlay);
display: flex; display: flex;
align-content: space-around; align-content: space-around;

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,83 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2017 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://github.com/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API;
use function Amp\{all, some, wait};
use Amp\Artax\Client;
/**
* Class to simplify making and validating simultaneous requests
*/
class ParallelAPIRequest {
/**
* Set of requests to make in parallel
*
* @var array
*/
protected $requests = [];
/**
* Add a request
*
* @param string|Request $request
* @param string|number $key
* @return self
*/
public function addRequest($request, $key = null): self
{
if ( ! is_null($key))
{
$this->requests[$key] = $request;
return $this;
}
$this->requests[] = $request;
return $this;
}
/**
* Add multiple requests
*
* @param string[]|Request[] $requests
* @return self
*/
public function addRequests(array $requests): self
{
array_walk($requests, [$this, 'addRequest']);
return $this;
}
/**
* Actually make the requests
*
* @param bool $allowFailingRequests
* @return array
*/
public function makeRequests(bool $allowFailingRequests = FALSE): array
{
$client = new Client();
$promises = $client->requestMulti($this->requests);
$func = ($allowFailingRequests) ? 'some' : 'all';
$results = wait($func($promises));
return $results;
}
}

View File

@ -97,10 +97,14 @@ class Controller {
$this->config = $container->get('config'); $this->config = $container->get('config');
$this->request = $container->get('request'); $this->request = $container->get('request');
$this->response = $container->get('response'); $this->response = $container->get('response');
$this->baseData['url'] = $auraUrlGenerator;
$this->baseData['urlGenerator'] = $urlGenerator; $this->baseData = array_merge((array)$this->baseData, [
$this->baseData['auth'] = $container->get('auth'); 'url' => $auraUrlGenerator,
$this->baseData['config'] = $this->config; 'urlGenerator' => $urlGenerator,
'auth' => $container->get('auth'),
'config' => $this->config
]);
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
$session = $container->get('session'); $session = $container->get('session');

View File

@ -158,12 +158,12 @@ class Anime extends BaseController {
if ($result) if ($result)
{ {
$this->set_flash_message('Added new anime to list', 'success'); $this->setFlashMessage('Added new anime to list', 'success');
$this->cache->clear(); $this->cache->clear();
} }
else else
{ {
$this->set_flash_message('Failed to add new anime to list', 'error'); $this->setFlashMessage('Failed to add new anime to list', 'error');
} }
$this->sessionRedirect(); $this->sessionRedirect();
@ -232,12 +232,12 @@ class Anime extends BaseController {
if ($fullResult['statusCode'] === 200) if ($fullResult['statusCode'] === 200)
{ {
$this->set_flash_message("Successfully updated.", 'success'); $this->setFlashMessage("Successfully updated.", 'success');
$this->cache->clear(); $this->cache->clear();
} }
else else
{ {
$this->set_flash_message('Failed to update anime.', 'error'); $this->setFlashMessage('Failed to update anime.', 'error');
} }
$this->sessionRedirect(); $this->sessionRedirect();
@ -277,12 +277,12 @@ class Anime extends BaseController {
if ((bool)$response === TRUE) if ((bool)$response === TRUE)
{ {
$this->set_flash_message("Successfully deleted anime.", 'success'); $this->setFlashMessage("Successfully deleted anime.", 'success');
$this->cache->clear(); $this->cache->clear();
} }
else else
{ {
$this->set_flash_message('Failed to delete anime.', 'error'); $this->setFlashMessage('Failed to delete anime.', 'error');
} }
$this->sessionRedirect(); $this->sessionRedirect();

View File

@ -16,7 +16,6 @@
namespace Aviat\AnimeClient\Model; namespace Aviat\AnimeClient\Model;
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
use Aviat\Ion\Model; use Aviat\Ion\Model;
/** /**
@ -24,31 +23,6 @@ use Aviat\Ion\Model;
*/ */
class API extends Model { class API extends Model {
use ContainerAware;
/**
* Config manager
* @var ConfigInterface
*/
protected $config;
/**
* Cache manager
* @var \Psr\Cache\CacheItemPoolInterface
*/
protected $cache;
/**
* Constructor
*
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
$this->config = $container->get('config');
}
/** /**
* Sort the list entries by their title * Sort the list entries by their title
* *

View File

@ -18,6 +18,7 @@ namespace Aviat\AnimeClient\Model;
use function Amp\some; use function Amp\some;
use function Amp\wait; use function Amp\wait;
use Amp\Artax\Client; use Amp\Artax\Client;
use Aviat\AnimeClient\API\Kitsu\Enum\AnimeWatchingStatus; use Aviat\AnimeClient\API\Kitsu\Enum\AnimeWatchingStatus;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
@ -58,8 +59,6 @@ class Anime extends API {
* @param ContainerInterface $container * @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) { public function __construct(ContainerInterface $container) {
parent::__construct($container);
$config = $container->get('config'); $config = $container->get('config');
$this->kitsuModel = $container->get('kitsu-model'); $this->kitsuModel = $container->get('kitsu-model');
$this->malModel = $container->get('mal-model'); $this->malModel = $container->get('mal-model');

View File

@ -36,7 +36,7 @@ class Manga extends API
* Map API constants to display constants * Map API constants to display constants
* @var array * @var array
*/ */
protected $const_map = [ protected $constMap = [
MangaReadingStatus::READING => self::READING, MangaReadingStatus::READING => self::READING,
MangaReadingStatus::PLAN_TO_READ => self::PLAN_TO_READ, MangaReadingStatus::PLAN_TO_READ => self::PLAN_TO_READ,
MangaReadingStatus::ON_HOLD => self::ON_HOLD, MangaReadingStatus::ON_HOLD => self::ON_HOLD,
@ -44,7 +44,7 @@ class Manga extends API
MangaReadingStatus::COMPLETED => self::COMPLETED MangaReadingStatus::COMPLETED => self::COMPLETED
]; ];
protected $status_map = [ protected $statusMap = [
'current' => self::READING, 'current' => self::READING,
'planned' => self::PLAN_TO_READ, 'planned' => self::PLAN_TO_READ,
'completed' => self::COMPLETED, 'completed' => self::COMPLETED,
@ -59,8 +59,6 @@ class Manga extends API
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
parent::__construct($container);
$this->kitsuModel = $container->get('kitsu-model'); $this->kitsuModel = $container->get('kitsu-model');
} }
@ -72,7 +70,7 @@ class Manga extends API
*/ */
public function getList($status) public function getList($status)
{ {
$APIstatus = array_flip($this->const_map)[$status]; $APIstatus = array_flip($this->constMap)[$status];
$data = $this->kitsuModel->getMangaList($APIstatus); $data = $this->kitsuModel->getMangaList($APIstatus);
return $this->mapByStatus($data)[$status]; return $this->mapByStatus($data)[$status];
} }
@ -161,7 +159,7 @@ class Manga extends API
]; ];
foreach ($data as &$entry) { foreach ($data as &$entry) {
$key = $this->status_map[$entry['reading_status']]; $key = $this->statusMap[$entry['reading_status']];
$output[$key][] = $entry; $output[$key][] = $entry;
} }