From b2990e8457bdad3eb57491508edff22156d76cda Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Thu, 21 Apr 2016 11:14:21 -0400 Subject: [PATCH] Add button to clear api cache --- app/config/routes.php | 6 ++++++ app/views/blank.php | 3 +++ app/views/header.php | 7 +++++++ public/css/base.css | 11 +++++++++++ public/css/base.myth.css | 9 +++++++++ public/js/base/events.js | 7 +++++++ src/Aviat/AnimeClient/Controller.php | 20 ++++++++++++++++++++ 7 files changed, 63 insertions(+) create mode 100644 app/views/blank.php diff --git a/app/config/routes.php b/app/config/routes.php index 956eaa31..8ace6518 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -142,6 +142,12 @@ return [ // --------------------------------------------------------------------- // Default / Shared routes // --------------------------------------------------------------------- + 'cache_purge' => [ + 'path' => '/cache_purge', + 'action' => 'clear_cache', + 'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE, + 'verb' => 'get', + ], 'login' => [ 'path' => '/login', 'action' => 'login', diff --git a/app/views/blank.php b/app/views/blank.php new file mode 100644 index 00000000..e7cdbc20 --- /dev/null +++ b/app/views/blank.php @@ -0,0 +1,3 @@ +
+

+
\ No newline at end of file diff --git a/app/views/header.php b/app/views/header.php index 6a8ce3cc..306f5bf9 100644 --- a/app/views/header.php +++ b/app/views/header.php @@ -30,6 +30,13 @@ [Manga List] + is_authenticated()): ?> +   + + + +   + is_authenticated()): ?> Logout diff --git a/public/css/base.css b/public/css/base.css index 046f8f09..0131e202 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -165,6 +165,17 @@ h1 a { color: #fff; } +.user-btn { + border-color: #12db18; + color: #12db18; +} + +.user-btn:hover, +.user-btn:active { + border-color: #db7d12; + background-color: #db7d12; +} + /* ----------------------------------------------------------------------------- CSS loading icon ------------------------------------------------------------------------------*/ diff --git a/public/css/base.myth.css b/public/css/base.myth.css index 77931528..6aa3f078 100644 --- a/public/css/base.myth.css +++ b/public/css/base.myth.css @@ -100,6 +100,15 @@ a:hover, a:active { color:#fff; } +.user-btn { + border-color: var(--edit-link-color); + color: var(--edit-link-color); +} +.user-btn:hover, .user-btn:active { + border-color: var(--edit-link-hover-color); + background-color: var(--edit-link-hover-color); +} + /* ----------------------------------------------------------------------------- CSS loading icon ------------------------------------------------------------------------------*/ diff --git a/public/js/base/events.js b/public/js/base/events.js index 356d864e..8178d7bd 100644 --- a/public/js/base/events.js +++ b/public/js/base/events.js @@ -20,4 +20,11 @@ } }); + // Clear the api cache + ac.on('.js-clear-cache', 'click', function (event) { + ac.get('/cache_purge', () => { + ac.showMessage('success', `Sucessfully purged api cache`); + }); + }); + })(AnimeClient); \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Controller.php b/src/Aviat/AnimeClient/Controller.php index e53760d3..88f262eb 100644 --- a/src/Aviat/AnimeClient/Controller.php +++ b/src/Aviat/AnimeClient/Controller.php @@ -27,6 +27,12 @@ class Controller { use \Aviat\Ion\Di\ContainerAware; + /** + * Cache manager + * @var \Aviat\Ion\Cache\CacheInterface + */ + protected $cache; + /** * The global configuration object * @var object $config @@ -83,6 +89,7 @@ class Controller { $this->setContainer($container); $auraUrlGenerator = $container->get('aura-router')->getGenerator(); $urlGenerator = $container->get('url-generator'); + $this->cache = $container->get('cache'); $this->config = $container->get('config'); $this->request = $container->get('request'); $this->response = $container->get('response'); @@ -354,6 +361,19 @@ class Controller { ]); } + /** + * Purges the API cache + * + * @return void + */ + public function clear_cache() + { + $this->cache->purge(); + $this->outputHTML('blank', [ + 'title' => 'Cache cleared' + ], NULL, 200); + } + /** * Add a message box to the page *