Compare commits
No commits in common. "2537235ce6d9a2a120bea9f4550b3e4eea21c138" and "e10448f1e3b5a9f9143fdac4838ccd5c19d2aa21" have entirely different histories.
2537235ce6
...
e10448f1e3
@ -7,7 +7,6 @@ import (
|
||||
"html/template"
|
||||
"image/png"
|
||||
|
||||
"git.odit.services/lfk/document-server/templates"
|
||||
"github.com/boombuler/barcode"
|
||||
"github.com/boombuler/barcode/code128"
|
||||
"github.com/boombuler/barcode/ean"
|
||||
@ -80,19 +79,10 @@ func (t *DefaultTemplater) GenerateBarcode(code string, format string, prefix st
|
||||
return base64.StdEncoding.EncodeToString(buf.Bytes()), nil
|
||||
}
|
||||
|
||||
func (t *DefaultTemplater) SelectSponsorImage(id int) (string, error) {
|
||||
sponsors := []string{
|
||||
"vrbank",
|
||||
"odit",
|
||||
"sparkasse",
|
||||
}
|
||||
return templates.GetImage(sponsors[id%len(sponsors)]), nil
|
||||
}
|
||||
|
||||
func (t *DefaultTemplater) StringToTemplate(templateString string) (*template.Template, error) {
|
||||
return template.New("template").Funcs(template.FuncMap{
|
||||
"barcode": t.GenerateBarcode,
|
||||
"sponsorLogo": t.SelectSponsorImage,
|
||||
"sponsorLogo": func(id int) string { return "a" },
|
||||
}).Parse(templateString)
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -3,8 +3,6 @@ package templates
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
//go:embed card/en.html
|
||||
@ -22,9 +20,6 @@ var ContractTemplateDe string
|
||||
//go:embed images/sponsoringheader.base64
|
||||
var ImageSponsoringHeaderBase64 string
|
||||
|
||||
//go:embed images/error.base64
|
||||
var ImageErrorBase64 string
|
||||
|
||||
func GetTemplate(locale, templateName string) (string, error) {
|
||||
switch templateName {
|
||||
case "card":
|
||||
@ -44,12 +39,3 @@ func GetTemplate(locale, templateName string) (string, error) {
|
||||
}
|
||||
return "", fmt.Errorf("template not found with name %s and locale %s", templateName, locale)
|
||||
}
|
||||
|
||||
func GetImage(imageName string) string {
|
||||
content, err := os.ReadFile("static/images/" + imageName + ".base64")
|
||||
if content == nil || err != nil {
|
||||
log.Printf("error reading image %s: %v", imageName, err)
|
||||
return ImageErrorBase64
|
||||
}
|
||||
return string(content)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user