Add robots.txt, clean up index template
This commit is contained in:
parent
764475b2a5
commit
4dcf674c4b
@ -6,28 +6,29 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#f0f0f0" />
|
<meta name="theme-color" content="#f0f0f0">
|
||||||
|
|
||||||
<title>Dispatch</title>
|
<title>Dispatch</title>
|
||||||
|
<meta name="description" content="Web-based IRC client.">
|
||||||
|
|
||||||
<% if sw { %>
|
<% if sw { %>
|
||||||
<link rel="preload" href="/data" as="fetch" crossorigin="anonymous" />
|
<link rel="preload" href="/data" as="fetch" crossorigin>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
<%== inlineScript %>
|
<%== inlineScript %>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<link rel="preload" href="/font/fontello.woff2?48901973" as="font" type="font/woff2" crossorigin="anonymous" />
|
<link rel="preload" href="/font/fontello.woff2?48901973" as="font" type="font/woff2" crossorigin>
|
||||||
<link rel="preload" href="/font/RobotoMono-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
|
<link rel="preload" href="/font/RobotoMono-Regular.woff2" as="font" type="font/woff2" crossorigin>
|
||||||
<link rel="preload" href="/font/Montserrat-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
|
<link rel="preload" href="/font/Montserrat-Regular.woff2" as="font" type="font/woff2" crossorigin>
|
||||||
<link rel="preload" href="/font/Montserrat-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
|
<link rel="preload" href="/font/Montserrat-Bold.woff2" as="font" type="font/woff2" crossorigin>
|
||||||
<link rel="preload" href="/font/RobotoMono-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
|
<link rel="preload" href="/font/RobotoMono-Bold.woff2" as="font" type="font/woff2" crossorigin>
|
||||||
|
|
||||||
<% if cssPath != "" { %>
|
<% if cssPath != "" { %>
|
||||||
<link href="<%== cssPath %>" rel="stylesheet" />
|
<link href="<%== cssPath %>" rel="stylesheet">
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<link rel="manifest" href="/manifest.json">
|
<link rel="manifest" href="/manifest.json">
|
||||||
@ -43,6 +44,8 @@
|
|||||||
<% for _, script := range scripts { %>
|
<% for _, script := range scripts { %>
|
||||||
<script src="<%== script %>"></script>
|
<script src="<%== script %>"></script>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
<noscript>This page needs JavaScript enabled to function.</noscript>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -8,17 +8,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func IndexTemplate(w io.Writer, data *indexData, cssPath string, inlineScript string, scripts []string, sw bool) error {
|
func IndexTemplate(w io.Writer, data *indexData, cssPath string, inlineScript string, scripts []string, sw bool) error {
|
||||||
io.WriteString(w, "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /><meta name=\"theme-color\" content=\"#f0f0f0\" /><title>Dispatch</title>")
|
io.WriteString(w, "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"theme-color\" content=\"#f0f0f0\"><title>Dispatch</title><meta name=\"description\" content=\"Web-based IRC client.\">")
|
||||||
if sw {
|
if sw {
|
||||||
io.WriteString(w, "<link rel=\"preload\" href=\"/data\" as=\"fetch\" crossorigin=\"anonymous\" />")
|
io.WriteString(w, "<link rel=\"preload\" href=\"/data\" as=\"fetch\" crossorigin>")
|
||||||
}
|
}
|
||||||
io.WriteString(w, "<script>")
|
io.WriteString(w, "<script>")
|
||||||
io.WriteString(w, inlineScript )
|
io.WriteString(w, inlineScript )
|
||||||
io.WriteString(w, "</script><link rel=\"preload\" href=\"/font/fontello.woff2?48901973\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\" /><link rel=\"preload\" href=\"/font/RobotoMono-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\" /><link rel=\"preload\" href=\"/font/Montserrat-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\" /><link rel=\"preload\" href=\"/font/Montserrat-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\" /><link rel=\"preload\" href=\"/font/RobotoMono-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\" />")
|
io.WriteString(w, "</script><link rel=\"preload\" href=\"/font/fontello.woff2?48901973\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/RobotoMono-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/Montserrat-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/Montserrat-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/RobotoMono-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>")
|
||||||
if cssPath != "" {
|
if cssPath != "" {
|
||||||
io.WriteString(w, "<link href=\"")
|
io.WriteString(w, "<link href=\"")
|
||||||
io.WriteString(w, cssPath )
|
io.WriteString(w, cssPath )
|
||||||
io.WriteString(w, "\" rel=\"stylesheet\" />")
|
io.WriteString(w, "\" rel=\"stylesheet\">")
|
||||||
}
|
}
|
||||||
io.WriteString(w, "<link rel=\"manifest\" href=\"/manifest.json\"></head><body><div id=\"root\"></div>")
|
io.WriteString(w, "<link rel=\"manifest\" href=\"/manifest.json\"></head><body><div id=\"root\"></div>")
|
||||||
if data != nil {
|
if data != nil {
|
||||||
@ -31,6 +31,6 @@ io.WriteString(w, "<script src=\"")
|
|||||||
io.WriteString(w, script )
|
io.WriteString(w, script )
|
||||||
io.WriteString(w, "\"></script>")
|
io.WriteString(w, "\"></script>")
|
||||||
}
|
}
|
||||||
io.WriteString(w, "</body></html>")
|
io.WriteString(w, "<noscript>This page needs JavaScript enabled to function.</noscript></body></html>")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,8 @@ var (
|
|||||||
".json": "application/json",
|
".json": "application/json",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
robots = []byte("User-agent: *\nDisallow: /")
|
||||||
|
|
||||||
hstsHeader string
|
hstsHeader string
|
||||||
cspEnabled bool
|
cspEnabled bool
|
||||||
)
|
)
|
||||||
@ -232,6 +234,13 @@ func (d *Dispatch) serveFiles(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.URL.Path == "/robots.txt" {
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
w.Header().Set("Content-Length", strconv.Itoa(len(robots)))
|
||||||
|
w.Write(robots)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if strings.HasSuffix(r.URL.Path, file.Path) {
|
if strings.HasSuffix(r.URL.Path, file.Path) {
|
||||||
d.serveFile(w, r, file)
|
d.serveFile(w, r, file)
|
||||||
|
Loading…
Reference in New Issue
Block a user