added the default button set to the image server
@@ -57,6 +57,7 @@ type AmConfig struct {
|
|||||||
Rendering struct {
|
Rendering struct {
|
||||||
TemplateDir string `yaml:"templatedir"`
|
TemplateDir string `yaml:"templatedir"`
|
||||||
CookieKey string `yaml:"cookiekey"`
|
CookieKey string `yaml:"cookiekey"`
|
||||||
|
ButtonSet string `yaml:"buttonSet"`
|
||||||
} `yaml:"rendering"`
|
} `yaml:"rendering"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ database:
|
|||||||
rendering:
|
rendering:
|
||||||
templatedir: custom_templates
|
templatedir: custom_templates
|
||||||
cookiekey: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
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"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.erbosoft.com/amy/amsterdam/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed static_images/*
|
//go:embed static_images/*
|
||||||
var static_images embed.FS
|
var static_images embed.FS
|
||||||
|
|
||||||
|
//go:embed buttons/*
|
||||||
|
var buttons embed.FS
|
||||||
|
|
||||||
/* mimeTypeFromFilenane returns the MIME type of a file, given its filename.
|
/* mimeTypeFromFilenane returns the MIME type of a file, given its filename.
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* filaname - The name of the file to be tested.
|
* 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) {
|
func AmServeImage(ctxt AmContext) (string, any, error) {
|
||||||
components := strings.SplitAfter(ctxt.URLPath(), "/")
|
components := strings.SplitAfter(ctxt.URLPath(), "/")
|
||||||
var err error = nil
|
var err error = nil
|
||||||
if len(components) == 4 && components[2] == "builtin/" {
|
var b []byte
|
||||||
var b []byte
|
if len(components) == 4 {
|
||||||
b, err = static_images.ReadFile(filepath.Join("static_images", components[3]))
|
if components[2] == "builtin/" {
|
||||||
if err == nil {
|
b, err = static_images.ReadFile(filepath.Join("static_images", components[3]))
|
||||||
ctxt.SetOutputType(mimeTypeFromFilename(components[3]))
|
if err == nil {
|
||||||
return "bytes", b, 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)
|
ctxt.SetRC(http.StatusNotFound)
|
||||||
|
|||||||