summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-01-17 16:49:19 +0100
committerYorhel <git@yorhel.nl>2021-01-17 17:00:46 +0100
commit074bf602f896ebd9eb3c8b2c130eca05299a44dc (patch)
treec16c42a0c54dfe11f5e38120429a984c9e2ed5ee
parent7be45b3ed34537746454bf93e5a67be648b0b46a (diff)
Make/CSS: Put icons.css file hash in the URL
Advantage is that it's both more robust and avoids unecessary reloads when the file hasn't changed. The -strip argument to convert is needed in order to generate icons.png in a deterministic way; without that it includes a creation timestamp in the file metadata.
-rw-r--r--Makefile2
-rw-r--r--css/v2.css2
-rwxr-xr-xutil/spritegen.pl2
3 files changed, 3 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index ad99c196..816f8d20 100644
--- a/Makefile
+++ b/Makefile
@@ -93,7 +93,7 @@ static/g/icons.opt.png: static/g/icons.png
zopflipng -m --lossy_transparent $< $@
static/g/%.css: css/skins/%.sass css/v2.css data/icons/icons.css | static/g
- ( echo '$$version: "$(shell git show-ref --head --abbrev -s HEAD)";'; echo '@import "css/skins/$*"' ) | sassc --stdin -I. --style compressed >$@
+ ( echo '$$icons-version: "$(shell sha1sum static/g/icons.png | head -c8)";'; echo '@import "css/skins/$*"' ) | sassc --stdin -I. --style compressed >$@
diff --git a/css/v2.css b/css/v2.css
index b3bc51f7..e29e9142 100644
--- a/css/v2.css
+++ b/css/v2.css
@@ -1228,7 +1228,7 @@ div.imagebrowse { padding: 0; display: flex; flex-wrap: wrap }
/****** Icons *******/
.icons {
- background: url(/g/icons.png??#{$version}) no-repeat;
+ background: url(/g/icons.png?#{$icons-version}) no-repeat;
width: 16px;
height: 14px;
margin: 0 2px 0 0;
diff --git a/util/spritegen.pl b/util/spritegen.pl
index c2644883..26cd4da8 100755
--- a/util/spritegen.pl
+++ b/util/spritegen.pl
@@ -98,7 +98,7 @@ sub img {
my($w, $h) = @_;
my @cmd = (config->{convert_path}, -size => "${w}x$h", 'canvas:rgba(0,0,0,0)',
map(+($_->{p}, -geometry => "+$_->{x}+$_->{y}", '-composite'), @img),
- "png32:$ticons"
+ '-strip', "png32:$ticons"
);
system(@cmd);
}