Add maintenance page
This commit is contained in:
@@ -6,6 +6,7 @@ type PixelWebConfig struct {
|
||||
StaticResourceDir string `toml:"static_resource_dir"`
|
||||
TemplateDir string `toml:"template_dir"`
|
||||
DebugMode bool `toml:"debug_mode"`
|
||||
MaintenanceMode bool `toml:"maintenance_mode"`
|
||||
}
|
||||
|
||||
const DefaultConfig = `# Pixeldrain Web UI server configuration
|
||||
@@ -14,4 +15,6 @@ api_url_external = "https://sia.pixeldrain.com/api" # Used in the web browser, s
|
||||
api_url_internal = "http://127.0.0.1:8080/api" # Used for internal API requests to the pixeldrain server, not visible to users
|
||||
static_resource_dir = "res/static"
|
||||
template_dir = "res/template"
|
||||
debug_mode = false`
|
||||
debug_mode = false
|
||||
maintenance_mode = false
|
||||
`
|
||||
|
33
res/template/maintenance.html
Normal file
33
res/template/maintenance.html
Normal file
@@ -0,0 +1,33 @@
|
||||
{{define "maintenance"}}<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
{{template "meta_tags" "Maintenance"}}
|
||||
{{template "user_style" .}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<img id="header_image" class="header_image" src="/res/img/header_neuropol.png" alt="Header image"/>
|
||||
<br/>
|
||||
<div id='body' class="body">
|
||||
<div id="header" class="highlight_light border_top border_bottom" style="font-size: 2em; line-height: 1.2em;">
|
||||
Pixeldrain is under maintenanace
|
||||
</div>
|
||||
<p>
|
||||
This means the website has temporarily been taken down to apply
|
||||
changes which cannot be applied in the background (probably a
|
||||
database upgrade).
|
||||
</p>
|
||||
<p>
|
||||
The website should be back online shortly. You can check out
|
||||
my <a href="https://twitter.com/Fornax96">Twitter</a> to get a
|
||||
feeling for when the website will be back up.
|
||||
</p>
|
||||
<p>
|
||||
I'm sorry for the inconvenience.
|
||||
</p>
|
||||
{{template "footer"}}
|
||||
</div>
|
||||
{{template "analytics"}}
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
@@ -48,10 +48,20 @@ func New(r *httprouter.Router, prefix string, conf *conf.PixelWebConfig) *WebCon
|
||||
fs.ServeHTTP(w, r)
|
||||
})
|
||||
|
||||
// General navigation
|
||||
r.GET(p+"/" /* */, wc.serveTemplate("home", false))
|
||||
// Static assets
|
||||
r.GET(p+"/favicon.ico" /* */, wc.serveFile("/favicon.ico"))
|
||||
r.GET(p+"/robots.txt" /* */, wc.serveFile("/robots.txt"))
|
||||
|
||||
if conf.MaintenanceMode {
|
||||
r.NotFound = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
wc.templates.Get().ExecuteTemplate(w, "maintenance", wc.newTemplateData(w, r))
|
||||
})
|
||||
return wc
|
||||
}
|
||||
|
||||
// General navigation
|
||||
r.GET(p+"/" /* */, wc.serveTemplate("home", false))
|
||||
r.GET(p+"/api" /* */, wc.serveTemplate("apidoc", false))
|
||||
r.GET(p+"/history" /* */, wc.serveTemplate("history_cookies", false))
|
||||
r.GET(p+"/u/:id" /* */, wc.serveFileViewer)
|
||||
|
Reference in New Issue
Block a user