From 6b322d18da0e624a574caf10a896f2c772ffc539 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 5 Oct 2015 16:54:25 -0400 Subject: [PATCH] Miscellaneous updates, prep for menu generator --- README.md | 4 +- app/bootstrap.php | 12 +- app/config/base_config.php | 3 +- app/config/config.php | 5 +- app/config/menus.php | 61 +++++++++ app/config/routes.php | 69 ++-------- app/config/routing.php | 10 +- phpdoc.dist.xml | 2 +- src/Aviat/AnimeClient/Controller.php | 7 +- src/Aviat/AnimeClient/Controller/Anime.php | 19 ++- src/Aviat/AnimeClient/Controller/Manga.php | 21 ++- src/Aviat/AnimeClient/Helper/Menu.php | 20 +++ src/Aviat/AnimeClient/Helper/UrlHelper.php | 19 +++ src/Aviat/AnimeClient/MenuGenerator.php | 106 ++++++++++++++ src/Aviat/AnimeClient/Model.php | 10 +- src/Aviat/AnimeClient/Model/API.php | 9 +- src/Aviat/AnimeClient/Model/Anime.php | 75 ++++------ src/Aviat/AnimeClient/Model/Manga.php | 152 ++++++++++----------- src/Aviat/Ion/ArrayWrapper.php | 21 +++ src/Aviat/Ion/StringWrapper.php | 6 +- src/Aviat/Ion/Type/ArrayType.php | 142 +++++++++++++++++++ src/Aviat/Ion/Type/StringType.php | 10 ++ src/Aviat/Ion/View/HtmlView.php | 14 +- tests/Ion/Type/ArrayTypeTest.php | 54 ++++++++ 24 files changed, 631 insertions(+), 220 deletions(-) create mode 100644 app/config/menus.php create mode 100644 src/Aviat/AnimeClient/Helper/Menu.php create mode 100644 src/Aviat/AnimeClient/Helper/UrlHelper.php create mode 100644 src/Aviat/AnimeClient/MenuGenerator.php create mode 100644 src/Aviat/Ion/ArrayWrapper.php create mode 100644 src/Aviat/Ion/Type/ArrayType.php create mode 100644 src/Aviat/Ion/Type/StringType.php create mode 100644 tests/Ion/Type/ArrayTypeTest.php diff --git a/README.md b/README.md index 28053f2a..1e8b4a65 100644 --- a/README.md +++ b/README.md @@ -31,14 +31,14 @@ A self-hosted client that allows custom formatting of data from the hummingbird ### Requirements -* PHP 5.4+ +* PHP 5.5+ * PDO SQLite (For collection tab) * GD ### Installation 1. Install dependencies via composer: `composer install` -2. Configure settings in `app/config/config.php` and `app/config/routing.php` to your liking +2. Configure settings in `app/config/config.php` to your liking 3. Create the following directories if they don't exist, and make sure they are world writable * app/cache * public/images/manga diff --git a/app/bootstrap.php b/app/bootstrap.php index 79a6fa17..ccca2cf8 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -7,6 +7,7 @@ namespace Aviat\AnimeClient; use \Whoops\Handler\PrettyPageHandler; use \Whoops\Handler\JsonResponseHandler; +use Aura\Html\HelperLocatorFactory; use \Aura\Web\WebFactory; use \Aura\Router\RouterFactory; use \Aura\Session\SessionFactory; @@ -51,6 +52,15 @@ $di = function() { $aura_router = (new RouterFactory())->newInstance(); $container->set('aura-router', $aura_router); + // Create Html helper Object + $html_helper = (new HelperLocatorFactory)->newInstance(); + $html_helper->set('menu', function() use ($container) { + $menu_helper = new Helper\Menu(); + $menu_helper->setContainer($container); + return $menu_helper; + }); + $container->set('html-helper', $html_helper); + // Create Request/Response Objects $web_factory = new WebFactory([ '_GET' => $_GET, @@ -79,4 +89,4 @@ $di = function() { $di()->get('router')->dispatch(); -// End of bootstrap.php +// End of bootstrap.php \ No newline at end of file diff --git a/app/config/base_config.php b/app/config/base_config.php index e78b5338..95cd0380 100644 --- a/app/config/base_config.php +++ b/app/config/base_config.php @@ -13,6 +13,7 @@ $base_config = [ 'img_cache_path' => _dir(ROOT_DIR, 'public/images'), // Included config files - 'routes' => require __DIR__ . '/routes.php', 'database' => require __DIR__ . '/database.php', + 'menus' => require __DIR__ . '/menus.php', + 'routes' => require __DIR__ . '/routes.php', ]; \ No newline at end of file diff --git a/app/config/config.php b/app/config/config.php index 7e59cf92..15bfb5c1 100644 --- a/app/config/config.php +++ b/app/config/config.php @@ -14,9 +14,12 @@ $config = [ // General config // ---------------------------------------------------------------------------- - // do you wish to show the anime collection tab? + // do you wish to show the anime collection? 'show_anime_collection' => TRUE, + // do you wish to show the manga collection? + 'show_manga_collection' => TRUE, + // path to public directory on the server 'asset_dir' => realpath(__DIR__ . '/../../public'), diff --git a/app/config/menus.php b/app/config/menus.php new file mode 100644 index 00000000..1d4ce011 --- /dev/null +++ b/app/config/menus.php @@ -0,0 +1,61 @@ + [ + 'default' => '', + 'items' => [ + 'anime_list' => '{anime_list}', + 'manga_list' => '{manga_list}', + 'collection' => '{collection}' + ] + ], + 'view_type' => [ + 'is_parent' => FALSE, + 'default' => 'cover_view', + 'items' => [ + 'cover_view' => '{parent}', + 'list_view' => '{parent}/list' + ] + ], + 'anime_list' => [ + 'default' => '', + 'route_prefix' => '/anime', + 'items' => [ + 'watching' => '/watching', + 'plan_to_watch' => '/plan_to_watch', + 'on_hold' => '/on_hold', + 'dropped' => '/dropped', + 'completed' => '/completed', + 'all' => '/all' + ], + 'children' => [ + 'view_type' + ] + ], + 'manga_list' => [ + 'default' => '', + 'route_prefix' => '/manga', + 'items' => [ + 'reading' => '/reading', + 'plan_to_read' => '/plan_to_read', + 'on_hold' => '/on_hold', + 'dropped' => '/dropped', + 'completed' => '/completed', + 'all' => '/all' + ], + 'children' => [ + 'view_type' + ] + ], + 'collection' => [ + 'default' => '', + 'route_prefix' => '/collection', + 'items' => [ + 'anime' => '/anime', + 'manga' => '/manga', + ], + 'children' => [ + 'view_type' + ] + ] +]; \ No newline at end of file diff --git a/app/config/routes.php b/app/config/routes.php index 1320249a..2b8e18ba 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -9,99 +9,56 @@ return [ // Routes on all controllers 'common' => [ 'update' => [ - 'path' => '/update', - 'action' => ['update'], + 'path' => '/{controller}/update', + 'action' => 'update', 'verb' => 'post' ], 'login_form' => [ - 'path' => '/login', - 'action' => ['login'], + 'path' => '/{controller}/login', + 'action' => 'login', 'verb' => 'get' ], 'login_action' => [ - 'path' => '/login', - 'action' => ['login_action'], + 'path' => '/{controller}/login', + 'action' => 'login_action', 'verb' => 'post' ], 'logout' => [ - 'path' => '/logout', - 'action' => ['logout'] + 'path' => '/{controller}/logout', + 'action' => 'logout' ], ], // Routes on collection controller 'collection' => [ 'collection_add_form' => [ 'path' => '/collection/add', - 'action' => ['form'], + 'action' => 'form', 'params' => [], ], 'collection_edit_form' => [ 'path' => '/collection/edit/{id}', - 'action' => ['form'], + 'action' => 'form', 'tokens' => [ 'id' => '[0-9]+' ] ], 'collection_add' => [ 'path' => '/collection/add', - 'action' => ['add'], + 'action' => 'add', 'verb' => 'post' ], 'collection_edit' => [ 'path' => '/collection/edit', - 'action' => ['edit'], + 'action' => 'edit', 'verb' => 'post' ], 'collection' => [ 'path' => '/collection/view{/view}', - 'action' => ['index'], + 'action' => 'index', 'params' => [], 'tokens' => [ 'view' => '[a-z_]+' ] ], ], - // Routes on anime controller - 'anime' => [ - 'index' => [ - 'path' => '/', - 'action' => ['redirect'], - 'params' => [ - 'url' => '', // Determined by config - 'code' => '301', - 'type' => 'anime' - ] - ], - 'search' => [ - 'path' => '/anime/search', - 'action' => ['search'], - ], - 'anime_list' => [ - 'path' => '/anime/{type}{/view}', - 'action' => ['anime_list'], - 'tokens' => [ - 'type' => '[a-z_]+', - 'view' => '[a-z_]+' - ] - ], - ], - 'manga' => [ - 'index' => [ - 'path' => '/', - 'action' => ['redirect'], - 'params' => [ - 'url' => '', // Determined by config - 'code' => '301', - 'type' => 'manga' - ] - ], - 'manga_list' => [ - 'path' => '/manga/{type}{/view}', - 'action' => ['manga_list'], - 'tokens' => [ - 'type' => '[a-z_]+', - 'view' => '[a-z_]+' - ] - ] - ] ]; diff --git a/app/config/routing.php b/app/config/routing.php index b1626e00..16068c3e 100644 --- a/app/config/routing.php +++ b/app/config/routing.php @@ -5,7 +5,7 @@ // ---------------------------------------------------------------------------- return [ - // Subfolder prefix for url + // Subfolder prefix for url, if in a subdirectory of the web root 'subfolder_prefix' => '', // Path to public directory, where images/css/javascript are located, @@ -16,9 +16,9 @@ return [ 'default_list' => 'anime', // anime or manga // Default pages for anime/manga - 'default_anime_path' => "/anime/watching", - 'default_manga_path' => '/manga/all', + 'default_anime_list_path' => "watching", // watching|plan_to_watch|on_hold|dropped|completed|all + 'default_manga_list_path' => "all", // reading|plan_to_read|on_hold|dropped|completed|all - // Default to list view? - 'default_to_list_view' => FALSE, + // Default view type (cover_view/list_view) + 'default_view_type' => 'cover_view', ]; \ No newline at end of file diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml index 221e6285..194e906e 100644 --- a/phpdoc.dist.xml +++ b/phpdoc.dist.xml @@ -11,6 +11,6 @@