Skip to content

Commit

Permalink
Complete switch to React-based UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-osman committed Dec 22, 2019
1 parent 2ddb98f commit 87b2d71
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 202 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/assets/vfsdata.go
/ui/vfsdata.go
/i5
/i5.exe
53 changes: 0 additions & 53 deletions assets/generate.go

This file was deleted.

75 changes: 0 additions & 75 deletions assets/templates/error.html

This file was deleted.

53 changes: 0 additions & 53 deletions assets/templates/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate go run assets/generate.go
//go:generate go run ui/generate.go

package main

Expand Down
6 changes: 3 additions & 3 deletions status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"net/http"

"github.com/gorilla/mux"
"github.com/nathan-osman/i5/assets"
"github.com/nathan-osman/i5/conman"
"github.com/nathan-osman/i5/db"
"github.com/nathan-osman/i5/dockmon"
"github.com/nathan-osman/i5/ui"
)

// Status provides a set of endpoints that display status information.
Expand All @@ -24,8 +24,8 @@ func New(cfg *Config) *dockmon.Container {
conman: cfg.Conman,
router: mux.NewRouter(),
}
s.router.PathPrefix("/static/").Handler(
http.StripPrefix("/static/", http.FileServer(assets.Assets)),
s.router.PathPrefix("/").Handler(
http.FileServer(ui.Assets),
)
return &dockmon.Container{
Domains: []string{cfg.Domain},
Expand Down
19 changes: 19 additions & 0 deletions ui/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// +build ignore

package main

import (
"net/http"

"github.com/shurcooL/vfsgen"
)

func main() {
if err := vfsgen.Generate(http.Dir("ui/build"), vfsgen.Options{
Filename: "ui/vfsdata.go",
PackageName: "ui",
VariableName: "Assets",
}); err != nil {
panic(err)
}
}
91 changes: 75 additions & 16 deletions util/rendererror.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,86 @@ package util
import (
"bytes"
"html/template"
"io/ioutil"
"net/http"
"strconv"

"github.com/nathan-osman/i5/assets"
)

var errorTemplate *template.Template
var errorTemplate = template.Must(template.New("").Parse(`<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
func init() {
f, err := assets.Assets.Open("templates/error.html")
if err != nil {
panic(err)
}
defer f.Close()
b, err := ioutil.ReadAll(f)
if err != nil {
panic(err)
}
errorTemplate = template.Must(template.New("").Parse(string(b)))
}
<title>{{.}}</title>
<!-- Everything needs to be kept inline -->
<style>
html, body {
height: 100%;
}
body {
align-items: center;
background-color: #f7f7f7;
color: #777;
display: flex;
font-family: sans-serif;
justify-content: center;
margin: 0;
}
a {
color: #ff6600;
}
footer {
border-top: 2px solid #ddd;
display: flex;
padding-top: 12px;
}
h1 {
font-size: 30pt;
font-weight: normal;
margin: 0;
}
p {
color: #aaa;
}
pre {
white-space: pre-wrap;
}
.content {
max-width: 800px;
}
.logo {
margin-right: 8px;
width: 30pt;
}
@media (max-width: 839px) {
.content {
margin: 20px;
}
}
</style>
</head>
<body>
<div class="content">
<h1>Something Went Wrong</h1>
<p>Our server was unable to display the page you requested.</p>
<p>More technical information may be available below:</p>
<pre>{{.}}</pre>
<footer>
<!-- EVERYTHING needs to be kept inline :P -->
<img class="logo" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIHZpZXdCb3g9IjAgMCA2Ny43MzMgNjcuNzMzIj48ZyBhcmlhLWxhYmVsPSJpNSIgc3R5bGU9ImxpbmUtaGVpZ2h0OjEuMjUiIGZvbnQtd2VpZ2h0PSI0MDAiIGZvbnQtc2l6ZT0iNzQuMDgzIiBmb250LWZhbWlse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IuNzQxLTMuODUyIDIuNzQxLTkuODUzIDAtNS4xMTItMi4xNDgtNy44NTMtMi4xNDktMi44MTUtNi4wMDEtMi44MTUtMy45MjYgMC05LjcwNSAzLjMzNGwtLjk2My0uNjY3IDUuNzA0LTI4LjA3OHE4LjM3Mi45NjQgMTIuNDQ2Ljk2NCA2Ljc0MiAwIDEyLjg5LTIuMDc1LjE0OSAxLjYzLjE0OSAyLjQ0NSAwIDMuODUyLTIuMDc0IDYuMjIzLTIgMi4zNy02LjQ0NiAyLjM3LTEuNzAzIDAtNC4wNzQtLjM3LTIuMzctLjM3LTQuNTItLjgxNS0xLjg1MS0uMzctMy43NzctLjY2NmwtMi45NjQgMTMuNDA5cTQuODE2LTIuMjk3IDkuMTg3LTIuMjk3IDYuMDc0IDAgOS41NTYgNC4xNDkgMy41NTYgNC4wNzQgMy41NTYgMTEuMTEyIDAgNi4wMDEtMi42NjcgMTAuNTk0LTIuNTkzIDQuNTkzLTcuNDA4IDcuMTg2LTQuNzQxIDIuNTE5LTEwLjk2NCAyLjUxOXoiIHN0eWxlPSItaW5rc2NhcGUtZm9udC1zcGVjaWZpY2F0aW9uOkxvYnN0ZXIiIGZpbGw9InB1cnBsZSIvPjwvZz48L3N2Zz4NCg==">
<!-- Branding -->
<p>
Powered by:<br>
<a href="https://github.com/nathan-osman/i5">i5 (reverse proxy)</a>
</p>
</footer>
</div>
</body>
</html>
`))

// RenderError renders the error template with the specified error.
func RenderError(w http.ResponseWriter, r *http.Request, statusCode int, message string) {
Expand Down

0 comments on commit 87b2d71

Please sign in to comment.