From bbeb2094e69b913e2c3d3cc681f6b0274dce0125 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Fri, 2 Sep 2016 20:19:16 -0700 Subject: [PATCH] Add domain configuration option Fixes #35 --- README.md | 12 ++++- composer.json | 44 ++++++++----------- ...fig.php => genealabs-laravel-caffeine.php} | 1 + .../LaravelCaffeineDripMiddleware.php | 4 +- src/LaravelCaffeineServiceProvider.php | 4 +- 5 files changed, 34 insertions(+), 31 deletions(-) rename config/{config.php => genealabs-laravel-caffeine.php} (81%) diff --git a/README.md b/README.md index 5fa885a..df21b8f 100644 --- a/README.md +++ b/README.md @@ -51,13 +51,21 @@ existing routes. ``` ## Configuration -To change the default drip interval of 5 minutes, simply publish the configuration file: +The following elements are configurable: +- **domain:** (default: `url('/')`) Change to point to a different domain than + your app. This is useful if you are behind a proxy or load-balancer. +- **route:** (default: `genealabs/laravel-caffeine/drip`) Change to customize + the drip URL in the browser. This is just cosmetic. +- **dripIntervalInMilliSeconds:** (default: 5 mins) Change to configure the drip + interval. + +You only need to publish the config file it you want to customize it: ```sh php artisan vendor:publish --tag=genealabs-laravel-caffeine ``` You can now change the default value in `/app/config/genealabs-laravel-caffeine.php` as desired. Deleting the -`/app/config/genealabs-laravel-caffeine.php` file will revert back to the default 5-minute interval. +`/app/config/genealabs-laravel-caffeine.php` file will revert back to the default settings. ## Usage That was it! It will apply itself automatically where it finds a form with a `_token` field, or a meta tag named diff --git a/composer.json b/composer.json index 5cc5083..687816a 100644 --- a/composer.json +++ b/composer.json @@ -1,29 +1,21 @@ { - "name": "genealabs/laravel-caffeine", - "description": "Keeping Your Laravel Forms Awake", - "license": "MIT", - "authors": [ - { - "name": "Mike Bronner", - "email": "hello@genealabs.com" + "name": "genealabs/laravel-caffeine", + "description": "Keeping Your Laravel Forms Awake", + "license": "MIT", + "authors": [ + { + "name": "Mike Bronner", + "email": "hello@genealabs.com" + } + ], + "autoload": { + "psr-4": { + "GeneaLabs\\LaravelCaffeine\\": "src/" + } + }, + "require": { + "php": ">=5.5.0", + "illuminate/support": "~5.1", + "illuminate/routing": "~5.1" } - ], - "autoload": { - "psr-4": { - "GeneaLabs\\LaravelCaffeine\\": "src/" - } - }, - "require": { - "php": ">=5.5.0", - "illuminate/support": "~5.1", - "illuminate/routing": "~5.1" - }, - "require-dev": { - "phpunit/phpunit": "4.*" - }, - "autoload-dev": { - "psr-4": { - "GeneaLabs\\LaravelCaffein\\Tests\\": "tests/" - } - } } diff --git a/config/config.php b/config/genealabs-laravel-caffeine.php similarity index 81% rename from config/config.php rename to config/genealabs-laravel-caffeine.php index b4907f0..ff9b5e3 100644 --- a/config/config.php +++ b/config/genealabs-laravel-caffeine.php @@ -2,5 +2,6 @@ return [ 'dripIntervalInMilliSeconds' => 300000, + 'domain' => url('/'), 'route' => 'genealabs/laravel-caffeine/drip', ]; diff --git a/src/Http/Middleware/LaravelCaffeineDripMiddleware.php b/src/Http/Middleware/LaravelCaffeineDripMiddleware.php index d1182a7..c82ec37 100644 --- a/src/Http/Middleware/LaravelCaffeineDripMiddleware.php +++ b/src/Http/Middleware/LaravelCaffeineDripMiddleware.php @@ -33,7 +33,9 @@ public function handle($request, Closure $next) && (strpos($content, '_token') || (preg_match("/\publishes([__DIR__ . '/../config/config.php' => config_path('genealabs-laravel-caffeine.php')], 'genealabs-laravel-caffeine'); + $this->publishes([__DIR__ . '/../config/genealabs-laravel-caffeine.php' => config_path('genealabs-laravel-caffeine.php')], 'genealabs-laravel-caffeine'); } public function register() { - // Nothing to see here, folks ... + $this->mergeConfigFrom(__DIR__ . '/../config/genealabs-laravel-caffeine.php', 'genealabs-laravel-caffeine'); } /**