diff --git a/.devtools/sethooks.ps1 b/.devtools/sethooks.ps1 new file mode 100644 index 0000000..930a120 --- /dev/null +++ b/.devtools/sethooks.ps1 @@ -0,0 +1,4 @@ +git config core.eol lf +git config core.autocrlf input + +git config core.hooksPath .githooks/windows \ No newline at end of file diff --git a/.devtools/sethooks.sh b/.devtools/sethooks.sh index 7df28b7..ddb6619 100755 --- a/.devtools/sethooks.sh +++ b/.devtools/sethooks.sh @@ -1,3 +1,3 @@ #!/usr/bin/sh -git config core.hooksPath .githooks \ No newline at end of file +git config core.hooksPath .githooks/linux \ No newline at end of file diff --git a/.devtools/updatehashes.ps1 b/.devtools/updatehashes.ps1 new file mode 100644 index 0000000..993cab6 --- /dev/null +++ b/.devtools/updatehashes.ps1 @@ -0,0 +1,27 @@ +# Updates html files with cache busting urls including file hashes. + +# Actual file processing +$htmlfiles = Get-ChildItem -Path . -Recurse -Filter "*.html" | Where {$_.FullName -notlike "*\node_modules\*"} | Resolve-path -relative +foreach ($htmlfile in $htmlfiles) { + Write-Host "[info] Processing '${htmlfile}' for cache busting..." -ForegroundColor Blue + + $resfiles = (@(Get-ChildItem -Path . -Recurse -Filter "*.css") + (Get-ChildItem -Path . -Recurse -Filter "*.js")) | Resolve-Path -relative + + if ($args[0] -eq "gitadd") { + $resfiles = (git status -s | Select-String -Pattern "[A-Z] .+") | ForEach-Object { -split $_.Line | Select-Object -Last 1 } + } + + foreach ($resfile in $resfiles) { + $resfile = $resfile -replace '\\', '/' -replace '\./', '' + # Check if resource is used in html file + if ($null -ne (Select-String -Path $htmlfile -Pattern $resfile)) { + $hash = (Get-FileHash $resfile -Algorithm SHA1).Hash + + # This is just for cache busting... + # If 7 first characters of SHA1 is okay for git, it should be more than enough for us + $hash = $hash.Substring(0, 7).ToLower() + + (Get-Content -Raw -Path $htmlfile).replace('\r\n', "\n") -replace "$resfile(\?v=[a-z0-9]+)?", "${resfile}?v=$hash" | Set-Content $htmlfile + } + } +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..07764a7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=lf \ No newline at end of file diff --git a/.githooks/pre-commit b/.githooks/linux/pre-commit similarity index 100% rename from .githooks/pre-commit rename to .githooks/linux/pre-commit diff --git a/.githooks/windows/pre-commit b/.githooks/windows/pre-commit new file mode 100755 index 0000000..6b35b79 --- /dev/null +++ b/.githooks/windows/pre-commit @@ -0,0 +1,9 @@ +#!/bin/sh +# +# Script to perform some basic operations to the code before committing. + +# Adds file hashes to html script imports for cache busting purposes +powershell .devtools/updatehashes.ps1 gitadd + +# Adds file to current commit +git add "**.html" \ No newline at end of file diff --git a/docs/02-sample.png b/docs/02-sample.png index 6bc24a7..d702989 100644 Binary files a/docs/02-sample.png and b/docs/02-sample.png differ diff --git a/docs/03-arbimg.png b/docs/03-arbimg.png index 3893d45..ed2e127 100644 Binary files a/docs/03-arbimg.png and b/docs/03-arbimg.png differ diff --git a/docs/04-catsonaspacestation.png b/docs/04-catsonaspacestation.png index 7cae7a9..09e6c73 100644 Binary files a/docs/04-catsonaspacestation.png and b/docs/04-catsonaspacestation.png differ diff --git a/docs/05-openOutpaintFish.png b/docs/05-openOutpaintFish.png index e03a6e8..73fa60e 100644 Binary files a/docs/05-openOutpaintFish.png and b/docs/05-openOutpaintFish.png differ diff --git a/docs/06-desert.png b/docs/06-desert.png index f44776d..27e528f 100644 Binary files a/docs/06-desert.png and b/docs/06-desert.png differ diff --git a/pages/embed.test.html b/pages/embed.test.html index 877e48f..1376eb6 100644 --- a/pages/embed.test.html +++ b/pages/embed.test.html @@ -8,6 +8,7 @@ diff --git a/res/fonts/OpenSans.ttf b/res/fonts/OpenSans.ttf index db43334..79a4385 100644 Binary files a/res/fonts/OpenSans.ttf and b/res/fonts/OpenSans.ttf differ