Compare commits

...

8 Commits

Author SHA1 Message Date
leah 84932c2449 use the config file 2022-01-26 19:28:26 +00:00
leah 667161d876 add example config file 2022-01-26 19:01:26 +00:00
leah da5a3f53dc update gitignore 2022-01-26 19:00:48 +00:00
leah 7e177e3b1a add a tests dir 2022-01-26 17:00:42 +00:00
leah 078b6a7a65 add resources/ 2022-01-26 17:00:32 +00:00
leah 4c10954036 add http server 2022-01-26 17:00:22 +00:00
leah e9e99646cb add some html boilerplate 2022-01-26 17:00:13 +00:00
leah e7e119b934 add todo 2022-01-26 16:59:53 +00:00
9 changed files with 107 additions and 1 deletions

3
.gitignore vendored
View File

@ -15,3 +15,6 @@
# Dependency directories (remove the comment below to include it)
# vendor/
# sensitive data that shouldn't be pushed
data/*
config.yml

View File

@ -1,3 +1,11 @@
# admin
quick little admin panel.
quick little admin panel
## todo
- [ ] respectable web ui
- [ ] signup form
- [ ] lots of db code
- [ ] gitea authentication
- [ ] pam auth (maube?)
- [ ] automatic user creaton/deletion
- [ ] resource usage dashboard

14
config.example.yml Normal file
View File

@ -0,0 +1,14 @@
server:
name: "south london"
homepage: "https://southlondon.cc"
admin:
# webroot: "/admin" # Set this if you're running the admin panel on using a
# custom path instead of a subdomain.
# e.g. southlondon.cc/admin instead of admin.southlondon.cc
auth:
gitea-url: "https://tildegit.org"
authorized-users:
- lp0

2
go.mod
View File

@ -1,3 +1,5 @@
module tildegit.org/southlondon/admin
go 1.17
require gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b

4
go.sum Normal file
View File

@ -0,0 +1,4 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

57
main.go Normal file
View File

@ -0,0 +1,57 @@
package main
import (
"fmt"
"html"
"io/ioutil"
"log"
"net/http"
"gopkg.in/yaml.v3"
)
type ServerConfig struct {
Name string
Homepage string
}
type AdminConfig struct {
WebRoot string
}
type AuthConfig struct {
GiteaURL string
AuthorizedUsers []string
}
type Config struct {
Server ServerConfig
Admin AdminConfig
Auth AuthConfig
}
var config = new(Config)
func loadConfig() (err error) {
configfile, err := ioutil.ReadFile("config.yml")
if err != nil {
return err
}
err = yaml.Unmarshal(configfile, &config)
return err
}
func main() {
err := loadConfig()
if err != nil {
log.Fatal("oh no !!!")
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
})
err = http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal(err)
}
}

3
resources/main.css Normal file
View File

@ -0,0 +1,3 @@
body {
color: purple;
}

14
templates/home.html Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>{ server.name } Admin Panel</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
<script src='main.js'></script>
</head>
<body>
</body>
</html>

1
tests/.empty Normal file
View File

@ -0,0 +1 @@
leah you better write some fucking tests this time around