Finish moving get_cached_image method to Util class
This commit is contained in:
parent
f00acbe2d6
commit
a108adfa23
@ -1,4 +1,3 @@
|
|||||||
<?php namespace Aviat\AnimeClient ?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@ -12,49 +11,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body class="<?= $escape->attr($url_type) ?> list">
|
<body class="<?= $escape->attr($url_type) ?> list">
|
||||||
<header>
|
<header>
|
||||||
<h1 class="flex flex-align-end flex-wrap">
|
<?php include 'main-menu.php' ?>
|
||||||
<span class="flex-no-wrap grow-1">
|
|
||||||
<?php if(strpos($route_path, 'collection') === FALSE): ?>
|
|
||||||
<a href="<?= $escape->attr($urlGenerator->default_url($url_type)) ?>">
|
|
||||||
<?= $config->get('whose_list') ?>'s <?= ucfirst($url_type) ?> List
|
|
||||||
</a>
|
|
||||||
<?php if($config->get("show_{$url_type}_collection")): ?>
|
|
||||||
[<a href="<?= $urlGenerator->url('collection/view') ?>"><?= ucfirst($url_type) ?> Collection</a>]
|
|
||||||
<?php endif ?>
|
|
||||||
[<a href="<?= $urlGenerator->default_url($other_type) ?>"><?= ucfirst($other_type) ?> List</a>]
|
|
||||||
<?php else: ?>
|
|
||||||
<a href="<?= $urlGenerator->url('collection/view') ?>">
|
|
||||||
<?= $config->get('whose_list') ?>'s <?= ucfirst($url_type) ?> Collection
|
|
||||||
</a>
|
|
||||||
[<a href="<?= $urlGenerator->default_url('anime') ?>">Anime List</a>]
|
|
||||||
[<a href="<?= $urlGenerator->default_url('manga') ?>">Manga List</a>]
|
|
||||||
<?php endif ?>
|
|
||||||
</span>
|
|
||||||
<?php if ($auth->is_authenticated()): ?>
|
|
||||||
<span class="flex-no-wrap"> </span>
|
|
||||||
<span class="flex-no-wrap small-font">
|
|
||||||
<button type="button" class="js-clear-cache user-btn">Clear API Cache</button>
|
|
||||||
</span>
|
|
||||||
<span class="flex-no-wrap"> </span>
|
|
||||||
<?php endif ?>
|
|
||||||
<span class="flex-no-wrap small-font">
|
|
||||||
<?php if ($auth->is_authenticated()): ?>
|
|
||||||
<a class="bracketed" href="<?= $url->generate('logout') ?>">Logout</a>
|
|
||||||
<?php else: ?>
|
|
||||||
[<a href="<?= $url->generate('login'); ?>"><?= $config->get('whose_list') ?>'s Login</a>]
|
|
||||||
<?php endif ?>
|
|
||||||
</span>
|
|
||||||
</h1>
|
|
||||||
<nav>
|
|
||||||
<?php if ($container->get('anime-client')->is_view_page()): ?>
|
|
||||||
<?= $helper->menu($menu_name) ?>
|
|
||||||
<br />
|
|
||||||
<ul>
|
|
||||||
<li class="<?= Util::is_not_selected('list', $urlGenerator->last_segment()) ?>"><a href="<?= $urlGenerator->url($route_path) ?>">Cover View</a></li>
|
|
||||||
<li class="<?= Util::is_selected('list', $urlGenerator->last_segment()) ?>"><a href="<?= $urlGenerator->url("{$route_path}/list") ?>">List View</a></li>
|
|
||||||
</ul>
|
|
||||||
<?php endif ?>
|
|
||||||
</nav>
|
|
||||||
<?php if(isset($message) && is_array($message)):
|
<?php if(isset($message) && is_array($message)):
|
||||||
extract($message);
|
extract($message);
|
||||||
include 'message.php';
|
include 'message.php';
|
||||||
|
44
app/views/main-menu.php
Normal file
44
app/views/main-menu.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php namespace Aviat\AnimeClient ?>
|
||||||
|
<h1 class="flex flex-align-end flex-wrap">
|
||||||
|
<span class="flex-no-wrap grow-1">
|
||||||
|
<?php if(strpos($route_path, 'collection') === FALSE): ?>
|
||||||
|
<a href="<?= $escape->attr($urlGenerator->default_url($url_type)) ?>">
|
||||||
|
<?= $config->get('whose_list') ?>'s <?= ucfirst($url_type) ?> List
|
||||||
|
</a>
|
||||||
|
<?php if($config->get("show_{$url_type}_collection")): ?>
|
||||||
|
[<a href="<?= $urlGenerator->url('collection/view') ?>"><?= ucfirst($url_type) ?> Collection</a>]
|
||||||
|
<?php endif ?>
|
||||||
|
[<a href="<?= $urlGenerator->default_url($other_type) ?>"><?= ucfirst($other_type) ?> List</a>]
|
||||||
|
<?php else: ?>
|
||||||
|
<a href="<?= $urlGenerator->url('collection/view') ?>">
|
||||||
|
<?= $config->get('whose_list') ?>'s <?= ucfirst($url_type) ?> Collection
|
||||||
|
</a>
|
||||||
|
[<a href="<?= $urlGenerator->default_url('anime') ?>">Anime List</a>]
|
||||||
|
[<a href="<?= $urlGenerator->default_url('manga') ?>">Manga List</a>]
|
||||||
|
<?php endif ?>
|
||||||
|
</span>
|
||||||
|
<?php if ($auth->is_authenticated()): ?>
|
||||||
|
<span class="flex-no-wrap"> </span>
|
||||||
|
<span class="flex-no-wrap small-font">
|
||||||
|
<button type="button" class="js-clear-cache user-btn">Clear API Cache</button>
|
||||||
|
</span>
|
||||||
|
<span class="flex-no-wrap"> </span>
|
||||||
|
<?php endif ?>
|
||||||
|
<span class="flex-no-wrap small-font">
|
||||||
|
<?php if ($auth->is_authenticated()): ?>
|
||||||
|
<a class="bracketed" href="<?= $url->generate('logout') ?>">Logout</a>
|
||||||
|
<?php else: ?>
|
||||||
|
[<a href="<?= $url->generate('login'); ?>"><?= $config->get('whose_list') ?>'s Login</a>]
|
||||||
|
<?php endif ?>
|
||||||
|
</span>
|
||||||
|
</h1>
|
||||||
|
<nav>
|
||||||
|
<?php if ($container->get('util')->is_view_page()): ?>
|
||||||
|
<?= $helper->menu($menu_name) ?>
|
||||||
|
<br />
|
||||||
|
<ul>
|
||||||
|
<li class="<?= Util::is_not_selected('list', $urlGenerator->last_segment()) ?>"><a href="<?= $urlGenerator->url($route_path) ?>">Cover View</a></li>
|
||||||
|
<li class="<?= Util::is_selected('list', $urlGenerator->last_segment()) ?>"><a href="<?= $urlGenerator->url("{$route_path}/list") ?>">List View</a></li>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
|
</nav>
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace Aviat\AnimeClient\Command;
|
namespace Aviat\AnimeClient\Command;
|
||||||
|
|
||||||
use Aviat\AnimeClient\Model;
|
use Aviat\AnimeClient\Util;
|
||||||
/**
|
/**
|
||||||
* Generates thumbnail image cache so that cover images load faster
|
* Generates thumbnail image cache so that cover images load faster
|
||||||
*/
|
*/
|
||||||
@ -21,7 +21,7 @@ class CacheImages extends BaseCommand {
|
|||||||
|
|
||||||
protected $mangaModel;
|
protected $mangaModel;
|
||||||
protected $animeModel;
|
protected $animeModel;
|
||||||
protected $model;
|
protected $util;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert manga images
|
* Convert manga images
|
||||||
@ -37,7 +37,7 @@ class CacheImages extends BaseCommand {
|
|||||||
$current = 0;
|
$current = 0;
|
||||||
foreach($manga_list as $item)
|
foreach($manga_list as $item)
|
||||||
{
|
{
|
||||||
$this->model->get_cached_image($item['poster_image'], $item['id'], 'manga');
|
$this->util->get_cached_image($item['poster_image'], $item['id'], 'manga');
|
||||||
$current++;
|
$current++;
|
||||||
|
|
||||||
echo "Cached {$current} of {$total} manga images. \n";
|
echo "Cached {$current} of {$total} manga images. \n";
|
||||||
@ -57,7 +57,7 @@ class CacheImages extends BaseCommand {
|
|||||||
$current = 0;
|
$current = 0;
|
||||||
foreach($raw_list as $item)
|
foreach($raw_list as $item)
|
||||||
{
|
{
|
||||||
$this->model->get_cached_image($item['anime']['cover_image'], $item['anime']['slug'], 'anime');
|
$this->util->get_cached_image($item['anime']['cover_image'], $item['anime']['slug'], 'anime');
|
||||||
$current++;
|
$current++;
|
||||||
|
|
||||||
echo "Cached {$current} of {$total} anime images. \n";
|
echo "Cached {$current} of {$total} anime images. \n";
|
||||||
@ -75,7 +75,7 @@ class CacheImages extends BaseCommand {
|
|||||||
public function execute(array $args, array $options = array())
|
public function execute(array $args, array $options = array())
|
||||||
{
|
{
|
||||||
$this->setContainer($this->setupContainer());
|
$this->setContainer($this->setupContainer());
|
||||||
$this->model = new Model($this->container);
|
$this->util = new Util($this->container);
|
||||||
$this->animeModel = $this->container->get('anime-model');
|
$this->animeModel = $this->container->get('anime-model');
|
||||||
$this->mangaModel = $this->container->get('manga-model');
|
$this->mangaModel = $this->container->get('manga-model');
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ use Aviat\Ion\View\JsonView;
|
|||||||
* Controller base, defines output methods
|
* Controller base, defines output methods
|
||||||
*
|
*
|
||||||
* @property Response object $response
|
* @property Response object $response
|
||||||
* @property Config object $config
|
|
||||||
*/
|
*/
|
||||||
class Controller {
|
class Controller {
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ class Controller {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The global configuration object
|
* The global configuration object
|
||||||
* @var object $config
|
* @var Aviat\Ion\ConfigInterface $config
|
||||||
*/
|
*/
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
@ -148,7 +147,7 @@ class Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$anime_client = $this->container->get('anime-client');
|
$util = $this->container->get('util');
|
||||||
$double_form_page = $server_params['HTTP_REFERER'] == $this->request->getUri();
|
$double_form_page = $server_params['HTTP_REFERER'] == $this->request->getUri();
|
||||||
|
|
||||||
// Don't attempt to set the redirect url if
|
// Don't attempt to set the redirect url if
|
||||||
@ -161,7 +160,7 @@ class Controller {
|
|||||||
|
|
||||||
if (is_null($url))
|
if (is_null($url))
|
||||||
{
|
{
|
||||||
$url = ($anime_client->is_view_page())
|
$url = ($util->is_view_page())
|
||||||
? $this->request->url->get()
|
? $this->request->url->get()
|
||||||
: $server_params['HTTP_REFERER'];
|
: $server_params['HTTP_REFERER'];
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,8 @@ class AnimeCollection extends Collection {
|
|||||||
{
|
{
|
||||||
$anime = (object)$this->anime_model->get_anime($data['id']);
|
$anime = (object)$this->anime_model->get_anime($data['id']);
|
||||||
|
|
||||||
|
$util = $this->container->get('util');
|
||||||
|
|
||||||
$this->db->set([
|
$this->db->set([
|
||||||
'hummingbird_id' => $data['id'],
|
'hummingbird_id' => $data['id'],
|
||||||
'slug' => $anime->slug,
|
'slug' => $anime->slug,
|
||||||
@ -137,7 +139,7 @@ class AnimeCollection extends Collection {
|
|||||||
'show_type' => $anime->show_type,
|
'show_type' => $anime->show_type,
|
||||||
'age_rating' => $anime->age_rating,
|
'age_rating' => $anime->age_rating,
|
||||||
'cover_image' => basename(
|
'cover_image' => basename(
|
||||||
$this->get_cached_image($anime->cover_image, $anime->slug, 'anime')
|
$util->get_cached_image($anime->cover_image, $anime->slug, 'anime')
|
||||||
),
|
),
|
||||||
'episode_count' => $anime->episode_count,
|
'episode_count' => $anime->episode_count,
|
||||||
'episode_length' => $anime->episode_length,
|
'episode_length' => $anime->episode_length,
|
||||||
@ -222,6 +224,8 @@ class AnimeCollection extends Collection {
|
|||||||
|
|
||||||
foreach ($anime as $item)
|
foreach ($anime as $item)
|
||||||
{
|
{
|
||||||
|
$util = $this->container->get('util');
|
||||||
|
|
||||||
$this->db->set([
|
$this->db->set([
|
||||||
'hummingbird_id' => $item->id,
|
'hummingbird_id' => $item->id,
|
||||||
'slug' => $item->slug,
|
'slug' => $item->slug,
|
||||||
@ -230,7 +234,7 @@ class AnimeCollection extends Collection {
|
|||||||
'show_type' => $item->show_type,
|
'show_type' => $item->show_type,
|
||||||
'age_rating' => $item->age_rating,
|
'age_rating' => $item->age_rating,
|
||||||
'cover_image' => basename(
|
'cover_image' => basename(
|
||||||
$this->get_cached_image($item->cover_image, $item->slug, 'anime')
|
$util->get_cached_image($item->cover_image, $item->slug, 'anime')
|
||||||
),
|
),
|
||||||
'episode_count' => $item->episode_count,
|
'episode_count' => $item->episode_count,
|
||||||
'episode_length' => $item->episode_length
|
'episode_length' => $item->episode_length
|
||||||
|
Loading…
Reference in New Issue
Block a user