diff options
Diffstat (limited to 'weed/server')
| -rw-r--r-- | weed/server/master_ui/master.html | 8 | ||||
| -rw-r--r-- | weed/server/master_ui/templates.go | 15 |
2 files changed, 18 insertions, 5 deletions
diff --git a/weed/server/master_ui/master.html b/weed/server/master_ui/master.html index 2e37c3a62..40d49991b 100644 --- a/weed/server/master_ui/master.html +++ b/weed/server/master_ui/master.html @@ -33,14 +33,14 @@ {{ with .RaftServer }} <tr> <th>Leader</th> - <td><a href="http://{{ .Leader }}">{{ .Leader }}</a></td> + <td><a href="{{ url .Leader }}">{{ .Leader }}</a></td> </tr> <tr> <th>Other Masters</th> <td class="col-sm-5"> <ul class="list-unstyled"> {{ range $k, $p := .Peers }} - <li><a href="http://{{ $p.Name }}/ui/index.html">{{ $p.Name }}</a></li> + <li><a href="{{ url $p.Name }}/ui/index.html">{{ $p.Name }}</a></li> {{ end }} </ul> </td> @@ -88,9 +88,9 @@ <tr> <td><code>{{ $dc.Id }}</code></td> <td>{{ $rack.Id }}</td> - <td><a href="http://{{ $dn.Url }}/ui/index.html">{{ $dn.Url }}</a> + <td><a href="{{ url $dn.Url }}/ui/index.html">{{ $dn.Url }}</a> {{ if ne $dn.PublicUrl $dn.Url }} - / <a href="http://{{ $dn.PublicUrl }}/ui/index.html">{{ $dn.PublicUrl }}</a> + / <a href="{{ url $dn.PublicUrl }}/ui/index.html">{{ $dn.PublicUrl }}</a> {{ end }} </td> <td>{{ $dn.Volumes }}</td> diff --git a/weed/server/master_ui/templates.go b/weed/server/master_ui/templates.go index a6dcc57d7..d32c5efdf 100644 --- a/weed/server/master_ui/templates.go +++ b/weed/server/master_ui/templates.go @@ -3,6 +3,7 @@ package master_ui import ( _ "embed" "html/template" + "strings" ) //go:embed master.html @@ -11,5 +12,17 @@ var masterHtml string //go:embed masterNewRaft.html var masterNewRaftHtml string -var StatusTpl = template.Must(template.New("status").Parse(masterHtml)) +var templateFunctions = template.FuncMap{ + "url": func(input string) string { + + if !strings.HasPrefix(input, "http://") && !strings.HasPrefix(input, "https://") { + return "http://" + input + } + + return input + }, +} + +var StatusTpl = template.Must(template.New("status").Funcs(templateFunctions).Parse(masterHtml)) + var StatusNewRaftTpl = template.Must(template.New("status").Parse(masterNewRaftHtml)) |
