stash/internal/static/embed.go
WithoutPants 51999135be
Add SFW content mode option (#6262)
* Use more neutral language for content
* Add sfw mode setting
* Make configuration context mandatory
* Add sfw class when sfw mode active
* Hide nsfw performer fields in sfw mode
* Hide nsfw sort options
* Hide nsfw filter/sort options in sfw mode
* Replace o-count with like counter in sfw mode
* Use sfw label for o-counter filter in sfw mode
* Use likes instead of o-count in sfw mode in other places
* Rename sfw mode to sfw content mode
* Use sfw image for default performers in sfw mode
* Document SFW content mode
* Add SFW mode setting to setup
* Clarify README
* Change wording of sfw mode description
* Handle configuration loading error correctly
* Hide age in performer cards
2025-11-18 11:13:35 +11:00

67 lines
1.5 KiB
Go

// Package static provides the static files embedded in the application.
package static
import (
"embed"
"fmt"
"io"
"io/fs"
)
//go:embed performer performer_male performer_sfw scene image gallery tag studio group
var data embed.FS
const (
Performer = "performer"
PerformerMale = "performer_male"
DefaultSFWPerformerImage = "performer_sfw/performer.svg"
Scene = "scene"
DefaultSceneImage = "scene/scene.svg"
Image = "image"
DefaultImageImage = "image/image.svg"
Gallery = "gallery"
DefaultGalleryImage = "gallery/gallery.svg"
Tag = "tag"
DefaultTagImage = "tag/tag.svg"
Studio = "studio"
DefaultStudioImage = "studio/studio.svg"
Group = "group"
DefaultGroupImage = "group/group.svg"
)
// Sub returns an FS rooted at path, using fs.Sub.
// It will panic if an error occurs.
func Sub(path string) fs.FS {
ret, err := fs.Sub(data, path)
if err != nil {
panic(fmt.Sprintf("creating static SubFS: %v", err))
}
return ret
}
// Open opens the file at path for reading.
// It will panic if an error occurs.
func Open(path string) fs.File {
f, err := data.Open(path)
if err != nil {
panic(fmt.Sprintf("opening static file: %v", err))
}
return f
}
// ReadAll returns the contents of the file at path.
// It will panic if an error occurs.
func ReadAll(path string) []byte {
f := Open(path)
ret, err := io.ReadAll(f)
if err != nil {
panic(fmt.Sprintf("reading static file: %v", err))
}
return ret
}