mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-21 06:30:10 -07:00
Add timestamps to asset files
This commit is contained in:
parent
f106c74da3
commit
d72f512dd1
@ -5,7 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||||
<title>{% block title %}PrintABrick{% endblock %}</title>
|
<title>{% block title %}PrintABrick{% endblock %}</title>
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
<link rel="stylesheet" href="{{ asset('resources/css/main.css') }}">
|
<link rel="stylesheet" href="{{ fileTimestamp(asset('resources/css/main.css')) }}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
|
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="{{ asset('apple-touch-icon.png') }}">
|
<link rel="apple-touch-icon" sizes="180x180" href="{{ asset('apple-touch-icon.png') }}">
|
||||||
@ -20,11 +20,9 @@
|
|||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block javascripts %}
|
{% block javascripts %}
|
||||||
<script type="text/javascript" src="{{ asset('resources/js/three.js') }}"></script>
|
<script type="text/javascript" src="{{ fileTimestamp(asset('resources/js/three.js')) }}"></script>
|
||||||
|
<script type="text/javascript" src="{{ fileTimestamp(asset('resources/js/OrbitControls.js')) }}"></script>
|
||||||
<script type="text/javascript" src="{{ asset('resources/js/OrbitControls.js') }}"></script>
|
<script src="{{ fileTimestamp(asset('resources/js/main.js')) }}"></script>
|
||||||
|
|
||||||
<script src="{{ asset('resources/js/main.js') }}"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -32,6 +32,7 @@ class AppExtension extends \Twig_Extension
|
|||||||
new \Twig_SimpleFunction('remoteSize', [$this, 'remoteSize']),
|
new \Twig_SimpleFunction('remoteSize', [$this, 'remoteSize']),
|
||||||
new \Twig_SimpleFunction('remoteFilename', [$this, 'remoteFilename']),
|
new \Twig_SimpleFunction('remoteFilename', [$this, 'remoteFilename']),
|
||||||
new \Twig_SimpleFunction('remoteFileExists', [$this, 'remoteFileExists']),
|
new \Twig_SimpleFunction('remoteFileExists', [$this, 'remoteFileExists']),
|
||||||
|
new \Twig_SimpleFunction('fileTimestamp', [$this, 'fileTimestamp']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +73,15 @@ class AppExtension extends \Twig_Extension
|
|||||||
return $size;
|
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)
|
public function remoteFilename($url)
|
||||||
{
|
{
|
||||||
return basename($url);
|
return basename($url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user