Skip to content

Commit

Permalink
Includes live reload script if necessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny authored Aug 2, 2016
1 parent 0f288a5 commit 91cebdc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions res/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
$ext = pathinfo($pathname, PATHINFO_EXTENSION);
if ($ext == 'html') {
$html = file_get_contents($_SERVER['DOCUMENT_ROOT'].$pathname);
// includes "live relaod" script in HTML files
$script = file_get_contents(__DIR__.'/livereload.js');
$html = str_replace('</body>', $script."\n".'</body>', $html);
// includes "live reload" script in HTML files
if (file_exists($_SERVER['DOCUMENT_ROOT'].'/../.phpoole/watch.flag')) {
$script = file_get_contents(__DIR__.'/livereload.js');
$html = str_replace('</body>', $script."\n".'</body>', $html);
}
// replaces base url by localhost
$html = str_replace(trim(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/../.phpoole/baseurl')), 'http://localhost:8000/', $html);
echo $html;
Expand Down

0 comments on commit 91cebdc

Please sign in to comment.