From 06213df29f74fbf4a35611d545eaa8d4e35e51aa Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Mon, 17 Apr 2017 16:13:36 -0400 Subject: [PATCH] Miscellaneous code cleanup --- README.md | 4 ++++ console | 4 ++-- src/API/Kitsu/Model.php | 10 +++++----- src/Command/SyncKitsuWithMal.php | 8 -------- src/Controller/Index.php | 2 +- src/MenuGenerator.php | 2 +- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c8d5d2ca..9bdcd556 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,10 @@ Update your anime/manga list on Kitsu.io and MyAnimeList.net 3. Configure settings in `app/config/config.toml` to your liking 4. Create the following directories if they don't exist, and make sure they are world writable * public/js/cache + * public/images/avatars + * public/images/anime + * public/images/characters + * public/images/manga 5. Make sure the `console` script is executable ### Using MAL API diff --git a/console b/console index 3a7c90fc..674a96e5 100755 --- a/console +++ b/console @@ -18,9 +18,9 @@ unset($APP_DIR); unset($SRC_DIR); unset($CONF_DIR); -// --------------------------------------------------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // Start console script -// --------------------------------------------------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- $console = new \ConsoleKit\Console([ 'cache-prime' => Command\CachePrime::class, 'cache-clear' => Command\CacheClear::class, diff --git a/src/API/Kitsu/Model.php b/src/API/Kitsu/Model.php index 1f5d6891..88b109fd 100644 --- a/src/API/Kitsu/Model.php +++ b/src/API/Kitsu/Model.php @@ -47,7 +47,7 @@ class Model { use ContainerAware; use KitsuTrait; - const FULL_TRANSFORMED_LIST_CACHE_KEY = 'kitsu-full-organized-anime-list'; + const LIST_PAGE_SIZE = 100; /** * Class to map anime list items @@ -382,7 +382,7 @@ class Model { { $status = $options['filter']['status'] ?? ''; $count = $this->getAnimeListCount($status); - $size = 100; + $size = static::LIST_PAGE_SIZE; $pages = ceil($count / $size); $requester = new ParallelAPIRequest(); @@ -468,7 +468,7 @@ class Model { * @param array $options * @return Request */ - public function getPagedAnimeList(int $limit = 100, int $offset = 0, array $options = [ + public function getPagedAnimeList(int $limit, int $offset = 0, array $options = [ 'include' => 'anime.mappings' ]): Request { @@ -626,7 +626,7 @@ class Model { { $status = $options['filter']['status'] ?? ''; $count = $this->getMangaListCount($status); - $size = 100; + $size = static::LIST_PAGE_SIZE; $pages = ceil($count / $size); $requester = new ParallelAPIRequest(); @@ -676,7 +676,7 @@ class Model { * @param array $options * @return Request */ - public function getPagedMangaList(int $limit = 100, int $offset = 0, array $options = [ + public function getPagedMangaList(int $limit, int $offset = 0, array $options = [ 'include' => 'manga.mappings' ]): Request { diff --git a/src/Command/SyncKitsuWithMal.php b/src/Command/SyncKitsuWithMal.php index 9218eaec..6af414ca 100644 --- a/src/Command/SyncKitsuWithMal.php +++ b/src/Command/SyncKitsuWithMal.php @@ -149,10 +149,6 @@ class SyncKitsuWithMal extends BaseCommand { 'status' => AnimeWatchingStatus::MAL_TO_KITSU[$item['my_status']], 'progress' => $item['my_watched_episodes'], 'reconsuming' => (bool) $item['my_rewatching'], - 'reconsumeCount' => array_key_exists('times_rewatched', $item) - ? $item['times_rewatched'] - : 0, - // 'notes' => , 'rating' => $item['my_score'] / 2, 'updatedAt' => (new \DateTime()) ->setTimestamp((int)$item['my_last_updated']) @@ -179,10 +175,6 @@ class SyncKitsuWithMal extends BaseCommand { 'progress' => $item['my_read_chapters'], 'volumes' => $item['my_read_volumes'], 'reconsuming' => (bool) $item['my_rereadingg'], - /* 'reconsumeCount' => array_key_exists('times_rewatched', $item) - ? $item['times_rewatched'] - : 0, */ - // 'notes' => , 'rating' => $item['my_score'] / 2, 'updatedAt' => (new \DateTime()) ->setTimestamp((int)$item['my_last_updated']) diff --git a/src/Controller/Index.php b/src/Controller/Index.php index db14c01b..6eb48148 100644 --- a/src/Controller/Index.php +++ b/src/Controller/Index.php @@ -111,7 +111,7 @@ class Index extends BaseController { $data = $model->getUserData($username); $orgData = JsonAPI::organizeData($data); $this->outputHTML('me', [ - 'title' => 'About' . $this->config->get('whose_list'), + 'title' => 'About ' . $this->config->get('whose_list'), 'data' => $orgData[0], 'attributes' => $orgData[0]['attributes'], 'relationships' => $orgData[0]['relationships'], diff --git a/src/MenuGenerator.php b/src/MenuGenerator.php index d6615d86..89199ddd 100644 --- a/src/MenuGenerator.php +++ b/src/MenuGenerator.php @@ -98,7 +98,7 @@ class MenuGenerator extends UrlGenerator { foreach ($menuConfig as $title => $path) { $has = $this->string($this->path())->contains($path); - $selected = ($has && strlen($this->path()) >= strlen($path)); + $selected = ($has && mb_strlen($this->path()) >= mb_strlen($path)); $link = $this->helper->a($this->url($path), $title);