From f386766841ee4f54cfec0aee0764a199ef294003 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 8 Dec 2015 14:52:59 -0500 Subject: [PATCH] Fix collection functionality --- app/bootstrap.php | 4 ++-- app/config/config.php | 2 +- app/config/menus.php | 8 -------- app/config/minify_js_groups.php | 10 ++++++++-- app/config/routes.php | 6 +++++- app/views/collection/add.php | 4 ++-- app/views/collection/cover.php | 12 ++++++------ app/views/collection/edit.php | 4 ++-- app/views/header.php | 18 +++++++++++++++--- build/update_header_comments.php | 1 + .../js/{collection.js => anime_collection.js} | 4 ++-- .../AnimeClient/Controller/Collection.php | 5 +++-- 12 files changed, 47 insertions(+), 31 deletions(-) rename public/js/{collection.js => anime_collection.js} (69%) diff --git a/app/bootstrap.php b/app/bootstrap.php index 9e8aa662..6e5c5e4f 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -1,8 +1,8 @@ set('url-generator', new UrlGenerator($container)); $container->set('auth', new HummingbirdAuth($container)); - + // Miscellaneous helper methods $anime_client = new AnimeClient(); $anime_client->setContainer($container); diff --git a/app/config/config.php b/app/config/config.php index f5429465..ea3b15a6 100644 --- a/app/config/config.php +++ b/app/config/config.php @@ -30,7 +30,7 @@ $config = [ 'show_anime_collection' => TRUE, // do you wish to show the manga collection? - 'show_manga_collection' => TRUE, + 'show_manga_collection' => FALSE, // path to public directory on the server 'asset_dir' => realpath(__DIR__ . '/../../public'), diff --git a/app/config/menus.php b/app/config/menus.php index a4d4a74f..6cfc1576 100644 --- a/app/config/menus.php +++ b/app/config/menus.php @@ -20,7 +20,6 @@ return [ 'on_hold' => '/on_hold', 'dropped' => '/dropped', 'completed' => '/completed', - //'collection' => '/collection/view', 'all' => '/all' ] ], @@ -34,12 +33,5 @@ return [ 'completed' => '/completed', 'all' => '/all' ] - ], - 'collection' => [ - 'route_prefix' => '/collection', - 'items' => [ - 'anime' => '/anime', - 'manga' => '/manga', - ] ] ]; \ No newline at end of file diff --git a/app/config/minify_js_groups.php b/app/config/minify_js_groups.php index 47cdd158..e39a7af3 100644 --- a/app/config/minify_js_groups.php +++ b/app/config/minify_js_groups.php @@ -36,11 +36,17 @@ return [ 'anime_edit.js', 'manga_edit.js' ], - 'collection' => [ + 'anime_collection' => [ 'lib/jquery.min.js', 'lib/jquery.throttle-debounce.js', 'lib/jsrender.js', - 'collection.js' + 'anime_collection.js' + ], + 'manga_collection' => [ + 'lib/jquery.min.js', + 'lib/jquery.throttle-debounce.js', + 'lib/jsrender.js', + 'manga_collection.js' ] ]; diff --git a/app/config/routes.php b/app/config/routes.php index b5d49b32..d75c8b4e 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -29,8 +29,12 @@ return [ ] ], ], - // Routes on collection controller + // Routes on anime collection controller 'collection' => [ + 'collection_search' => [ + 'path' => '/collection/search', + 'action' => 'search' + ], 'collection_add_form' => [ 'path' => '/collection/add', 'action' => 'form', diff --git a/app/views/collection/add.php b/app/views/collection/add.php index cbbaa396..3ff15a21 100644 --- a/app/views/collection/add.php +++ b/app/views/collection/add.php @@ -1,4 +1,4 @@ - +is_authenticated()): ?>
@@ -34,5 +34,5 @@ {{:title}} - + \ No newline at end of file diff --git a/app/views/collection/cover.php b/app/views/collection/cover.php index 4476b954..b3162624 100644 --- a/app/views/collection/cover.php +++ b/app/views/collection/cover.php @@ -1,7 +1,7 @@
- -[Add Item] - +is_authenticated()): ?> +[Add Item] +

There's nothing here!

@@ -27,9 +27,9 @@ - - [">Edit] - + is_authenticated()): ?> + [">Edit] + diff --git a/app/views/collection/edit.php b/app/views/collection/edit.php index 29411f01..fd6bf1c6 100644 --- a/app/views/collection/edit.php +++ b/app/views/collection/edit.php @@ -1,4 +1,4 @@ - +is_authenticated()): ?>
@@ -33,5 +33,5 @@ {{:title}} - + \ No newline at end of file diff --git a/app/views/header.php b/app/views/header.php index 51e5c85d..014103a0 100644 --- a/app/views/header.php +++ b/app/views/header.php @@ -13,9 +13,21 @@

- - get('whose_list') ?>'s - [ List] + + + get('whose_list') ?>'s List + + get("show_{$url_type}_collection")): ?> + [ Collection] + + [ List] + + + get('whose_list') ?>'s Collection + + [Anime List] + [Manga List] + is_authenticated()): ?> diff --git a/build/update_header_comments.php b/build/update_header_comments.php index 031e2741..967e881a 100644 --- a/build/update_header_comments.php +++ b/build/update_header_comments.php @@ -2,6 +2,7 @@ $animeclient_file_patterns = [ 'app/config/*.php', + 'app/booststrap.php', 'src/functions.php', 'src/Aviat/AnimeClient/*.php' ]; diff --git a/public/js/collection.js b/public/js/anime_collection.js similarity index 69% rename from public/js/collection.js rename to public/js/anime_collection.js index ed40a344..db9c06d0 100755 --- a/public/js/collection.js +++ b/public/js/anime_collection.js @@ -2,10 +2,10 @@ function search(query, callback) { - $.get(BASE_URL + 'search', {'query':query}, callback); + $.get(BASE_URL + 'collection/search', {'query':query}, callback); } - $("#search").on('keypress', $.throttle(250, function(e) { + $("#search").on('keypress', $.throttle(750, function(e) { var query = encodeURIComponent($(this).val()); search(query, function(res) { var template = $.templates("#show_list"); diff --git a/src/Aviat/AnimeClient/Controller/Collection.php b/src/Aviat/AnimeClient/Controller/Collection.php index 8fd3e970..8e7cb3f9 100644 --- a/src/Aviat/AnimeClient/Controller/Collection.php +++ b/src/Aviat/AnimeClient/Controller/Collection.php @@ -53,6 +53,7 @@ class Collection extends BaseController { parent::__construct($container); $this->urlGenerator = $container->get('url-generator'); + $this->anime_model = new AnimeModel($container); $this->anime_collection_model = new AnimeCollectionModel($container); $this->base_data = array_merge($this->base_data, [ 'menu_name' => 'collection', @@ -71,7 +72,7 @@ class Collection extends BaseController { public function search() { $query = $this->request->query->get('query'); - $this->outputJSON($this->model->search($query)); + $this->outputJSON($this->anime_model->search($query)); } /** @@ -109,7 +110,7 @@ class Collection extends BaseController { $this->outputHTML('collection/' . strtolower($action), [ 'action' => $action, 'action_url' => $this->urlGenerator->full_url("collection/" . strtolower($action)), - 'title' => $this->config->whose_list . " Anime Collection · {$action}", + 'title' => $this->config->get('whose_list') . " Anime Collection · {$action}", 'media_items' => $this->anime_collection_model->get_media_type_list(), 'item' => ($action === "Edit") ? $this->anime_collection_model->get($id) : [] ]);