4
.devtools/sethooks.ps1
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
git config core.eol lf
|
||||||
|
git config core.autocrlf input
|
||||||
|
|
||||||
|
git config core.hooksPath .githooks/windows
|
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/sh
|
#!/usr/bin/sh
|
||||||
|
|
||||||
git config core.hooksPath .githooks
|
git config core.hooksPath .githooks/linux
|
27
.devtools/updatehashes.ps1
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* text eol=lf
|
9
.githooks/windows/pre-commit
Executable file
|
@ -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"
|
Before Width: | Height: | Size: 6.6 MiB After Width: | Height: | Size: 6.6 MiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 4.4 MiB After Width: | Height: | Size: 4.4 MiB |
Before Width: | Height: | Size: 463 KiB After Width: | Height: | Size: 463 KiB |
Before Width: | Height: | Size: 667 KiB After Width: | Height: | Size: 666 KiB |
|
@ -8,6 +8,7 @@
|
||||||
<iframe
|
<iframe
|
||||||
id="openoutpaint"
|
id="openoutpaint"
|
||||||
style="width: 100%; height: 800px"
|
style="width: 100%; height: 800px"
|
||||||
|
src="../index.html?v=e2520a0"
|
||||||
src="../index.html?v=49afaa2"
|
src="../index.html?v=49afaa2"
|
||||||
frameborder="0"></iframe>
|
frameborder="0"></iframe>
|
||||||
<button id="add-res">Add Resource</button>
|
<button id="add-res">Add Resource</button>
|
||||||
|
|