update
parent
6ccf516c58
commit
4fb43d081c
|
@ -294,6 +294,39 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{/* actions */}}
|
||||||
|
{{with .Actions}}
|
||||||
|
{{if gt (len .) 0}}
|
||||||
|
{{range $action := .}}
|
||||||
|
<p>{{ $action.Instructions }}</p>
|
||||||
|
{{/* count width */}}
|
||||||
|
{{ $length := len $action.Button.Text }}
|
||||||
|
{{ $width := add (mul $length 9) 20 }}
|
||||||
|
{{if (lt $width 200)}}{{$width = 200}}{{else if (gt $width 570)}}{{$width = 570}}{{else}}{{end}}
|
||||||
|
|
||||||
|
{{/* button */}}
|
||||||
|
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<div>
|
||||||
|
{{ if $action.Button.Text }}
|
||||||
|
<a href="{{ $action.Button.Link }}" class="button"
|
||||||
|
style="{{ with $action.Button.Color }}background-color: {{ . }};{{ end }} {{ with $action.Button.TextColor }}color: {{ . }};{{ end }} width: {{$width}}px;"
|
||||||
|
target="_blank">
|
||||||
|
{{ $action.Button.Text }}
|
||||||
|
</a>
|
||||||
|
{{end}}
|
||||||
|
{{ if $action.InviteCode }}
|
||||||
|
<span class="invite-code">{{ $action.InviteCode }}</span>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{/* Main Body */}}
|
{{/* Main Body */}}
|
||||||
{{ if (ne .Content "") }}
|
{{ if (ne .Content "") }}
|
||||||
{{ .Content | ToHTML }}
|
{{ .Content | ToHTML }}
|
||||||
|
@ -314,6 +347,7 @@
|
||||||
<br />
|
<br />
|
||||||
{{ if .Sender }}{{.Sender}}{{else}}{{.App.Name}}{{end}}
|
{{ if .Sender }}{{.Sender}}{{else}}{{.App.Name}}{{end}}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -21,6 +21,25 @@ type App struct {
|
||||||
Copyright string
|
Copyright string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Button struct {
|
||||||
|
Text string
|
||||||
|
Link string
|
||||||
|
|
||||||
|
// Color of the button, default blue(#3869D4)
|
||||||
|
Color string
|
||||||
|
// TextColor of the button, default blue(#ffffff)
|
||||||
|
TextColor string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Action struct {
|
||||||
|
// Instructions text show before button
|
||||||
|
Instructions string
|
||||||
|
|
||||||
|
// InviteCode should not be used with button
|
||||||
|
InviteCode string
|
||||||
|
Button Button
|
||||||
|
}
|
||||||
|
|
||||||
type Body struct {
|
type Body struct {
|
||||||
// App replaced with global config
|
// App replaced with global config
|
||||||
App App
|
App App
|
||||||
|
@ -29,6 +48,8 @@ type Body struct {
|
||||||
Content string
|
Content string
|
||||||
Outros []string
|
Outros []string
|
||||||
|
|
||||||
|
Actions []Action
|
||||||
|
|
||||||
// Greeting ignored if empty
|
// Greeting ignored if empty
|
||||||
Greeting string
|
Greeting string
|
||||||
// Receiver ignored if Greeting or Receiver empty
|
// Receiver ignored if Greeting or Receiver empty
|
||||||
|
|
|
@ -10,6 +10,31 @@ func TestSendSimple(t *testing.T) {
|
||||||
[]string{"test@kumoly.io"}, "TestSendSimple",
|
[]string{"test@kumoly.io"}, "TestSendSimple",
|
||||||
&Body{
|
&Body{
|
||||||
Content: `Testing`,
|
Content: `Testing`,
|
||||||
|
Actions: []Action{
|
||||||
|
{Instructions: "click",
|
||||||
|
Button: Button{
|
||||||
|
Text: "click me", Link: "kumoly.io",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{Instructions: "long button",
|
||||||
|
Button: Button{
|
||||||
|
Text: `long long
|
||||||
|
longlonglonglonglonglonglonglonglonglong
|
||||||
|
longlonglonglonglonglonglonglonglonglong
|
||||||
|
longlonglonglonglonglonglonglonglonglong
|
||||||
|
text`,
|
||||||
|
Link: "kumoly.io",
|
||||||
|
Color: "#90CAF9",
|
||||||
|
TextColor: "#000000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{Instructions: "None",
|
||||||
|
Button: Button{},
|
||||||
|
},
|
||||||
|
{Instructions: "click",
|
||||||
|
InviteCode: "12354",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -23,6 +23,12 @@ var mdParser = goldmark.New(
|
||||||
func init() {
|
func init() {
|
||||||
engine = template.Must(template.New("email").Funcs(template.FuncMap{
|
engine = template.Must(template.New("email").Funcs(template.FuncMap{
|
||||||
"ToHTML": ToHTML,
|
"ToHTML": ToHTML,
|
||||||
|
"add": func(a, b int) int {
|
||||||
|
return a + b
|
||||||
|
},
|
||||||
|
"mul": func(a, b int) int {
|
||||||
|
return a * b
|
||||||
|
},
|
||||||
}).Parse(mailTmpl))
|
}).Parse(mailTmpl))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue