From 4d6c15b0309f320bf0e56e12d8c1cb160f9b695a Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Wed, 22 Apr 2020 11:39:44 -0400 Subject: [PATCH] Add menu items for history, add manga reading history --- app/appConf/menus.toml | 30 +-- app/appConf/routes.php | 17 +- app/views/history.php | 45 ++++ app/views/history/anime.php | 19 -- app/views/main-menu.php | 6 +- index.php | 27 ++- src/AnimeClient/API/Kitsu/Model.php | 12 +- .../Transformer/AnimeHistoryTransformer.php | 56 +++-- .../Transformer/MangaHistoryTransformer.php | 218 ++++++++++++++++++ src/AnimeClient/Controller/History.php | 40 +++- src/AnimeClient/Model/Settings.php | 7 +- src/AnimeClient/Types/Config.php | 5 + src/AnimeClient/Types/HistoryItem.php | 16 +- src/AnimeClient/constants.php | 6 + 14 files changed, 415 insertions(+), 89 deletions(-) create mode 100644 app/views/history.php delete mode 100644 app/views/history/anime.php create mode 100644 src/AnimeClient/API/Kitsu/Transformer/MangaHistoryTransformer.php diff --git a/app/appConf/menus.toml b/app/appConf/menus.toml index fd1df9fa..0f7df3b6 100644 --- a/app/appConf/menus.toml +++ b/app/appConf/menus.toml @@ -1,19 +1,21 @@ [anime_list] - route_prefix = "/anime" + route_prefix = "" [anime_list.items] - watching = '/watching' - plan_to_watch = '/plan_to_watch' - on_hold = '/on_hold' - dropped = '/dropped' - completed = '/completed' - all = '/all' + watch_history = '/history/anime' + watching = '/anime/watching' + plan_to_watch = '/anime/plan_to_watch' + on_hold = '/anime/on_hold' + dropped = '/anime/dropped' + completed = '/anime/completed' + all = '/anime/all' [manga_list] - route_prefix = "/manga" + route_prefix = "" [manga_list.items] - reading = '/reading' - plan_to_read = '/plan_to_read' - on_hold = '/on_hold' - dropped = '/dropped' - completed = '/completed' - all = '/all' \ No newline at end of file + reading_history = '/history/manga' + reading = '/manga/reading' + plan_to_read = '/manga/plan_to_read' + on_hold = '/manga/on_hold' + dropped = '/manga/dropped' + completed = '/manga/completed' + all = '/manga/all' \ No newline at end of file diff --git a/app/appConf/routes.php b/app/appConf/routes.php index 6534c171..3f7c62ab 100644 --- a/app/appConf/routes.php +++ b/app/appConf/routes.php @@ -193,16 +193,6 @@ $routes = [ 'username' => '.*?' ] ], - 'anime_history' => [ - 'controller' => 'history', - 'path' => '/history/anime', - 'action' => 'anime', - ], - 'manga_history' => [ - 'controller' => 'history', - 'path' => '/history/manga', - 'action' => 'manga', - ], // --------------------------------------------------------------------- // Default / Shared routes // --------------------------------------------------------------------- @@ -289,6 +279,13 @@ $routes = [ 'view' => ALPHA_SLUG_PATTERN, ], ], + 'history' => [ + 'controller' => 'history', + 'path' => '/history/{type}', + 'tokens' => [ + 'type' => SLUG_PATTERN + ] + ], 'index_redirect' => [ 'path' => '/', 'action' => 'redirectToDefaultRoute', diff --git a/app/views/history.php b/app/views/history.php new file mode 100644 index 00000000..a1783f65 --- /dev/null +++ b/app/views/history.php @@ -0,0 +1,45 @@ +
+ +

No recent history.

+ +
+ $item): ?> +
+
picture( + $item['coverImg'], + 'jpg', + ['width' => '110px', 'height' => '156px'], + ['width' => '110px', 'height' => '156px'] + ) ?>
+
+ +
+
+ +
+ + $date->format('l, F d'), + $item['dateRange'] + ); + [$startTime, $endTime] = array_map( + fn ($date) => $date->format('h:i:s A'), + $item['dateRange'] + ); + ?> + + + + + + + format('l, F d h:i:s A') ?> + + +
+
+ +
+ +
diff --git a/app/views/history/anime.php b/app/views/history/anime.php deleted file mode 100644 index 4d12b7bf..00000000 --- a/app/views/history/anime.php +++ /dev/null @@ -1,19 +0,0 @@ -
- -

No recent watch history.

- -
- $item): ?> -
-
picture( - $item['coverImg'], - 'jpg', - ['width' => '110px', 'height' => '156px'], - ['width' => '110px', 'height' => '156px'] - ) ?>
-
-
- -
- -
diff --git a/app/views/main-menu.php b/app/views/main-menu.php index f38082d3..0a3524d6 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') === 1; -$hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') === 1; +$hasAnime = stripos($_SERVER['REQUEST_URI'], 'anime') !== FALSE; +$hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') !== FALSE; ?>