mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
bugfix: fix vmalert navbar url. (#2949)
the doc url should not be joined by `prefix` because it's an abs url.
This commit is contained in:
parent
2635211bf4
commit
9f5fc040a7
2 changed files with 83 additions and 62 deletions
|
@ -2,6 +2,7 @@
|
||||||
"strings"
|
"strings"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/utils"
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/utils"
|
||||||
) %}
|
) %}
|
||||||
|
@ -86,7 +87,11 @@ type NavItem struct {
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-md-0">
|
<ul class="navbar-nav me-auto mb-2 mb-md-0">
|
||||||
{% for _, item := range items %}
|
{% for _, item := range items %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link{% if current == item.Name %} active{% endif %}" href="{%s path.Join(prefix,item.Url) %}">
|
{% code
|
||||||
|
u, _ := url.Parse(item.Url)
|
||||||
|
%}
|
||||||
|
<a class="nav-link{% if current == item.Name %} active{% endif %}"
|
||||||
|
href="{% if u.IsAbs() %}{%s item.Url %}{% else %}{%s path.Join(prefix,item.Url) %}{% endif %}">
|
||||||
{%s item.Name %}
|
{%s item.Name %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -94,4 +99,4 @@ type NavItem struct {
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
{% endfunc %}
|
{% endfunc %}
|
||||||
|
|
|
@ -7,53 +7,54 @@ package tpl
|
||||||
//line app/vmalert/tpl/header.qtpl:1
|
//line app/vmalert/tpl/header.qtpl:1
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/utils"
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:9
|
//line app/vmalert/tpl/header.qtpl:10
|
||||||
import (
|
import (
|
||||||
qtio422016 "io"
|
qtio422016 "io"
|
||||||
|
|
||||||
qt422016 "github.com/valyala/quicktemplate"
|
qt422016 "github.com/valyala/quicktemplate"
|
||||||
)
|
)
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:9
|
//line app/vmalert/tpl/header.qtpl:10
|
||||||
var (
|
var (
|
||||||
_ = qtio422016.Copy
|
_ = qtio422016.Copy
|
||||||
_ = qt422016.AcquireByteBuffer
|
_ = qt422016.AcquireByteBuffer
|
||||||
)
|
)
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:9
|
//line app/vmalert/tpl/header.qtpl:10
|
||||||
func StreamHeader(qw422016 *qt422016.Writer, r *http.Request, navItems []NavItem, title string) {
|
func StreamHeader(qw422016 *qt422016.Writer, r *http.Request, navItems []NavItem, title string) {
|
||||||
//line app/vmalert/tpl/header.qtpl:9
|
//line app/vmalert/tpl/header.qtpl:10
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line app/vmalert/tpl/header.qtpl:10
|
//line app/vmalert/tpl/header.qtpl:11
|
||||||
prefix := utils.Prefix(r.URL.Path)
|
prefix := utils.Prefix(r.URL.Path)
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:10
|
//line app/vmalert/tpl/header.qtpl:11
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>vmalert`)
|
<title>vmalert`)
|
||||||
//line app/vmalert/tpl/header.qtpl:14
|
//line app/vmalert/tpl/header.qtpl:15
|
||||||
if title != "" {
|
if title != "" {
|
||||||
//line app/vmalert/tpl/header.qtpl:14
|
//line app/vmalert/tpl/header.qtpl:15
|
||||||
qw422016.N().S(` - `)
|
qw422016.N().S(` - `)
|
||||||
//line app/vmalert/tpl/header.qtpl:14
|
//line app/vmalert/tpl/header.qtpl:15
|
||||||
qw422016.E().S(title)
|
qw422016.E().S(title)
|
||||||
//line app/vmalert/tpl/header.qtpl:14
|
//line app/vmalert/tpl/header.qtpl:15
|
||||||
}
|
}
|
||||||
//line app/vmalert/tpl/header.qtpl:14
|
//line app/vmalert/tpl/header.qtpl:15
|
||||||
qw422016.N().S(`</title>
|
qw422016.N().S(`</title>
|
||||||
<link href="`)
|
<link href="`)
|
||||||
//line app/vmalert/tpl/header.qtpl:15
|
//line app/vmalert/tpl/header.qtpl:16
|
||||||
qw422016.E().S(prefix)
|
qw422016.E().S(prefix)
|
||||||
//line app/vmalert/tpl/header.qtpl:15
|
//line app/vmalert/tpl/header.qtpl:16
|
||||||
qw422016.N().S(`static/css/bootstrap.min.css" rel="stylesheet" />
|
qw422016.N().S(`static/css/bootstrap.min.css" rel="stylesheet" />
|
||||||
<style>
|
<style>
|
||||||
body{
|
body{
|
||||||
|
@ -104,124 +105,139 @@ func StreamHeader(qw422016 *qt422016.Writer, r *http.Request, navItems []NavItem
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
`)
|
`)
|
||||||
//line app/vmalert/tpl/header.qtpl:64
|
//line app/vmalert/tpl/header.qtpl:65
|
||||||
streamprintNavItems(qw422016, r, title, navItems)
|
streamprintNavItems(qw422016, r, title, navItems)
|
||||||
//line app/vmalert/tpl/header.qtpl:64
|
//line app/vmalert/tpl/header.qtpl:65
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<main class="px-2">
|
<main class="px-2">
|
||||||
`)
|
`)
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
}
|
}
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
func WriteHeader(qq422016 qtio422016.Writer, r *http.Request, navItems []NavItem, title string) {
|
func WriteHeader(qq422016 qtio422016.Writer, r *http.Request, navItems []NavItem, title string) {
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
StreamHeader(qw422016, r, navItems, title)
|
StreamHeader(qw422016, r, navItems, title)
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
}
|
}
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
func Header(r *http.Request, navItems []NavItem, title string) string {
|
func Header(r *http.Request, navItems []NavItem, title string) string {
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
WriteHeader(qb422016, r, navItems, title)
|
WriteHeader(qb422016, r, navItems, title)
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
return qs422016
|
return qs422016
|
||||||
//line app/vmalert/tpl/header.qtpl:66
|
//line app/vmalert/tpl/header.qtpl:67
|
||||||
}
|
}
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:70
|
//line app/vmalert/tpl/header.qtpl:71
|
||||||
type NavItem struct {
|
type NavItem struct {
|
||||||
Name string
|
Name string
|
||||||
Url string
|
Url string
|
||||||
}
|
}
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:76
|
//line app/vmalert/tpl/header.qtpl:77
|
||||||
func streamprintNavItems(qw422016 *qt422016.Writer, r *http.Request, current string, items []NavItem) {
|
func streamprintNavItems(qw422016 *qt422016.Writer, r *http.Request, current string, items []NavItem) {
|
||||||
//line app/vmalert/tpl/header.qtpl:76
|
//line app/vmalert/tpl/header.qtpl:77
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line app/vmalert/tpl/header.qtpl:78
|
//line app/vmalert/tpl/header.qtpl:79
|
||||||
prefix := "/vmalert/"
|
prefix := "/vmalert/"
|
||||||
if strings.HasPrefix(r.URL.Path, prefix) {
|
if strings.HasPrefix(r.URL.Path, prefix) {
|
||||||
prefix = ""
|
prefix = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:82
|
//line app/vmalert/tpl/header.qtpl:83
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
|
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="collapse navbar-collapse" id="navbarCollapse">
|
<div class="collapse navbar-collapse" id="navbarCollapse">
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-md-0">
|
<ul class="navbar-nav me-auto mb-2 mb-md-0">
|
||||||
`)
|
`)
|
||||||
//line app/vmalert/tpl/header.qtpl:87
|
//line app/vmalert/tpl/header.qtpl:88
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
//line app/vmalert/tpl/header.qtpl:87
|
//line app/vmalert/tpl/header.qtpl:88
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
|
`)
|
||||||
|
//line app/vmalert/tpl/header.qtpl:91
|
||||||
|
u, _ := url.Parse(item.Url)
|
||||||
|
|
||||||
|
//line app/vmalert/tpl/header.qtpl:92
|
||||||
|
qw422016.N().S(`
|
||||||
<a class="nav-link`)
|
<a class="nav-link`)
|
||||||
//line app/vmalert/tpl/header.qtpl:89
|
//line app/vmalert/tpl/header.qtpl:93
|
||||||
if current == item.Name {
|
if current == item.Name {
|
||||||
//line app/vmalert/tpl/header.qtpl:89
|
//line app/vmalert/tpl/header.qtpl:93
|
||||||
qw422016.N().S(` active`)
|
qw422016.N().S(` active`)
|
||||||
//line app/vmalert/tpl/header.qtpl:89
|
//line app/vmalert/tpl/header.qtpl:93
|
||||||
}
|
}
|
||||||
//line app/vmalert/tpl/header.qtpl:89
|
//line app/vmalert/tpl/header.qtpl:93
|
||||||
qw422016.N().S(`" href="`)
|
qw422016.N().S(`"
|
||||||
//line app/vmalert/tpl/header.qtpl:89
|
href="`)
|
||||||
qw422016.E().S(path.Join(prefix, item.Url))
|
//line app/vmalert/tpl/header.qtpl:94
|
||||||
//line app/vmalert/tpl/header.qtpl:89
|
if u.IsAbs() {
|
||||||
|
//line app/vmalert/tpl/header.qtpl:94
|
||||||
|
qw422016.E().S(item.Url)
|
||||||
|
//line app/vmalert/tpl/header.qtpl:94
|
||||||
|
} else {
|
||||||
|
//line app/vmalert/tpl/header.qtpl:94
|
||||||
|
qw422016.E().S(path.Join(prefix, item.Url))
|
||||||
|
//line app/vmalert/tpl/header.qtpl:94
|
||||||
|
}
|
||||||
|
//line app/vmalert/tpl/header.qtpl:94
|
||||||
qw422016.N().S(`">
|
qw422016.N().S(`">
|
||||||
`)
|
`)
|
||||||
//line app/vmalert/tpl/header.qtpl:90
|
//line app/vmalert/tpl/header.qtpl:95
|
||||||
qw422016.E().S(item.Name)
|
qw422016.E().S(item.Name)
|
||||||
//line app/vmalert/tpl/header.qtpl:90
|
//line app/vmalert/tpl/header.qtpl:95
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
`)
|
`)
|
||||||
//line app/vmalert/tpl/header.qtpl:93
|
//line app/vmalert/tpl/header.qtpl:98
|
||||||
}
|
}
|
||||||
//line app/vmalert/tpl/header.qtpl:93
|
//line app/vmalert/tpl/header.qtpl:98
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
`)
|
`)
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
}
|
}
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
func writeprintNavItems(qq422016 qtio422016.Writer, r *http.Request, current string, items []NavItem) {
|
func writeprintNavItems(qq422016 qtio422016.Writer, r *http.Request, current string, items []NavItem) {
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
streamprintNavItems(qw422016, r, current, items)
|
streamprintNavItems(qw422016, r, current, items)
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
}
|
}
|
||||||
|
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
func printNavItems(r *http.Request, current string, items []NavItem) string {
|
func printNavItems(r *http.Request, current string, items []NavItem) string {
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
writeprintNavItems(qb422016, r, current, items)
|
writeprintNavItems(qb422016, r, current, items)
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
return qs422016
|
return qs422016
|
||||||
//line app/vmalert/tpl/header.qtpl:97
|
//line app/vmalert/tpl/header.qtpl:102
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue