diff --git a/.gitignore b/.gitignore index a487281..f4e826c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Project Specific tmp/ +.idea/ # Logs #logs diff --git a/server-v2/badges/svg.go b/server-v2/badges/svg.go index f60352d..3e7ac15 100644 --- a/server-v2/badges/svg.go +++ b/server-v2/badges/svg.go @@ -3,6 +3,7 @@ package badges import ( "github.com/essentialkaos/go-badge" "server/libraries" + "strings" ) type Generator struct { @@ -20,9 +21,22 @@ func NewGenerator() (*Generator, error) { } func (g *Generator) GenerateBadge(library *libraries.ArduinoLibrary) []byte { - return g.badgeGenerator.GenerateFlat("Library Manager", library.Name+" "+library.Version, "#00C129") + return g.generateBadge(library.Name+" "+library.Version, "#00C129") } func (g *Generator) GenerateNotFoundBadge(libraryName string) []byte { - return g.badgeGenerator.GenerateFlat("Library Manager", libraryName, "#A2A2A2") + return g.generateBadge(libraryName, "#A2A2A2") +} + +func (g *Generator) generateBadge(content string, color string) []byte { + label := "ZXOLibrary Manager" + badgeString := string(g.badgeGenerator.GenerateFlat(label, content, color)) + + // spacing + badgeString = strings.Replace(badgeString, "ZXO", "    ", 4) + + // insert arduino image before svg enclosing + badgeString = strings.Replace(badgeString, "", ``, 2) + + return []byte(badgeString) }