mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 13:40:38 +03:00
Image resource refactor
This commit pulls most of the image related logic into its own package, to make it easier to reason about and extend. This is also a rewrite of the transformation logic used in Hugo Pipes, mostly to allow constructs like the one below: {{ ($myimg | fingerprint ).Width }} Fixes #5903 Fixes #6234 Fixes #6266
This commit is contained in:
parent
58d4c0a8be
commit
f9978ed164
34 changed files with 2674 additions and 1556 deletions
|
@ -14,8 +14,10 @@
|
|||
package htesting
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
@ -37,3 +39,20 @@ func CreateTempDir(fs afero.Fs, prefix string) (string, func(), error) {
|
|||
}
|
||||
return tempDir, func() { fs.RemoveAll(tempDir) }, nil
|
||||
}
|
||||
|
||||
// BailOut panics with a stack trace after the given duration. Useful for
|
||||
// hanging tests.
|
||||
func BailOut(after time.Duration) {
|
||||
time.AfterFunc(after, func() {
|
||||
buf := make([]byte, 1<<16)
|
||||
runtime.Stack(buf, true)
|
||||
panic(string(buf))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
|
||||
func RandIntn(n int) int {
|
||||
return rnd.Intn(n)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue