Skip to content

Commit f44f1fd

Browse files
13791379
authored andcommitted
feat: import from hexo jekyll hugo
style: format code
1 parent 4338ad7 commit f44f1fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2614
-40
lines changed

consts/enum.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ func (c *CommentStatus) Scan(src interface{}) error {
387387
}
388388
return nil
389389
}
390+
390391
func CommentStatusFromString(str string) (CommentStatus, error) {
391392
if str == "PUBLISHED" {
392393
return CommentStatusPublished, nil
@@ -421,10 +422,14 @@ const (
421422
type EditorType int32
422423

423424
const (
424-
EditorTypeMarkdown = iota
425+
EditorTypeMarkdown EditorType = iota
425426
EditorTypeRichText
426427
)
427428

429+
func (e EditorType) Ptr() *EditorType {
430+
return &e
431+
}
432+
428433
func (e *EditorType) Scan(src interface{}) error {
429434
if src == nil {
430435
return xerr.BadParam.New("").WithMsg("field nil")

dal/dal.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func Transaction(ctx context.Context, fn func(txCtx context.Context) error) erro
130130
return fn(txCtx)
131131
})
132132
}
133+
133134
func GetDB() *gorm.DB {
134135
return DB
135136
}

event/listener/comment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func NewCommentListener(
5454
bus.Subscribe(event.CommentNewEventName, c.HandleCommentNew)
5555
bus.Subscribe(event.CommentReplyEventName, c.HandleCommentReply)
5656
}
57+
5758
func (c *CommentListener) HandleCommentNew(ctx context.Context, ce event.Event) error {
5859
newCommentNotice, err := c.OptionService.GetOrByDefaultWithErr(ctx, property.CommentNewNotice, property.CommentNewNotice.DefaultValue)
5960
if err != nil {
@@ -142,6 +143,7 @@ func (c *CommentListener) HandleCommentNew(ctx context.Context, ce event.Event)
142143
}
143144
return c.EmailService.SendTemplateEmail(ctx, users[0].Email, subject, content.String())
144145
}
146+
145147
func (c *CommentListener) HandleCommentReply(ctx context.Context, ce event.Event) error {
146148
commentReplyNotice, err := c.OptionService.GetOrByDefaultWithErr(ctx, property.CommentReplyNotice, property.CommentNewNotice.DefaultValue)
147149
if err != nil {

event/listener/post_update.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ func NewPostUpdateListener(bus event.Bus,
2929
}
3030

3131
func (p *PostUpdateListener) HandlePostUpdateEvent(ctx context.Context, postUpdateEvent event.Event) error {
32-
3332
postID := postUpdateEvent.(*event.PostUpdateEvent).PostID
3433

3534
categories, err := p.PostCategoryService.ListCategoryByPostID(ctx, postID)

go.mod

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.19
55
require (
66
github.com/Masterminds/sprig/v3 v3.2.2
77
github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible
8+
github.com/clbanning/mxj/v2 v2.5.7
89
github.com/disintegration/imaging v1.6.2
910
github.com/fsnotify/fsnotify v1.6.0
1011
github.com/gin-contrib/cors v1.4.0
@@ -18,10 +19,14 @@ require (
1819
github.com/minio/minio-go/v7 v7.0.45
1920
github.com/natefinch/lumberjack v2.0.0+incompatible
2021
github.com/patrickmn/go-cache v2.1.0+incompatible
22+
github.com/pelletier/go-toml/v2 v2.0.5
2123
github.com/pkg/errors v0.9.1
2224
github.com/pquerna/otp v1.4.0
25+
github.com/spf13/afero v1.9.2
26+
github.com/spf13/cast v1.5.0
2327
github.com/spf13/viper v1.14.0
2428
github.com/yeqown/go-qrcode v1.5.10
29+
github.com/yuin/goldmark v1.5.3
2530
go.uber.org/dig v1.15.0
2631
go.uber.org/fx v1.18.2
2732
go.uber.org/zap v1.24.0
@@ -64,12 +69,9 @@ require (
6469
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6570
github.com/modern-go/reflect2 v1.0.2 // indirect
6671
github.com/pelletier/go-toml v1.9.5 // indirect
67-
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
6872
github.com/rs/xid v1.4.0 // indirect
6973
github.com/shopspring/decimal v1.2.0 // indirect
7074
github.com/sirupsen/logrus v1.9.0 // indirect
71-
github.com/spf13/afero v1.9.2 // indirect
72-
github.com/spf13/cast v1.5.0 // indirect
7375
github.com/spf13/jwalterweatherman v1.1.0 // indirect
7476
github.com/spf13/pflag v1.0.5 // indirect
7577
github.com/subosito/gotenv v1.4.1 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
5757
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
5858
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
5959
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
60+
github.com/clbanning/mxj/v2 v2.5.7 h1:7q5lvUpaPF/WOkqgIDiwjBJaznaLCCBd78pi8ZyAnE0=
61+
github.com/clbanning/mxj/v2 v2.5.7/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
6062
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
6163
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
6264
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
@@ -392,6 +394,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
392394
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
393395
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
394396
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
397+
github.com/yuin/goldmark v1.5.3 h1:3HUJmBFbQW9fhQOzMgseU134xfi6hU+mjWywx5Ty+/M=
398+
github.com/yuin/goldmark v1.5.3/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
395399
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
396400
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
397401
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=

handler/admin/backup.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package admin
22

33
import (
44
"net/http"
5+
"path"
56
"path/filepath"
67

78
"github.com/gin-gonic/gin"
@@ -116,6 +117,10 @@ func (b *BackupHandler) ImportMarkdown(ctx *gin.Context) (interface{}, error) {
116117
if err != nil {
117118
return nil, xerr.WithMsg(err, "上传文件错误").WithStatus(xerr.StatusBadRequest)
118119
}
120+
filenameExt := path.Ext(fileHeader.Filename)
121+
if filenameExt != ".md" && filenameExt != ".markdown" && filenameExt != ".mdown" {
122+
return nil, xerr.WithMsg(err, "Unsupported format").WithStatus(xerr.StatusBadRequest)
123+
}
119124
return nil, b.BackupService.ImportMarkdown(ctx, fileHeader)
120125
}
121126

handler/admin/email.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func NewEmailHandler(emailService service.EmailService) *EmailHandler {
1717
EmailService: emailService,
1818
}
1919
}
20+
2021
func (e *EmailHandler) Test(ctx *gin.Context) (interface{}, error) {
2122
p := &param.TestEmail{}
2223
if err := ctx.ShouldBindJSON(p); err != nil {

handler/content/api/journal.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ func (j *JournalHandler) GetJournal(ctx *gin.Context) (interface{}, error) {
7979
}
8080

8181
func (j *JournalHandler) ListTopComment(ctx *gin.Context) (interface{}, error) {
82-
8382
journalID, err := util.ParamInt32(ctx, "journalID")
8483
if err != nil {
8584
return nil, err

handler/content/archive.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func NewArchiveHandler(
4444
func (a *ArchiveHandler) Archives(ctx *gin.Context, model template.Model) (string, error) {
4545
return a.PostModel.Archives(ctx, 0, model)
4646
}
47+
4748
func (a *ArchiveHandler) ArchivesPage(ctx *gin.Context, model template.Model) (string, error) {
4849
page, err := util.ParamInt32(ctx, "page")
4950
if err != nil {

0 commit comments

Comments
 (0)