aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-01-26 14:16:40 -0800
committerChristine Dodrill <me@christine.website>2019-01-26 14:16:40 -0800
commit75c6b7060169f84f88e27c277edbcbfa739d7f54 (patch)
tree1e32633da3a606a6e746115c3fa916a3d896d884
parente1f9dd089da6eb098e010ef7498036a8ecb2c1ae (diff)
downloadx-75c6b7060169f84f88e27c277edbcbfa739d7f54.tar.xz
x-75c6b7060169f84f88e27c277edbcbfa739d7f54.zip
subsume within.website
-rw-r--r--go.mod2
-rw-r--r--go.sum4
-rw-r--r--within.website/.gitignore2
-rw-r--r--within.website/build.go39
-rw-r--r--within.website/main.go69
5 files changed, 116 insertions, 0 deletions
diff --git a/go.mod b/go.mod
index ed81975..37801db 100644
--- a/go.mod
+++ b/go.mod
@@ -44,6 +44,7 @@ require (
github.com/kr/pty v1.1.3 // indirect
github.com/layeh/gopher-luar v1.0.4
github.com/mattn/go-runewidth v0.0.4 // indirect
+ github.com/mmikulicic/stringlist v0.0.0-20170411212101-a0d1ef9a7ccb
github.com/mndrix/golog v0.0.0-20170330170653-a28e2a269775
github.com/mndrix/ps v0.0.0-20170330174427-18e65badd6ab // indirect
github.com/olekukonko/tablewriter v0.0.1 // indirect
@@ -66,6 +67,7 @@ require (
github.com/yookoala/realpath v1.0.0 // indirect
github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed
github.com/yuin/gopher-lua v0.0.0-20190111065735-507fb6e5b04d
+ go.jonnrb.io/vanity v0.1.0
go4.org v0.0.0-20181109185143-00e24f1b2599
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc
golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b // indirect
diff --git a/go.sum b/go.sum
index 81808c4..d9552f9 100644
--- a/go.sum
+++ b/go.sum
@@ -104,6 +104,8 @@ github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8Bz
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/mmikulicic/stringlist v0.0.0-20170411212101-a0d1ef9a7ccb h1:J7xIYNprbALCDmUz9kVVxJbAg9u7o3JIRwD3mOd89tg=
+github.com/mmikulicic/stringlist v0.0.0-20170411212101-a0d1ef9a7ccb/go.mod h1:19Brp+Rld8TLwZ2oCHvTE3xDhCMr0jSCWwzcc9ejZgQ=
github.com/mndrix/golog v0.0.0-20170330170653-a28e2a269775 h1:KPqf9x/eMg3ZnHATLXcM1OgQMNVkPUv1QcGv6zTRMRg=
github.com/mndrix/golog v0.0.0-20170330170653-a28e2a269775/go.mod h1:Q4YHYl483MNk6wwg3g8YsINpKe5S2UzUJCRSRlFaSU0=
github.com/mndrix/ps v0.0.0-20170330174427-18e65badd6ab h1:fPrYMvMnWuED0MLhLyrny1fLaHhtiXK30pNyBGrk9Gs=
@@ -157,6 +159,8 @@ github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed h1:I1vcLHWU9m30rA90rMr
github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed/go.mod h1:9w6KSdZh23UWqOywWsRLUcJUrUNjRh4Ql3z9uVgnSP4=
github.com/yuin/gopher-lua v0.0.0-20190111065735-507fb6e5b04d h1:5JtS12nrJrdMZhJOZc5lslNHm9yJv6ig67yjy4nE4OM=
github.com/yuin/gopher-lua v0.0.0-20190111065735-507fb6e5b04d/go.mod h1:fFiAh+CowNFr0NK5VASokuwKwkbacRmHsVA7Yb1Tqac=
+go.jonnrb.io/vanity v0.1.0 h1:cVGnSsKskgSfmqVpoZLIjJK+RBnNuv38w+s5ETsSY7g=
+go.jonnrb.io/vanity v0.1.0/go.mod h1:dGzlD3p54k6ABHBFWqvGjQ4ZJv5/n7Wl4R/PgkXQS5k=
go4.org v0.0.0-20181109185143-00e24f1b2599 h1:4WHwK0SeICTm4UREYCO3QAhYgBLbRJKNwoUsFp8nk9o=
go4.org v0.0.0-20181109185143-00e24f1b2599/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
diff --git a/within.website/.gitignore b/within.website/.gitignore
new file mode 100644
index 0000000..4697cff
--- /dev/null
+++ b/within.website/.gitignore
@@ -0,0 +1,2 @@
+web
+slug.tar.gz \ No newline at end of file
diff --git a/within.website/build.go b/within.website/build.go
new file mode 100644
index 0000000..d72d9f5
--- /dev/null
+++ b/within.website/build.go
@@ -0,0 +1,39 @@
+//+build ignore
+
+// Builds and deploys the application to minipaas.
+package main
+
+import (
+ "context"
+ "log"
+ "os"
+
+ "github.com/Xe/x/internal/greedo"
+ "github.com/Xe/x/internal/minipaas"
+ "github.com/Xe/x/internal/yeet"
+)
+
+func main() {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ env := append(os.Environ(), []string{"CGO_ENABLED=0", "GOOS=linux"}...)
+ yeet.ShouldWork(ctx, env, yeet.WD, "go", "build", "-o=web")
+ yeet.ShouldWork(ctx, env, yeet.WD, "appsluggr", "-web=web")
+ fin, err := os.Open("slug.tar.gz")
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer fin.Close()
+
+ fname := "within.website-" + yeet.DateTag + ".tar.gz"
+ pubURL, err := greedo.CopyFile(fname, fin)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ err = minipaas.Exec("tar:from within.website " + pubURL)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
diff --git a/within.website/main.go b/within.website/main.go
new file mode 100644
index 0000000..b1e1d5e
--- /dev/null
+++ b/within.website/main.go
@@ -0,0 +1,69 @@
+package main
+
+import (
+ "context"
+ "flag"
+ "net/http"
+
+ "github.com/Xe/x/internal"
+ "github.com/mmikulicic/stringlist"
+ "go.jonnrb.io/vanity"
+ "within.website/ln"
+ "within.website/ln/opname"
+)
+
+var (
+ domain = flag.String("domain", "within.website", "domain this is run on")
+ githubUsername = flag.String("github-user", "Xe", "GitHub username for GitHub repos")
+ gogsDomain = flag.String("gogs-url", "https://git.xeserv.us", "Gogs domain to use")
+ gogsUsername = flag.String("gogs-username", "xena", "Gogs username for above Gogs instance")
+ port = flag.String("port", "2134", "HTTP port to listen on")
+
+ githubRepos = stringlist.Flag("github-repo", "list of GitHub repositories to use")
+ gogsRepos = stringlist.Flag("gogs-repo", "list of Gogs repositories to use")
+)
+
+var githubReposDefault = []string{
+ "ln",
+ "x",
+ "xultybau",
+ "johaus",
+ "confyg",
+}
+
+var gogsReposDefault = []string{
+ "gorqlite",
+}
+
+func main() {
+ internal.HandleStartup()
+ ctx := opname.With(context.Background(), "main")
+ ctx = ln.WithF(ctx, ln.F{
+ "domain": *domain,
+ })
+
+ if len(*githubRepos) == 0 {
+ *githubRepos = githubReposDefault
+ }
+
+ if len(*gogsRepos) == 0 {
+ *gogsRepos = gogsReposDefault
+ }
+
+ for _, repo := range *githubRepos {
+ http.Handle("/"+repo, vanity.GitHubHandler(*domain+"/"+repo, *githubUsername, repo, "https"))
+ http.Handle("/"+repo+"/", vanity.GitHubHandler(*domain+"/"+repo, *githubUsername, repo, "https"))
+
+ ln.Log(ctx, ln.F{"github_repo": repo, "github_user": *githubUsername}, ln.Info("adding github repo"))
+ }
+
+ for _, repo := range *gogsRepos {
+ http.Handle("/"+repo, vanity.GogsHandler(*domain+"/"+repo, *gogsDomain, *gogsUsername, repo, "https"))
+ http.Handle("/"+repo+"/", vanity.GogsHandler(*domain+"/"+repo, *gogsDomain, *gogsUsername, repo, "https"))
+
+ ln.Log(ctx, ln.F{"gogs_domain": *gogsDomain, "gogs_username": *gogsUsername, "gogs_repo": repo}, ln.Info("adding gogs repo"))
+ }
+
+ ln.Log(ctx, ln.F{"port": *port}, ln.Info("Listening on HTTP"))
+ http.ListenAndServe(":"+*port, nil)
+}