@@ -43,6 +43,9 @@ import (
43
43
// Used from static.go && dynamic.go
44
44
var mailSubjectSplit = regexp .MustCompile (`(?m)^-{3,}[\s]*$` )
45
45
46
+ // Generate manfest.json data uri once
47
+ var manifestData = makeManifestData ()
48
+
46
49
// NewFuncMap returns functions for injecting to templates
47
50
func NewFuncMap () []template.FuncMap {
48
51
return []template.FuncMap {map [string ]interface {}{
@@ -88,6 +91,9 @@ func NewFuncMap() []template.FuncMap {
88
91
"AllowedReactions" : func () []string {
89
92
return setting .UI .Reactions
90
93
},
94
+ "ManifestData" : func () template.URL {
95
+ return manifestData
96
+ },
91
97
"Safe" : Safe ,
92
98
"SafeJS" : SafeJS ,
93
99
"Str2html" : Str2html ,
@@ -144,7 +150,6 @@ func NewFuncMap() []template.FuncMap {
144
150
"MD5" : base .EncodeMD5 ,
145
151
"ActionContent2Commits" : ActionContent2Commits ,
146
152
"PathEscape" : url .PathEscape ,
147
- "QueryEscape" : url .QueryEscape ,
148
153
"EscapePound" : func (str string ) string {
149
154
return strings .NewReplacer ("%" , "%25" , "#" , "%23" , " " , "%20" , "?" , "%3F" ).Replace (str )
150
155
},
@@ -921,3 +926,11 @@ func buildSubjectBodyTemplate(stpl *texttmpl.Template, btpl *template.Template,
921
926
log .Warn ("Failed to parse template [%s/body]: %v" , name , err )
922
927
}
923
928
}
929
+
930
+ func makeManifestData () template.URL {
931
+ name := url .QueryEscape (setting .AppName )
932
+ prefix := url .QueryEscape (setting .StaticURLPrefix )
933
+ subUrl := url .QueryEscape (setting .AppSubURL ) + "/"
934
+
935
+ return template .URL (`data:application/json,{"short_name":"` + name + `","name":"` + name + `","icons":[{"src":"` + prefix + `/img/logo-lg.png","type":"image/png","sizes":"880x880"},{"src":"` + prefix + `/img/logo-sm.png","type":"image/png","sizes":"120x120"},{"src":"` + prefix + `/img/logo-512.png","type":"image/png","sizes":"512x512"},{"src":"` + prefix + `/img/logo-192.png","type":"image/png","sizes":"192x192"}],"start_url":"` + subUrl + `","scope":"` + subUrl + `","background_color":"%23FAFAFA","display":"standalone"}` )
936
+ }
0 commit comments