Version 5.1 - All the GraphQL #32
@ -14,6 +14,7 @@
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
use function Aviat\AnimeClient\loadToml;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Lower level configuration
|
||||
@ -23,7 +24,9 @@
|
||||
$APP_DIR = realpath(__DIR__ . '/../');
|
||||
$ROOT_DIR = realpath("{$APP_DIR}/../");
|
||||
|
||||
$base_config = [
|
||||
$tomlConfig = loadToml(__DIR__);
|
||||
|
||||
$base_config = array_merge($tomlConfig, [
|
||||
'asset_dir' => "{$ROOT_DIR}/public",
|
||||
|
||||
// Template file path
|
||||
@ -34,6 +37,5 @@ $base_config = [
|
||||
'img_cache_path' => "{$ROOT_DIR}/public/images",
|
||||
|
||||
// Included config files
|
||||
'menus' => require 'menus.php',
|
||||
'routes' => require 'routes.php',
|
||||
];
|
||||
]);
|
@ -1,41 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime List Client
|
||||
*
|
||||
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2017 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
'anime_list' => [
|
||||
'route_prefix' => '/anime',
|
||||
'items' => [
|
||||
'watching' => '/watching',
|
||||
'plan_to_watch' => '/plan_to_watch',
|
||||
'on_hold' => '/on_hold',
|
||||
'dropped' => '/dropped',
|
||||
'completed' => '/completed',
|
||||
'all' => '/all'
|
||||
]
|
||||
],
|
||||
'manga_list' => [
|
||||
'route_prefix' => '/manga',
|
||||
'items' => [
|
||||
'reading' => '/reading',
|
||||
'plan_to_read' => '/plan_to_read',
|
||||
'on_hold' => '/on_hold',
|
||||
'dropped' => '/dropped',
|
||||
'completed' => '/completed',
|
||||
'all' => '/all'
|
||||
]
|
||||
]
|
||||
];
|
19
app/appConf/menus.toml
Normal file
19
app/appConf/menus.toml
Normal file
@ -0,0 +1,19 @@
|
||||
[anime_list]
|
||||
route_prefix = "/anime"
|
||||
[anime_list.items]
|
||||
watching = '/watching'
|
||||
plan_to_watch = '/plan_to_watch'
|
||||
on_hold = '/on_hold'
|
||||
dropped = '/dropped'
|
||||
completed = '/completed'
|
||||
all = '/all'
|
||||
|
||||
[manga_list]
|
||||
route_prefix = "/manga"
|
||||
[manga_list.items]
|
||||
reading = '/reading'
|
||||
plan_to_read = '/plan_to_read'
|
||||
on_hold = '/on_hold'
|
||||
dropped = '/dropped'
|
||||
completed = '/completed'
|
||||
all = '/all'
|
19
app/appConf/route_config.toml
Normal file
19
app/appConf/route_config.toml
Normal file
@ -0,0 +1,19 @@
|
||||
################################################################################
|
||||
# Route config
|
||||
#
|
||||
# Default views and paths
|
||||
################################################################################
|
||||
|
||||
# Path to public directory, where images/css/javascript are located,
|
||||
# appended to the url
|
||||
asset_path = "/public"
|
||||
|
||||
# Which list should be the default?
|
||||
default_lis = "anime" # anime or manga
|
||||
|
||||
# Default pages for anime/manga
|
||||
default_anime_list_path = "watching" # watching|plan_to_watch|on_hold|dropped|completed|all
|
||||
default_manga_list_path = "reading" # reading|plan_to_read|on_hold|dropped|completed|all
|
||||
|
||||
# Default view type (cover_view/list_view)
|
||||
default_view_type = "cover_view"
|
@ -22,211 +22,189 @@ use const Aviat\AnimeClient\{
|
||||
|
||||
use Aviat\AnimeClient\AnimeClient;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Routing Config
|
||||
//
|
||||
// Maps paths to controlers and methods
|
||||
// -------------------------------------------------------------------------
|
||||
return [
|
||||
// -------------------------------------------------------------------------
|
||||
// Routing options
|
||||
//
|
||||
// Specify default paths and views
|
||||
// -------------------------------------------------------------------------
|
||||
'route_config' => [
|
||||
// Path to public directory, where images/css/javascript are located,
|
||||
// appended to the url
|
||||
'asset_path' => '/public',
|
||||
|
||||
// Which list should be the default?
|
||||
'default_list' => 'anime', // anime or manga
|
||||
|
||||
// Default pages for anime/manga
|
||||
'default_anime_list_path' => "watching", // watching|plan_to_watch|on_hold|dropped|completed|all
|
||||
'default_manga_list_path' => "reading", // reading|plan_to_read|on_hold|dropped|completed|all
|
||||
|
||||
// Default view type (cover_view/list_view)
|
||||
'default_view_type' => 'cover_view',
|
||||
// ---------------------------------------------------------------------
|
||||
// Anime List Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'anime.add.get' => [
|
||||
'path' => '/anime/add',
|
||||
'action' => 'addForm',
|
||||
'verb' => 'get',
|
||||
],
|
||||
// -------------------------------------------------------------------------
|
||||
// Routing Config
|
||||
//
|
||||
// Maps paths to controlers and methods
|
||||
// -------------------------------------------------------------------------
|
||||
'routes' => [
|
||||
// ---------------------------------------------------------------------
|
||||
// Anime List Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'anime.add.get' => [
|
||||
'path' => '/anime/add',
|
||||
'action' => 'addForm',
|
||||
'verb' => 'get',
|
||||
'anime.add.post' => [
|
||||
'path' => '/anime/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'anime.details' => [
|
||||
'path' => '/anime/details/{id}',
|
||||
'action' => 'details',
|
||||
'tokens' => [
|
||||
'id' => '[a-z0-9\-]+',
|
||||
],
|
||||
'anime.add.post' => [
|
||||
'path' => '/anime/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'anime.delete' => [
|
||||
'path' => '/anime/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Manga Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'manga.search' => [
|
||||
'path' => '/manga/search',
|
||||
'action' => 'search',
|
||||
],
|
||||
'manga.add.get' => [
|
||||
'path' => '/manga/add',
|
||||
'action' => 'addForm',
|
||||
'verb' => 'get',
|
||||
],
|
||||
'manga.add.post' => [
|
||||
'path' => '/manga/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'manga.delete' => [
|
||||
'path' => '/manga/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'manga.details' => [
|
||||
'path' => '/manga/details/{id}',
|
||||
'action' => 'details',
|
||||
'tokens' => [
|
||||
'id' => '[a-z0-9\-]+',
|
||||
],
|
||||
'anime.details' => [
|
||||
'path' => '/anime/details/{id}',
|
||||
'action' => 'details',
|
||||
'tokens' => [
|
||||
'id' => '[a-z0-9\-]+',
|
||||
],
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Anime Collection Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'collection.search' => [
|
||||
'path' => '/collection/search',
|
||||
'action' => 'search',
|
||||
],
|
||||
'collection.add.get' => [
|
||||
'path' => '/collection/add',
|
||||
'action' => 'form',
|
||||
'params' => [],
|
||||
],
|
||||
'collection.edit.get' => [
|
||||
'path' => '/collection/edit/{id}',
|
||||
'action' => 'form',
|
||||
'tokens' => [
|
||||
'id' => '[0-9]+',
|
||||
],
|
||||
'anime.delete' => [
|
||||
'path' => '/anime/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'collection.add.post' => [
|
||||
'path' => '/collection/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'collection.edit.post' => [
|
||||
'path' => '/collection/edit',
|
||||
'action' => 'edit',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'collection.view' => [
|
||||
'path' => '/collection/view{/view}',
|
||||
'action' => 'index',
|
||||
'params' => [],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+',
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Manga Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'manga.search' => [
|
||||
'path' => '/manga/search',
|
||||
'action' => 'search',
|
||||
],
|
||||
'collection.delete' => [
|
||||
'path' => '/collection/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Manga Collection Routes
|
||||
// ---------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------
|
||||
// Other Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'character' => [
|
||||
'path' => '/character/{slug}',
|
||||
'action' => 'index',
|
||||
'params' => [],
|
||||
'tokens' => [
|
||||
'slug' => '[a-z0-9\-]+'
|
||||
]
|
||||
],
|
||||
'user_info' => [
|
||||
'path' => '/me',
|
||||
'action' => 'me',
|
||||
'controller' => 'me',
|
||||
'verb' => 'get',
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Default / Shared routes
|
||||
// ---------------------------------------------------------------------
|
||||
'cache_purge' => [
|
||||
'path' => '/cache_purge',
|
||||
'action' => 'clearCache',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'verb' => 'get',
|
||||
],
|
||||
'login' => [
|
||||
'path' => '/login',
|
||||
'action' => 'login',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'verb' => 'get',
|
||||
],
|
||||
'login.post' => [
|
||||
'path' => '/login',
|
||||
'action' => 'loginAction',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'verb' => 'post',
|
||||
],
|
||||
'logout' => [
|
||||
'path' => '/logout',
|
||||
'action' => 'logout',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
],
|
||||
'update' => [
|
||||
'path' => '/{controller}/update',
|
||||
'action' => 'update',
|
||||
'verb' => 'post',
|
||||
'tokens' => [
|
||||
'controller' => '[a-z_]+',
|
||||
],
|
||||
'manga.add.get' => [
|
||||
'path' => '/manga/add',
|
||||
'action' => 'addForm',
|
||||
'verb' => 'get',
|
||||
],
|
||||
'update.post' => [
|
||||
'path' => '/{controller}/update_form',
|
||||
'action' => 'formUpdate',
|
||||
'verb' => 'post',
|
||||
'tokens' => [
|
||||
'controller' => '[a-z_]+',
|
||||
],
|
||||
'manga.add.post' => [
|
||||
'path' => '/manga/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'edit' => [
|
||||
'path' => '/{controller}/edit/{id}/{status}',
|
||||
'action' => 'edit',
|
||||
'tokens' => [
|
||||
'id' => '[0-9a-z_]+',
|
||||
'status' => '([a-zA-Z\-_]|%20)+',
|
||||
],
|
||||
'manga.delete' => [
|
||||
'path' => '/manga/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'manga.details' => [
|
||||
'path' => '/manga/details/{id}',
|
||||
'action' => 'details',
|
||||
'tokens' => [
|
||||
'id' => '[a-z0-9\-]+',
|
||||
],
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Anime Collection Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'collection.search' => [
|
||||
'path' => '/collection/search',
|
||||
'action' => 'search',
|
||||
],
|
||||
'collection.add.get' => [
|
||||
'path' => '/collection/add',
|
||||
'action' => 'form',
|
||||
'params' => [],
|
||||
],
|
||||
'collection.edit.get' => [
|
||||
'path' => '/collection/edit/{id}',
|
||||
'action' => 'form',
|
||||
'tokens' => [
|
||||
'id' => '[0-9]+',
|
||||
],
|
||||
],
|
||||
'collection.add.post' => [
|
||||
'path' => '/collection/add',
|
||||
'action' => 'add',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'collection.edit.post' => [
|
||||
'path' => '/collection/edit',
|
||||
'action' => 'edit',
|
||||
'verb' => 'post',
|
||||
],
|
||||
'collection.view' => [
|
||||
'path' => '/collection/view{/view}',
|
||||
'action' => 'index',
|
||||
'params' => [],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+',
|
||||
],
|
||||
],
|
||||
'collection.delete' => [
|
||||
'path' => '/collection/delete',
|
||||
'action' => 'delete',
|
||||
'verb' => 'post',
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Manga Collection Routes
|
||||
// ---------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------
|
||||
// Other Routes
|
||||
// ---------------------------------------------------------------------
|
||||
'character' => [
|
||||
'path' => '/character/{slug}',
|
||||
'action' => 'index',
|
||||
'params' => [],
|
||||
'tokens' => [
|
||||
'slug' => '[a-z0-9\-]+'
|
||||
]
|
||||
],
|
||||
'user_info' => [
|
||||
'path' => '/me',
|
||||
'action' => 'me',
|
||||
'controller' => 'me',
|
||||
'verb' => 'get',
|
||||
],
|
||||
// ---------------------------------------------------------------------
|
||||
// Default / Shared routes
|
||||
// ---------------------------------------------------------------------
|
||||
'cache_purge' => [
|
||||
'path' => '/cache_purge',
|
||||
'action' => 'clearCache',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'verb' => 'get',
|
||||
],
|
||||
'login' => [
|
||||
'path' => '/login',
|
||||
'action' => 'login',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'verb' => 'get',
|
||||
],
|
||||
'login.post' => [
|
||||
'path' => '/login',
|
||||
'action' => 'loginAction',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'verb' => 'post',
|
||||
],
|
||||
'logout' => [
|
||||
'path' => '/logout',
|
||||
'action' => 'logout',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
],
|
||||
'update' => [
|
||||
'path' => '/{controller}/update',
|
||||
'action' => 'update',
|
||||
'verb' => 'post',
|
||||
'tokens' => [
|
||||
'controller' => '[a-z_]+',
|
||||
],
|
||||
],
|
||||
'update.post' => [
|
||||
'path' => '/{controller}/update_form',
|
||||
'action' => 'formUpdate',
|
||||
'verb' => 'post',
|
||||
'tokens' => [
|
||||
'controller' => '[a-z_]+',
|
||||
],
|
||||
],
|
||||
'edit' => [
|
||||
'path' => '/{controller}/edit/{id}/{status}',
|
||||
'action' => 'edit',
|
||||
'tokens' => [
|
||||
'id' => '[0-9a-z_]+',
|
||||
'status' => '([a-zA-Z\-_]|%20)+',
|
||||
],
|
||||
],
|
||||
'list' => [
|
||||
'path' => '/{controller}/{type}{/view}',
|
||||
'action' => DEFAULT_CONTROLLER_METHOD,
|
||||
'tokens' => [
|
||||
'type' => '[a-z_]+',
|
||||
'view' => '[a-z_]+',
|
||||
],
|
||||
],
|
||||
'index_redirect' => [
|
||||
'path' => '/',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'action' => 'redirectToDefaultRoute',
|
||||
],
|
||||
'list' => [
|
||||
'path' => '/{controller}/{type}{/view}',
|
||||
'action' => DEFAULT_CONTROLLER_METHOD,
|
||||
'tokens' => [
|
||||
'type' => '[a-z_]+',
|
||||
'view' => '[a-z_]+',
|
||||
],
|
||||
],
|
||||
'index_redirect' => [
|
||||
'path' => '/',
|
||||
'controller' => DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'action' => 'redirectToDefaultRoute',
|
||||
],
|
||||
];
|
@ -30,7 +30,11 @@
|
||||
<tr id="a-<?= $item['id'] ?>">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<td>
|
||||
<a class="bracketed" href="<?= $urlGenerator->url("/anime/edit/{$item['id']}/{$item['watching_status']}") ?>">Edit</a>
|
||||
<a class="bracketed" href="<?= $url->generate('edit', [
|
||||
'controller' => 'anime',
|
||||
'id' => $item['id'],
|
||||
'status' => $item['watching_status']
|
||||
]) ?>">Edit</a>
|
||||
</td>
|
||||
<?php endif ?>
|
||||
<td class="justify">
|
||||
|
@ -21,8 +21,11 @@
|
||||
<div class="table">
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<div class="row">
|
||||
<span class="edit"><a class="bracketed" href="<?= $urlGenerator->url("collection/edit/{$item['hummingbird_id']}") ?>">Edit</a></span>
|
||||
<?php /*<span class="delete"><a class="bracketed" href="<?= $urlGenerator->url("collection/delete/{$item['hummingbird_id']}") ?>">Delete</a></span> */ ?>
|
||||
<span class="edit">
|
||||
<a class="bracketed" href="<?= $url->generate('collection.edit.get', [
|
||||
'id' => $item['hummingbird_id']
|
||||
]) ?>">Edit</a>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<div class="row">
|
||||
|
@ -1,6 +1,6 @@
|
||||
<main>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<a class="bracketed" href="<?= $urlGenerator->fullUrl('collection/add', 'anime') ?>">Add Item</a>
|
||||
<a class="bracketed" href="<?= $url->generate('collection.add.get') ?>">Add Item</a>
|
||||
<?php endif ?>
|
||||
<?php if (empty($sections)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
@ -26,12 +26,11 @@
|
||||
<tr>
|
||||
<?php if($auth->isAuthenticated()): ?>
|
||||
<td>
|
||||
<a class="bracketed" href="<?= $urlGenerator->fullUrl("collection/edit/{$item['hummingbird_id']}") ?>">Edit</a>
|
||||
<?php /*<a class="bracketed" href="<?= $urlGenerator->fullUrl("collection/delete/{$item['hummingbird_id']}") ?>">Delete</a>*/ ?>
|
||||
<a class="bracketed" href="<?= $url->generate('collection.edit.get', ['id' => $item['hummingbird_id']]) ?>">Edit</a>
|
||||
</td>
|
||||
<?php endif ?>
|
||||
<td class="align_left">
|
||||
<a href="https://hummingbird.me/anime/<?= $item['slug'] ?>">
|
||||
<a href="<?= $url->generate('anime.details', ['id' => $item['slug']]) ?>">
|
||||
<?= $item['title'] ?>
|
||||
</a>
|
||||
<?= ( ! empty($item['alternate_title'])) ? " <br /><small> " . $item['alternate_title'] . "</small>" : "" ?>
|
||||
|
@ -6,11 +6,11 @@
|
||||
<?= $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>]
|
||||
[<a href="<?= $url->generate('collection.view') ?>"><?= ucfirst($url_type) ?> Collection</a>]
|
||||
<?php endif ?>
|
||||
[<a href="<?= $urlGenerator->defaultUrl($other_type) ?>"><?= ucfirst($other_type) ?> List</a>]
|
||||
<?php else: ?>
|
||||
<a href="<?= $urlGenerator->url('collection/view') ?>">
|
||||
<a href="<?= $url->generate('collection.view') ?>">
|
||||
<?= $config->get('whose_list') ?>'s <?= ucfirst($url_type) ?> Collection
|
||||
</a>
|
||||
[<a href="<?= $urlGenerator->defaultUrl('anime') ?>">Anime List</a>]
|
||||
|
@ -1,6 +1,6 @@
|
||||
<main>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<a class="bracketed" href="<?= $urlGenerator->url('manga/add') ?>">Add Item</a>
|
||||
<a class="bracketed" href="<?= $url->generate('manga.add.get') ?>">Add Item</a>
|
||||
<?php endif ?>
|
||||
<?php if (empty($sections)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
@ -14,6 +14,7 @@
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<div class="edit_buttons" hidden>
|
||||
<button class="plus_one_chapter">+1 Chapter</button>
|
||||
<?php /* <button class="plus_one_volume">+1 Volume</button> */ ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<img src="<?= $escape->attr($item['manga']['image']) ?>" />
|
||||
@ -29,7 +30,15 @@
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<div class="row">
|
||||
<span class="edit">
|
||||
<a class="bracketed" title="Edit information about this manga" href="<?= $urlGenerator->url("manga/edit/{$item['id']}/{$name}") ?>">Edit</a>
|
||||
<a class="bracketed"
|
||||
title="Edit information about this manga"
|
||||
href="<?= $url->generate('edit', [
|
||||
'controller' => 'manga',
|
||||
'id' => $item['id'],
|
||||
'status' => $name
|
||||
]) ?>">
|
||||
Edit
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<main>
|
||||
<?php if ($auth->isAuthenticated()): ?>
|
||||
<a class="bracketed" href="<?= $urlGenerator->url('manga/add') ?>">Add Item</a>
|
||||
<a class="bracketed" href="<?= $url->generate('manga.add.get') ?>">Add Item</a>
|
||||
<?php endif ?>
|
||||
<?php if (empty($sections)): ?>
|
||||
<h3>There's nothing here!</h3>
|
||||
@ -27,7 +27,11 @@
|
||||
<tr id="manga-<?= $item['id'] ?>">
|
||||
<?php if($auth->isAuthenticated()): ?>
|
||||
<td>
|
||||
<a class="bracketed" href="<?= $urlGenerator->url("manga/edit/{$item['id']}/{$name}") ?>">Edit</a>
|
||||
<a class="bracketed" href="<?= $url->generate('edit', [
|
||||
'controller' => 'manga',
|
||||
'id' => $item['id'],
|
||||
'status' => $name
|
||||
]) ?>">Edit</a>
|
||||
</td>
|
||||
<?php endif ?>
|
||||
<td class="align_left">
|
||||
|
@ -55,6 +55,7 @@ class Controller {
|
||||
'config' => $this->config
|
||||
]);
|
||||
|
||||
$this->url = $auraUrlGenerator;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
|
||||
$session = $container->get('session');
|
||||
@ -133,7 +134,7 @@ class Controller {
|
||||
}
|
||||
|
||||
$this->setFlashMessage('Invalid username or password.');
|
||||
$this->redirect($this->urlGenerator->url('login'), 303);
|
||||
$this->redirect($this->url->generate('login'), 303);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,7 +116,7 @@ class Anime extends BaseController {
|
||||
$this->config->get('whose_list') . "'s Anime List",
|
||||
'Add'
|
||||
),
|
||||
'action_url' => $this->urlGenerator->url('anime/add'),
|
||||
'action_url' => $this->url->generate('anime.add.post'),
|
||||
'status_list' => AnimeWatchingStatus::KITSU_TO_TITLE
|
||||
]);
|
||||
}
|
||||
@ -168,8 +168,9 @@ class Anime extends BaseController {
|
||||
),
|
||||
'item' => $item,
|
||||
'statuses' => AnimeWatchingStatus::KITSU_TO_TITLE,
|
||||
'action' => $this->container->get('url-generator')
|
||||
->url('/anime/update_form'),
|
||||
'action' => $this->url->generate('update.post', [
|
||||
'controller' => 'anime'
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -41,18 +41,6 @@ class Collection extends BaseController {
|
||||
*/
|
||||
private $animeModel;
|
||||
|
||||
/**
|
||||
* Data to be sent to all routes in this controller
|
||||
* @var array $baseData
|
||||
*/
|
||||
protected $baseData;
|
||||
|
||||
/**
|
||||
* Url Generator class
|
||||
* @var UrlGenerator
|
||||
*/
|
||||
protected $urlGenerator;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -62,7 +50,6 @@ class Collection extends BaseController {
|
||||
{
|
||||
parent::__construct($container);
|
||||
|
||||
$this->urlGenerator = $container->get('url-generator');
|
||||
$this->animeModel = $container->get('anime-model');
|
||||
$this->animeCollectionModel = $container->get('anime-collection-model');
|
||||
$this->baseData = array_merge($this->baseData, [
|
||||
@ -118,10 +105,11 @@ class Collection extends BaseController {
|
||||
$this->setSessionRedirect();
|
||||
|
||||
$action = (is_null($id)) ? "Add" : "Edit";
|
||||
$urlAction = strtolower($action);
|
||||
|
||||
$this->outputHTML('collection/' . strtolower($action), [
|
||||
$this->outputHTML('collection/' . $urlAction, [
|
||||
'action' => $action,
|
||||
'action_url' => $this->urlGenerator->fullUrl('collection/' . strtolower($action)),
|
||||
'action_url' => $this->url->generate("collection.{$urlAction}.post"),
|
||||
'title' => $this->formatTitle(
|
||||
$this->config->get('whose_list') . "'s Anime Collection",
|
||||
$action
|
||||
|
@ -106,7 +106,7 @@ class Manga extends Controller {
|
||||
$this->config->get('whose_list') . "'s Manga List",
|
||||
'Add'
|
||||
),
|
||||
'action_url' => $this->urlGenerator->url('manga/add'),
|
||||
'action_url' => $this->url->generate('manga.add.post'),
|
||||
'status_list' => $statuses
|
||||
]);
|
||||
}
|
||||
@ -159,8 +159,9 @@ class Manga extends Controller {
|
||||
'title' => $title,
|
||||
'status_list' => MangaReadingStatus::KITSU_TO_TITLE,
|
||||
'item' => $item,
|
||||
'action' => $this->container->get('url-generator')
|
||||
->url('/manga/update_form'),
|
||||
'action' => $this->url->generate('update.post', [
|
||||
'controller' => 'manga'
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,12 @@ trait ControllerTrait {
|
||||
*/
|
||||
protected $urlGenerator;
|
||||
|
||||
/**
|
||||
* Aura url generator
|
||||
* @var \Aura\Router\Generator
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Session segment
|
||||
* @var \Aura\Session\Segment
|
||||
|
@ -16,10 +16,7 @@
|
||||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\Ion\
|
||||
{
|
||||
ArrayWrapper, StringWrapper
|
||||
};
|
||||
use Aviat\Ion\{ArrayWrapper, StringWrapper};
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
|
||||
/**
|
||||
|
@ -59,9 +59,8 @@ class RoutingBase {
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->config = $container->get('config');
|
||||
$baseRoutes = $this->config->get('routes');
|
||||
$this->routes = $baseRoutes['routes'];
|
||||
$this->routeConfig = $baseRoutes['route_config'];
|
||||
$this->routes = $this->config->get('routes');
|
||||
$this->routeConfig = $this->config->get('route_config');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,32 +108,5 @@ class UrlGenerator extends RoutingBase {
|
||||
|
||||
throw new InvalidArgumentException("Invalid default type: '{$type}'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate full url path from the route path based on config
|
||||
*
|
||||
* @param string $path - (optional) The route path
|
||||
* @param string $type - (optional) The controller (anime or manga), defaults to anime
|
||||
* @return string
|
||||
*/
|
||||
public function fullUrl(string $path = "", string $type = "anime"): string
|
||||
{
|
||||
$configDefaultRoute = $this->__get("default_{$type}_path");
|
||||
|
||||
// Remove beginning/trailing slashes
|
||||
$path = trim($path, '/');
|
||||
|
||||
// Set the default view
|
||||
if ($path === '')
|
||||
{
|
||||
$path .= trim($configDefaultRoute, '/');
|
||||
if ($this->__get('default_to_list_view'))
|
||||
{
|
||||
$path .= '/list';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->url($path);
|
||||
}
|
||||
}
|
||||
// End of UrlGenerator.php
|
@ -95,13 +95,11 @@ class AnimeClientTestCase extends TestCase {
|
||||
'file' => ':memory:',
|
||||
]
|
||||
],
|
||||
'route_config' => [
|
||||
'asset_path' => '/assets'
|
||||
],
|
||||
'routes' => [
|
||||
'route_config' => [
|
||||
'asset_path' => '/assets'
|
||||
],
|
||||
'routes' => [
|
||||
|
||||
]
|
||||
],
|
||||
'mal' => [
|
||||
'username' => 'foo',
|
||||
|
@ -72,39 +72,37 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
{
|
||||
$defaultConfig = [
|
||||
'routes' => [
|
||||
'routes' => [
|
||||
'login_form' => [
|
||||
'path' => '/login',
|
||||
'action' => 'login',
|
||||
'verb' => 'get'
|
||||
],
|
||||
'watching' => [
|
||||
'path' => '/anime/watching{/view}',
|
||||
'action' => 'anime_list',
|
||||
'params' => [
|
||||
'type' => 'currently-watching',
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'plan_to_read' => [
|
||||
'path' => '/manga/plan_to_read{/view}',
|
||||
'action' => 'manga_list',
|
||||
'params' => [
|
||||
'type' => 'Plan to Read',
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'login_form' => [
|
||||
'path' => '/login',
|
||||
'action' => 'login',
|
||||
'verb' => 'get'
|
||||
],
|
||||
'watching' => [
|
||||
'path' => '/anime/watching{/view}',
|
||||
'action' => 'anime_list',
|
||||
'params' => [
|
||||
'type' => 'currently-watching',
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'plan_to_read' => [
|
||||
'path' => '/manga/plan_to_read{/view}',
|
||||
'action' => 'manga_list',
|
||||
'params' => [
|
||||
'type' => 'Plan to Read',
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
],
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_list' => 'anime'
|
||||
]
|
||||
],
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_list' => 'anime'
|
||||
]
|
||||
];
|
||||
|
||||
$data = [
|
||||
@ -134,8 +132,8 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
]
|
||||
];
|
||||
|
||||
$data['manga_default_routing_anime']['config']['routes']['route_config']['default_list'] = 'manga';
|
||||
$data['manga_default_routing_manga']['config']['routes']['route_config']['default_list'] = 'manga';
|
||||
$data['manga_default_routing_anime']['config']['route_config']['default_list'] = 'manga';
|
||||
$data['manga_default_routing_manga']['config']['route_config']['default_list'] = 'manga';
|
||||
|
||||
return $data;
|
||||
}
|
||||
@ -169,36 +167,34 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
public function testDefaultRoute()
|
||||
{
|
||||
$config = [
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_anime_list_path' => "watching",
|
||||
'default_manga_list_path' => 'all',
|
||||
'default_list' => 'manga'
|
||||
],
|
||||
'routes' => [
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_anime_list_path' => "watching",
|
||||
'default_manga_list_path' => 'all',
|
||||
'default_list' => 'manga'
|
||||
'login_form' => [
|
||||
'path' => '/login',
|
||||
'action' => ['login'],
|
||||
'verb' => 'get'
|
||||
],
|
||||
'routes' => [
|
||||
'login_form' => [
|
||||
'path' => '/login',
|
||||
'action' => ['login'],
|
||||
'verb' => 'get'
|
||||
],
|
||||
'index' => [
|
||||
'path' => '/',
|
||||
'action' => ['redirect'],
|
||||
'params' => [
|
||||
'url' => '', // Determined by config
|
||||
'code' => '301'
|
||||
]
|
||||
],
|
||||
'index' => [
|
||||
'path' => '/',
|
||||
'action' => ['redirect'],
|
||||
'params' => [
|
||||
'url' => '', // Determined by config
|
||||
'code' => '301',
|
||||
'type' => 'manga'
|
||||
]
|
||||
'index' => [
|
||||
'path' => '/',
|
||||
'action' => ['redirect'],
|
||||
'params' => [
|
||||
'url' => '', // Determined by config
|
||||
'code' => '301'
|
||||
]
|
||||
],
|
||||
'index' => [
|
||||
'path' => '/',
|
||||
'action' => ['redirect'],
|
||||
'params' => [
|
||||
'url' => '', // Determined by config
|
||||
'code' => '301',
|
||||
'type' => 'manga'
|
||||
]
|
||||
]
|
||||
]
|
||||
@ -218,17 +214,15 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'controller_list_sanity_check' => [
|
||||
'config' => [
|
||||
'routes' => [
|
||||
'routes' => [
|
||||
|
||||
],
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_anime_list_path' => "watching",
|
||||
'default_manga_list_path' => 'all',
|
||||
'default_list' => 'manga'
|
||||
],
|
||||
]
|
||||
],
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_anime_list_path' => "watching",
|
||||
'default_manga_list_path' => 'all',
|
||||
'default_list' => 'manga'
|
||||
],
|
||||
],
|
||||
'expected' => [
|
||||
'anime' => 'Aviat\AnimeClient\Controller\Anime',
|
||||
@ -240,17 +234,15 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'empty_controller_list' => [
|
||||
'config' => [
|
||||
'routes' => [
|
||||
'routes' => [
|
||||
|
||||
],
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_anime_path' => "/anime/watching",
|
||||
'default_manga_path' => '/manga/all',
|
||||
'default_list' => 'manga'
|
||||
],
|
||||
]
|
||||
],
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_anime_path' => "/anime/watching",
|
||||
'default_manga_path' => '/manga/all',
|
||||
'default_list' => 'manga'
|
||||
],
|
||||
],
|
||||
'expected' => [
|
||||
'anime' => 'Aviat\AnimeClient\Controller\Anime',
|
||||
|
@ -49,60 +49,4 @@ class UrlGeneratorTest extends AnimeClientTestCase {
|
||||
$result = $urlGenerator->assetUrl(...$args);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function dataFullUrl()
|
||||
{
|
||||
return [
|
||||
'default_view' => [
|
||||
'config' => [
|
||||
'routes' => [
|
||||
'routes' => [],
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_list' => 'manga',
|
||||
'default_anime_path' => '/anime/watching',
|
||||
'default_manga_path' => '/manga/all',
|
||||
'default_to_list_view' => FALSE,
|
||||
]
|
||||
],
|
||||
],
|
||||
'path' => '',
|
||||
'type' => 'manga',
|
||||
'expected' => '//localhost/manga/all',
|
||||
],
|
||||
'default_view_list' => [
|
||||
'config' => [
|
||||
'routes' => [
|
||||
'routes' => [],
|
||||
'route_config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_list' => 'manga',
|
||||
'default_anime_path' => '/anime/watching',
|
||||
'default_manga_path' => '/manga/all',
|
||||
'default_to_list_view' => TRUE,
|
||||
]
|
||||
],
|
||||
],
|
||||
'path' => '',
|
||||
'type' => 'manga',
|
||||
'expected' => '//localhost/manga/all/list',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataFullUrl
|
||||
*/
|
||||
public function testFullUrl($config, $path, $type, $expected)
|
||||
{
|
||||
$config = new Config($config);
|
||||
$this->container->setInstance('config', $config);
|
||||
$urlGenerator = new UrlGenerator($this->container);
|
||||
|
||||
$result = $urlGenerator->fullUrl($path, $type);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user