aboutsummaryrefslogtreecommitdiff
path: root/cmd/within.website/main.go
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/main.go
parent3338d3e7fcf985a68f44f29b1c25215b0d42cdb7 (diff)
downloadx-4756dab75c0eb3a2255dced9058d4ee7b6efc9ee.tar.xz
x-4756dab75c0eb3a2255dced9058d4ee7b6efc9ee.zip
cmd/within.website: start on info page
Diffstat (limited to 'cmd/within.website/main.go')
-rw-r--r--cmd/within.website/main.go41
1 files changed, 41 insertions, 0 deletions
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>`