From b5949466e463a7ec89e9fe98a7336fa9ef294608 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Thu, 14 Apr 2016 17:51:00 -0400 Subject: [PATCH] Add detail view to anime list --- app/config/routes.php | 7 ++++ app/views/manga/cover.php | 2 +- app/views/manga/details.php | 38 ++++++++++++++++++++++ app/views/manga/list.php | 2 +- src/Aviat/AnimeClient/AnimeClient.php | 3 +- src/Aviat/AnimeClient/Controller/Anime.php | 2 +- src/Aviat/AnimeClient/Controller/Manga.php | 16 +++++++++ src/Aviat/AnimeClient/Model/Manga.php | 12 +++++++ 8 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 app/views/manga/details.php diff --git a/app/config/routes.php b/app/config/routes.php index aa138002..956eaa31 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -87,6 +87,13 @@ return [ 'action' => 'delete', 'verb' => 'post', ], + 'manga.details' => [ + 'path' => '/manga/details/{id}', + 'action' => 'details', + 'tokens' => [ + 'id' => '[a-z0-9\-]+', + ], + ], // --------------------------------------------------------------------- // Anime Collection Routes // --------------------------------------------------------------------- diff --git a/app/views/manga/cover.php b/app/views/manga/cover.php index 0677ff34..2bb8498e 100644 --- a/app/views/manga/cover.php +++ b/app/views/manga/cover.php @@ -19,7 +19,7 @@
- + html($item['manga']['title']) ?> ({$item['manga']['alternate_title']})" : ""; ?> diff --git a/app/views/manga/details.php b/app/views/manga/details.php new file mode 100644 index 00000000..986fca43 --- /dev/null +++ b/app/views/manga/details.php @@ -0,0 +1,38 @@ +
+
+
+ <?= $data['title'] ?> cover image +
+
+ + + + + + + + + + + + + + + + + +
Manga Type
Volume Count
Chapter Count
Genres + +
+
+
+

+ +

+ + +
+

+
+
+
\ No newline at end of file diff --git a/app/views/manga/list.php b/app/views/manga/list.php index 92593abe..a0b35bd2 100644 --- a/app/views/manga/list.php +++ b/app/views/manga/list.php @@ -29,7 +29,7 @@ - + diff --git a/src/Aviat/AnimeClient/AnimeClient.php b/src/Aviat/AnimeClient/AnimeClient.php index 431e9a89..435afc86 100644 --- a/src/Aviat/AnimeClient/AnimeClient.php +++ b/src/Aviat/AnimeClient/AnimeClient.php @@ -38,7 +38,8 @@ class AnimeClient { 'update', 'update_form', 'login', - 'logout' + 'logout', + 'details' ]; /** diff --git a/src/Aviat/AnimeClient/Controller/Anime.php b/src/Aviat/AnimeClient/Controller/Anime.php index dd6d4acb..47512258 100644 --- a/src/Aviat/AnimeClient/Controller/Anime.php +++ b/src/Aviat/AnimeClient/Controller/Anime.php @@ -287,7 +287,7 @@ class Anime extends BaseController { $data = $this->model->get_anime($anime_id); $this->outputHTML('anime/details', [ - 'title' => $data['title'], + 'title' => 'Anime · ' . $data['title'], 'data' => $data, ]); } diff --git a/src/Aviat/AnimeClient/Controller/Manga.php b/src/Aviat/AnimeClient/Controller/Manga.php index ad836699..47aeffdd 100644 --- a/src/Aviat/AnimeClient/Controller/Manga.php +++ b/src/Aviat/AnimeClient/Controller/Manga.php @@ -253,5 +253,21 @@ class Manga extends Controller { $this->session_redirect(); } + + /** + * View details of an manga + * + * @param string $manga_id + * @return void + */ + public function details($manga_id) + { + $data = $this->model->get_manga($manga_id); + + $this->outputHTML('manga/details', [ + 'title' => 'Manga · ' . $data['manga']['romaji_title'], + 'data' => $data['manga'], + ]); + } } // End of MangaController.php \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Model/Manga.php b/src/Aviat/AnimeClient/Model/Manga.php index 24334239..6a6e3c94 100644 --- a/src/Aviat/AnimeClient/Model/Manga.php +++ b/src/Aviat/AnimeClient/Model/Manga.php @@ -224,6 +224,18 @@ class Manga extends API { return $transformed_data; } + /** + * Get the details of a manga + * + * @param string $manga_id + * @return array + */ + public function get_manga($manga_id) + { + $raw = $this->_manga_api_call('get', "manga/{$manga_id}.json"); + return Json::decode($raw['body'], TRUE); + } + /** * Map transformed anime data to be organized by reading status *