From c948704a12619fda5a4f79b49b92ac2a8dcb2cf9 Mon Sep 17 00:00:00 2001 From: Robert Durica Date: Thu, 10 Aug 2023 23:15:04 +0200 Subject: [PATCH] Logout & new core version --- README.md | 1 + src/app/Component/Form/Login/LoginForm.php | 3 +- src/app/Presenter/Error4xxPresenter.php | 9 ++- src/app/Presenter/ErrorPresenter.php | 3 +- src/app/Presenter/templates/Error/403.latte | 7 --- src/app/Presenter/templates/Error/404.latte | 8 --- src/app/Presenter/templates/Error/405.latte | 6 -- src/app/Presenter/templates/Error/410.latte | 6 -- src/app/Presenter/templates/Error/4xx.latte | 4 -- src/app/Presenter/templates/Error/500.phtml | 27 -------- src/app/Presenter/templates/Error/503.phtml | 24 ------- .../Presenter/templates/Home/default.latte | 12 +++- src/app/Presenter/templates/navbar.latte | 63 +++++++++++++++++++ src/composer.json | 2 +- src/composer.lock | 14 ++--- 15 files changed, 93 insertions(+), 96 deletions(-) delete mode 100644 src/app/Presenter/templates/Error/403.latte delete mode 100644 src/app/Presenter/templates/Error/404.latte delete mode 100644 src/app/Presenter/templates/Error/405.latte delete mode 100644 src/app/Presenter/templates/Error/410.latte delete mode 100644 src/app/Presenter/templates/Error/4xx.latte delete mode 100644 src/app/Presenter/templates/Error/500.phtml delete mode 100644 src/app/Presenter/templates/Error/503.phtml create mode 100644 src/app/Presenter/templates/navbar.latte diff --git a/README.md b/README.md index e5b7639..db4adab 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This interactive platform allows administrators to create and assign fun tasks a capturing their achievements through various media formats like videos, images, or written responses to quizzes and queries. +![image](https://github.com/rdurica/b-day-challenge/assets/16089770/c2bd90bb-ab1a-47fc-911f-9a127dbdb700) ## Contributing If you would like to contribute to this project, please fork the repository and create a pull request. We welcome all diff --git a/src/app/Component/Form/Login/LoginForm.php b/src/app/Component/Form/Login/LoginForm.php index 548f82a..173a0ff 100644 --- a/src/app/Component/Form/Login/LoginForm.php +++ b/src/app/Component/Form/Login/LoginForm.php @@ -12,6 +12,7 @@ use Rdurica\Core\Component\Component; use Rdurica\Core\Component\ComponentRenderer; use Rdurica\Core\Model\Service\UserService; +use Rdurica\Core\Util\FlashType; /** * LoginForm. @@ -57,7 +58,7 @@ public function formOnSuccess(Form $form, ArrayHash $values): void $this->user->login($identity); $this->getPresenter()->redirect('Home:'); } catch (AuthenticationException $e) { - $this->getPresenter()->flashMessage($e->getMessage(), 'danger'); + $this->getPresenter()->flashMessage($e->getMessage(), FlashType::ERROR); $this->redirect('this'); } } diff --git a/src/app/Presenter/Error4xxPresenter.php b/src/app/Presenter/Error4xxPresenter.php index eec8895..14e3cfb 100644 --- a/src/app/Presenter/Error4xxPresenter.php +++ b/src/app/Presenter/Error4xxPresenter.php @@ -7,10 +7,13 @@ use Nette\Application\BadRequestException; use Nette\Application\Request; use Nette\Application\UI\Presenter; +use Rdurica\Core\Presenter\SetMdbTemplateLayout; final class Error4xxPresenter extends Presenter { + use SetMdbTemplateLayout; + /** * @throws BadRequestException */ @@ -26,7 +29,9 @@ public function startup(): void public function renderDefault(BadRequestException $exception): void { // load template 403.latte or 404.latte or ... 4xx.latte - $file = __DIR__ . "/templates/Error/{$exception->getCode()}.latte"; - $this->template->setFile(is_file($file) ? $file : __DIR__ . '/templates/Error/4xx.latte'); + $file = __DIR__ . "/../../vendor/rdurica/core/src/Templates/Error/{$exception->getCode()}.latte"; + $this->template->setFile( + is_file($file) ? $file : __DIR__ . '/../../vendor/rdurica/core/src/Templates/Error/4xx.latte' + ); } } diff --git a/src/app/Presenter/ErrorPresenter.php b/src/app/Presenter/ErrorPresenter.php index 5442db5..38ddaf8 100644 --- a/src/app/Presenter/ErrorPresenter.php +++ b/src/app/Presenter/ErrorPresenter.php @@ -4,7 +4,6 @@ namespace App\Presenter; -use Nette; use Nette\Application\BadRequestException; use Nette\Application\Helpers; use Nette\Application\IPresenter; @@ -41,7 +40,7 @@ public function run(Request $request): Response return new CallbackResponse( function (IRequest $httpRequest, IResponse $httpResponse): void { if (preg_match('#^text/html(?:;|$)#', (string)$httpResponse->getHeader('Content-Type'))) { - require __DIR__ . '/templates/Error/500.phtml'; + require __DIR__ . '/../../vendor/rdurica/core/src/Templates/Error/500.phtml'; } } ); diff --git a/src/app/Presenter/templates/Error/403.latte b/src/app/Presenter/templates/Error/403.latte deleted file mode 100644 index de00328..0000000 --- a/src/app/Presenter/templates/Error/403.latte +++ /dev/null @@ -1,7 +0,0 @@ -{block content} -

Access Denied

- -

You do not have permission to view this page. Please try contact the web -site administrator if you believe you should be able to view this page.

- -

error 403

diff --git a/src/app/Presenter/templates/Error/404.latte b/src/app/Presenter/templates/Error/404.latte deleted file mode 100644 index 022001c..0000000 --- a/src/app/Presenter/templates/Error/404.latte +++ /dev/null @@ -1,8 +0,0 @@ -{block content} -

Page Not Found

- -

The page you requested could not be found. It is possible that the address is -incorrect, or that the page no longer exists. Please use a search engine to find -what you are looking for.

- -

error 404

diff --git a/src/app/Presenter/templates/Error/405.latte b/src/app/Presenter/templates/Error/405.latte deleted file mode 100644 index d424892..0000000 --- a/src/app/Presenter/templates/Error/405.latte +++ /dev/null @@ -1,6 +0,0 @@ -{block content} -

Method Not Allowed

- -

The requested method is not allowed for the URL.

- -

error 405

diff --git a/src/app/Presenter/templates/Error/410.latte b/src/app/Presenter/templates/Error/410.latte deleted file mode 100644 index 99bde92..0000000 --- a/src/app/Presenter/templates/Error/410.latte +++ /dev/null @@ -1,6 +0,0 @@ -{block content} -

Page Not Found

- -

The page you requested has been taken off the site. We apologize for the inconvenience.

- -

error 410

diff --git a/src/app/Presenter/templates/Error/4xx.latte b/src/app/Presenter/templates/Error/4xx.latte deleted file mode 100644 index d5ce82f..0000000 --- a/src/app/Presenter/templates/Error/4xx.latte +++ /dev/null @@ -1,4 +0,0 @@ -{block content} -

Oops...

- -

Your browser sent a request that this server could not understand or process.

diff --git a/src/app/Presenter/templates/Error/500.phtml b/src/app/Presenter/templates/Error/500.phtml deleted file mode 100644 index a2b900c..0000000 --- a/src/app/Presenter/templates/Error/500.phtml +++ /dev/null @@ -1,27 +0,0 @@ - - - -Server Error - - - -
-
-

Server Error

- -

We're sorry! The server encountered an internal error and - was unable to complete your request. Please try again later.

- -

error 500

-
-
- - diff --git a/src/app/Presenter/templates/Error/503.phtml b/src/app/Presenter/templates/Error/503.phtml deleted file mode 100644 index f123919..0000000 --- a/src/app/Presenter/templates/Error/503.phtml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - -Site is temporarily down for maintenance - -

We're Sorry

- -

The site is temporarily down for maintenance. Please try again in a few minutes.

diff --git a/src/app/Presenter/templates/Home/default.latte b/src/app/Presenter/templates/Home/default.latte index 4cc7eaa..836f682 100644 --- a/src/app/Presenter/templates/Home/default.latte +++ b/src/app/Presenter/templates/Home/default.latte @@ -1 +1,11 @@ -{block content} \ No newline at end of file +{block navbar}{include './../navbar.latte'}{/block} +{block content} + +{/block} \ No newline at end of file diff --git a/src/app/Presenter/templates/navbar.latte b/src/app/Presenter/templates/navbar.latte new file mode 100644 index 0000000..a7e57a1 --- /dev/null +++ b/src/app/Presenter/templates/navbar.latte @@ -0,0 +1,63 @@ + + \ No newline at end of file diff --git a/src/composer.json b/src/composer.json index 8fecdd8..a9ae89d 100644 --- a/src/composer.json +++ b/src/composer.json @@ -6,7 +6,7 @@ "license": ["MIT"], "require": { "php": ">= 8.0", - "rdurica/core": "^0.1.0", + "rdurica/core": "~0.2.0", "tracy/tracy": "^2.9" }, "require-dev": { diff --git a/src/composer.lock b/src/composer.lock index 67a66b4..560ea05 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cb0a98fd0448126b0837892ae3d9f99b", + "content-hash": "b37489becfd806acb923fc79025450db", "packages": [ { "name": "latte/latte", @@ -1309,16 +1309,16 @@ }, { "name": "rdurica/core", - "version": "0.1.0", + "version": "0.2.0", "source": { "type": "git", "url": "https://github.com/rdurica/core.git", - "reference": "fea8b86c81a45475bb5f63b942149e6ec69dd66f" + "reference": "2c7227bc6cd99d9b6ee195132b548479d24bdc81" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rdurica/core/zipball/fea8b86c81a45475bb5f63b942149e6ec69dd66f", - "reference": "fea8b86c81a45475bb5f63b942149e6ec69dd66f", + "url": "https://api.github.com/repos/rdurica/core/zipball/2c7227bc6cd99d9b6ee195132b548479d24bdc81", + "reference": "2c7227bc6cd99d9b6ee195132b548479d24bdc81", "shasum": "" }, "require": { @@ -1357,9 +1357,9 @@ "description": "Most used functions and common services", "support": { "issues": "https://github.com/rdurica/core/issues", - "source": "https://github.com/rdurica/core/tree/0.1.0" + "source": "https://github.com/rdurica/core/tree/0.2.0" }, - "time": "2023-08-09T21:02:11+00:00" + "time": "2023-08-10T21:09:19+00:00" }, { "name": "tracy/tracy",