fix (plugin): new favicon plugin type

This commit is contained in:
MickaelK
2025-09-15 13:54:11 +10:00
parent 8adfa58ffe
commit 45b8fd99e5
4 changed files with 60 additions and 42 deletions

View File

@ -1,6 +1,7 @@
package common
import (
"bytes"
"io"
"io/fs"
"net/http"
@ -223,6 +224,25 @@ func (this Get) CSS() string {
return s
}
var favicon struct {
binary []byte
mime string
}
func (this Register) Favicon(binary []byte) {
favicon.binary = binary
favicon.mime = "image/svg+xml"
if bytes.HasPrefix(binary, []byte{0x00, 0x00, 0x01, 0x00}) {
favicon.mime = "image/x-icon"
} else if bytes.HasPrefix(binary, []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}) {
favicon.mime = "image/png"
}
}
func (this Get) Favicon() ([]byte, string) {
return favicon.binary, favicon.mime
}
const OverrideVideoSourceMapper = "/overrides/video-transcoder.js"
var afterload []func()