Manga lists and detail pages
This commit is contained in:
parent
3030b6b908
commit
f1893d9708
@ -14,7 +14,6 @@
|
|||||||
<?php /*if ($auth->is_authenticated()): ?>
|
<?php /*if ($auth->is_authenticated()): ?>
|
||||||
<div class="edit_buttons" hidden>
|
<div class="edit_buttons" hidden>
|
||||||
<button class="plus_one_chapter">+1 Chapter</button>
|
<button class="plus_one_chapter">+1 Chapter</button>
|
||||||
<button class="plus_one_volume">+1 Volume</button>
|
|
||||||
</div>
|
</div>
|
||||||
<?php endif */ ?>
|
<?php endif */ ?>
|
||||||
<img src="<?= $escape->attr($item['manga']['image']) ?>" />
|
<img src="<?= $escape->attr($item['manga']['image']) ?>" />
|
||||||
@ -43,8 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="volume_completion">
|
<div class="volume_completion">
|
||||||
Volumes: <span class="volumes_read"><?= $item['volumes']['read'] ?></span> /
|
Volumes: <span class="volume_count"><?= $item['volumes']['total'] ?></span>
|
||||||
<span class="volume_count"><?= $item['volumes']['total'] ?></span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -57,4 +55,4 @@
|
|||||||
</main>
|
</main>
|
||||||
<?php /*if ($auth->is_authenticated()): ?>
|
<?php /*if ($auth->is_authenticated()): ?>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php/g/edit') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/edit') ?>"></script>
|
||||||
<?php endif*/ ?>
|
<?php endif*/ ?>
|
@ -1,7 +1,7 @@
|
|||||||
<main class="details">
|
<main class="details">
|
||||||
<section class="flex flex-no-wrap">
|
<section class="flex flex-no-wrap">
|
||||||
<div>
|
<div>
|
||||||
<img class="cover" src="<?= $data['poster_image'] ?>" alt="<?= $data['title'] ?> cover image" />
|
<img class="cover" src="<?= $data['cover_image'] ?>" alt="<?= $data['title'] ?> cover image" />
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<table>
|
<table>
|
||||||
@ -26,9 +26,9 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h2><a rel="external" href="https://hummingbird.me/manga/<?= $data['id'] ?>"><?= $data['romaji_title'] ?></a></h2>
|
<h2><a rel="external" href="<?= $data['url'] ?>"><?= $data['title'] ?></a></h2>
|
||||||
<?php if( ! empty($data['english_title'])): ?>
|
<?php if( ! empty($data['en_title'])): ?>
|
||||||
<h3><?= $data['english_title'] ?></h3>
|
<h3><?= $data['en_title'] ?></h3>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
<?php endif*/ ?>
|
<?php endif*/ ?>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
<th>Rating</th>
|
<th>Rating</th>
|
||||||
<th>Chapters</th>
|
<th>Completed Chapters</th>
|
||||||
<th>Volumes</th>
|
<th># of Volumes</th>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td><?= $item['user_rating'] ?> / 10</td>
|
<td><?= $item['user_rating'] ?> / 10</td>
|
||||||
<td><?= $item['chapters']['read'] ?> / <?= $item['chapters']['total'] ?></td>
|
<td><?= $item['chapters']['read'] ?> / <?= $item['chapters']['total'] ?></td>
|
||||||
<td><?= $item['volumes']['read'] ?> / <?= $item['volumes']['total'] ?></td>
|
<td><?= $item['volumes']['total'] ?></td>
|
||||||
<td><?= $item['manga']['type'] ?></td>
|
<td><?= $item['manga']['type'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
@ -24,8 +24,8 @@ use Aviat\Ion\Enum as BaseEnum;
|
|||||||
class MangaReadingStatus extends BaseEnum {
|
class MangaReadingStatus extends BaseEnum {
|
||||||
const READING = 1;
|
const READING = 1;
|
||||||
const PLAN_TO_READ = 2;
|
const PLAN_TO_READ = 2;
|
||||||
const DROPPED = 3;
|
const DROPPED = 5;
|
||||||
const ON_HOLD = 4;
|
const ON_HOLD = 4;
|
||||||
const COMPLETED = 5;
|
const COMPLETED = 3;
|
||||||
}
|
}
|
||||||
// End of MangaReadingStatus.php
|
// End of MangaReadingStatus.php
|
@ -18,7 +18,7 @@ namespace Aviat\AnimeClient\API\Kitsu;
|
|||||||
|
|
||||||
use Aviat\AnimeClient\AnimeClient;
|
use Aviat\AnimeClient\AnimeClient;
|
||||||
use Aviat\AnimeClient\API\Kitsu\Transformer\{
|
use Aviat\AnimeClient\API\Kitsu\Transformer\{
|
||||||
AnimeTransformer, AnimeListTransformer, MangaListTransformer
|
AnimeTransformer, AnimeListTransformer, MangaTransformer, MangaListTransformer
|
||||||
};
|
};
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
@ -47,9 +47,9 @@ class KitsuModel {
|
|||||||
*/
|
*/
|
||||||
protected $animeTransformer;
|
protected $animeTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var MangaListTransformer
|
* @var MangaListTransformer
|
||||||
*/
|
*/
|
||||||
protected $mangaListTransformer;
|
protected $mangaListTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,6 +62,7 @@ class KitsuModel {
|
|||||||
|
|
||||||
$this->animeTransformer = new AnimeTransformer();
|
$this->animeTransformer = new AnimeTransformer();
|
||||||
$this->animeListTransformer = new AnimeListTransformer();
|
$this->animeListTransformer = new AnimeListTransformer();
|
||||||
|
$this->mangaTransformer = new MangaTransformer();
|
||||||
$this->mangaListTransformer = new MangaListTransformer();
|
$this->mangaListTransformer = new MangaListTransformer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,16 +99,17 @@ class KitsuModel {
|
|||||||
return $this->animeTransformer->transform($baseData);
|
return $this->animeTransformer->transform($baseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getManga(string $mangaId): array
|
||||||
|
{
|
||||||
|
$baseData = $this->getRawMediaData('manga', $mangaId);
|
||||||
|
return $this->mangaTransformer->transform($baseData);
|
||||||
|
}
|
||||||
|
|
||||||
public function getRawAnimeData($animeId): array
|
public function getRawAnimeData($animeId): array
|
||||||
{
|
{
|
||||||
return $this->getRawMediaData('anime', $animeId);
|
return $this->getRawMediaData('anime', $animeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAnimeMedia($entryId): array
|
|
||||||
{
|
|
||||||
return $this->getRequest("library-entries/{$entryId}/media");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAnimeList($status): array
|
public function getAnimeList($status): array
|
||||||
{
|
{
|
||||||
$options = [
|
$options = [
|
||||||
@ -139,34 +141,34 @@ class KitsuModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getMangaList($status): array
|
public function getMangaList($status): array
|
||||||
{
|
{
|
||||||
$options = [
|
$options = [
|
||||||
'query' => [
|
'query' => [
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'user_id' => 2644,
|
'user_id' => 2644,
|
||||||
'media_type' => 'Manga',
|
'media_type' => 'Manga',
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
],
|
],
|
||||||
'include' => 'media',
|
'include' => 'media',
|
||||||
'page' => [
|
'page' => [
|
||||||
'offset' => 0,
|
'offset' => 0,
|
||||||
'limit' => 200
|
'limit' => 200
|
||||||
],
|
],
|
||||||
'sort' => '-updated_at'
|
'sort' => '-updated_at'
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$data = $this->getRequest('library-entries', $options);
|
$data = $this->getRequest('library-entries', $options);
|
||||||
|
|
||||||
foreach($data['data'] as $i => &$item)
|
|
||||||
{
|
|
||||||
$item['manga'] = $data['included'][$i];
|
|
||||||
}
|
|
||||||
|
|
||||||
$transformed = $this->mangaListTransformer->transformCollection($data['data']);
|
foreach($data['data'] as $i => &$item)
|
||||||
|
{
|
||||||
|
$item['manga'] = $data['included'][$i];
|
||||||
|
}
|
||||||
|
|
||||||
return $transformed;
|
$transformed = $this->mangaListTransformer->transformCollection($data['data']);
|
||||||
}
|
|
||||||
|
return $transformed;
|
||||||
|
}
|
||||||
|
|
||||||
private function getGenres(string $type, string $id): array
|
private function getGenres(string $type, string $id): array
|
||||||
{
|
{
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package AnimeListClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 4.0
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\API\Kitsu\Transformer;
|
namespace Aviat\AnimeClient\API\Kitsu\Transformer;
|
||||||
@ -34,17 +34,15 @@ class MangaListTransformer extends AbstractTransformer {
|
|||||||
*/
|
*/
|
||||||
public function transform($item)
|
public function transform($item)
|
||||||
{
|
{
|
||||||
?><pre><?= print_r($item, TRUE) ?></pre><?php
|
|
||||||
die();
|
|
||||||
$manga =& $item['manga'];
|
$manga =& $item['manga'];
|
||||||
|
|
||||||
$rating = (is_numeric($item['rating']))
|
$rating = (is_numeric($item['attributes']['rating']))
|
||||||
? intval(2 * $item['rating'])
|
? intval(2 * $item['attributes']['rating'])
|
||||||
: '-';
|
: '-';
|
||||||
|
|
||||||
$total_chapters = ($manga['attributes']['chapterCount'] > 0)
|
$total_chapters = ($manga['attributes']['chapterCount'] > 0)
|
||||||
? $manga['attributes']['chapterCount']
|
? $manga['attributes']['chapterCount']
|
||||||
: '-';
|
: '-';
|
||||||
|
|
||||||
$total_volumes = ($manga['attributes']['volumeCount'] > 0)
|
$total_volumes = ($manga['attributes']['volumeCount'] > 0)
|
||||||
? $manga['attributes']['volumeCount']
|
? $manga['attributes']['volumeCount']
|
||||||
@ -53,40 +51,29 @@ die();
|
|||||||
$map = [
|
$map = [
|
||||||
'id' => $item['id'],
|
'id' => $item['id'],
|
||||||
'chapters' => [
|
'chapters' => [
|
||||||
'read' => $item['chapters_read'],
|
'read' => $item['attributes']['progress'],
|
||||||
'total' => $total_chapters
|
'total' => $total_chapters
|
||||||
],
|
],
|
||||||
'volumes' => [
|
'volumes' => [
|
||||||
'read' => $item['volumes_read'],
|
'read' => '-', //$item['attributes']['volumes_read'],
|
||||||
'total' => $total_volumes
|
'total' => $total_volumes
|
||||||
],
|
],
|
||||||
'manga' => [
|
'manga' => [
|
||||||
'title' => $manga['romaji_title'],
|
'title' => $manga['attributes']['canonicalTitle'],
|
||||||
'alternate_title' => NULL,
|
'alternate_title' => NULL,
|
||||||
'slug' => $manga['id'],
|
'slug' => $manga['id'],
|
||||||
'url' => 'https://hummingbird.me/manga/' . $manga['id'],
|
'url' => 'https://kitsu.io/manga/' . $manga['id'],
|
||||||
'type' => $manga['manga_type'],
|
'type' => $manga['attributes']['mangaType'],
|
||||||
'image' => $manga['poster_image_thumb'],
|
'image' => $manga['attributes']['posterImage']['small'],
|
||||||
'genres' => $manga['genres'],
|
'genres' => [], //$manga['genres'],
|
||||||
],
|
],
|
||||||
'reading_status' => $item['status'],
|
'reading_status' => $item['attributes']['status'],
|
||||||
'notes' => $item['notes'],
|
'notes' => $item['attributes']['notes'],
|
||||||
'rereading' => (bool)$item['rereading'],
|
'rereading' => (bool)$item['attributes']['reconsuming'],
|
||||||
'reread' => $item['reread_count'],
|
'reread' => $item['attributes']['reconsumeCount'],
|
||||||
'user_rating' => $rating,
|
'user_rating' => $rating,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (array_key_exists('english_title', $manga))
|
|
||||||
{
|
|
||||||
$diff = levenshtein($manga['romaji_title'], $manga['english_title']);
|
|
||||||
|
|
||||||
// If the titles are REALLY similar, don't bother showing both
|
|
||||||
if ($diff >= 5)
|
|
||||||
{
|
|
||||||
$map['manga']['alternate_title'] = $manga['english_title'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $map;
|
return $map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,39 +1,55 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Anime List Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package AnimeListClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 4.0
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\API\Kitsu\Transformer;
|
namespace Aviat\AnimeClient\API\Kitsu\Transformer;
|
||||||
|
|
||||||
use Aviat\Ion\Transformer\AbstractTransformer;
|
use Aviat\Ion\Transformer\AbstractTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transformer for anime description page
|
* Transformer for anime description page
|
||||||
*/
|
*/
|
||||||
class MangaTransformer extends AbstractTransformer {
|
class MangaTransformer extends AbstractTransformer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert raw api response to a more
|
* Convert raw api response to a more
|
||||||
* logical and workable structure
|
* logical and workable structure
|
||||||
*
|
*
|
||||||
* @param array $item API library item
|
* @param array $item API library item
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function transform($item)
|
public function transform($item)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'title' => $item['canonicalTitle'],
|
||||||
];
|
'en_title' => $item['titles']['en'],
|
||||||
}
|
'jp_title' => $item['titles']['en_jp'],
|
||||||
|
'cover_image' => $item['posterImage']['small'],
|
||||||
|
'manga_type' => $item['mangaType'],
|
||||||
|
'chapter_count' => $this->count($item['chapterCount']),
|
||||||
|
'volume_count' => $this->count($item['volumeCount']),
|
||||||
|
'synopsis' => $item['synopsis'],
|
||||||
|
'url' => "https://kitsu.io/manga/{$item['slug']}",
|
||||||
|
'genres' => $item['genres'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function count(int $value = null)
|
||||||
|
{
|
||||||
|
return ((int)$value === 0)
|
||||||
|
? '-'
|
||||||
|
: $value;
|
||||||
|
}
|
||||||
}
|
}
|
@ -264,8 +264,8 @@ class Manga extends Controller {
|
|||||||
$data = $this->model->get_manga($manga_id);
|
$data = $this->model->get_manga($manga_id);
|
||||||
|
|
||||||
$this->outputHTML('manga/details', [
|
$this->outputHTML('manga/details', [
|
||||||
'title' => 'Manga · ' . $data['manga']['romaji_title'],
|
'title' => 'Manga · ' . $data['title'],
|
||||||
'data' => $data['manga'],
|
'data' => $data,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package AnimeListClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 4.0
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Model;
|
namespace Aviat\AnimeClient\Model;
|
||||||
@ -46,12 +46,20 @@ class Manga extends API {
|
|||||||
MangaReadingStatus::COMPLETED => self::COMPLETED
|
MangaReadingStatus::COMPLETED => self::COMPLETED
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(ContainerInterface $container)
|
protected $status_map = [
|
||||||
{
|
'current' => self::READING,
|
||||||
parent::__construct($container);
|
'planned' => self::PLAN_TO_READ,
|
||||||
|
'completed' => self::COMPLETED,
|
||||||
|
'on_hold' => self::ON_HOLD,
|
||||||
|
'dropped' => self::DROPPED
|
||||||
|
];
|
||||||
|
|
||||||
$this->kitsuModel = $container->get('kitsu-model');
|
public function __construct(ContainerInterface $container)
|
||||||
}
|
{
|
||||||
|
parent::__construct($container);
|
||||||
|
|
||||||
|
$this->kitsuModel = $container->get('kitsu-model');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make an authenticated manga API call
|
* Make an authenticated manga API call
|
||||||
@ -102,10 +110,9 @@ class Manga extends API {
|
|||||||
*/
|
*/
|
||||||
public function get_list($status)
|
public function get_list($status)
|
||||||
{
|
{
|
||||||
$data = $this->kitsuModel->getMangaList($status);
|
$APIstatus = array_flip($this->const_map)[$status];
|
||||||
return $this->map_by_status($data)[$status];
|
$data = $this->kitsuModel->getMangaList($APIstatus);
|
||||||
/*$data = $this->cache->get($this, '_get_list_from_api');
|
return $this->map_by_status($data)[$status];
|
||||||
return ($status !== 'All') ? $data[$status] : $data;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,8 +124,7 @@ class Manga extends API {
|
|||||||
*/
|
*/
|
||||||
public function get_manga($manga_id)
|
public function get_manga($manga_id)
|
||||||
{
|
{
|
||||||
$raw = $this->_manga_api_call('get', "manga/{$manga_id}.json");
|
return $this->kitsuModel->getManga($manga_id);
|
||||||
return Json::decode($raw['body'], TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,7 +152,7 @@ class Manga extends API {
|
|||||||
$entry['manga']['slug'],
|
$entry['manga']['slug'],
|
||||||
'manga'
|
'manga'
|
||||||
);*/
|
);*/
|
||||||
$key = $this->const_map[$entry['reading_status']];
|
$key = $this->status_map[$entry['reading_status']];
|
||||||
$output[$key][] = $entry;
|
$output[$key][] = $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user