Compare commits
3 Commits
0cb09dc4b8
...
0fefece3e3
Author | SHA1 | Date |
---|---|---|
Timothy Warren | 0fefece3e3 | |
Timothy Warren | 5fe48dfd57 | |
Timothy Warren | 45b545d32d |
|
@ -43,7 +43,6 @@ Update your anime/manga list on Kitsu.io and MyAnimeList.net
|
|||
3. Configure settings in `app/config/config.toml` to your liking
|
||||
4. Create the following directories if they don't exist, and make sure they are world writable
|
||||
* app/logs
|
||||
* public/js/cache
|
||||
* public/images/avatars
|
||||
* public/images/anime
|
||||
* public/images/characters
|
||||
|
|
|
@ -28,6 +28,8 @@ $tomlConfig = loadToml(__DIR__);
|
|||
|
||||
return array_merge($tomlConfig, [
|
||||
'asset_dir' => "{$ROOT_DIR}/public",
|
||||
'base_config_dir' => __DIR__,
|
||||
'config_dir' => "{$APP_DIR}/config",
|
||||
|
||||
// Template file path
|
||||
'view_path' => "{$APP_DIR}/views",
|
||||
|
|
|
@ -215,6 +215,12 @@ return [
|
|||
'controller' => DEFAULT_CONTROLLER,
|
||||
'verb' => 'get',
|
||||
],
|
||||
'settings-post' => [
|
||||
'path' => '/settings',
|
||||
'action' => 'settings',
|
||||
'controller' => DEFAULT_CONTROLLER,
|
||||
'verb' => 'post',
|
||||
],
|
||||
'login' => [
|
||||
'path' => '/login',
|
||||
'action' => 'login',
|
||||
|
|
|
@ -15,5 +15,3 @@ default_list = "anime" # anime or 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"
|
14
index.php
14
index.php
|
@ -16,6 +16,8 @@
|
|||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\AnimeClient\Types\Config as ConfigType;
|
||||
|
||||
use function Aviat\Ion\_dir;
|
||||
|
||||
// Work around the silly timezone error
|
||||
|
@ -43,19 +45,17 @@ $CONF_DIR = _dir($APP_DIR, 'config');
|
|||
// -----------------------------------------------------------------------------
|
||||
// Dependency Injection setup
|
||||
// -----------------------------------------------------------------------------
|
||||
$base_config = require $APPCONF_DIR . '/base_config.php';
|
||||
$baseConfig = require $APPCONF_DIR . '/base_config.php';
|
||||
$di = require $APP_DIR . '/bootstrap.php';
|
||||
|
||||
$config = loadToml($CONF_DIR);
|
||||
$config_array = array_merge($base_config, $config);
|
||||
// User config
|
||||
$config_array['default_config'] = $base_config;
|
||||
$config_array['user_config_settings'] = $config;
|
||||
$configArray = array_merge($baseConfig, $config);
|
||||
|
||||
$container = $di($config_array);
|
||||
$checkedConfig = (new ConfigType($configArray))->toArray();
|
||||
$container = $di($checkedConfig);
|
||||
|
||||
// Unset 'constants'
|
||||
unset($APP_DIR, $APPCONF_DIR);
|
||||
unset($APP_DIR, $CONF_DIR, $APPCONF_DIR);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Dispatch to the current route
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Hummingbird Anime List Client
|
||||
*
|
||||
|
@ -51,6 +51,7 @@ use Amp\Socket\{
|
|||
use Amp\Uri\{
|
||||
InvalidUriException, Uri
|
||||
};
|
||||
use const Aviat\AnimeClient\USER_AGENT;
|
||||
use function Amp\{
|
||||
asyncCall, call
|
||||
};
|
||||
|
@ -63,7 +64,7 @@ use function Amp\{
|
|||
* @see Client
|
||||
*/
|
||||
final class HummingbirdClient implements Client {
|
||||
const DEFAULT_USER_AGENT = 'Hummingbird Anime Client/5.0';
|
||||
const DEFAULT_USER_AGENT = USER_AGENT;
|
||||
|
||||
private $cookieJar;
|
||||
private $socketPool;
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Aviat\AnimeClient\Types;
|
|||
use ArrayAccess;
|
||||
use LogicException;
|
||||
|
||||
class AbstractType implements ArrayAccess {
|
||||
abstract class AbstractType implements ArrayAccess {
|
||||
/**
|
||||
* Populate values for unserializing data
|
||||
*
|
||||
|
@ -83,7 +83,7 @@ class AbstractType implements ArrayAccess {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property_exists($this, $name))
|
||||
if ( ! property_exists($this, $name))
|
||||
{
|
||||
$existing = json_encode($this);
|
||||
|
||||
|
@ -154,4 +154,31 @@ class AbstractType implements ArrayAccess {
|
|||
unset($this->$offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively cast properties to an array
|
||||
*
|
||||
* @param null $parent
|
||||
* @return mixed
|
||||
*/
|
||||
public function toArray($parent = null)
|
||||
{
|
||||
$object = $parent ?? $this;
|
||||
|
||||
if (is_scalar($object))
|
||||
{
|
||||
return $object;
|
||||
}
|
||||
|
||||
$output = [];
|
||||
|
||||
foreach ($object as $key => $value)
|
||||
{
|
||||
$output[$key] = is_scalar($value)
|
||||
? $value
|
||||
: $this->toArray((array) $value);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Hummingbird Anime List Client
|
||||
*
|
||||
* An API client for Kitsu to manage anime and manga watch lists
|
||||
*
|
||||
* PHP version 7
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2018 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 4.0
|
||||
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Types;
|
||||
|
||||
class Config extends AbstractType {
|
||||
// Config files/namespaces
|
||||
public $anilist;
|
||||
public $cache;
|
||||
public $database;
|
||||
public $route_config;
|
||||
|
||||
// Settings in config.toml
|
||||
public $kitsu_username;
|
||||
public $show_anime_collection;
|
||||
public $show_manga_collection;
|
||||
public $whose_list;
|
||||
|
||||
// Application config
|
||||
public $menus;
|
||||
public $routes;
|
||||
|
||||
// Generated config values
|
||||
public $asset_dir;
|
||||
public $base_config_dir;
|
||||
public $config_dir;
|
||||
public $data_cache_path;
|
||||
public $img_cache_path;
|
||||
public $view_path;
|
||||
|
||||
public function setAnilist ($data): void
|
||||
{
|
||||
$this->anilist = new class($data) extends AbstractType {
|
||||
public $client_id;
|
||||
public $client_secret;
|
||||
public $redirect_uri;
|
||||
|
||||
public $access_token;
|
||||
public $refresh_token;
|
||||
|
||||
public $user_id;
|
||||
public $username;
|
||||
};
|
||||
}
|
||||
|
||||
public function setCache ($data): void
|
||||
{
|
||||
$this->cache = new class($data) extends AbstractType {
|
||||
public $driver;
|
||||
public $connection;
|
||||
public $options;
|
||||
};
|
||||
}
|
||||
|
||||
public function setDatabase ($data): void
|
||||
{
|
||||
$this->database = new class($data) extends AbstractType {
|
||||
public $collection;
|
||||
|
||||
public function setCollection ($data): void
|
||||
{
|
||||
$this->collection = new class($data) extends AbstractType {
|
||||
public $type;
|
||||
public $host;
|
||||
public $user;
|
||||
public $pass;
|
||||
public $port;
|
||||
public $database;
|
||||
public $file;
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public function setRoute_config ($data): void
|
||||
{
|
||||
$this->route_config = new class($data) extends AbstractType {
|
||||
public $asset_path;
|
||||
public $default_list;
|
||||
public $default_anime_list_path;
|
||||
public $default_manga_list_path;
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue