Skip to content

Commit

Permalink
Move model to its own package
Browse files Browse the repository at this point in the history
Jade AST cant access the real struct if it is not in a different package
  • Loading branch information
Wikidepia committed Jul 4, 2024
1 parent 2c3f059 commit a835c77
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 25 deletions.
3 changes: 2 additions & 1 deletion handlers/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handlers
import (
"instafix/utils"
"instafix/views"
"instafix/views/model"
"net/url"
"strconv"
"strings"
Expand Down Expand Up @@ -30,7 +31,7 @@ func mediaidToCode(mediaID int) string {
func Embed() fiber.Handler {
return func(c *fiber.Ctx) error {
c.Set("Content-Type", "text/html; charset=utf-8")
viewsData := &views.ViewsData{}
viewsData := &model.ViewsData{}
viewsBuf := bytebufferpool.Get()
defer bytebufferpool.Put(viewsBuf)

Expand Down
3 changes: 2 additions & 1 deletion handlers/oembed.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"instafix/views"
"instafix/views/model"

"github.com/PurpleSec/escape"
"github.com/gofiber/fiber/v2"
Expand All @@ -20,7 +21,7 @@ func OEmbed() fiber.Handler {
defer bytebufferpool.Put(viewsBuf)

// Totally safe 100% valid template 👍
OEmbedData := &views.OEmbedData{
OEmbedData := &model.OEmbedData{
Text: escape.JSON(headingText),
URL: headingURL,
}
Expand Down
4 changes: 3 additions & 1 deletion views/embed.jade
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
:go:func Embed(v *ViewsData)
:go:func Embed(v *model.ViewsData)

:go:import "instafix/views/model"

mixin for(golang)
#cmd Precompile jade templates to #{golang} code.
Expand Down
38 changes: 20 additions & 18 deletions views/embed.jade.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion views/home.jade.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion views/model.go → views/model/model.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package views
package model

type ViewsData struct {
Card string
Expand Down
8 changes: 6 additions & 2 deletions views/oembed.manual.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a835c77

Please sign in to comment.