From 3c124456d057dce84dcfbfdaf4c566e7153ec922 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Wed, 6 Jan 2016 11:08:56 -0500 Subject: [PATCH] Simplify routing --- app/config/config.php | 7 - app/config/routes.php | 107 +++- app/config/routing.php | 35 -- app/views/anime/cover.php | 7 +- app/views/anime/list.php | 3 + app/views/error.php | 5 + app/views/manga/edit.php | 8 - public/css/base.css | 6 + public/css/base.myth.css | 10 +- public/css/marx.css | 474 +++++++++++++----- public/css/marx.myth.css | 437 ++++++++++++++++ src/Aviat/AnimeClient/AnimeClient.php | 5 + src/Aviat/AnimeClient/Controller.php | 19 +- src/Aviat/AnimeClient/Dispatcher.php | 120 ++--- .../Transformer/AnimeListTransformer.php | 4 +- .../Transformer/MangaListTransformer.php | 11 +- src/Aviat/AnimeClient/Model/Anime.php | 4 +- src/Aviat/AnimeClient/RoutingBase.php | 5 +- tests/AnimeClient/DispatcherTest.php | 96 ++-- tests/AnimeClient/RoutingBaseTest.php | 2 +- tests/AnimeClient/UrlGeneratorTest.php | 53 +- tests/AnimeClient_TestCase.php | 14 +- 22 files changed, 1032 insertions(+), 400 deletions(-) delete mode 100644 app/config/routing.php create mode 100644 app/views/error.php create mode 100644 public/css/marx.myth.css diff --git a/app/config/config.php b/app/config/config.php index c6abf9c8..b72d11ce 100644 --- a/app/config/config.php +++ b/app/config/config.php @@ -34,11 +34,4 @@ $config = [ // path to public directory on the server 'asset_dir' => realpath(__DIR__ . '/../../public'), - - // ---------------------------------------------------------------------------- - // Included config files - // ---------------------------------------------------------------------------- - - // Routing paths and options - 'routing' => require __DIR__ . '/routing.php', ]; \ No newline at end of file diff --git a/app/config/routes.php b/app/config/routes.php index d098280a..9f2cd6fd 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -11,15 +11,41 @@ * @license MIT */ +use Aviat\AnimeClient\AnimeClient; + return [ - 'convention' => [ - 'default_namespace' => '\\Aviat\\AnimeClient\\Controller', - 'default_controller' => '\\Aviat\\AnimeClient\\Controller\\Anime', - 'default_method' => 'index', - '404_method' => 'not_found' + // ------------------------------------------------------------------------- + // Routing options + // + // Specify default paths and views + // ------------------------------------------------------------------------- + 'route_config' => [ + // Subfolder prefix for url, if in a subdirectory of the web root + 'subfolder_prefix' => '', + + // Path to public directory, where images/css/javascript are located, + // appended to the url + 'asset_path' => '/public', + + // Which list should be the default? + 'default_list' => 'anime', // anime or manga + + // Default pages for anime/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', ], - // Routes on anime collection controller - 'anime' => [ + // ------------------------------------------------------------------------- + // Routing Config + // + // Maps paths to controlers and methods + // ------------------------------------------------------------------------- + 'routes' => [ + // --------------------------------------------------------------------- + // Anime List Routes + // --------------------------------------------------------------------- 'anime_add_form' => [ 'path' => '/anime/add', 'action' => 'add_form', @@ -29,12 +55,10 @@ return [ 'path' => '/anime/add', 'action' => 'add', 'verb' => 'post' - ] - ], - 'manga' => [ - - ], - 'collection' => [ + ], + // --------------------------------------------------------------------- + // Anime Collection Routes + // --------------------------------------------------------------------- 'collection_search' => [ 'path' => '/collection/search', 'action' => 'search' @@ -69,5 +93,58 @@ return [ 'view' => '[a-z_]+' ] ], - ], -]; + // --------------------------------------------------------------------- + // Default / Shared routes + // --------------------------------------------------------------------- + 'login' => [ + 'path' => '/{controller}/login', + 'action' => 'login', + 'verb' => 'get' + ], + 'login_post' => [ + 'path' => '/{controller}/login', + 'action' => 'login_action', + 'verb' => 'post' + ], + 'logout' => [ + 'path' => '/{controller}/logout', + 'action' => 'logout' + ], + 'update' => [ + 'path' => '/{controller}/update', + 'action' => 'update', + 'tokens' => [ + 'controller' => '[a-z_]+' + ] + ], + 'update_form' => [ + 'path' => '/{controller}/update_form', + 'action' => 'form_update', + 'verb' => 'post', + 'tokens' => [ + 'controller' => '[a-z_]+' + ] + ], + 'edit' => [ + 'path' => '/{controller}/edit/{id}/{status}', + 'action' => 'edit', + 'tokens' => [ + 'id' => '[0-9a-z_]+', + 'status' => '[a-zA-z\- ]+', + ] + ], + 'list' => [ + 'path' => '/{controller}/{type}{/view}', + 'action' => AnimeClient::DEFAULT_CONTROLLER_METHOD, + 'tokens' => [ + 'type' => '[a-z_]+', + 'view' => '[a-z_]+' + ] + ], + 'index_redirect' => [ + 'path' => '/', + 'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE, + 'action' => 'redirect_to_default' + ], + ] +]; \ No newline at end of file diff --git a/app/config/routing.php b/app/config/routing.php deleted file mode 100644 index 83d4b292..00000000 --- a/app/config/routing.php +++ /dev/null @@ -1,35 +0,0 @@ - '', - - // Path to public directory, where images/css/javascript are located, - // appended to the url - 'asset_path' => '/public', - - // Which list should be the default? - 'default_list' => 'anime', // anime or manga - - // Default pages for anime/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', -]; \ No newline at end of file diff --git a/app/views/anime/cover.php b/app/views/anime/cover.php index 45051cd7..92577322 100644 --- a/app/views/anime/cover.php +++ b/app/views/anime/cover.php @@ -32,13 +32,18 @@
- +
+ 0): ?> +
+
Rewatched time(s)
+
+
Rating: / 10
Episodes: diff --git a/app/views/anime/list.php b/app/views/anime/list.php index 804fa490..030c74e1 100644 --- a/app/views/anime/list.php +++ b/app/views/anime/list.php @@ -48,6 +48,9 @@ + 0): ?> + Rewatched time(s)
+ diff --git a/app/views/error.php b/app/views/error.php new file mode 100644 index 00000000..e26f7883 --- /dev/null +++ b/app/views/error.php @@ -0,0 +1,5 @@ +
+

+

