Browse Source

Add support for surrounding in curly quotes

master
mark 11 months ago
parent
commit
a6a4eb2e50
1 changed files with 13 additions and 6 deletions
  1. +13
    -6
      main.go

+ 13
- 6
main.go View File

@@ -14,7 +14,8 @@ import (
)

type bindText struct {
Text string `form:"text" binding:"required"`
Text string `form:"text" binding:"required"`
Quote string `form:"quote"`
}

func setupRouter() *gin.Engine {
@@ -23,14 +24,20 @@ func setupRouter() *gin.Engine {
r.Static("/", "./public")

r.POST("/make", func(c *gin.Context) {
var bText bindText
var formData bindText

if err := c.ShouldBind(&bText); err != nil {
if err := c.ShouldBind(&formData); err != nil {
c.String(http.StatusBadRequest, "error: no text given")
return
}

text := bText.Text
text := formData.Text
quote := formData.Quote

if quote == "true" {
// Adds curly quotes with a U+200A HAIR SPACE between them and the text
text = "\u201c\u200a" + text + "\u200a\u201d"
}

img, err := iasipgen.Generate(text)

@@ -59,12 +66,12 @@ func setupRouter() *gin.Engine {
}

func main() {
err := iasipgen.LoadFont("Textile.ttf")
err := iasipgen.LoadFont("Textile_patched.ttf")
if err != nil {
fmt.Println("Couldn't load font: ", err)
os.Exit(1)
}

r := setupRouter()
r.Run(":42069")
r.Run(":42069") // nice
}

Loading…
Cancel
Save