-
Notifications
You must be signed in to change notification settings - Fork 12
/
comment.go
82 lines (68 loc) · 2.12 KB
/
comment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package config
// CommentConfig ...
type CommentConfig struct {
Author string `yaml:"author"`
Emails []string `yaml:"emails"`
Notify bool `yaml:"notify"`
NotAllowedEmails []string `yaml:"not_allowed_emails"`
NotAllowedAuthors []string `yaml:"not_allowed_authors"`
Templates CommentTemplatesConfig `yaml:"templates"`
Push CommentPushConfig `yaml:"push"`
}
// DefaultCommentConfig ...
func DefaultCommentConfig() CommentConfig {
return CommentConfig{
Templates: DefaultCommentTemplatesConfig(),
Push: DefaultCommentPushConfig(),
}
}
// CommentTemplatesConfig ...
type CommentTemplatesConfig struct {
Admin string `yaml:"admin"`
Guest string `yaml:"guest"`
}
// DefaultCommentTemplatesConfig ...
func DefaultCommentTemplatesConfig() CommentTemplatesConfig {
const adminTemplate = `
<b>您的博文“{{.Title}}”有新的评论啦!</b><br/><br/>
<pre>{{ .Content }}</pre>
<br/>
<b>链接:</b><a href="{{.Link}}">{{.Link}}</a><br/>
<b>作者:</b>{{.Author}}<br/>
<b>邮箱:</b>{{.Email}}<br/>
<b>网址:</b>{{.HomePage}}<br/>
<b>时间:</b>{{.Date}}<br/>
`
const guestTemplate = `
<b>您在博文“{{.Title}}”的评论有新的回复啦!</b><br/><br/>
<pre>{{ .Content }}</pre>
<br/>
<b>链接:</b><a href="{{.Link}}">{{.Link}}</a><br/>
<b>作者:</b>{{.Author}}<br/>
<b>时间:</b>{{.Date}}<br/>
<br/>该邮件为系统自动发出,请勿直接回复该邮件。<br/>
`
return CommentTemplatesConfig{
Admin: adminTemplate,
Guest: guestTemplate,
}
}
// CommentPushConfig ...
type CommentPushConfig struct {
Chanify *CommentChanifyPushConfig `yaml:"chanify"`
}
// DefaultCommentPushConfig ...
func DefaultCommentPushConfig() CommentPushConfig {
return CommentPushConfig{
Chanify: nil,
}
}
// CommentChanifyPushConfig ...
type CommentChanifyPushConfig struct {
Endpoint string `yaml:"endpoint"`
Token string `yaml:"token"`
}
// DefaultCommentChanifyPushConfig ...
func DefaultCommentChanifyPushConfig() CommentChanifyPushConfig {
return CommentChanifyPushConfig{}
}