From cabce89ca77fc7c583bff6405ff36ffd61e980a6 Mon Sep 17 00:00:00 2001 From: Mathias Jorgensen Date: Mon, 3 Oct 2022 23:11:38 +0200 Subject: [PATCH 1/2] added configuration --- README.md | 10 ++++++++++ src/TrongateServiceProvider.php | 8 +++++++- src/config/trongate.php | 26 ++++++++++++++++++++++++++ src/resources/views/trongate.blade.php | 8 +++++++- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/config/trongate.php diff --git a/README.md b/README.md index 88a6614..0ffdb36 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,16 @@ We believe in backwards compatability just as much as Trongate, below are the su composer require shitware-ltd/laravel-trongate ``` +## Configuration + +We understand that the default countdown of `5` seconds and `1` second delay before redirect might not suit your needs. + +To fix this, publish the configuration file and modify just to your needs! + +```bash +php artisan vendor:publish --provider="ShitwareLtd\LaravelTrongate\TrongateServiceProvider" --tag="config" +``` + ## License MIT diff --git a/src/TrongateServiceProvider.php b/src/TrongateServiceProvider.php index 65587fc..49bdede 100644 --- a/src/TrongateServiceProvider.php +++ b/src/TrongateServiceProvider.php @@ -10,12 +10,18 @@ class TrongateServiceProvider extends ServiceProvider { public function register() { - + $this->mergeConfigFrom(__DIR__.'./config/trongate.php', 'trongate'); } public function boot(Kernel $kernel) { $this->loadViewsFrom(__DIR__.'/resources/views', 'trongate'); $kernel->pushMiddleware(TrongateMiddleware::class); + + if ($this->app->runningInConsole()) { + $this->publishes([ + __DIR__.'/config/trongate.php' => config_path('trongate.php'), + ], 'config'); + } } } diff --git a/src/config/trongate.php b/src/config/trongate.php new file mode 100644 index 0000000..b4db24e --- /dev/null +++ b/src/config/trongate.php @@ -0,0 +1,26 @@ + 5, + + /* + |-------------------------------------------------------------------------- + | Delay before redirection + |-------------------------------------------------------------------------- + | + | Bask in the glory of Trongate for just a while longer before + | redirecting the visitor. Specify the time (in seconds) before the + | redirect will occur. + | + */ + 'redirect_delay' => 1, +]; diff --git a/src/resources/views/trongate.blade.php b/src/resources/views/trongate.blade.php index ed82ad0..08a2006 100644 --- a/src/resources/views/trongate.blade.php +++ b/src/resources/views/trongate.blade.php @@ -9,6 +9,12 @@

You've made a huge mistake for using Laravel.

Use Trongate!

-

You will be redirected in 5 seconds.

+

+ You will be redirected in + + {{ config('trongate.countdown') }} + + seconds. +

From 85747c4b6ba01be7afe884cc2ef86743dddee7ce Mon Sep 17 00:00:00 2001 From: Mathias Jorgensen Date: Tue, 4 Oct 2022 22:14:04 +0200 Subject: [PATCH 2/2] bad rng --- src/config/trongate.php | 14 +------------- src/resources/views/trongate.blade.php | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/config/trongate.php b/src/config/trongate.php index b4db24e..01bb391 100644 --- a/src/config/trongate.php +++ b/src/config/trongate.php @@ -7,20 +7,8 @@ |-------------------------------------------------------------------------- | | Who doesn't love a good ol' countdown? Specify the time (in seconds) - | we should be counting down before redirection delay hits. + | we should be counting down before redirecting the visitor. | */ 'countdown' => 5, - - /* - |-------------------------------------------------------------------------- - | Delay before redirection - |-------------------------------------------------------------------------- - | - | Bask in the glory of Trongate for just a while longer before - | redirecting the visitor. Specify the time (in seconds) before the - | redirect will occur. - | - */ - 'redirect_delay' => 1, ]; diff --git a/src/resources/views/trongate.blade.php b/src/resources/views/trongate.blade.php index 08a2006..db3649e 100644 --- a/src/resources/views/trongate.blade.php +++ b/src/resources/views/trongate.blade.php @@ -11,7 +11,7 @@

You will be redirected in - + {{ config('trongate.countdown') }} seconds.