mirror of
https://github.com/Luzifer/badge-gen.git
synced 2024-11-08 05:10:02 +00:00
Replace bindata with go:embed
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
3f6103d473
commit
73b722d998
5 changed files with 10 additions and 287 deletions
4
app.go
4
app.go
|
@ -221,7 +221,7 @@ func createBadge(title, text, color string) ([]byte, string) {
|
|||
|
||||
width := titleW + textW + 4*xSpacing
|
||||
|
||||
t, _ := Asset("assets/badgeTemplate.tpl")
|
||||
t, _ := assets.ReadFile("assets/badgeTemplate.tpl")
|
||||
tpl, _ := template.New("svg").Parse(string(t))
|
||||
|
||||
if c, ok := colorList[color]; ok {
|
||||
|
@ -246,7 +246,7 @@ func generateETag(in []byte) string {
|
|||
}
|
||||
|
||||
func handleDemoPage(res http.ResponseWriter, r *http.Request) {
|
||||
t, _ := Asset("assets/demoPage.tpl.html")
|
||||
t, _ := assets.ReadFile("assets/demoPage.tpl.html")
|
||||
tpl, _ := template.New("demoPage").Parse(string(t))
|
||||
|
||||
examples := serviceHandlerDocumentationList{}
|
||||
|
|
6
assets.go
Normal file
6
assets.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package main
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed assets/*
|
||||
var assets embed.FS
|
283
bindata.go
283
bindata.go
File diff suppressed because one or more lines are too long
2
font.go
2
font.go
|
@ -15,7 +15,7 @@ const (
|
|||
)
|
||||
|
||||
func calculateTextWidth(text string) (int, error) {
|
||||
binFont, _ := Asset("assets/DejaVuSans.ttf")
|
||||
binFont, _ := assets.ReadFile("assets/DejaVuSans.ttf")
|
||||
font, err := truetype.Parse(binFont)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
func TestEmbeddedFontHash(t *testing.T) {
|
||||
// Check the embedded font did not change
|
||||
font, err := Asset("assets/DejaVuSans.ttf")
|
||||
font, err := assets.ReadFile("assets/DejaVuSans.ttf")
|
||||
if err != nil {
|
||||
t.Errorf("Could not load embedded font: %s", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue