diff --git a/.gitignore b/.gitignore index f4f4872..2f8ecd8 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ !LICENSE !/templates/** !/static/** +!.prettierrc # !Makefile diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..baba830 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "tabWidth": 2, + "printWidth": 1000 +} \ No newline at end of file diff --git a/config.go b/config.go index 41ae28f..fe49111 100644 --- a/config.go +++ b/config.go @@ -46,7 +46,7 @@ func loadConfig() (Config, error) { databasePath := envOrDefault("MINIBIN_DATABASE_PATH", "minibin.sqlite") - expiriesSetting := envOrDefault("MINIBIN_EXPIRIES", "1h,12h,1d,7d,2w,1mo,6mo,1y,5y, 0") + expiriesSetting := envOrDefault("MINIBIN_EXPIRIES", "1h,12h,1d,7d,2w,1mo,6mo,1y,5y,0") var expiries []Expiry for entry := range strings.SplitSeq(expiriesSetting, ",") { expiry, err := parseExpiry(entry) diff --git a/main.go b/main.go index f515ba4..cc2fb00 100644 --- a/main.go +++ b/main.go @@ -27,12 +27,16 @@ func main() { log.Fatal(err) } - pages, err := template.ParseFiles("templates/home.html", "templates/nojs/home.html") + pages, err := template.ParseFiles("templates/home.html") if err != nil { log.Fatal(err) } mux := http.NewServeMux() + fs := http.FileServer(http.Dir("static")) + mux.Handle("GET /css/", fs) + mux.Handle("GET /js/", fs) + mux.Handle("GET /static/", http.StripPrefix("/static/", fs)) mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) { data := HomePageData{ Expiries: config.Expiries, diff --git a/static/css/main.css b/static/css/main.css new file mode 100644 index 0000000..e94cf49 --- /dev/null +++ b/static/css/main.css @@ -0,0 +1,140 @@ +:root { + --bg: #191919; + --surface: #2a2a2a; + --text: #eee; + --text-muted: #aaa; + --border: #4e4e4e; + --border-strong: #7e7e7e; +} + +* { + box-sizing: border-box; +} + +body { + background-color: var(--bg); + color: var(--text); + margin: 0; + font-family: Consolas, monospace; + font-size: 14px; +} + +h1, +h2 { + margin: 0; + font-weight: 400; +} + +h1 { + font-size: 18px; + font-weight: 700; +} + +main { + width: min(100% - 36px, 720px); + margin: 0 auto; + padding: 44px 0 64px; +} + +textarea { + background: var(--bg); + display: block; + width: 100%; + min-height: 120px; + height: 120px; + resize: vertical; + border: 1px solid var(--border); + font: inherit; + padding: 12px; + outline: none; + color: var(--text); + margin-bottom: 12px; +} + +.upload-tabs { + display: flex; + flex-wrap: wrap; + gap: 0.75rem; +} + +.upload-tabs > label { + cursor: pointer; + border-bottom: 1px solid transparent; + color: var(--text-muted); +} + +.upload-tabs > input { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); +} + +.upload-tabs > input:checked + label { + border-bottom-color: currentColor; + color: var(--text); +} + +.upload-tabs > input:focus-visible + label { + border: 1px solid currentColor; +} + +.file-panel, +.paste-panel { + display: none; + width: 100%; +} + +#type-file:checked ~ .file-panel, +#type-paste:checked ~ .paste-panel { + display: block; +} + +input[type="file"] { + display: block; + border: 1px solid var(--border); + color: var(--text); + width: 100%; + cursor: pointer; + margin-bottom: 12px; + font: inherit; +} + +input[type="file"]::file-selector-button { + background-color: var(--surface); + border: none; + color: var(--text); + padding: 10px; + font: inherit; +} + +label[for="file-expiry"], +label[for="paste-expiry"] { + color: var(--text-muted); +} +select { + padding: 0 0 2px; + background: var(--bg); + border: none; + color: var(--text); + border-bottom: 1px solid var(--border-strong); + border-radius: 0; + font: inherit; + margin-bottom: 12px; +} + +option { + background-color: var(--bg); + font: inherit; +} + +button[type="submit"] { + border-radius: 0; + border: none; + background-color: var(--text); + padding: 11px; + color: var(--surface); + font: inherit; + cursor: pointer; +} diff --git a/templates/home.html b/templates/home.html index edd137e..bb5bc47 100644 --- a/templates/home.html +++ b/templates/home.html @@ -4,34 +4,43 @@ minibin + -

minibin

-

simple file and paste hosting service

- -
- - - - - -
+
+

minibin

+

simple file and paste hosting service

+
+ + + + +
+
+ + + + +
+
+
+
+ - - - - - -
+ + + + +
+
+
diff --git a/templates/nojs/home.html b/templates/nojs/home.html deleted file mode 100644 index b803401..0000000 --- a/templates/nojs/home.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - minibin - - -

minibin

-

simple file and paste hosting service

-
- - - - - -
- -
- - - - -
- -