aboutsummaryrefslogtreecommitdiff
path: root/cmd/within.website
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-06-02 22:55:46 -0400
committerChristine Dodrill <me@christine.website>2019-06-02 22:55:46 -0400
commit4756dab75c0eb3a2255dced9058d4ee7b6efc9ee (patch)
tree92a468076ccd2eac9eead54fd44c9af16b5589f1 /cmd/within.website
parent3338d3e7fcf985a68f44f29b1c25215b0d42cdb7 (diff)
downloadx-4756dab75c0eb3a2255dced9058d4ee7b6efc9ee.tar.xz
x-4756dab75c0eb3a2255dced9058d4ee7b6efc9ee.zip
cmd/within.website: start on info page
Diffstat (limited to 'cmd/within.website')
-rw-r--r--cmd/within.website/bindata.go235
-rw-r--r--cmd/within.website/main.go41
-rw-r--r--cmd/within.website/static/gruvbox.css60
3 files changed, 336 insertions, 0 deletions
diff --git a/cmd/within.website/bindata.go b/cmd/within.website/bindata.go
new file mode 100644
index 0000000..1f8958a
--- /dev/null
+++ b/cmd/within.website/bindata.go
@@ -0,0 +1,235 @@
+// Code generated by go-bindata. DO NOT EDIT.
+// sources:
+// static/gruvbox.css
+package main
+
+import (
+ "bytes"
+ "compress/gzip"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+ "time"
+)
+
+func bindataRead(data []byte, name string) ([]byte, error) {
+ gz, err := gzip.NewReader(bytes.NewBuffer(data))
+ if err != nil {
+ return nil, fmt.Errorf("Read %q: %v", name, err)
+ }
+
+ var buf bytes.Buffer
+ _, err = io.Copy(&buf, gz)
+ clErr := gz.Close()
+
+ if err != nil {
+ return nil, fmt.Errorf("Read %q: %v", name, err)
+ }
+ if clErr != nil {
+ return nil, err
+ }
+
+ return buf.Bytes(), nil
+}
+
+type asset struct {
+ bytes []byte
+ info os.FileInfo
+}
+
+type bindataFileInfo struct {
+ name string
+ size int64
+ mode os.FileMode
+ modTime time.Time
+}
+
+func (fi bindataFileInfo) Name() string {
+ return fi.name
+}
+func (fi bindataFileInfo) Size() int64 {
+ return fi.size
+}
+func (fi bindataFileInfo) Mode() os.FileMode {
+ return fi.mode
+}
+func (fi bindataFileInfo) ModTime() time.Time {
+ return fi.modTime
+}
+func (fi bindataFileInfo) IsDir() bool {
+ return false
+}
+func (fi bindataFileInfo) Sys() interface{} {
+ return nil
+}
+
+var _staticGruvboxCss = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x7c\x91\x4d\x6e\xdb\x30\x10\x85\xf7\x3c\xc5\x00\xde\xb4\x80\x14\x98\x52\xe4\x38\xf4\xa6\xdd\xf5\x1a\xfc\x19\x5a\x44\x48\x51\xa5\x68\xd7\x41\xa1\xbb\x17\xa2\xe4\x44\x62\x93\xd0\x0b\x0b\x43\xce\x7b\x33\xef\x73\xdc\x74\xf0\x97\x00\x68\xdf\xc5\x52\x73\x67\xec\x2b\x83\x9f\xc1\x70\x5b\xc0\x2f\xb4\x57\x8c\x46\xf2\x02\x06\xde\x0d\xe5\x80\xc1\xe8\x13\x01\x70\xfc\x56\xfe\x31\x2a\xb6\x0c\xea\x63\x40\x37\xd5\x7a\xae\x94\xe9\xce\x0c\xaa\xa5\xe0\x78\x38\x9b\x8e\x01\xbf\x44\x7f\x22\x23\x21\xc2\xab\xd7\xe4\x25\xb8\x7c\x39\x07\x7f\xe9\x14\x83\x5d\x75\x9c\x7e\x53\x83\xf4\xd6\x07\x06\xe9\xec\x50\x28\x21\xaa\xd4\xd7\x07\xcc\xda\xca\xe5\xe9\xae\x96\xf5\xb1\x3e\x6c\xec\xe9\xec\x2e\x7c\x50\x18\x18\xec\x93\x04\x2f\x80\x33\x2e\xa3\xb9\xe2\xf4\x75\x35\x83\x89\xa8\x92\xea\x5d\x4a\xd0\x43\x75\x4c\x52\x1f\xf8\x50\x55\xed\x2b\x9a\xa4\x5a\x5a\x40\x5b\x15\xd0\xd6\x05\xb4\x8f\x05\xb4\x4d\x92\x99\xb7\x2d\x85\x8f\xd1\x3b\x06\x0f\x34\xa5\x30\x6d\x6d\xbd\x7c\xf9\x7d\xf1\x71\x59\x22\xcd\x55\x5a\xd4\x91\x01\xed\x6f\x30\x78\x6b\x14\xec\x84\xe2\xf8\x5c\xaf\x73\xdb\x3f\x34\xe8\x80\xee\xfb\xdb\x66\xbf\x75\x79\x24\xe4\x87\x43\x65\x38\x7c\xeb\x03\x6a\x0c\xc3\x3c\x71\x39\xc8\x16\x1d\x32\xb0\xe6\xdc\xc6\xef\xc9\x78\xb2\x5e\xf2\x9f\xcf\x86\x82\x16\x9a\xca\xa7\xd3\xdb\xe5\x86\xc5\x7b\xca\x00\x23\x49\x7f\x77\x26\xb9\xd4\x5b\x62\x77\x7e\xf7\x27\x39\x9f\xa5\xf1\x9d\xd2\x4a\xfc\x0b\x5a\x9b\xe9\x56\xcc\x3e\x9d\x43\x3f\xeb\x46\x3d\x6d\xe4\x3f\x21\x38\x9f\x8f\x39\xae\xba\x33\x9e\xeb\x3d\xfe\xa7\x7a\x68\x1a\xd9\x3c\x9e\x32\xf5\x9c\x6d\x96\x50\x7e\x39\x92\x91\xfc\x0b\x00\x00\xff\xff\x20\x13\x05\xe2\xa8\x03\x00\x00")
+
+func staticGruvboxCssBytes() ([]byte, error) {
+ return bindataRead(
+ _staticGruvboxCss,
+ "static/gruvbox.css",
+ )
+}
+
+func staticGruvboxCss() (*asset, error) {
+ bytes, err := staticGruvboxCssBytes()
+ if err != nil {
+ return nil, err
+ }
+
+ info := bindataFileInfo{name: "static/gruvbox.css", size: 936, mode: os.FileMode(420), modTime: time.Unix(1559522447, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
+}
+
+// Asset loads and returns the asset for the given name.
+// It returns an error if the asset could not be found or
+// could not be loaded.
+func Asset(name string) ([]byte, error) {
+ cannonicalName := strings.Replace(name, "\\", "/", -1)
+ if f, ok := _bindata[cannonicalName]; ok {
+ a, err := f()
+ if err != nil {
+ return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
+ }
+ return a.bytes, nil
+ }
+ return nil, fmt.Errorf("Asset %s not found", name)
+}
+
+// MustAsset is like Asset but panics when Asset would return an error.
+// It simplifies safe initialization of global variables.
+func MustAsset(name string) []byte {
+ a, err := Asset(name)
+ if err != nil {
+ panic("asset: Asset(" + name + "): " + err.Error())
+ }
+
+ return a
+}
+
+// AssetInfo loads and returns the asset info for the given name.
+// It returns an error if the asset could not be found or
+// could not be loaded.
+func AssetInfo(name string) (os.FileInfo, error) {
+ cannonicalName := strings.Replace(name, "\\", "/", -1)
+ if f, ok := _bindata[cannonicalName]; ok {
+ a, err := f()
+ if err != nil {
+ return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
+ }
+ return a.info, nil
+ }
+ return nil, fmt.Errorf("AssetInfo %s not found", name)
+}
+
+// AssetNames returns the names of the assets.
+func AssetNames() []string {
+ names := make([]string, 0, len(_bindata))
+ for name := range _bindata {
+ names = append(names, name)
+ }
+ return names
+}
+
+// _bindata is a table, holding each asset generator, mapped to its name.
+var _bindata = map[string]func() (*asset, error){
+ "static/gruvbox.css": staticGruvboxCss,
+}
+
+// AssetDir returns the file names below a certain
+// directory embedded in the file by go-bindata.
+// For example if you run go-bindata on data/... and data contains the
+// following hierarchy:
+// data/
+// foo.txt
+// img/
+// a.png
+// b.png
+// then AssetDir("data") would return []string{"foo.txt", "img"}
+// AssetDir("data/img") would return []string{"a.png", "b.png"}
+// AssetDir("foo.txt") and AssetDir("notexist") would return an error
+// AssetDir("") will return []string{"data"}.
+func AssetDir(name string) ([]string, error) {
+ node := _bintree
+ if len(name) != 0 {
+ cannonicalName := strings.Replace(name, "\\", "/", -1)
+ pathList := strings.Split(cannonicalName, "/")
+ for _, p := range pathList {
+ node = node.Children[p]
+ if node == nil {
+ return nil, fmt.Errorf("Asset %s not found", name)
+ }
+ }
+ }
+ if node.Func != nil {
+ return nil, fmt.Errorf("Asset %s not found", name)
+ }
+ rv := make([]string, 0, len(node.Children))
+ for childName := range node.Children {
+ rv = append(rv, childName)
+ }
+ return rv, nil
+}
+
+type bintree struct {
+ Func func() (*asset, error)
+ Children map[string]*bintree
+}
+var _bintree = &bintree{nil, map[string]*bintree{
+ "static": &bintree{nil, map[string]*bintree{
+ "gruvbox.css": &bintree{staticGruvboxCss, map[string]*bintree{}},
+ }},
+}}
+
+// RestoreAsset restores an asset under the given directory
+func RestoreAsset(dir, name string) error {
+ data, err := Asset(name)
+ if err != nil {
+ return err
+ }
+ info, err := AssetInfo(name)
+ if err != nil {
+ return err
+ }
+ err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
+ if err != nil {
+ return err
+ }
+ err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
+ if err != nil {
+ return err
+ }
+ err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+// RestoreAssets restores an asset under the given directory recursively
+func RestoreAssets(dir, name string) error {
+ children, err := AssetDir(name)
+ // File
+ if err != nil {
+ return RestoreAsset(dir, name)
+ }
+ // Dir
+ for _, child := range children {
+ err = RestoreAssets(dir, filepath.Join(name, child))
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func _filePath(dir, name string) string {
+ cannonicalName := strings.Replace(name, "\\", "/", -1)
+ return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
+}
+
diff --git a/cmd/within.website/main.go b/cmd/within.website/main.go
index 19063f8..910b4f9 100644
--- a/cmd/within.website/main.go
+++ b/cmd/within.website/main.go
@@ -7,11 +7,14 @@ import (
"github.com/Xe/x/internal"
"github.com/Xe/x/vanity"
+ assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/mmikulicic/stringlist"
"within.website/ln"
"within.website/ln/opname"
)
+//go:generate go-bindata -pkg main static
+
var (
domain = flag.String("domain", "within.website", "domain this is run on")
githubUsername = flag.String("github-user", "Xe", "GitHub username for GitHub repos")
@@ -65,6 +68,44 @@ func main() {
ln.Log(ctx, ln.F{"gogs_domain": *gogsDomain, "gogs_username": *gogsUsername, "gogs_repo": repo}, ln.Info("adding gogs repo"))
}
+ http.Handle("/static/", http.FileServer(
+ &assetfs.AssetFS{
+ Asset: Asset,
+ AssetDir: AssetDir,
+ },
+ ))
+
+ http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/" {
+ http.NotFound(w, r)
+ return
+ }
+
+ w.Header().Add("Content-Type", "text/html")
+ w.Write([]byte(indexTemplate))
+ })
+
ln.Log(ctx, ln.F{"port": *port}, ln.Info("Listening on HTTP"))
http.ListenAndServe(":"+*port, nil)
+
}
+
+const indexTemplate = `<!DOCTYPE html>
+<html>
+ <head>
+ <title>within.website Go Packages</title>
+ <link rel="stylesheet" href="/static/gruvbox.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ </head>
+ <body id="top">
+ <main>
+ <h1><code>within.website</code> Go Packages</h1>
+
+ <hr />
+
+ <footer class="is-text-center">
+ <p>Need help with these packages? Inquire <a href="https://github.com/Xe">Within</a>.</p>
+ </footer>
+ </main>
+ </body>
+</html>`
diff --git a/cmd/within.website/static/gruvbox.css b/cmd/within.website/static/gruvbox.css
new file mode 100644
index 0000000..43c1ba0
--- /dev/null
+++ b/cmd/within.website/static/gruvbox.css
@@ -0,0 +1,60 @@
+main {
+ font-family: Arial, Helvetica, sans-serif;
+ max-width: 38rem;
+ padding: 2rem;
+ margin: auto;
+}
+
+body {
+ background: #282828;
+ color: #ebdbb2;
+}
+
+pre {
+ background-color: #3c3836;
+ padding: 1em;
+ border: 0;
+}
+
+a, a:active, a:visited {
+ color: #b16286;
+ background-color: #1d2021;
+}
+
+h1, h2, h3, h4, h5 {
+ margin-bottom: .1rem;
+}
+
+blockquote {
+ border-left: 1px solid #bdae93;
+ margin: 0.5em 10px;
+ padding: 0.5em 10px;
+}
+
+@media (prefers-color-scheme: light) {
+ body {
+ background: #fbf1c7;
+ color: #3c3836;
+ }
+
+ pre {
+ background-color: #ebdbb2;
+ padding: 1em;
+ border: 0;
+ }
+
+ a, a:active, a:visited {
+ color: #b16286;
+ background-color: #f9f5d7;
+ }
+
+ h1, h2, h3, h4, h5 {
+ margin-bottom: .1rem;
+ }
+
+ blockquote {
+ border-left: 1px solid #655c54;
+ margin: 0.5em 10px;
+ padding: 0.5em 10px;
+ }
+}