diff --git a/app/Resources/views/html.html.twig b/app/Resources/views/html.html.twig index d9c36f1..6b035d4 100644 --- a/app/Resources/views/html.html.twig +++ b/app/Resources/views/html.html.twig @@ -5,7 +5,7 @@ {% block title %}PrintABrick{% endblock %} {% block stylesheets %} - + {% endblock %} @@ -20,11 +20,9 @@ {% endblock %} {% block javascripts %} - - - - - + + + {% endblock %} diff --git a/src/AppBundle/Twig/AppExtension.php b/src/AppBundle/Twig/AppExtension.php index f3b0542..f46e7db 100644 --- a/src/AppBundle/Twig/AppExtension.php +++ b/src/AppBundle/Twig/AppExtension.php @@ -32,6 +32,7 @@ class AppExtension extends \Twig_Extension new \Twig_SimpleFunction('remoteSize', [$this, 'remoteSize']), new \Twig_SimpleFunction('remoteFilename', [$this, 'remoteFilename']), new \Twig_SimpleFunction('remoteFileExists', [$this, 'remoteFileExists']), + new \Twig_SimpleFunction('fileTimestamp', [$this, 'fileTimestamp']), ]; } @@ -72,6 +73,15 @@ class AppExtension extends \Twig_Extension return $size; } + public function fileTimestamp($filePath) { + $changeDate = filemtime($_SERVER['DOCUMENT_ROOT'].'/'.$filePath); + if (!$changeDate) { + //Fallback if mtime could not be found: + $changeDate = mktime(0, 0, 0, date('m'), date('d'), date('Y')); + } + return $filePath.'?'.$changeDate; + } + public function remoteFilename($url) { return basename($url);