Skip to content

Commit bbeb209

Browse files
committed
Add domain configuration option
Fixes #35
1 parent d107246 commit bbeb209

File tree

5 files changed

+34
-31
lines changed

5 files changed

+34
-31
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,21 @@ existing routes.
5151
```
5252

5353
## Configuration
54-
To change the default drip interval of 5 minutes, simply publish the configuration file:
54+
The following elements are configurable:
55+
- **domain:** (default: `url('/')`) Change to point to a different domain than
56+
your app. This is useful if you are behind a proxy or load-balancer.
57+
- **route:** (default: `genealabs/laravel-caffeine/drip`) Change to customize
58+
the drip URL in the browser. This is just cosmetic.
59+
- **dripIntervalInMilliSeconds:** (default: 5 mins) Change to configure the drip
60+
interval.
61+
62+
You only need to publish the config file it you want to customize it:
5563
```sh
5664
php artisan vendor:publish --tag=genealabs-laravel-caffeine
5765
```
5866

5967
You can now change the default value in `/app/config/genealabs-laravel-caffeine.php` as desired. Deleting the
60-
`/app/config/genealabs-laravel-caffeine.php` file will revert back to the default 5-minute interval.
68+
`/app/config/genealabs-laravel-caffeine.php` file will revert back to the default settings.
6169

6270
## Usage
6371
That was it! It will apply itself automatically where it finds a form with a `_token` field, or a meta tag named

composer.json

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
{
2-
"name": "genealabs/laravel-caffeine",
3-
"description": "Keeping Your Laravel Forms Awake",
4-
"license": "MIT",
5-
"authors": [
6-
{
7-
"name": "Mike Bronner",
8-
"email": "[email protected]"
2+
"name": "genealabs/laravel-caffeine",
3+
"description": "Keeping Your Laravel Forms Awake",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Mike Bronner",
8+
"email": "[email protected]"
9+
}
10+
],
11+
"autoload": {
12+
"psr-4": {
13+
"GeneaLabs\\LaravelCaffeine\\": "src/"
14+
}
15+
},
16+
"require": {
17+
"php": ">=5.5.0",
18+
"illuminate/support": "~5.1",
19+
"illuminate/routing": "~5.1"
920
}
10-
],
11-
"autoload": {
12-
"psr-4": {
13-
"GeneaLabs\\LaravelCaffeine\\": "src/"
14-
}
15-
},
16-
"require": {
17-
"php": ">=5.5.0",
18-
"illuminate/support": "~5.1",
19-
"illuminate/routing": "~5.1"
20-
},
21-
"require-dev": {
22-
"phpunit/phpunit": "4.*"
23-
},
24-
"autoload-dev": {
25-
"psr-4": {
26-
"GeneaLabs\\LaravelCaffein\\Tests\\": "tests/"
27-
}
28-
}
2921
}

config/config.php renamed to config/genealabs-laravel-caffeine.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
return [
44
'dripIntervalInMilliSeconds' => 300000,
5+
'domain' => url('/'),
56
'route' => 'genealabs/laravel-caffeine/drip',
67
];

src/Http/Middleware/LaravelCaffeineDripMiddleware.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public function handle($request, Closure $next)
3333
&& (strpos($content, '_token')
3434
|| (preg_match("/\<meta name=[\"\']csrf[_-]token[\"\']/", $content)))
3535
) {
36-
$dripUrl = url(config('genealabs-laravel-caffeine.route', 'genealabs/laravel-caffeine/drip'));
36+
$domain = config('genealabs-laravel-caffeine.domain', url('/'));
37+
$route = config('genealabs-laravel-caffeine.route', 'genealabs/laravel-caffeine/drip');
38+
$dripUrl = trim($domain, ' /') . "/" . trim($route, ' /');
3739
$interval = config('genealabs-laravel-caffeine.dripIntervalInMilliSeconds', 300000);
3840

3941
$newContent = '<script>setInterval(function(){';

src/LaravelCaffeineServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public function boot()
1212
require __DIR__ . '/Http/routes.php';
1313
}
1414

15-
$this->publishes([__DIR__ . '/../config/config.php' => config_path('genealabs-laravel-caffeine.php')], 'genealabs-laravel-caffeine');
15+
$this->publishes([__DIR__ . '/../config/genealabs-laravel-caffeine.php' => config_path('genealabs-laravel-caffeine.php')], 'genealabs-laravel-caffeine');
1616
}
1717

1818
public function register()
1919
{
20-
// Nothing to see here, folks ...
20+
$this->mergeConfigFrom(__DIR__ . '/../config/genealabs-laravel-caffeine.php', 'genealabs-laravel-caffeine');
2121
}
2222

2323
/**

0 commit comments

Comments
 (0)