Version 5.1 - All the GraphQL #32
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
*.workspace
|
||||
vendor
|
||||
app/cache/*
|
||||
app/logs/*
|
||||
public/images/*
|
||||
public/js/cache/*
|
||||
composer.lock
|
||||
|
@ -9,6 +9,10 @@ use Aura\Html\HelperLocatorFactory;
|
||||
use Aura\Web\WebFactory;
|
||||
use Aura\Router\RouterFactory;
|
||||
use Aura\Session\SessionFactory;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Handler\BrowserConsoleHandler;
|
||||
|
||||
use Aviat\Ion\Di\Container;
|
||||
use Aviat\AnimeClient\Auth\HummingbirdAuth;
|
||||
|
||||
@ -18,6 +22,15 @@ use Aviat\AnimeClient\Auth\HummingbirdAuth;
|
||||
return function(array $config_array = []) {
|
||||
$container = new Container();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Logging
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$app_logger = new Logger('animeclient');
|
||||
$app_logger->pushHandler(new RotatingFileHandler(__DIR__.'/logs/app.log', Logger::NOTICE));
|
||||
$app_logger->pushHandler(new BrowserConsoleHandler(Logger::DEBUG));
|
||||
$container->setLogger($app_logger);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Injected Objects
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -9,6 +9,7 @@ return [
|
||||
'on_hold' => '/on_hold',
|
||||
'dropped' => '/dropped',
|
||||
'completed' => '/completed',
|
||||
//'collection' => '/collection/view',
|
||||
'all' => '/all'
|
||||
]
|
||||
],
|
||||
|
0
app/logs/.gitkeep
Normal file
0
app/logs/.gitkeep
Normal file
@ -8,12 +8,12 @@
|
||||
<section class="media-wrap">
|
||||
<?php foreach($items as $item): ?>
|
||||
<article class="media" id="manga-<?= $item['id'] ?>">
|
||||
<?php /*if (is_logged_in()): ?>
|
||||
<?php if ($auth->is_authenticated()): ?>
|
||||
<div class="edit_buttons" hidden>
|
||||
<button class="plus_one_chapter">+1 Chapter</button>
|
||||
<button class="plus_one_volume">+1 Volume</button>
|
||||
</div>
|
||||
<?php endif*/ ?>
|
||||
<?php endif ?>
|
||||
<img src="<?= $escape->attr($item['manga']['image']) ?>" />
|
||||
<div class="name">
|
||||
<a href="<?= $item['manga']['url'] ?>">
|
||||
@ -45,6 +45,6 @@
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
</main>
|
||||
<?php /*if (is_logged_in()): ?>
|
||||
<?php if ($auth->is_authenticated()): ?>
|
||||
<script src="<?= $urlGenerator->asset_url('js.php?g=edit') ?>"></script>
|
||||
<?php endif*/ ?>
|
||||
<?php endif ?>
|
||||
|
@ -13,6 +13,8 @@
|
||||
"danielstjules/stringy": "~2.1",
|
||||
"filp/whoops": "dev-php7#fe32a402b086b21360e82013e8a0355575c7c6f4",
|
||||
"guzzlehttp/guzzle": "6.*",
|
||||
"monolog/monolog": "1.*",
|
||||
"psr/log": "~1.0",
|
||||
"robmorgan/phinx": "0.4.*",
|
||||
"szymach/c-pchart": "1.*"
|
||||
}
|
||||
|
@ -80,6 +80,6 @@ $container->set('error-handler', $defaultHandler);
|
||||
// -----------------------------------------------------------------------------
|
||||
// Dispatch to the current route
|
||||
// -----------------------------------------------------------------------------
|
||||
$container->get('dispatcher')();
|
||||
$container->get('dispatcher')->__invoke();
|
||||
|
||||
// End of index.php
|
0
public/js/collection.js
Normal file → Executable file
0
public/js/collection.js
Normal file → Executable file
14
public/js/manga_edit.js
Normal file → Executable file
14
public/js/manga_edit.js
Normal file → Executable file
@ -1,7 +1,9 @@
|
||||
/**
|
||||
* Javascript for editing manga, if logged in
|
||||
*/
|
||||
(function ($, undefined) {
|
||||
(function ($) {
|
||||
|
||||
"use strict";
|
||||
|
||||
if (CONTROLLER !== "manga") return;
|
||||
|
||||
@ -28,10 +30,18 @@
|
||||
// Update the total count
|
||||
data[type + "s_read"] = ++completed;
|
||||
|
||||
$.post(BASE_URL + 'update', data, function(res) {
|
||||
$.ajax({
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
mimeType: 'application/json',
|
||||
url: BASE_URL + '/' + CONTROLLER + '/update'
|
||||
}).done(function(res) {
|
||||
console.table(res);
|
||||
parent_sel.find("."+type+"s_read").text(completed);
|
||||
add_message('success', "Sucessfully updated " + res.manga[0].romaji_title);
|
||||
}).fail(function() {
|
||||
add_message('error', "Failed to updated " + res.manga[0].romaji_title);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Aviat\Ion\Di;
|
||||
|
||||
use ArrayObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Dependency container
|
||||
@ -16,6 +17,13 @@ class Container implements ContainerInterface {
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Map of logger instances
|
||||
*
|
||||
* @var ArrayObject
|
||||
*/
|
||||
protected $loggers = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -24,6 +32,7 @@ class Container implements ContainerInterface {
|
||||
public function __construct(array $values = [])
|
||||
{
|
||||
$this->container = new ArrayObject($values);
|
||||
$this->loggers = new ArrayObject([]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +65,7 @@ class Container implements ContainerInterface {
|
||||
*
|
||||
* @param string $id
|
||||
* @param mixed $value
|
||||
* @return Container
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function set($id, $value)
|
||||
{
|
||||
@ -76,5 +85,41 @@ class Container implements ContainerInterface {
|
||||
{
|
||||
return $this->container->offsetExists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a logger channel is registered
|
||||
* @param string $key The logger channel
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasLogger($key = 'default')
|
||||
{
|
||||
return $this->loggers->offsetExists($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a logger to the Container
|
||||
*
|
||||
* @param LoggerInterface $logger
|
||||
* @param string $key The logger 'channel'
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function setLogger(LoggerInterface $logger, $key = 'default')
|
||||
{
|
||||
$this->loggers[$key] = $logger;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a logger for the selected channel
|
||||
*
|
||||
* @param string $key The logger to retreive
|
||||
* @return LoggerInterface|null
|
||||
*/
|
||||
public function getLogger($key = 'default')
|
||||
{
|
||||
return ($this->hasLogger($key))
|
||||
? $this->loggers[$key]
|
||||
: NULL;
|
||||
}
|
||||
}
|
||||
// End of Container.php
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace Aviat\Ion\Di;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Interface for the Dependency Injection Container
|
||||
*/
|
||||
@ -15,4 +17,20 @@ interface ContainerInterface extends \Interop\Container\ContainerInterface {
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function set($key, $value);
|
||||
|
||||
/**
|
||||
* Add a logger to the Container
|
||||
*
|
||||
* @param LoggerInterface $logger
|
||||
* @param string $key The logger 'channel'
|
||||
*/
|
||||
public function setLogger(LoggerInterface $logger, $key = 'default');
|
||||
|
||||
/**
|
||||
* Retrieve a logger for the selected channel
|
||||
*
|
||||
* @param string $key The logger to retreive
|
||||
* @return LoggerInterface|null
|
||||
*/
|
||||
public function getLogger($key = 'default');
|
||||
}
|
@ -2,6 +2,9 @@
|
||||
|
||||
use Aviat\Ion\Di\Container;
|
||||
use Aviat\Ion\Di\Exception\ContainerException;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Handler\TestHandler;
|
||||
use Monolog\Handler\NullHandler;
|
||||
|
||||
|
||||
class ContainerTest extends AnimeClient_TestCase {
|
||||
@ -48,4 +51,27 @@ class ContainerTest extends AnimeClient_TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public function testLoggerMethods()
|
||||
{
|
||||
// Does the container have the default logger?
|
||||
$this->assertFalse($this->container->hasLogger());
|
||||
$this->assertFalse($this->container->hasLogger('default'));
|
||||
|
||||
$logger1 = new Logger('default');
|
||||
$logger2 = new Logger('testing');
|
||||
$logger1->pushHandler(new NullHandler());
|
||||
$logger2->pushHandler(new TestHandler());
|
||||
|
||||
// Set the logger channels
|
||||
$this->container->setLogger($logger1);
|
||||
$this->container->setLogger($logger2, 'test');
|
||||
|
||||
$this->assertEquals($logger1, $this->container->getLogger('default'));
|
||||
$this->assertEquals($logger2, $this->container->getLogger('test'));
|
||||
$this->assertNull($this->container->getLogger('foo'));
|
||||
|
||||
$this->assertTrue($this->container->hasLogger());
|
||||
$this->assertTrue($this->container->hasLogger('default'));
|
||||
$this->assertTrue($this->container->hasLogger('test'));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user