A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
1.5 KiB

  1. #!/bin/bash
  2. #
  3. # Copyright © 2020 A Bunch Tell LLC.
  4. #
  5. # This file is part of WriteFreely.
  6. #
  7. # WriteFreely is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License, included
  9. # in the LICENSE file in this source code package.
  10. #
  11. ###############################################################################
  12. #
  13. # WriteFreely CSS invalidation script
  14. #
  15. # usage: ./invalidate-css.sh <build-directory>
  16. #
  17. # This script provides an automated way to invalidate stylesheets cached in the
  18. # browser. It uses the last git commit hashes of the most frequently modified
  19. # LESS files in the project and appends them to the stylesheet `href` in all
  20. # template files.
  21. #
  22. # This is designed to be used when building a WriteFreely release.
  23. #
  24. ###############################################################################
  25. # Get parent build directory from first argument
  26. buildDir=$1
  27. # Get short hash of each primary LESS file's last commit
  28. cssHash=$(git log -n 1 --pretty=format:%h -- less/core.less)
  29. cssNewHash=$(git log -n 1 --pretty=format:%h -- less/new-core.less)
  30. cssPadHash=$(git log -n 1 --pretty=format:%h -- less/pad.less)
  31. echo "Adding write.css version ($cssHash $cssNewHash $cssPadHash) to .tmpl files..."
  32. cd "$buildDir/templates" || exit 1
  33. find . -type f -name "*.tmpl" -print0 | xargs -0 sed -i "s/write.css/write.css?${cssHash}${cssNewHash}${cssPadHash}/g"
  34. find . -type f -name "*.tmpl" -print0 | xargs -0 sed -i "s/{{.Theme}}.css/{{.Theme}}.css?${cssHash}${cssNewHash}${cssPadHash}/g"