added the default button set to the image server
@@ -57,6 +57,7 @@ type AmConfig struct {
|
||||
Rendering struct {
|
||||
TemplateDir string `yaml:"templatedir"`
|
||||
CookieKey string `yaml:"cookiekey"`
|
||||
ButtonSet string `yaml:"buttonSet"`
|
||||
} `yaml:"rendering"`
|
||||
}
|
||||
|
||||
|
||||
@@ -15,3 +15,4 @@ database:
|
||||
rendering:
|
||||
templatedir: custom_templates
|
||||
cookiekey: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
buttonSet: classic
|
||||
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
@@ -17,11 +17,16 @@ import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"git.erbosoft.com/amy/amsterdam/config"
|
||||
)
|
||||
|
||||
//go:embed static_images/*
|
||||
var static_images embed.FS
|
||||
|
||||
//go:embed buttons/*
|
||||
var buttons embed.FS
|
||||
|
||||
/* mimeTypeFromFilenane returns the MIME type of a file, given its filename.
|
||||
* Parameters:
|
||||
* filaname - The name of the file to be tested.
|
||||
@@ -43,12 +48,22 @@ func mimeTypeFromFilename(filename string) string {
|
||||
func AmServeImage(ctxt AmContext) (string, any, error) {
|
||||
components := strings.SplitAfter(ctxt.URLPath(), "/")
|
||||
var err error = nil
|
||||
if len(components) == 4 && components[2] == "builtin/" {
|
||||
var b []byte
|
||||
b, err = static_images.ReadFile(filepath.Join("static_images", components[3]))
|
||||
if err == nil {
|
||||
ctxt.SetOutputType(mimeTypeFromFilename(components[3]))
|
||||
return "bytes", b, nil
|
||||
var b []byte
|
||||
if len(components) == 4 {
|
||||
if components[2] == "builtin/" {
|
||||
b, err = static_images.ReadFile(filepath.Join("static_images", components[3]))
|
||||
if err == nil {
|
||||
ctxt.SetOutputType(mimeTypeFromFilename(components[3]))
|
||||
return "bytes", b, nil
|
||||
}
|
||||
}
|
||||
if components[2] == "button/" {
|
||||
b, err = buttons.ReadFile(filepath.Join("buttons", config.GlobalConfig.Rendering.ButtonSet,
|
||||
components[3]))
|
||||
if err == nil {
|
||||
ctxt.SetOutputType(mimeTypeFromFilename(components[3]))
|
||||
return "bytes", b, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
ctxt.SetRC(http.StatusNotFound)
|
||||
|
||||