A bit of code cleanup

This commit is contained in:
Jason Streifling 2024-09-10 19:59:56 +02:00
parent 4592bdf970
commit e4624b8705
4 changed files with 14 additions and 21 deletions

View File

@ -8,9 +8,7 @@ import (
"google.golang.org/api/option"
)
type Client struct {
*auth.Client
}
type Client struct{ *auth.Client }
func NewClient(c *Config) (*Client, error) {
var err error

View File

@ -10,9 +10,7 @@ import (
"github.com/gorilla/sessions"
)
type CookieStore struct {
sessions.CookieStore
}
type CookieStore struct{ sessions.CookieStore }
func NewKey() ([]byte, error) {
key := make([]byte, 32)

View File

@ -29,7 +29,7 @@ func WriteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
return
}
type editorHTMLData struct {
type htmlData struct {
Title string
Description string
Content string
@ -37,12 +37,12 @@ func WriteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
Tags []*b.Tag
Mode int
}
var data htmlData
var data editorHTMLData
if session.Values["article"] == nil {
data = editorHTMLData{}
data = htmlData{}
} else {
data = session.Values["article"].(editorHTMLData)
data = session.Values["article"].(htmlData)
}
data.Mode = EditMode
@ -211,11 +211,10 @@ func ShowRejectedArticles(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerF
return
}
type htmlData struct {
data := new(struct {
MyIDs map[int64]bool
RejectedArticles []*b.Article
}
data := new(htmlData)
})
data.RejectedArticles, err = db.GetCertainArticles(false, true)
if err != nil {
@ -530,16 +529,14 @@ func ReviewArticleForDeletion(c *b.Config, db *b.DB, s *b.CookieStore) http.Hand
return
}
type htmlData struct {
var err error
data := new(struct {
Title string
Description string
Content template.HTML
Tags []*b.Tag
ID int64
}
var err error
data := new(htmlData)
})
data.ID, err = strconv.ParseInt(r.PathValue("id"), 10, 64)
if err != nil {

View File

@ -277,12 +277,12 @@ func ShowAllUsers(c *b.Config, db *b.DB, s *b.CookieStore, action string) http.H
return
}
type htmlData struct {
data := new(struct {
Users map[int64]*b.User
Action string
}
})
data := &htmlData{Action: action}
data.Action = action
data.Users, err = db.GetAllUsers()
if err != nil {
log.Println(err)