+
+
diff --git a/app/views/manga/edit.php b/app/views/manga/edit.php index 0ece571f..71bef259 100644 --- a/app/views/manga/edit.php +++ b/app/views/manga/edit.php @@ -22,14 +22,6 @@ - - - - checked="checked" - /> - - diff --git a/public/css/base.css b/public/css/base.css index 6567ce49..0d7c0f00 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -353,6 +353,10 @@ button { Manga-list-specific styles ------------------------------------------------------------------------------*/ +.manga .row { + padding: 1px; +} + .manga .media { border: 1px solid #ddd; width: 200px; @@ -362,6 +366,8 @@ button { .manga .media > .edit_buttons { position: absolute; + top: 86px; top: calc(50% - 58.5px); + left: 5px; left: calc(50% - 95px); } \ No newline at end of file diff --git a/public/css/base.myth.css b/public/css/base.myth.css index 2bc471f2..da36ef17 100644 --- a/public/css/base.myth.css +++ b/public/css/base.myth.css @@ -275,6 +275,10 @@ button { /* ----------------------------------------------------------------------------- Manga-list-specific styles ------------------------------------------------------------------------------*/ +.manga .row { + padding:1px; +} + .manga .media { border:1px solid #ddd; width:200px; @@ -284,6 +288,8 @@ button { .manga .media > .edit_buttons { position:absolute; - top: calc(50% - (117px / 2)); - left: calc(50% - (190px / 2)); + top: 86px; + top: calc(50% - 58.5px); + left: 5px; + left: calc(50% - 95px); } diff --git a/public/css/marx.css b/public/css/marx.css index 69f24e52..f5696df9 100644 --- a/public/css/marx.css +++ b/public/css/marx.css @@ -1,167 +1,229 @@ :root { box-sizing: border-box; cursor: default; - font-family: 'Open Sans', 'Helvetica Neue', Helvetica, 'Lucida Grande', sans-serif; + font-family: 'Open Sans', 'Nimbus Sans L', 'Helvetica Neue', Helvetica, 'Lucida Grande', sans-serif; line-height: 1.4; overflow-y: scroll; -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; - text-size-adjust: 100%; } + -ms-text-size-adjust: 100%; + text-size-adjust: 100%; +} audio:not([controls]) { - display: none; } + display: none; +} details { - display: block; } + display: block; +} /*input[type="number"] { width: auto; }*/ + input[type="search"] { - -webkit-appearance: textfield; } - input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; } + -webkit-appearance: textfield; +} + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} main { - display: block; } + display: block; +} summary { - display: block; } + display: block; +} pre { - overflow: auto; } + overflow: auto; +} progress { - display: inline-block; } + display: inline-block; +} small { - font-size: 75%; } + font-size: 75%; +} big { - font-size: 125%; } + font-size: 125%; +} template { - display: none; } + display: none; +} textarea { overflow: auto; - resize: vertical; } + resize: vertical; +} [hidden] { - display: none; } + display: none; +} [unselectable] { -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; } + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} -*, ::before, ::after { +*, +::before, +::after { border-style: solid; border-width: 0; - box-sizing: inherit; } + box-sizing: inherit; +} * { font-size: inherit; line-height: inherit; margin: 0; - padding: 0; } + padding: 0; +} -::before, ::after { +::before, +::after { text-decoration: inherit; - vertical-align: inherit; } + vertical-align: inherit; +} a { - text-decoration: none; } + text-decoration: none; +} -audio, canvas, iframe, img, svg, video { - vertical-align: middle; } +audio, +canvas, +iframe, +img, +svg, +video { + vertical-align: middle; +} -button, input, select, textarea { +button, +input, +select, +textarea { /*background-color: transparent;*/ border: .1rem solid #ccc; color: inherit; font-family: inherit; font-style: inherit; font-weight: inherit; - min-height: 1.4em; } + min-height: 1.4em; +} -code, kbd, pre, samp { - font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, monospace; } +code, +kbd, +pre, +samp { + font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, monospace; +} table { border-collapse: collapse; - border-spacing: 0; } + border-spacing: 0; +} ::-moz-selection { background-color: #b3d4fc; - text-shadow: none; } + text-shadow: none; +} ::selection { background-color: #b3d4fc; - text-shadow: none; } + text-shadow: none; +} button::-moz-focus-inner { - border: 0; } + border: 0; +} @media screen { [hidden~="screen"] { - display: inherit; } + display: inherit; + } + [hidden~="screen"]:not(:active):not(:focus):not(:target) { clip: rect(0 0 0 0) !important; - position: absolute !important; } } + position: absolute !important; + } +} body { color: #444; - font-family: 'Open Sans', 'Helvetica Neue', Helvetica, 'Lucida Grande', sans-serif; + font-family: 'Open Sans', 'Nimbus Sans L', 'Helvetica Neue', Helvetica, 'Lucida Grande', sans-serif; font-size: 1.6rem; font-style: normal; - font-weight: 400; } + font-weight: 400; +} p { - margin: 0 0 1.6rem; } + margin: 0 0 1.6rem; +} -h1, h2, h3, h4, h5, h6 { - font-family: 'Lato', 'Open Sans', 'Helvetica Neue', Helvetica, 'Lucida Grande', sans-serif; - margin: 2rem 0 1.6rem; } +h1, +h2, +h3, +h4, +h5, +h6 { + font-family: 'Lato', 'Open Sans', 'Nimbus Sans L', 'Helvetica Neue', Helvetica, 'Lucida Grande', sans-serif; + margin: 2rem 0 1.6rem; +} h1 { border-bottom: .1rem solid rgba(0, 0, 0, 0.2); font-size: 3.6rem; font-style: normal; - font-weight: 500; } + font-weight: 500; +} h2 { font-size: 3rem; font-style: normal; - font-weight: 500; } + font-weight: 500; +} h3 { font-size: 2.4rem; font-style: normal; font-weight: 500; - margin: 1.6rem 0 0.4rem; } + margin: 1.6rem 0 0.4rem; +} h4 { font-size: 1.8rem; font-style: normal; font-weight: 600; - margin: 1.6rem 0 0.4rem; } + margin: 1.6rem 0 0.4rem; +} h5 { font-size: 1.6rem; font-style: normal; font-weight: 600; - margin: 1.6rem 0 0.4rem; } + margin: 1.6rem 0 0.4rem; +} h6 { color: #777; font-size: 1.4rem; font-style: normal; font-weight: 600; - margin: 1.6rem 0 0.4rem; } + margin: 1.6rem 0 0.4rem; +} small { - color: #777; } + color: #777; +} pre { background: #efefef; @@ -172,7 +234,8 @@ pre { margin: 1.6rem 0; padding: 1.6rem; word-break: break-all; - word-wrap: break-word; } + word-wrap: break-word; +} code { background: #efefef; @@ -180,51 +243,73 @@ code { font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 1.4rem; word-break: break-all; - word-wrap: break-word; } + word-wrap: break-word; +} a { color: #1271db; -webkit-transition: .25s ease; - transition: .25s ease; } - a:hover, a:focus { - text-decoration: none; } + transition: .25s ease; +} + +a:hover, +a:focus { + text-decoration: none; +} dl { - margin-bottom: 1.6rem; } + margin-bottom: 1.6rem; +} dd { - margin-left: 4rem; } + margin-left: 4rem; +} -ul, ol { +ul, +ol { margin-bottom: 0.8rem; - padding-left: 2rem; } + padding-left: 2rem; +} blockquote { border-left: .2rem solid #1271db; font-family: Georgia, Times, 'Times New Roman', serif; font-style: italic; margin: 1.6rem 0; - padding-left: 1.6rem; } + padding-left: 1.6rem; +} figcaption { - font-family: Georgia, Times, 'Times New Roman', serif; } + font-family: Georgia, Times, 'Times New Roman', serif; +} html { - font-size: 62.5%; } + font-size: 62.5%; +} body { - padding: 0; } + padding: 0; +} -main, header, footer, article, section, aside, details, summary { +main, +header, +footer, +article, +section, +aside, +details, +summary { display: block; height: auto; margin: 0 auto; - width: 100%; } + width: 100%; +} main { display: block; margin: 0 auto; - padding: 0 1.6rem 1.6rem; } + padding: 0 1.6rem 1.6rem; +} footer { border-top: .1rem solid rgba(0, 0, 0, 0.2); @@ -233,33 +318,57 @@ footer { float: left; max-width: 100%; padding: 1rem 0; - text-align: center; } + text-align: center; +} hr { border-top: .1rem solid rgba(0, 0, 0, 0.2); display: block; margin-bottom: 1.6rem; - width: 100%; } + width: 100%; +} img { height: auto; max-width: 100%; - vertical-align: baseline; } + vertical-align: baseline; +} @media screen and (max-width: 40rem) { - article, section, aside { + article, + section, + aside { clear: both; display: block; - max-width: 100%; } - img { - margin-right: 1.6rem; } } + max-width: 100%; + } -input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="date"], input[type="month"], input[type="time"], input[type="datetime"], input[type="datetime-local"], input[type="week"], input[type="number"], input[type="search"], input[type="tel"], input[type="color"], select { + img { + margin-right: 1.6rem; + } +} + +input[type="text"], +input[type="password"], +input[type="email"], +input[type="url"], +input[type="date"], +input[type="month"], +input[type="time"], +input[type="datetime"], +input[type="datetime-local"], +input[type="week"], +input[type="number"], +input[type="search"], +input[type="tel"], +input[type="color"], +select { border: .1rem solid #ccc; border-radius: 0; display: inline-block; padding: 0.8rem; - vertical-align: middle; } + vertical-align: middle; +} input:not([type]) { -webkit-appearance: none; @@ -270,59 +379,113 @@ input:not([type]) { color: #444; display: inline-block; padding: 0.8rem; - text-align: left; } + text-align: left; +} input[type="color"] { - padding: 0.8rem 1.6rem; } + padding: 0.8rem 1.6rem; +} -input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="date"]:focus, input[type="month"]:focus, input[type="time"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="week"]:focus, input[type="number"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="color"]:focus, select:focus, textarea:focus { - border-color: #b3d4fc; } +input[type="text"]:focus, +input[type="password"]:focus, +input[type="email"]:focus, +input[type="url"]:focus, +input[type="date"]:focus, +input[type="month"]:focus, +input[type="time"]:focus, +input[type="datetime"]:focus, +input[type="datetime-local"]:focus, +input[type="week"]:focus, +input[type="number"]:focus, +input[type="search"]:focus, +input[type="tel"]:focus, +input[type="color"]:focus, +select:focus, +textarea:focus { + border-color: #b3d4fc; +} input:not([type]):focus { - border-color: #b3d4fc; } + border-color: #b3d4fc; +} -input[type="radio"], input[type="checkbox"] { - vertical-align: middle; } +input[type="radio"], +input[type="checkbox"] { + vertical-align: middle; +} -input[type="file"]:focus, input[type="radio"]:focus, input[type="checkbox"]:focus { - outline: .1rem solid thin #444; } +input[type="file"]:focus, +input[type="radio"]:focus, +input[type="checkbox"]:focus { + outline: .1rem solid thin #444; +} -input[type="text"][disabled], input[type="password"][disabled], input[type="email"][disabled], input[type="url"][disabled], input[type="date"][disabled], input[type="month"][disabled], input[type="time"][disabled], input[type="datetime"][disabled], input[type="datetime-local"][disabled], input[type="week"][disabled], input[type="number"][disabled], input[type="search"][disabled], input[type="tel"][disabled], input[type="color"][disabled], select[disabled], textarea[disabled] { +input[type="text"][disabled], +input[type="password"][disabled], +input[type="email"][disabled], +input[type="url"][disabled], +input[type="date"][disabled], +input[type="month"][disabled], +input[type="time"][disabled], +input[type="datetime"][disabled], +input[type="datetime-local"][disabled], +input[type="week"][disabled], +input[type="number"][disabled], +input[type="search"][disabled], +input[type="tel"][disabled], +input[type="color"][disabled], +select[disabled], +textarea[disabled] { background-color: #efefef; color: #777; - cursor: not-allowed; } + cursor: not-allowed; +} input:not([type])[disabled] { background-color: #efefef; color: #777; - cursor: not-allowed; } + cursor: not-allowed; +} -input[readonly], select[readonly], textarea[readonly] { +input[readonly], +select[readonly], +textarea[readonly] { background-color: #efefef; border-color: #ccc; - color: #777; } + color: #777; +} -input:focus:invalid, textarea:focus:invalid, select:focus:invalid { +input:focus:invalid, +textarea:focus:invalid, +select:focus:invalid { border-color: #e9322d; - color: #b94a48; } + color: #b94a48; +} -input[type="file"]:focus:invalid:focus, input[type="radio"]:focus:invalid:focus, input[type="checkbox"]:focus:invalid:focus { - outline-color: #ff4136; } +input[type="file"]:focus:invalid:focus, +input[type="radio"]:focus:invalid:focus, +input[type="checkbox"]:focus:invalid:focus { + outline-color: #ff4136; +} select { background-color: #fff; - border: .1rem solid #ccc; } + border: .1rem solid #ccc; +} select[multiple] { - height: auto; } + height: auto; +} label { - line-height: 2; } + line-height: 2; +} fieldset { border: 0; margin: 0; - padding: 0.8rem 0; } + padding: 0.8rem 0; +} legend { border-bottom: .1rem solid #ccc; @@ -330,7 +493,8 @@ legend { display: block; margin-bottom: 0.8rem; padding: 0.8rem 0; - width: 100%; } + width: 100%; +} textarea { border: .1rem solid #ccc; @@ -338,9 +502,11 @@ textarea { display: block; margin-bottom: 0.8rem; padding: 0.8rem; - vertical-align: middle; } + vertical-align: middle; +} -input[type=submit], button { +input[type=submit], +button { background-color: transparent; border: .2rem solid #444; border-radius: 0; @@ -354,83 +520,119 @@ input[type=submit], button { text-decoration: none; text-transform: uppercase; -webkit-transition: .25s ease; - transition: .25s ease; + transition: .25s ease; -webkit-user-drag: none; -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - vertical-align: baseline; } - input[type=submit] a, button a { - color: #444; } + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + vertical-align: baseline; +} -input[type=submit]::-moz-focus-inner, button::-moz-focus-inner { - padding: 0; } +input[type=submit] a, +button a { + color: #444; +} -input[type=submit]:hover, button:hover { +input[type=submit]::-moz-focus-inner, +button::-moz-focus-inner { + padding: 0; +} + +input[type=submit]:hover, +button:hover { background: #444; border-color: #444; - color: #fff; } - input[type=submit]:hover a, button:hover a { - color: #fff; } + color: #fff; +} -input[type=submit]:active, button:active { +input[type=submit]:hover a, +button:hover a { + color: #fff; +} + +input[type=submit]:active, +button:active { background: #6a6a6a; border-color: #6a6a6a; - color: #fff; } - input[type=submit]:active a, button:active a { - color: #fff; } + color: #fff; +} -input[type=submit]:disabled, button:disabled { +input[type=submit]:active a, +button:active a { + color: #fff; +} + +input[type=submit]:disabled, +button:disabled { box-shadow: none; cursor: not-allowed; - opacity: .40; } + opacity: .40; +} nav ul { list-style: none; margin: 0; padding: 0; padding-top: 1.6rem; - text-align: center; } - nav ul li { - display: inline; } + text-align: center; +} + +nav ul li { + display: inline; +} + nav a { border-bottom: .2rem solid transparent; color: #444; padding: 0.8rem 1.6rem; text-decoration: none; -webkit-transition: .25s ease; - transition: .25s ease; } - nav a:hover, nav li.selected a { - border-color: rgba(0, 0, 0, 0.2); } - nav a:active { - border-color: rgba(0, 0, 0, 0.56); } + transition: .25s ease; +} + +nav a:hover, +nav li.selected a { + border-color: rgba(0, 0, 0, 0.2); +} + +nav a:active { + border-color: rgba(0, 0, 0, 0.56); +} table { - margin-bottom: 1.6rem; } + margin-bottom: 1.6rem; +} caption { - padding: 0.8rem 0; } + padding: 0.8rem 0; +} thead th { background: #efefef; - color: #444; } + color: #444; +} tr { background: #fff; - margin-bottom: 0.8rem; } + margin-bottom: 0.8rem; +} -th, td { +th, +td { border: .1rem solid #ccc; padding: 0.8rem 1.6rem; text-align: center; - vertical-align: inherit; } + vertical-align: inherit; +} tfoot tr { - background: none; } + background: none; +} tfoot td { color: #efefef; font-size: 0.8rem; font-style: italic; - padding: 1.6rem 0.4rem; } \ No newline at end of file + padding: 1.6rem 0.4rem; +} \ No newline at end of file diff --git a/public/css/marx.myth.css b/public/css/marx.myth.css new file mode 100644 index 00000000..07038a6b --- /dev/null +++ b/public/css/marx.myth.css @@ -0,0 +1,437 @@ +:root { + --default-font-list: 'Open Sans', 'Nimbus Sans L', 'Helvetica Neue', Helvetica, 'Lucida Grande', sans-serif; + box-sizing: border-box; + cursor: default; + font-family: var(--default-font-list); + line-height: 1.4; + overflow-y: scroll; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; + text-size-adjust: 100%; } + +audio:not([controls]) { + display: none; } + +details { + display: block; } + +/*input[type="number"] { + width: auto; }*/ +input[type="search"] { + -webkit-appearance: textfield; } + input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; } + +main { + display: block; } + +summary { + display: block; } + +pre { + overflow: auto; } + +progress { + display: inline-block; } + +small { + font-size: 75%; } + +big { + font-size: 125%; } + +template { + display: none; } + +textarea { + overflow: auto; + resize: vertical; } + +[hidden] { + display: none; } + +[unselectable] { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } + +*, ::before, ::after { + border-style: solid; + border-width: 0; + box-sizing: inherit; } + +* { + font-size: inherit; + line-height: inherit; + margin: 0; + padding: 0; } + +::before, ::after { + text-decoration: inherit; + vertical-align: inherit; } + +a { + text-decoration: none; } + +audio, canvas, iframe, img, svg, video { + vertical-align: middle; } + +button, input, select, textarea { + /*background-color: transparent;*/ + border: .1rem solid #ccc; + color: inherit; + font-family: inherit; + font-style: inherit; + font-weight: inherit; + min-height: 1.4em; } + +code, kbd, pre, samp { + font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, monospace; } + +table { + border-collapse: collapse; + border-spacing: 0; } + +::-moz-selection { + background-color: #b3d4fc; + text-shadow: none; } + +::selection { + background-color: #b3d4fc; + text-shadow: none; } + +button::-moz-focus-inner { + border: 0; } + +@media screen { + [hidden~="screen"] { + display: inherit; } + [hidden~="screen"]:not(:active):not(:focus):not(:target) { + clip: rect(0 0 0 0) !important; + position: absolute !important; } } + +body { + color: #444; + font-family: var(--default-font-list); + font-size: 1.6rem; + font-style: normal; + font-weight: 400; } + +p { + margin: 0 0 1.6rem; } + +h1, h2, h3, h4, h5, h6 { + font-family: 'Lato', var(--default-font-list); + margin: 2rem 0 1.6rem; } + +h1 { + border-bottom: .1rem solid rgba(0, 0, 0, 0.2); + font-size: 3.6rem; + font-style: normal; + font-weight: 500; } + +h2 { + font-size: 3rem; + font-style: normal; + font-weight: 500; } + +h3 { + font-size: 2.4rem; + font-style: normal; + font-weight: 500; + margin: 1.6rem 0 0.4rem; } + +h4 { + font-size: 1.8rem; + font-style: normal; + font-weight: 600; + margin: 1.6rem 0 0.4rem; } + +h5 { + font-size: 1.6rem; + font-style: normal; + font-weight: 600; + margin: 1.6rem 0 0.4rem; } + +h6 { + color: #777; + font-size: 1.4rem; + font-style: normal; + font-weight: 600; + margin: 1.6rem 0 0.4rem; } + +small { + color: #777; } + +pre { + background: #efefef; + color: #444; + display: block; + font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; + font-size: 1.4rem; + margin: 1.6rem 0; + padding: 1.6rem; + word-break: break-all; + word-wrap: break-word; } + +code { + background: #efefef; + color: #444; + font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; + font-size: 1.4rem; + word-break: break-all; + word-wrap: break-word; } + +a { + color: #1271db; + -webkit-transition: .25s ease; + transition: .25s ease; } + a:hover, a:focus { + text-decoration: none; } + +dl { + margin-bottom: 1.6rem; } + +dd { + margin-left: 4rem; } + +ul, ol { + margin-bottom: 0.8rem; + padding-left: 2rem; } + +blockquote { + border-left: .2rem solid #1271db; + font-family: Georgia, Times, 'Times New Roman', serif; + font-style: italic; + margin: 1.6rem 0; + padding-left: 1.6rem; } + +figcaption { + font-family: Georgia, Times, 'Times New Roman', serif; } + +html { + font-size: 62.5%; } + +body { + padding: 0; } + +main, header, footer, article, section, aside, details, summary { + display: block; + height: auto; + margin: 0 auto; + width: 100%; } + +main { + display: block; + margin: 0 auto; + padding: 0 1.6rem 1.6rem; } + +footer { + border-top: .1rem solid rgba(0, 0, 0, 0.2); + clear: both; + display: inline-block; + float: left; + max-width: 100%; + padding: 1rem 0; + text-align: center; } + +hr { + border-top: .1rem solid rgba(0, 0, 0, 0.2); + display: block; + margin-bottom: 1.6rem; + width: 100%; } + +img { + height: auto; + max-width: 100%; + vertical-align: baseline; } + +@media screen and (max-width: 40rem) { + article, section, aside { + clear: both; + display: block; + max-width: 100%; } + img { + margin-right: 1.6rem; } } + +input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="date"], input[type="month"], input[type="time"], input[type="datetime"], input[type="datetime-local"], input[type="week"], input[type="number"], input[type="search"], input[type="tel"], input[type="color"], select { + border: .1rem solid #ccc; + border-radius: 0; + display: inline-block; + padding: 0.8rem; + vertical-align: middle; } + +input:not([type]) { + -webkit-appearance: none; + background-clip: padding-box; + background-color: #fff; + border: .1rem solid #ccc; + border-radius: 0; + color: #444; + display: inline-block; + padding: 0.8rem; + text-align: left; } + +input[type="color"] { + padding: 0.8rem 1.6rem; } + +input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="date"]:focus, input[type="month"]:focus, input[type="time"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="week"]:focus, input[type="number"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="color"]:focus, select:focus, textarea:focus { + border-color: #b3d4fc; } + +input:not([type]):focus { + border-color: #b3d4fc; } + +input[type="radio"], input[type="checkbox"] { + vertical-align: middle; } + +input[type="file"]:focus, input[type="radio"]:focus, input[type="checkbox"]:focus { + outline: .1rem solid thin #444; } + +input[type="text"][disabled], input[type="password"][disabled], input[type="email"][disabled], input[type="url"][disabled], input[type="date"][disabled], input[type="month"][disabled], input[type="time"][disabled], input[type="datetime"][disabled], input[type="datetime-local"][disabled], input[type="week"][disabled], input[type="number"][disabled], input[type="search"][disabled], input[type="tel"][disabled], input[type="color"][disabled], select[disabled], textarea[disabled] { + background-color: #efefef; + color: #777; + cursor: not-allowed; } + +input:not([type])[disabled] { + background-color: #efefef; + color: #777; + cursor: not-allowed; } + +input[readonly], select[readonly], textarea[readonly] { + background-color: #efefef; + border-color: #ccc; + color: #777; } + +input:focus:invalid, textarea:focus:invalid, select:focus:invalid { + border-color: #e9322d; + color: #b94a48; } + +input[type="file"]:focus:invalid:focus, input[type="radio"]:focus:invalid:focus, input[type="checkbox"]:focus:invalid:focus { + outline-color: #ff4136; } + +select { + background-color: #fff; + border: .1rem solid #ccc; } + +select[multiple] { + height: auto; } + +label { + line-height: 2; } + +fieldset { + border: 0; + margin: 0; + padding: 0.8rem 0; } + +legend { + border-bottom: .1rem solid #ccc; + color: #444; + display: block; + margin-bottom: 0.8rem; + padding: 0.8rem 0; + width: 100%; } + +textarea { + border: .1rem solid #ccc; + border-radius: 0; + display: block; + margin-bottom: 0.8rem; + padding: 0.8rem; + vertical-align: middle; } + +input[type=submit], button { + background-color: transparent; + border: .2rem solid #444; + border-radius: 0; + color: #444; + cursor: pointer; + display: inline-block; + margin-bottom: 0.8rem; + margin-right: 0.4rem; + padding: 0.8rem 1.6rem; + text-align: center; + text-decoration: none; + text-transform: uppercase; + -webkit-transition: .25s ease; + transition: .25s ease; + -webkit-user-drag: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + vertical-align: baseline; } + input[type=submit] a, button a { + color: #444; } + +input[type=submit]::-moz-focus-inner, button::-moz-focus-inner { + padding: 0; } + +input[type=submit]:hover, button:hover { + background: #444; + border-color: #444; + color: #fff; } + input[type=submit]:hover a, button:hover a { + color: #fff; } + +input[type=submit]:active, button:active { + background: #6a6a6a; + border-color: #6a6a6a; + color: #fff; } + input[type=submit]:active a, button:active a { + color: #fff; } + +input[type=submit]:disabled, button:disabled { + box-shadow: none; + cursor: not-allowed; + opacity: .40; } + +nav ul { + list-style: none; + margin: 0; + padding: 0; + padding-top: 1.6rem; + text-align: center; } + nav ul li { + display: inline; } +nav a { + border-bottom: .2rem solid transparent; + color: #444; + padding: 0.8rem 1.6rem; + text-decoration: none; + -webkit-transition: .25s ease; + transition: .25s ease; } + nav a:hover, nav li.selected a { + border-color: rgba(0, 0, 0, 0.2); } + nav a:active { + border-color: rgba(0, 0, 0, 0.56); } + +table { + margin-bottom: 1.6rem; } + +caption { + padding: 0.8rem 0; } + +thead th { + background: #efefef; + color: #444; } + +tr { + background: #fff; + margin-bottom: 0.8rem; } + +th, td { + border: .1rem solid #ccc; + padding: 0.8rem 1.6rem; + text-align: center; + vertical-align: inherit; } + +tfoot tr { + background: none; } + +tfoot td { + color: #efefef; + font-size: 0.8rem; + font-style: italic; + padding: 1.6rem 0.4rem; } \ No newline at end of file diff --git a/src/Aviat/AnimeClient/AnimeClient.php b/src/Aviat/AnimeClient/AnimeClient.php index 6776d7e0..88636b28 100644 --- a/src/Aviat/AnimeClient/AnimeClient.php +++ b/src/Aviat/AnimeClient/AnimeClient.php @@ -18,6 +18,11 @@ class AnimeClient { use \Aviat\Ion\Di\ContainerAware; const SESSION_SEGMENT = 'Aviat\AnimeClient\Auth'; + const DEFAULT_CONTROLLER_NAMESPACE = 'Aviat\AnimeClient\Controller'; + const DEFAULT_CONTROLLER = 'Aviat\AnimeClient\Controller\Anime'; + const DEFAULT_CONTROLLER_METHOD = 'index'; + const NOT_FOUND_METHOD = 'not_found'; + const ERROR_MESSAGE_METHOD = 'error_page'; private static $form_pages = [ 'edit', diff --git a/src/Aviat/AnimeClient/Controller.php b/src/Aviat/AnimeClient/Controller.php index f8676627..a7dd5069 100644 --- a/src/Aviat/AnimeClient/Controller.php +++ b/src/Aviat/AnimeClient/Controller.php @@ -106,7 +106,7 @@ class Controller { */ public function redirect_to_default() { - $default_type = $this->config->get(['routing', 'default_list']); + $default_type = $this->config->get(['routes', 'route_config', 'default_list']); $this->redirect($this->urlGenerator->default_url($default_type), 303); } @@ -309,6 +309,23 @@ class Controller { ]); } + /** + * Display a generic error page + * + * @param string $title + * @param string $message + * @param string $long_message + * @return void + */ + public function error_page($title, $message, $long_message = "") + { + $this->outputHTML('error', [ + 'title' => $title, + 'message' => $message, + 'long_message' => $long_message + ]); + } + /** * Set a session flash variable to display a message on * next page load diff --git a/src/Aviat/AnimeClient/Dispatcher.php b/src/Aviat/AnimeClient/Dispatcher.php index 93e0a26d..607eaa1d 100644 --- a/src/Aviat/AnimeClient/Dispatcher.php +++ b/src/Aviat/AnimeClient/Dispatcher.php @@ -16,6 +16,7 @@ use Aura\Web\Request; use Aura\Web\Response; use Aviat\Ion\Di\ContainerInterface; +use Aviat\AnimeClient\AnimeClient; /** * Basic routing/ dispatch @@ -52,75 +53,6 @@ class Dispatcher extends RoutingBase { $this->request = $container->get('request'); $this->output_routes = $this->_setup_routes(); - $this->generate_convention_routes(); - } - - /** - * Generate routes based on controller methods - * - * @return void - */ - protected function generate_convention_routes() - { - $default_controller = $this->routes['convention']['default_controller']; - - $this->output_routes[] = $this->router->addGet('login', '/{controller}/login') - ->setValues([ - 'controller' => $default_controller, - 'action' => 'login' - ]); - - $this->output_routes[] = $this->router->addPost('login_post', '/{controller}/login') - ->setValues([ - 'controller' => $default_controller, - 'action' => 'login_action' - ]); - - $this->output_routes[] = $this->router->addGet('logout', '/{controller}/logout') - ->setValues([ - 'controller' => $default_controller, - 'action' => 'logout' - ]); - - $this->output_routes[] = $this->router->addPost('update', '/{controller}/update') - ->setValues([ - 'controller' => $default_controller, - 'action' => 'update' - ])->setTokens([ - 'controller' => '[a-z_]+' - ]); - - $this->output_routes[] = $this->router->addPost('update_form', '/{controller}/update_form') - ->setValues([ - 'controller' => $default_controller, - 'action' => 'form_update' - ])->setTokens([ - 'controller' => '[a-z_]+' - ]); - - $this->output_routes[] = $this->router->addGet('edit', '/{controller}/edit/{id}/{status}') - ->setValues([ - 'controller' => $default_controller, - 'action' => 'edit' - ])->setTokens([ - 'id' => '[0-9a-z_]+', - 'status' => '[a-zA-z\- ]+', - ]); - - $this->output_routes[] = $this->router->addGet('list', '/{controller}/{type}{/view}') - ->setValues([ - 'controller' => $default_controller, - 'action' => $this->routes['convention']['default_method'], - ])->setTokens([ - 'type' => '[a-z_]+', - 'view' => '[a-z_]+' - ]); - - $this->output_routes[] = $this->router->addGet('index_redirect', '/') - ->setValues([ - 'controller' => 'Aviat\\AnimeClient\\Controller', - 'action' => 'redirect_to_default' - ]); } /** @@ -132,7 +64,7 @@ class Dispatcher extends RoutingBase { { $error_handler = $this->container->get('error-handler'); - $raw_route = $this->request->server->get('PATH_INFO'); + $raw_route = $this->request->url->get(PHP_URL_PATH); $route_path = "/" . trim($raw_route, '/'); $error_handler->addDataTable('Route Info', [ @@ -162,8 +94,8 @@ class Dispatcher extends RoutingBase { public function __invoke($route = NULL) { $error_handler = $this->container->get('error-handler'); - $controller_name = $this->routes['convention']['default_controller']; - $action_method = $this->routes['convention']['404_method']; + $controller_name = AnimeClient::DEFAULT_CONTROLLER; + $action_method = AnimeClient::NOT_FOUND_METHOD; $params = []; if (is_null($route)) @@ -176,6 +108,24 @@ class Dispatcher extends RoutingBase { { $failure = $this->router->getFailedRoute(); $error_handler->addDataTable('failed_route', (array)$failure); + $action_method = AnimeClient::ERROR_MESSAGE_METHOD; + + switch(TRUE) + { + case $failure->failedMethod(): + $params['title'] = '405 Method Not Allowed'; + $params['message'] = 'Invalid HTTP Verb'; + break; + + case $failure->failedAccept(): + $params['title'] = '406 Not Acceptable'; + $params['message'] = 'Unacceptable content type'; + break; + + default: + $action_method = AnimeClient::NOT_FOUND_METHOD; + break; + } } else { @@ -229,8 +179,7 @@ class Dispatcher extends RoutingBase { public function get_controller() { $route_type = $this->__get('default_list'); - $request_uri = $this->request->server->get('PATH_INFO'); - + $request_uri = $this->request->url->get(PHP_URL_PATH); $path = trim($request_uri, '/'); $segments = explode('/', $path); @@ -251,8 +200,7 @@ class Dispatcher extends RoutingBase { */ public function get_controller_list() { - $convention_routing = $this->routes['convention']; - $default_namespace = $convention_routing['default_namespace']; + $default_namespace = AnimeClient::DEFAULT_CONTROLLER_NAMESPACE; $path = str_replace('\\', '/', $default_namespace); $path = trim($path, '/'); $actual_path = \_dir(SRC_DIR, $path); @@ -278,22 +226,13 @@ class Dispatcher extends RoutingBase { * * @return array */ - public function _setup_routes() + protected function _setup_routes() { - $routes = []; - $route_type = $this->get_controller(); - // Return early if invalid route array - if ( ! array_key_exists($route_type, $this->routes)) - { - return []; - } - - $applied_routes = $this->routes[$route_type]; - // Add routes - foreach ($applied_routes as $name => &$route) + $routes = []; + foreach ($this->routes as $name => &$route) { $path = $route['path']; unset($route['path']); @@ -305,7 +244,7 @@ class Dispatcher extends RoutingBase { } else { - $controller_class = $this->routes['convention']['default_controller']; + $controller_class = AnimeClient::DEFAULT_CONTROLLER; } // Prepend the controller to the route parameters @@ -313,7 +252,8 @@ class Dispatcher extends RoutingBase { // Select the appropriate router method based on the http verb $add = (array_key_exists('verb', $route)) - ? "add" . ucfirst(strtolower($route['verb'])) : "addGet"; + ? "add" . ucfirst(strtolower($route['verb'])) + : "addGet"; // Add the route to the router object if ( ! array_key_exists('tokens', $route)) diff --git a/src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php b/src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php index dc9beef8..c6de9eea 100644 --- a/src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php +++ b/src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php @@ -100,13 +100,13 @@ class AnimeListTransformer extends AbstractTransformer { { // Messy mapping of boolean values to their API string equivalents $privacy = 'public'; - if (array_key_exists('private', $item) && $item['private'] == TRUE) + if (array_key_exists('private', $item) && $item['private']) { $privacy = 'private'; } $rewatching = 'false'; - if (array_key_exists('rewatching', $item) && $item['rewatching'] == TRUE) + if (array_key_exists('rewatching', $item) && $item['rewatching']) { $rewatching = 'true'; } diff --git a/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php b/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php index 0c658efd..dddc1e0c 100644 --- a/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php +++ b/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php @@ -67,7 +67,7 @@ class MangaListTransformer extends AbstractTransformer { 'notes' => $item['notes'], 'rereading' => (bool)$item['rereading'], 'reread' => $item['reread_count'], - 'user_rating' => $rating + 'user_rating' => $rating, ]; if (array_key_exists('english_title', $manga)) @@ -92,13 +92,7 @@ class MangaListTransformer extends AbstractTransformer { */ public function untransform($item) { - $private = (array_key_exists('private', $item)) - ? (bool)$item['private'] - : FALSE; - - $rereading = (array_key_exists('rereading', $item)) - ? (bool)$item['rereading'] - : FALSE; + $rereading = (array_key_exists('rereading', $item)) && (bool)$item['rereading']; $map = [ 'id' => $item['id'], @@ -108,7 +102,6 @@ class MangaListTransformer extends AbstractTransformer { 'volumes_read' => (int)$item['volumes_read'], 'rereading' => $rereading, 'reread_count' => (int)$item['reread_count'], - 'private' => $private, 'notes' => $item['notes'], ]; diff --git a/src/Aviat/AnimeClient/Model/Anime.php b/src/Aviat/AnimeClient/Model/Anime.php index 80b94e62..6ec3b7b7 100644 --- a/src/Aviat/AnimeClient/Model/Anime.php +++ b/src/Aviat/AnimeClient/Model/Anime.php @@ -67,12 +67,10 @@ class Anime extends API { 'form_params' => $data ]); - $output = [ + return [ 'statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody(), TRUE) ]; - - return $output; } /** diff --git a/src/Aviat/AnimeClient/RoutingBase.php b/src/Aviat/AnimeClient/RoutingBase.php index 1568cef2..b52ec8c0 100644 --- a/src/Aviat/AnimeClient/RoutingBase.php +++ b/src/Aviat/AnimeClient/RoutingBase.php @@ -48,7 +48,8 @@ class RoutingBase { { $this->container = $container; $this->config = $container->get('config'); - $this->routes = $this->config->get('routes'); + $this->base_routes = $this->config->get('routes'); + $this->routes = $this->base_routes['routes']; } /** @@ -59,7 +60,7 @@ class RoutingBase { */ public function __get($key) { - $routing_config = $this->config->get('routing'); + $routing_config = $this->base_routes['route_config']; if (array_key_exists($key, $routing_config)) { diff --git a/tests/AnimeClient/DispatcherTest.php b/tests/AnimeClient/DispatcherTest.php index 5bd1d28a..f0b2c0b7 100644 --- a/tests/AnimeClient/DispatcherTest.php +++ b/tests/AnimeClient/DispatcherTest.php @@ -66,19 +66,12 @@ class DispatcherTest extends AnimeClient_TestCase { { $default_config = array( 'routes' => [ - 'convention' => [ - 'default_namespace' => '\\Aviat\\AnimeClient\\Controller', - 'default_controller' => '\\Aviat\\AnimeClient\\Controller\\Anime', - 'default_method' => 'index' - ], - 'common' => [ + 'routes' => [ 'login_form' => [ 'path' => '/login', 'action' => 'login', 'verb' => 'get' ], - ], - 'anime' => [ 'watching' => [ 'path' => '/anime/watching{/view}', 'action' => 'anime_list', @@ -89,8 +82,6 @@ class DispatcherTest extends AnimeClient_TestCase { 'view' => '[a-z_]+' ] ], - ], - 'manga' => [ 'plan_to_read' => [ 'path' => '/manga/plan_to_read{/view}', 'action' => 'manga_list', @@ -101,13 +92,13 @@ class DispatcherTest extends AnimeClient_TestCase { 'view' => '[a-z_]+' ] ], + ], + 'route_config' => [ + 'anime_path' => 'anime', + 'manga_path' => 'manga', + 'default_list' => 'anime' ] ], - 'routing' => [ - 'anime_path' => 'anime', - 'manga_path' => 'manga', - 'default_list' => 'anime' - ] ); $data = [ @@ -174,27 +165,20 @@ class DispatcherTest extends AnimeClient_TestCase { public function testDefaultRoute() { $config = [ - 'routing' => [ - 'anime_path' => 'anime', - 'manga_path' => 'manga', - 'default_anime_list_path' => "watching", - 'default_manga_list_path' => 'all', - 'default_list' => 'manga' - ], 'routes' => [ - 'convention' => [ - 'default_namespace' => '\\Aviat\\AnimeClient\\Controller', - 'default_controller' => '\\Aviat\\AnimeClient\\Controller\\Anime', - 'default_method' => 'index' + 'route_config' => [ + 'anime_path' => 'anime', + 'manga_path' => 'manga', + 'default_anime_list_path' => "watching", + 'default_manga_list_path' => 'all', + 'default_list' => 'manga' ], - 'common' => [ + 'routes' => [ 'login_form' => [ 'path' => '/login', 'action' => ['login'], 'verb' => 'get' ], - ], - 'anime' => [ 'index' => [ 'path' => '/', 'action' => ['redirect'], @@ -203,8 +187,6 @@ class DispatcherTest extends AnimeClient_TestCase { 'code' => '301' ] ], - ], - 'manga' => [ 'index' => [ 'path' => '/', 'action' => ['redirect'], @@ -213,7 +195,7 @@ class DispatcherTest extends AnimeClient_TestCase { 'code' => '301', 'type' => 'manga' ] - ], + ] ] ] ]; @@ -231,19 +213,17 @@ class DispatcherTest extends AnimeClient_TestCase { return array( 'controller_list_sanity_check' => [ 'config' => [ - 'routing' => [ - 'anime_path' => 'anime', - 'manga_path' => 'manga', - 'default_anime_list_path' => "watching", - 'default_manga_list_path' => 'all', - 'default_list' => 'manga' - ], 'routes' => [ - 'convention' => [ - 'default_namespace' => '\\Aviat\\AnimeClient\\Controller', - 'default_controller' => '\\Aviat\\AnimeClient\\Controller\\Anime', - 'default_method' => 'index' - ] + 'routes' => [ + + ], + 'route_config' => [ + 'anime_path' => 'anime', + 'manga_path' => 'manga', + 'default_anime_list_path' => "watching", + 'default_manga_list_path' => 'all', + 'default_list' => 'manga' + ], ] ], 'expected' => [ @@ -254,22 +234,24 @@ class DispatcherTest extends AnimeClient_TestCase { ], 'empty_controller_list' => [ 'config' => [ - 'routing' => [ - 'anime_path' => 'anime', - 'manga_path' => 'manga', - 'default_anime_path' => "/anime/watching", - 'default_manga_path' => '/manga/all', - 'default_list' => 'manga' - ], 'routes' => [ - 'convention' => [ - 'default_namespace' => '\\Aviat\\Ion\\Controller', - 'default_controller' => '\\Aviat\\Ion\\Controller\\Anime', - 'default_method' => 'index' - ] + 'routes' => [ + + ], + 'route_config' => [ + 'anime_path' => 'anime', + 'manga_path' => 'manga', + 'default_anime_path' => "/anime/watching", + 'default_manga_path' => '/manga/all', + 'default_list' => 'manga' + ], ] ], - 'expected' => [] + 'expected' => [ + 'anime' => 'Aviat\AnimeClient\Controller\Anime', + 'manga' => 'Aviat\AnimeClient\Controller\Manga', + 'collection' => 'Aviat\AnimeClient\Controller\Collection', + ] ] ); } diff --git a/tests/AnimeClient/RoutingBaseTest.php b/tests/AnimeClient/RoutingBaseTest.php index 72f4f603..b4636edd 100644 --- a/tests/AnimeClient/RoutingBaseTest.php +++ b/tests/AnimeClient/RoutingBaseTest.php @@ -33,7 +33,7 @@ class RoutingBaseTest extends AnimeClient_TestCase { */ public function testSegments($request_uri, $path, $segments, $last_segment) { - $this->markTestSkipped(); +$this->markTestSkipped(); $this->setSuperGlobals([ '_SERVER' => [ 'REQUEST_URI' => $request_uri diff --git a/tests/AnimeClient/UrlGeneratorTest.php b/tests/AnimeClient/UrlGeneratorTest.php index 94b45767..3635dedb 100644 --- a/tests/AnimeClient/UrlGeneratorTest.php +++ b/tests/AnimeClient/UrlGeneratorTest.php @@ -41,13 +41,16 @@ class UrlGeneratorTest extends AnimeClient_TestCase { return [ 'default_view' => [ 'config' => [ - 'routing' => [ - 'anime_path' => 'anime', - 'manga_path' => 'manga', - 'default_list' => 'manga', - 'default_anime_path' => '/anime/watching', - 'default_manga_path' => '/manga/all', - 'default_to_list_view' => FALSE, + 'routes' => [ + 'routes' => [], + 'route_config' => [ + 'anime_path' => 'anime', + 'manga_path' => 'manga', + 'default_list' => 'manga', + 'default_anime_path' => '/anime/watching', + 'default_manga_path' => '/manga/all', + 'default_to_list_view' => FALSE, + ] ], ], 'path' => '', @@ -56,13 +59,16 @@ class UrlGeneratorTest extends AnimeClient_TestCase { ], 'default_view_list' => [ 'config' => [ - 'routing' => [ - 'anime_path' => 'anime', - 'manga_path' => 'manga', - 'default_list' => 'manga', - 'default_anime_path' => '/anime/watching', - 'default_manga_path' => '/manga/all', - 'default_to_list_view' => TRUE, + 'routes' => [ + 'routes' => [], + 'route_config' => [ + 'anime_path' => 'anime', + 'manga_path' => 'manga', + 'default_list' => 'manga', + 'default_anime_path' => '/anime/watching', + 'default_manga_path' => '/manga/all', + 'default_to_list_view' => TRUE, + ] ], ], 'path' => '', @@ -89,14 +95,17 @@ class UrlGeneratorTest extends AnimeClient_TestCase { public function dataBaseUrl() { $config = [ - 'routing' => [ - 'anime_path' => 'anime', - 'manga_path' => 'manga', - 'default_list' => 'manga', - 'default_anime_path' => '/watching', - 'default_manga_path' => '/all', - 'default_to_list_view' => TRUE, - ], + 'routes' => [ + 'routes' => [], + 'route_config' => [ + 'anime_path' => 'anime', + 'manga_path' => 'manga', + 'default_list' => 'manga', + 'default_anime_path' => '/watching', + 'default_manga_path' => '/all', + 'default_to_list_view' => TRUE, + ], + ] ]; return [ diff --git a/tests/AnimeClient_TestCase.php b/tests/AnimeClient_TestCase.php index 60cecf78..ac802abb 100644 --- a/tests/AnimeClient_TestCase.php +++ b/tests/AnimeClient_TestCase.php @@ -48,17 +48,13 @@ class AnimeClient_TestCase extends PHPUnit_Framework_TestCase { 'file' => ':memory:', ] ], - 'routing' => [ - 'asset_path' => '/assets' - ], 'routes' => [ - 'convention' => [ - 'default_controller' => '', - 'default_method' => '', + 'route_config' => [ + 'asset_path' => '/assets' ], - 'common' => [], - 'anime' => [], - 'manga' => [] + 'routes' => [ + + ] ] ];