mirror of
https://github.com/writefreely/writefreely
synced 2024-11-28 11:30:18 +00:00
Merge pull request #288 from writeas/css-invalidation-release
Add CSS cache busting to templates in release
This commit is contained in:
commit
8cc793142e
2 changed files with 38 additions and 0 deletions
1
Makefile
1
Makefile
|
@ -86,6 +86,7 @@ release : clean ui assets
|
||||||
cp -r templates $(BUILDPATH)
|
cp -r templates $(BUILDPATH)
|
||||||
cp -r pages $(BUILDPATH)
|
cp -r pages $(BUILDPATH)
|
||||||
cp -r static $(BUILDPATH)
|
cp -r static $(BUILDPATH)
|
||||||
|
scripts/invalidate-css.sh $(BUILDPATH)
|
||||||
mkdir $(BUILDPATH)/keys
|
mkdir $(BUILDPATH)/keys
|
||||||
$(MAKE) build-linux
|
$(MAKE) build-linux
|
||||||
mv build/$(BINARY_NAME)-linux-amd64 $(BUILDPATH)/$(BINARY_NAME)
|
mv build/$(BINARY_NAME)-linux-amd64 $(BUILDPATH)/$(BINARY_NAME)
|
||||||
|
|
37
scripts/invalidate-css.sh
Executable file
37
scripts/invalidate-css.sh
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright © 2020 A Bunch Tell LLC.
|
||||||
|
#
|
||||||
|
# This file is part of WriteFreely.
|
||||||
|
#
|
||||||
|
# WriteFreely is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License, included
|
||||||
|
# in the LICENSE file in this source code package.
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# WriteFreely CSS invalidation script
|
||||||
|
#
|
||||||
|
# usage: ./invalidate-css.sh <build-directory>
|
||||||
|
#
|
||||||
|
# This script provides an automated way to invalidate stylesheets cached in the
|
||||||
|
# browser. It uses the last git commit hashes of the most frequently modified
|
||||||
|
# LESS files in the project and appends them to the stylesheet `href` in all
|
||||||
|
# template files.
|
||||||
|
#
|
||||||
|
# This is designed to be used when building a WriteFreely release.
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
# Get parent build directory from first argument
|
||||||
|
buildDir=$1
|
||||||
|
|
||||||
|
# Get short hash of each primary LESS file's last commit
|
||||||
|
cssHash=$(git log -n 1 --pretty=format:%h -- less/core.less)
|
||||||
|
cssNewHash=$(git log -n 1 --pretty=format:%h -- less/new-core.less)
|
||||||
|
cssPadHash=$(git log -n 1 --pretty=format:%h -- less/pad.less)
|
||||||
|
|
||||||
|
echo "Adding write.css version ($cssHash $cssNewHash $cssPadHash) to .tmpl files..."
|
||||||
|
cd "$buildDir/templates" || exit 1
|
||||||
|
find . -type f -name "*.tmpl" -print0 | xargs -0 sed -i "s/write.css/write.css?${cssHash}${cssNewHash}${cssPadHash}/g"
|
||||||
|
find . -type f -name "*.tmpl" -print0 | xargs -0 sed -i "s/{{.Theme}}.css/{{.Theme}}.css?${cssHash}${cssNewHash}${cssPadHash}/g"
|
Loading…
Reference in a new issue