Skip to content

Commit ff7118b

Browse files
committed
clean
1 parent 6b0df6d commit ff7118b

File tree

6 files changed

+11
-77
lines changed

6 files changed

+11
-77
lines changed

modules/templates/helper.go

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"path/filepath"
1919
"reflect"
2020
"regexp"
21-
"runtime"
2221
"strings"
2322
texttmpl "text/template"
2423
"time"
@@ -56,12 +55,6 @@ var mailSubjectSplit = regexp.MustCompile(`(?m)^-{3,}[\s]*$`)
5655
// NewFuncMap returns functions for injecting to templates
5756
func NewFuncMap() []template.FuncMap {
5857
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-
},
6558
"AppName": func() string {
6659
return setting.AppName
6760
},
@@ -81,10 +74,7 @@ func NewFuncMap() []template.FuncMap {
8174
"AppVer": func() string {
8275
return setting.AppVer
8376
},
84-
"AppBuiltWith": func() string {
85-
return setting.AppBuiltWith
86-
},
87-
"AppDomain": func() string {
77+
"AppDomain": func() string { // documented in mail-templates.md
8878
return setting.Domain
8979
},
9080
"AssetVersion": func() string {
@@ -108,11 +98,7 @@ func NewFuncMap() []template.FuncMap {
10898
"CustomEmojis": func() map[string]string {
10999
return setting.UI.CustomEmojisMap
110100
},
111-
"IsShowFullName": func() bool {
112-
return setting.UI.DefaultShowFullName
113-
},
114101
"Safe": Safe,
115-
"SafeJS": SafeJS,
116102
"JSEscape": JSEscape,
117103
"Str2html": Str2html,
118104
"TimeSince": timeutil.TimeSince,
@@ -140,33 +126,15 @@ func NewFuncMap() []template.FuncMap {
140126
"DateFmtLong": func(t time.Time) string {
141127
return t.Format(time.RFC1123Z)
142128
},
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,
160130
"EllipsisString": base.EllipsisString,
161-
"DiffTypeToStr": DiffTypeToStr,
162131
"DiffLineTypeToStr": DiffLineTypeToStr,
163132
"ShortSha": base.ShortSha,
164133
"ActionContent2Commits": ActionContent2Commits,
165134
"PathEscape": url.PathEscape,
166135
"PathEscapeSegments": util.PathEscapeSegments,
167136
"URLJoin": util.URLJoin,
168137
"RenderCommitMessage": RenderCommitMessage,
169-
"RenderCommitMessageLink": RenderCommitMessageLink,
170138
"RenderCommitMessageLinkSubject": RenderCommitMessageLinkSubject,
171139
"RenderCommitBody": RenderCommitBody,
172140
"RenderCodeBlock": RenderCodeBlock,
@@ -429,19 +397,13 @@ func NewFuncMap() []template.FuncMap {
429397
curBranch,
430398
)
431399
},
432-
"RefShortName": func(ref string) string {
433-
return git.RefName(ref).ShortName()
434-
},
435400
}}
436401
}
437402

438403
// NewTextFuncMap returns functions for injecting to text templates
439404
// It's a subset of those used for HTML and other templates
440405
func NewTextFuncMap() []texttmpl.FuncMap {
441406
return []texttmpl.FuncMap{map[string]interface{}{
442-
"GoVer": func() string {
443-
return util.ToTitleCase(runtime.Version())
444-
},
445407
"AppName": func() string {
446408
return setting.AppName
447409
},
@@ -454,33 +416,14 @@ func NewTextFuncMap() []texttmpl.FuncMap {
454416
"AppVer": func() string {
455417
return setting.AppVer
456418
},
457-
"AppBuiltWith": func() string {
458-
return setting.AppBuiltWith
459-
},
460-
"AppDomain": func() string {
419+
"AppDomain": func() string { // documented in mail-templates.md
461420
return setting.Domain
462421
},
463422
"TimeSince": timeutil.TimeSince,
464423
"TimeSinceUnix": timeutil.TimeSinceUnix,
465424
"DateFmtLong": func(t time.Time) string {
466425
return t.Format(time.RFC1123Z)
467426
},
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-
},
484427
"EllipsisString": base.EllipsisString,
485428
"URLJoin": util.URLJoin,
486429
"Dict": func(values ...interface{}) (map[string]interface{}, error) {
@@ -624,11 +567,6 @@ func Safe(raw string) template.HTML {
624567
return template.HTML(raw)
625568
}
626569

627-
// SafeJS renders raw as JS
628-
func SafeJS(raw string) template.JS {
629-
return template.JS(raw)
630-
}
631-
632570
// Str2html render Markdown text to HTML
633571
func Str2html(raw string) template.HTML {
634572
return template.HTML(markup.Sanitize(raw))
@@ -925,14 +863,6 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
925863
return push
926864
}
927865

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-
936866
// DiffLineTypeToStr returns diff line type name
937867
func DiffLineTypeToStr(diffType int) string {
938868
switch diffType {

routers/web/admin/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func Config(ctx *context.Context) {
115115

116116
ctx.Data["CustomConf"] = setting.CustomConf
117117
ctx.Data["AppUrl"] = setting.AppURL
118+
ctx.Data["AppBuiltWith"] = setting.AppBuiltWith
118119
ctx.Data["Domain"] = setting.Domain
119120
ctx.Data["OfflineMode"] = setting.OfflineMode
120121
ctx.Data["DisableRouterLog"] = setting.Log.DisableRouterLog

templates/admin/config.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<dt>{{.locale.Tr "admin.config.app_name"}}</dt>
1212
<dd>{{AppName}}</dd>
1313
<dt>{{.locale.Tr "admin.config.app_ver"}}</dt>
14-
<dd>{{AppVer}}{{AppBuiltWith}}</dd>
14+
<dd>{{AppVer}}{{.AppBuiltWith}}</dd>
1515
<dt>{{.locale.Tr "admin.config.custom_conf"}}</dt>
1616
<dd>{{.CustomConf}}</dd>
1717
<dt>{{.locale.Tr "admin.config.app_url"}}</dt>

templates/repo/clone_buttons.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- there is always at least one button (by context/repo.go) -->
22
{{if $.CloneButtonShowHTTPS}}
33
<button class="ui basic small compact clone button gt-no-transition" id="repo-clone-https" data-link="{{$.CloneButtonOriginLink.HTTPS}}">
4-
{{if UseHTTPS}}HTTPS{{else}}HTTP{{end}}
4+
HTTPS
55
</button>
66
{{end}}
77
{{if $.CloneButtonShowSSH}}

templates/repo/clone_script.tmpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
const value = localStorage.getItem('repo-clone-protocol') || 'https';
1212
const isSSH = value === 'ssh' && sshBtn || value !== 'ssh' && !httpsBtn;
1313

14-
if (httpsBtn) httpsBtn.classList[!isSSH ? 'add' : 'remove']('primary');
14+
if (httpsBtn) {
15+
httpsBtn.textContent = window.origin.split(':')[0].toUpperCase();
16+
httpsBtn.classList[!isSSH ? 'add' : 'remove']('primary');
17+
}
1518
if (sshBtn) sshBtn.classList[isSSH ? 'add' : 'remove']('primary');
1619

1720
const btn = isSSH ? sshBtn : httpsBtn;

templates/repo/search_name.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<span class="gt-ellipsis">{{.Name}}{{if IsShowFullName}}<span class="search-fullname"> {{.FullName}}</span>{{end}}</span>
1+
<span class="gt-ellipsis">{{.Name}}{{if DefaultShowFullName}}<span class="search-fullname"> {{.FullName}}</span>{{end}}</span>

0 commit comments

Comments
 (0)