Add detail view to anime list

This commit is contained in:
Timothy Warren 2016-04-14 17:51:00 -04:00
parent 01d25f2817
commit 3710f42505
8 changed files with 78 additions and 4 deletions

View File

@ -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
// ---------------------------------------------------------------------

View File

@ -19,7 +19,7 @@
<?php endif ?>
<img src="<?= $escape->attr($item['manga']['image']) ?>" />
<div class="name">
<a href="<?= $item['manga']['url'] ?>">
<a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>">
<?= $escape->html($item['manga']['title']) ?>
<?= (isset($item['manga']['alternate_title'])) ? "<br />({$item['manga']['alternate_title']})" : ""; ?>
</a>

View File

@ -0,0 +1,38 @@
<main class="details">
<section class="flex flex-no-wrap">
<div>
<img class="cover" src="<?= $data['poster_image'] ?>" alt="<?= $data['title'] ?> cover image" />
<br />
<br />
<table>
<tr>
<td>Manga Type</td>
<td><?= $data['manga_type'] ?></td>
</tr>
<tr>
<td>Volume Count</td>
<td><?= $data['volume_count'] ?></td>
</tr>
<tr>
<td>Chapter Count</td>
<td><?= $data['chapter_count'] ?></td>
</tr>
<tr>
<td>Genres</td>
<td>
<?= implode(', ', $data['genres']); ?>
</td>
</tr>
</table>
</div>
<div>
<h2><a rel="external" href="https://hummingbird.me/manga/<?= $data['id'] ?>"><?= $data['romaji_title'] ?></a></h2>
<?php if( ! empty($data['english_title'])): ?>
<h3><?= $data['english_title'] ?></h3>
<?php endif ?>
<br />
<p><?= nl2br($data['synopsis']) ?></p>
</div>
</section>
</main>

View File

@ -29,7 +29,7 @@
</td>
<?php endif ?>
<td class="align_left">
<a href="<?= $item['manga']['url'] ?>">
<a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>">
<?= $item['manga']['title'] ?>
</a>
<?= ( ! is_null($item['manga']['alternate_title'])) ? " &middot; " . $item['manga']['alternate_title'] : "" ?>

View File

@ -38,7 +38,8 @@ class AnimeClient {
'update',
'update_form',
'login',
'logout'
'logout',
'details'
];
/**

View File

@ -287,7 +287,7 @@ class Anime extends BaseController {
$data = $this->model->get_anime($anime_id);
$this->outputHTML('anime/details', [
'title' => $data['title'],
'title' => 'Anime &middot ' . $data['title'],
'data' => $data,
]);
}

View File

@ -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 &middot; ' . $data['manga']['romaji_title'],
'data' => $data['manga'],
]);
}
}
// End of MangaController.php

View File

@ -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
*