@@ -18,7 +18,6 @@ import (
18
18
"path/filepath"
19
19
"reflect"
20
20
"regexp"
21
- "runtime"
22
21
"strings"
23
22
texttmpl "text/template"
24
23
"time"
@@ -56,12 +55,6 @@ var mailSubjectSplit = regexp.MustCompile(`(?m)^-{3,}[\s]*$`)
56
55
// NewFuncMap returns functions for injecting to templates
57
56
func NewFuncMap () []template.FuncMap {
58
57
return []template.FuncMap {map [string ]interface {}{
59
- "GoVer" : func () string {
60
- return util .ToTitleCase (runtime .Version ())
61
- },
62
- "UseHTTPS" : func () bool {
63
- return strings .HasPrefix (setting .AppURL , "https" )
64
- },
65
58
"AppName" : func () string {
66
59
return setting .AppName
67
60
},
@@ -81,10 +74,7 @@ func NewFuncMap() []template.FuncMap {
81
74
"AppVer" : func () string {
82
75
return setting .AppVer
83
76
},
84
- "AppBuiltWith" : func () string {
85
- return setting .AppBuiltWith
86
- },
87
- "AppDomain" : func () string {
77
+ "AppDomain" : func () string { // documented in mail-templates.md
88
78
return setting .Domain
89
79
},
90
80
"AssetVersion" : func () string {
@@ -108,11 +98,7 @@ func NewFuncMap() []template.FuncMap {
108
98
"CustomEmojis" : func () map [string ]string {
109
99
return setting .UI .CustomEmojisMap
110
100
},
111
- "IsShowFullName" : func () bool {
112
- return setting .UI .DefaultShowFullName
113
- },
114
101
"Safe" : Safe ,
115
- "SafeJS" : SafeJS ,
116
102
"JSEscape" : JSEscape ,
117
103
"Str2html" : Str2html ,
118
104
"TimeSince" : timeutil .TimeSince ,
@@ -140,33 +126,15 @@ func NewFuncMap() []template.FuncMap {
140
126
"DateFmtLong" : func (t time.Time ) string {
141
127
return t .Format (time .RFC1123Z )
142
128
},
143
- "DateFmtShort" : func (t time.Time ) string {
144
- return t .Format ("Jan 02, 2006" )
145
- },
146
- "CountFmt" : base .FormatNumberSI ,
147
- "SubStr" : func (str string , start , length int ) string {
148
- if len (str ) == 0 {
149
- return ""
150
- }
151
- end := start + length
152
- if length == - 1 {
153
- end = len (str )
154
- }
155
- if len (str ) < end {
156
- return str
157
- }
158
- return str [start :end ]
159
- },
129
+ "CountFmt" : base .FormatNumberSI ,
160
130
"EllipsisString" : base .EllipsisString ,
161
- "DiffTypeToStr" : DiffTypeToStr ,
162
131
"DiffLineTypeToStr" : DiffLineTypeToStr ,
163
132
"ShortSha" : base .ShortSha ,
164
133
"ActionContent2Commits" : ActionContent2Commits ,
165
134
"PathEscape" : url .PathEscape ,
166
135
"PathEscapeSegments" : util .PathEscapeSegments ,
167
136
"URLJoin" : util .URLJoin ,
168
137
"RenderCommitMessage" : RenderCommitMessage ,
169
- "RenderCommitMessageLink" : RenderCommitMessageLink ,
170
138
"RenderCommitMessageLinkSubject" : RenderCommitMessageLinkSubject ,
171
139
"RenderCommitBody" : RenderCommitBody ,
172
140
"RenderCodeBlock" : RenderCodeBlock ,
@@ -429,19 +397,13 @@ func NewFuncMap() []template.FuncMap {
429
397
curBranch ,
430
398
)
431
399
},
432
- "RefShortName" : func (ref string ) string {
433
- return git .RefName (ref ).ShortName ()
434
- },
435
400
}}
436
401
}
437
402
438
403
// NewTextFuncMap returns functions for injecting to text templates
439
404
// It's a subset of those used for HTML and other templates
440
405
func NewTextFuncMap () []texttmpl.FuncMap {
441
406
return []texttmpl.FuncMap {map [string ]interface {}{
442
- "GoVer" : func () string {
443
- return util .ToTitleCase (runtime .Version ())
444
- },
445
407
"AppName" : func () string {
446
408
return setting .AppName
447
409
},
@@ -454,33 +416,14 @@ func NewTextFuncMap() []texttmpl.FuncMap {
454
416
"AppVer" : func () string {
455
417
return setting .AppVer
456
418
},
457
- "AppBuiltWith" : func () string {
458
- return setting .AppBuiltWith
459
- },
460
- "AppDomain" : func () string {
419
+ "AppDomain" : func () string { // documented in mail-templates.md
461
420
return setting .Domain
462
421
},
463
422
"TimeSince" : timeutil .TimeSince ,
464
423
"TimeSinceUnix" : timeutil .TimeSinceUnix ,
465
424
"DateFmtLong" : func (t time.Time ) string {
466
425
return t .Format (time .RFC1123Z )
467
426
},
468
- "DateFmtShort" : func (t time.Time ) string {
469
- return t .Format ("Jan 02, 2006" )
470
- },
471
- "SubStr" : func (str string , start , length int ) string {
472
- if len (str ) == 0 {
473
- return ""
474
- }
475
- end := start + length
476
- if length == - 1 {
477
- end = len (str )
478
- }
479
- if len (str ) < end {
480
- return str
481
- }
482
- return str [start :end ]
483
- },
484
427
"EllipsisString" : base .EllipsisString ,
485
428
"URLJoin" : util .URLJoin ,
486
429
"Dict" : func (values ... interface {}) (map [string ]interface {}, error ) {
@@ -624,11 +567,6 @@ func Safe(raw string) template.HTML {
624
567
return template .HTML (raw )
625
568
}
626
569
627
- // SafeJS renders raw as JS
628
- func SafeJS (raw string ) template.JS {
629
- return template .JS (raw )
630
- }
631
-
632
570
// Str2html render Markdown text to HTML
633
571
func Str2html (raw string ) template.HTML {
634
572
return template .HTML (markup .Sanitize (raw ))
@@ -925,14 +863,6 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
925
863
return push
926
864
}
927
865
928
- // DiffTypeToStr returns diff type name
929
- func DiffTypeToStr (diffType int ) string {
930
- diffTypes := map [int ]string {
931
- 1 : "add" , 2 : "modify" , 3 : "del" , 4 : "rename" , 5 : "copy" ,
932
- }
933
- return diffTypes [diffType ]
934
- }
935
-
936
866
// DiffLineTypeToStr returns diff line type name
937
867
func DiffLineTypeToStr (diffType int ) string {
938
868
switch diffType {
0 commit comments