Fix collection functionality

This commit is contained in:
Timothy Warren 2015-12-08 14:52:59 -05:00
parent 7d1c8c383c
commit 70bfe2bab7
12 changed files with 47 additions and 31 deletions

View File

@ -1,8 +1,8 @@
<?php
/**
* Bootstrap / Dependency Injection
*/
namespace Aviat\AnimeClient;
use Aura\Html\HelperLocatorFactory;

View File

@ -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'),

View File

@ -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',
]
]
];

View File

@ -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'
]
];

View File

@ -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',

View File

@ -1,4 +1,4 @@
<?php if (is_logged_in()): ?>
<?php if ($auth->is_authenticated()): ?>
<main>
<form action="<?= $action_url ?>" method="post">
<dl>
@ -34,5 +34,5 @@
<img src="{{:cover_image}}" alt="{{:title}}" />
</article>
</template>
<script src="<?= $config->asset_url('js.php?g=collection&debug=1') ?>"></script>
<script src="<?= $urlGenerator->asset_url('js.php?g=anime_collection') ?>"></script>
<?php endif ?>

View File

@ -1,7 +1,7 @@
<main>
<?php /*if (is_logged_in()): ?>
[<a href="<?= $config->full_url('collection/add', 'anime') ?>">Add Item</a>]
<?php endif*/ ?>
<?php if ($auth->is_authenticated()): ?>
[<a href="<?= $urlGenerator->url('collection/add', 'anime') ?>">Add Item</a>]
<?php endif ?>
<?php if (empty($sections)): ?>
<h3>There's nothing here!</h3>
<?php else: ?>
@ -27,9 +27,9 @@
</div>
</article>
<?php /*if (is_logged_in()): ?>
<span>[<a href="<?= $urlGenerator->full_url("collection/edit/{$item['hummingbird_id']}", "anime") ?>">Edit</a>]</span>
<?php endif*/ ?>
<?php if ($auth->is_authenticated()): ?>
<span>[<a href="<?= $urlGenerator->url("collection/edit/{$item['hummingbird_id']}", "anime") ?>">Edit</a>]</span>
<?php endif ?>
<?php endforeach ?>
</section>
</section>

View File

@ -1,4 +1,4 @@
<?php if (is_logged_in()): ?>
<?php if ($auth->is_authenticated()): ?>
<main>
<form action="<?= $action_url ?>" method="post">
<dl>
@ -33,5 +33,5 @@
<img src="{{:cover_image}}" alt="{{:title}}" />
</article>
</template>
<script src="<?= $config->asset_url('js.php?g=collection&debug=1') ?>"></script>
<script src="<?= $urlGenerator->asset_url('js.php?g=anime_collection') ?>"></script>
<?php endif ?>

View File

@ -13,9 +13,21 @@
<body class="<?= $escape->attr($url_type) ?> list">
<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) ?> <?= (strpos($route_path, 'collection') !== FALSE) ? 'Collection' : 'List' ?>
</a> [<a href="<?= $urlGenerator->default_url($other_type) ?>"><?= ucfirst($other_type) ?> List</a>]
<?= $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>
<span class="flex-no-wrap small-font">
<?php if ($auth->is_authenticated()): ?>

View File

@ -2,6 +2,7 @@
$animeclient_file_patterns = [
'app/config/*.php',
'app/booststrap.php',
'src/functions.php',
'src/Aviat/AnimeClient/*.php'
];

View File

@ -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");

View File

@ -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 &middot; {$action}",
'title' => $this->config->get('whose_list') . " Anime Collection &middot; {$action}",
'media_items' => $this->anime_collection_model->get_media_type_list(),
'item' => ($action === "Edit") ? $this->anime_collection_model->get($id) : []
]);