app/vmalert: load static js and css from proper paths if -http.pathPrefix command-line flag is set

This is a follow-up for b104f67beb
This commit is contained in:
Aliaksandr Valialkin 2022-06-27 13:12:16 +03:00
parent 926fccbb8d
commit 4b41a05ca7
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
4 changed files with 89 additions and 45 deletions

View file

@ -1,7 +1,12 @@
{% import (
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver"
) %}
{% func Footer() %}
{% code pathPrefix := httpserver.GetPathPrefix() %}
</main>
<script src="/static/js/jquery-3.6.0.min.js" type="text/javascript"></script>
<script src="/static/js/bootstrap.bundle.min.js" type="text/javascript"></script>
<script src="{%s pathPrefix %}/static/js/jquery-3.6.0.min.js" type="text/javascript"></script>
<script src="{%s pathPrefix %}/static/js/bootstrap.bundle.min.js" type="text/javascript"></script>
<script type="text/javascript">
function expandAll() {
$('.collapse').addClass('show');

View file

@ -5,25 +5,44 @@
package tpl
//line app/vmalert/tpl/footer.qtpl:1
import (
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver"
)
//line app/vmalert/tpl/footer.qtpl:5
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line app/vmalert/tpl/footer.qtpl:1
//line app/vmalert/tpl/footer.qtpl:5
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line app/vmalert/tpl/footer.qtpl:1
//line app/vmalert/tpl/footer.qtpl:5
func StreamFooter(qw422016 *qt422016.Writer) {
//line app/vmalert/tpl/footer.qtpl:1
//line app/vmalert/tpl/footer.qtpl:5
qw422016.N().S(`
`)
//line app/vmalert/tpl/footer.qtpl:6
pathPrefix := httpserver.GetPathPrefix()
//line app/vmalert/tpl/footer.qtpl:6
qw422016.N().S(`
</main>
<script src="/static/js/jquery-3.6.0.min.js" type="text/javascript"></script>
<script src="/static/js/bootstrap.bundle.min.js" type="text/javascript"></script>
<script src="`)
//line app/vmalert/tpl/footer.qtpl:8
qw422016.E().S(pathPrefix)
//line app/vmalert/tpl/footer.qtpl:8
qw422016.N().S(`/static/js/jquery-3.6.0.min.js" type="text/javascript"></script>
<script src="`)
//line app/vmalert/tpl/footer.qtpl:9
qw422016.E().S(pathPrefix)
//line app/vmalert/tpl/footer.qtpl:9
qw422016.N().S(`/static/js/bootstrap.bundle.min.js" type="text/javascript"></script>
<script type="text/javascript">
function expandAll() {
$('.collapse').addClass('show');
@ -56,31 +75,31 @@ func StreamFooter(qw422016 *qt422016.Writer) {
</body>
</html>
`)
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
}
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
func WriteFooter(qq422016 qtio422016.Writer) {
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
StreamFooter(qw422016)
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
qt422016.ReleaseWriter(qw422016)
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
}
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
func Footer() string {
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
qb422016 := qt422016.AcquireByteBuffer()
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
WriteFooter(qb422016)
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
qs422016 := string(qb422016.B)
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
qt422016.ReleaseByteBuffer(qb422016)
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
return qs422016
//line app/vmalert/tpl/footer.qtpl:36
//line app/vmalert/tpl/footer.qtpl:41
}

View file

@ -1,9 +1,14 @@
{% import (
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver"
) %}
{% func Header(title string, pages []NavItem) %}
{% code pathPrefix := httpserver.GetPathPrefix() %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>vmalert{% if title != "" %} - {%s title %}{% endif %}</title>
<link href="/static/css/bootstrap.min.css" rel="stylesheet" />
<link href="{%s pathPrefix %}/static/css/bootstrap.min.css" rel="stylesheet" />
<style>
body{
min-height: 75rem;

View file

@ -5,37 +5,52 @@
package tpl
//line app/vmalert/tpl/header.qtpl:1
import (
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver"
)
//line app/vmalert/tpl/header.qtpl:5
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line app/vmalert/tpl/header.qtpl:1
//line app/vmalert/tpl/header.qtpl:5
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line app/vmalert/tpl/header.qtpl:1
//line app/vmalert/tpl/header.qtpl:5
func StreamHeader(qw422016 *qt422016.Writer, title string, pages []NavItem) {
//line app/vmalert/tpl/header.qtpl:1
//line app/vmalert/tpl/header.qtpl:5
qw422016.N().S(`
`)
//line app/vmalert/tpl/header.qtpl:6
pathPrefix := httpserver.GetPathPrefix()
//line app/vmalert/tpl/header.qtpl:6
qw422016.N().S(`
<!DOCTYPE html>
<html lang="en">
<head>
<title>vmalert`)
//line app/vmalert/tpl/header.qtpl:5
//line app/vmalert/tpl/header.qtpl:10
if title != "" {
//line app/vmalert/tpl/header.qtpl:5
//line app/vmalert/tpl/header.qtpl:10
qw422016.N().S(` - `)
//line app/vmalert/tpl/header.qtpl:5
//line app/vmalert/tpl/header.qtpl:10
qw422016.E().S(title)
//line app/vmalert/tpl/header.qtpl:5
//line app/vmalert/tpl/header.qtpl:10
}
//line app/vmalert/tpl/header.qtpl:5
//line app/vmalert/tpl/header.qtpl:10
qw422016.N().S(`</title>
<link href="/static/css/bootstrap.min.css" rel="stylesheet" />
<link href="`)
//line app/vmalert/tpl/header.qtpl:11
qw422016.E().S(pathPrefix)
//line app/vmalert/tpl/header.qtpl:11
qw422016.N().S(`/static/css/bootstrap.min.css" rel="stylesheet" />
<style>
body{
min-height: 75rem;
@ -85,37 +100,37 @@ func StreamHeader(qw422016 *qt422016.Writer, title string, pages []NavItem) {
</head>
<body>
`)
//line app/vmalert/tpl/header.qtpl:55
//line app/vmalert/tpl/header.qtpl:60
StreamPrintNavItems(qw422016, title, pages)
//line app/vmalert/tpl/header.qtpl:55
//line app/vmalert/tpl/header.qtpl:60
qw422016.N().S(`
<main class="px-2">
`)
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
}
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
func WriteHeader(qq422016 qtio422016.Writer, title string, pages []NavItem) {
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
StreamHeader(qw422016, title, pages)
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
qt422016.ReleaseWriter(qw422016)
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
}
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
func Header(title string, pages []NavItem) string {
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
qb422016 := qt422016.AcquireByteBuffer()
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
WriteHeader(qb422016, title, pages)
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
qs422016 := string(qb422016.B)
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
qt422016.ReleaseByteBuffer(qb422016)
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
return qs422016
//line app/vmalert/tpl/header.qtpl:57
//line app/vmalert/tpl/header.qtpl:62
}