-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from GeneaLabs/Laravel-5.5
Integration of PR #72
- Loading branch information
Showing
11 changed files
with
290 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Change Log | ||
## [0.6.0] - 9 Dec 2017 | ||
### Added | ||
- drip timeout check and force page refresh if timeout occurred. | ||
|
||
### Changed | ||
- config file setting names to be more explicit. | ||
- middleware is injected only when called from a web page or during testing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,64 @@ | ||
<?php | ||
|
||
return [ | ||
'dripIntervalInMilliSeconds' => 300000, // Drip every 5 minutes | ||
'domain' => null, // defaults to url('/') | ||
'route' => 'genealabs/laravel-caffeine/drip', // Can be customized | ||
'thresholdDifference' => 10000, // When the drip will be considered old to reload the page | ||
'checkLastDripInterval' => 2000 // How often we will check if the drip is old | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Drip Interval | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may configure the interval with which Caffeine for Laravel | ||
| keeps the session alive. By default this is 5 minutes (expressed | ||
| in milliseconds). This needs to be shorter than your session | ||
| lifetime value configured set in "config/session.php". | ||
| | ||
| Default: 300000 (int) | ||
| | ||
*/ | ||
'dripInterval' => 300000, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Domain | ||
|-------------------------------------------------------------------------- | ||
| | ||
| You may optionally configure a separate domain that you are running | ||
| Caffeine for Laravel on. This may be of interest if you have a | ||
| monitoring service that queries other apps. Setting this to | ||
| null will use the domain of the current application. | ||
| | ||
| Default: null (null|string) | ||
| | ||
*/ | ||
'domain' => null, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Drip Endpoint URL | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Sometimes you may wish to white-label your app and not expose the AJAX | ||
| request URLs as belonging to this package. To achieve that you can | ||
| rename the URL used for dripping caffeine into your application. | ||
| | ||
| Default: 'genealabs/laravel-caffeine/drip' (string) | ||
| | ||
*/ | ||
'route' => 'genealabs/laravel-caffeine/drip', // Customizable end-point URL | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Checking for Lapsed Drips | ||
|-------------------------------------------------------------------------- | ||
| | ||
| If the browser is put to sleep on (for example on mobil devices or | ||
| laptops), it will still cause an error when trying to submit the | ||
| form. To avoid this, we force-reload the form 2 minutes prior | ||
| to session time-out or later. Setting this setting to 0 | ||
| will disable this check if you don't want to use it. | ||
| | ||
| Default: 2000 (int) | ||
| | ||
*/ | ||
'outdatedDripCheckInterval' => 2000, | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script> | ||
let lastCheck = new Date(); | ||
const caffeineSendDrip = function () { | ||
const ajax = window.XMLHttpRequest | ||
? new XMLHttpRequest | ||
: new ActiveXObject('Microsoft.XMLHTTP'); | ||
ajax.onreadystatechange = function () { | ||
if (ajax.readyState === 4 && ajax.status === 204) { | ||
lastCheck = new Date(); | ||
} | ||
}; | ||
ajax.open('GET', '{{ $url }}'); | ||
ajax.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | ||
ajax.send(); | ||
} | ||
setInterval(function () { | ||
caffeineSendDrip(); | ||
}, {{ $interval }}); | ||
if ({{ $ageCheckInterval }} > 0) { | ||
setInterval(function () { | ||
if (new Date() - lastCheck >= {{ $ageCheckInterval + $ageThreshold }}) { | ||
location.reload(true); | ||
} | ||
}, {{ $ageCheckInterval }}); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script> | ||
let lastCheck = new Date(); | ||
const caffeineSendDrip = function () { | ||
const ajax = window.XMLHttpRequest | ||
? new XMLHttpRequest | ||
: new ActiveXObject('Microsoft.XMLHTTP'); | ||
|
||
ajax.onreadystatechange = function () { | ||
if (ajax.readyState === 4 && ajax.status === 204) { | ||
lastCheck = new Date(); | ||
} | ||
}; | ||
|
||
ajax.open('GET', '/genealabs/laravel-caffeine/drip'); | ||
ajax.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | ||
ajax.send(); | ||
} | ||
|
||
setInterval(function () { | ||
caffeineSendDrip(); | ||
}, 300000); | ||
|
||
if (2000 > 0) { | ||
setInterval(function () { | ||
if (new Date() - lastCheck >= -58000) { | ||
location.reload(true); | ||
} | ||
}, 2000); | ||
} | ||
</script> |
Oops, something went wrong.