1
Fork 0

caddy: handle /contact and /blog

This commit is contained in:
Motiejus Jakštys 2024-01-28 22:47:10 +02:00
parent 1d0edddc9e
commit 47d1ba611b
3 changed files with 19 additions and 16 deletions

View File

@ -75,7 +75,7 @@
}; };
apps = { apps = {
e11sync-caddyfile = { e11sync-caddy = {
type = "app"; type = "app";
name = "e11sync-caddyfile"; name = "e11sync-caddyfile";
program = toString (pkgs.writeShellScript "wrapper" '' program = toString (pkgs.writeShellScript "wrapper" ''

View File

@ -6,10 +6,15 @@
writeTextFile { writeTextFile {
name = "e11sync-caddyfile"; name = "e11sync-caddyfile";
text = '' text = ''
@addSlash path /static /blog /contact
route @addSlash {
redir {uri}/ 302
}
header /static/* Cache-Control "public, max-age=31536000, immutable" header /static/* Cache-Control "public, max-age=31536000, immutable"
route /static/* { @staticRoutes path /static/* /contact/* /blog/*
uri strip_prefix /static route @staticRoutes {
file_server * { file_server * {
root ${e11sync-static} root ${e11sync-static}
precompressed br gzip precompressed br gzip

View File

@ -13,22 +13,20 @@ runCommand "e11sync-static" {
} '' } ''
unpackPhase unpackPhase
# check that {e11sync-djangostatic,e11sync-blog/static/style.*.css if ! cmp \
# is the same file e11sync-djangostatic/style.*.css \
hash1=$(echo e11sync-djangostatic/static/style.*.css | sed 's;.*/;;' ) e11sync-blog/static/style.*.css
hash2=$(echo e11sync-blog/static/style.*.css | sed 's;.*/;;' ) then
echo "style.*.css in blog and djangostatic do not match:"
if [ "$hash1" != "$hash2" ]; then ls -l e11sync-djangostatic/style/style.*.css blog/style/style.*.css
{ exit 1
echo "style.*.css in blog and django do not match:"
ls e11sync-djangostatic/style/style.*.css
ls blog/style/style.*.css
} >&2
fi fi
rm e11sync-djangostatic/style.*.css
mkdir -p $out mkdir -p $out
mv e11sync-djangostatic/* $out/ mv e11sync-blog/{static,blog,contact} $out/
mv --no-clobber e11sync-blog/{static,blog,contact} $out/ mv --no-clobber e11sync-djangostatic/* $out/static/
find $out \ find $out \
-name '*.css' -or \ -name '*.css' -or \