mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-23 01:20:11 +00:00
respect URL Base in http preloads and inline html links
This commit is contained in:
parent
95a6b48c3e
commit
b037b08152
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="{{ .cssClass }}">
|
<html lang="en" class="{{ .cssClass }}">
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" type="text/css" href="css/bundle.css">
|
<link rel="stylesheet" type="text/css" href="{{ .urlBase }}/css/bundle.css">
|
||||||
<script>
|
<script>
|
||||||
window.URLBase = "{{ .urlBase }}";
|
window.URLBase = "{{ .urlBase }}";
|
||||||
window.notificationsEnabled = {{ .notifications }};
|
window.notificationsEnabled = {{ .notifications }};
|
||||||
@ -40,7 +40,7 @@
|
|||||||
<div id="modal-about" class="modal">
|
<div id="modal-about" class="modal">
|
||||||
<div class="modal-content content card">
|
<div class="modal-content content card">
|
||||||
<span class="heading">{{ .strings.aboutProgram }} <span class="modal-close">×</span></span>
|
<span class="heading">{{ .strings.aboutProgram }} <span class="modal-close">×</span></span>
|
||||||
<img src="/banner.svg" class="mt-1" alt="jfa-go banner">
|
<img src="{{ .urlBase }}/banner.svg" class="mt-1" alt="jfa-go banner">
|
||||||
<p><i class="icon ri-github-fill"></i><a href="https://github.com/hrfee/jfa-go">jfa-go</a></p>
|
<p><i class="icon ri-github-fill"></i><a href="https://github.com/hrfee/jfa-go">jfa-go</a></p>
|
||||||
<p>{{ .strings.version }} <span class="code monospace">{{ .version }}</span></p>
|
<p>{{ .strings.version }} <span class="code monospace">{{ .version }}</span></p>
|
||||||
<p>{{ .strings.commitNoun }} <span class="code monospace">{{ .commit }}</span></p>
|
<p>{{ .strings.commitNoun }} <span class="code monospace">{{ .commit }}</span></p>
|
||||||
|
2
main.go
2
main.go
@ -567,6 +567,8 @@ func start(asDaemon, firstCall bool) {
|
|||||||
app.info.Fatalf("Failed to load language files: %+v\n", err)
|
app.info.Fatalf("Failed to load language files: %+v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cssHeader = app.loadCSSHeader()
|
||||||
|
|
||||||
app.info.Println("Loading routes")
|
app.info.Println("Loading routes")
|
||||||
if debugMode {
|
if debugMode {
|
||||||
gin.SetMode(gin.DebugMode)
|
gin.SetMode(gin.DebugMode)
|
||||||
|
8
views.go
8
views.go
@ -11,17 +11,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var css = []string{"bundle.css", "remixicon.css"}
|
var css = []string{"bundle.css", "remixicon.css"}
|
||||||
var cssHeader = func() string {
|
var cssHeader string
|
||||||
|
|
||||||
|
func (app *appContext) loadCSSHeader() string {
|
||||||
l := len(css)
|
l := len(css)
|
||||||
h := ""
|
h := ""
|
||||||
for i, f := range css {
|
for i, f := range css {
|
||||||
h += "</css/" + f + ">; rel=preload; as=style"
|
h += "<" + app.URLBase + "/css/" + f + ">; rel=preload; as=style"
|
||||||
if l > 1 && i != (l-1) {
|
if l > 1 && i != (l-1) {
|
||||||
h += ", "
|
h += ", "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return h
|
return h
|
||||||
}()
|
}
|
||||||
|
|
||||||
func gcHTML(gc *gin.Context, code int, file string, templ gin.H) {
|
func gcHTML(gc *gin.Context, code int, file string, templ gin.H) {
|
||||||
gc.Header("Cache-Control", "no-cache")
|
gc.Header("Cache-Control", "no-cache")
|
||||||
|
Loading…
Reference in New Issue
Block a user