Skip to content

Commit fecb154

Browse files
Paul LloydPaul Lloyd
Paul Lloyd
authored and
Paul Lloyd
committed
Revert changes
1 parent 5586af7 commit fecb154

File tree

3 files changed

+27
-32
lines changed

3 files changed

+27
-32
lines changed

.htaccess

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
RewriteRule ^(.*)$ http://bradshawsguide.org/$1 [R=301,L]
1414

1515
# Rewrite cache busting query strings on static files
16-
# RewriteCond %{REQUEST_FILENAME} !-f
17-
# RewriteRule ^assets/([a-z]+)/([a-z]+).([0-9]+).(js|css)$ /assets/$1/$2.$4 [L]
16+
RewriteCond %{REQUEST_FILENAME} !-f
17+
RewriteRule ^assets/([a-z]+)/([a-z]+).([0-9]+).(js|css)$ /assets/$1/$2.$4 [L]
1818

1919
# Make site links work
2020
RewriteCond %{REQUEST_FILENAME} !-f

build.php

-28
This file was deleted.

site/snippets/_header.php

+25-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@
1212
header("Pragma: cache");
1313
header("Cache-Control: max-age=$seconds_to_cache");
1414

15+
// Compile and cache LESS CSS file
16+
function autoCompileLess($input, $output) {
17+
$inputFile = $_SERVER['DOCUMENT_ROOT'].$input;
18+
$outputFile = $_SERVER['DOCUMENT_ROOT'].$output;
19+
$cacheFile = $inputFile.".cache";
20+
21+
if (file_exists($cacheFile)) {
22+
$cache = unserialize(file_get_contents($cacheFile));
23+
} else {
24+
$cache = $inputFile;
25+
}
26+
27+
$less = new lessc;
28+
$newCache = $less->cachedCompile($cache);
29+
30+
if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
31+
file_put_contents($cacheFile, serialize($newCache));
32+
file_put_contents($outputFile, $newCache['compiled']);
33+
}
34+
}
35+
36+
autoCompileLess('/assets/styles/less/styles.less', '/assets/styles/styles.css');
37+
1538
// Get modified file date
1639
function getFiledate($file, $format) {
1740
if (is_file($file)) {
@@ -33,7 +56,7 @@ function getFiledate($file, $format) {
3356
// Add a script element as a child of the body
3457
function downloadJSAtOnload() {
3558
var element = document.createElement("script");
36-
element.src = "/assets/scripts/scripts.js?v=<?= getFiledate('assets/scripts/scripts.js','YmdHis'); ?>";
59+
element.src = "/assets/scripts/scripts.<?= getFiledate('assets/scripts/scripts.js','YmdHis'); ?>.js";
3760
document.body.appendChild(element);
3861
}
3962

@@ -47,7 +70,7 @@ function downloadJSAtOnload() {
4770
}
4871
</script>
4972

50-
<link rel="stylesheet" href="/assets/styles/styles.css?v=<?= getFiledate('assets/styles/styles.css','YmdHis'); ?>" />
73+
<link rel="stylesheet" href="/assets/styles/styles.<?= getFiledate('assets/styles/styles.css','YmdHis'); ?>.css" />
5174
<link rel="icon" href="<?= url('assets/images/favicon.png') ?>" type="image/png"/>
5275
<link rel="apple-touch-icon-precomposed" href="<?= url('assets/images/apple-touch-icon.png') ?>"/>
5376
<link rel="license" href="<?= html($site->licenseurl) ?>"/>

0 commit comments

Comments
 (0)