Skip to content

Commit

Permalink
refactor: rename web assets and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNotGoodName committed Jul 20, 2022
1 parent 2c52ec4 commit 7418822
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
8 changes: 4 additions & 4 deletions core/envelope/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

type (
Attachment struct {
ID int64 `json:"id"`
MessageID int64 `json:"message_id"`
Name string `json:"name"`
Mime string `json:"mime"`
ID int64
MessageID int64
Name string
Mime string
}
)

Expand Down
4 changes: 2 additions & 2 deletions core/envelope/envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

type (
Envelope struct {
Message Message `json:"message"`
Attachments []Attachment `json:"attachments"`
Message Message
Attachments []Attachment
}

CreateEnvelopeRequest struct {
Expand Down
16 changes: 8 additions & 8 deletions core/envelope/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import "time"

type (
Message struct {
ID int64 `json:"id"`
To map[string]struct{} `json:"to"`
From string `json:"from"`
Subject string `json:"subject"`
Text string `json:"text"`
HTML string `json:"html"`
Date string `json:"date"`
CreatedAt time.Time `json:"created_at"`
ID int64
To map[string]struct{}
From string
Subject string
Text string
HTML string
Date string
CreatedAt time.Time
}
)

Expand Down
2 changes: 1 addition & 1 deletion left/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func New(addr string, c *controller.Controller, dataFS fs.FS) *Router {
// processing should be stopped.
r.Use(middleware.Timeout(60 * time.Second))

r.Get("/asset/*", handlePrefixFS("/asset/", web.AssetFS()))
r.Get("/css/*", handlePrefixFS("/css/", web.CSSFS()))

r.Get("/", c.IndexGet)
r.Route("/envelope/{id}", func(r chi.Router) {
Expand Down
2 changes: 1 addition & 1 deletion left/view/template/layout/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/asset/css/main.css">
<link rel="stylesheet" href="/css/main.css">
<title>SMTP Bridge</title>
</head>

Expand Down
7 changes: 3 additions & 4 deletions left/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ package web
import (
"embed"
"io/fs"
"log"
)

//go:embed dist
var dist embed.FS

func AssetFS() fs.FS {
f, err := fs.Sub(dist, "dist")
func CSSFS() fs.FS {
f, err := fs.Sub(dist, "dist/css")
if err != nil {
log.Fatalln("web.AssetFS:", err)
panic(err)
}
return f
}

0 comments on commit 7418822

Please sign in to comment.