From d5206362fa4e1d0c4d4b79d9bab2126568664362 Mon Sep 17 00:00:00 2001 From: ari melody Date: Fri, 25 Jul 2025 17:02:01 +0100 Subject: [PATCH 1/2] embed template file, improve cmd arg handling --- main.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 60bb278..a6b0606 100755 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "strconv" "strings" "time" + _ "embed" ) type ( @@ -30,6 +31,9 @@ type ( } ) +//go:embed templates/dir.html +var dirHTML string + func main() { if len(os.Args) < 2 { printHelp() } @@ -37,7 +41,7 @@ func main() { port := 8080 root := "/" - filesDir := "." + filesDir := "" i := 1 for { if i >= len(os.Args) { break } @@ -79,17 +83,25 @@ func main() { if !strings.HasSuffix(root, "/") { root += "/" } default: + if len(filesDir) > 0 { + fmt.Fprintf(os.Stderr, "unsupported argument: %s\n", os.Args[i]) + os.Exit(1) + } filesDir = os.Args[i] } i++ } + if len(filesDir) == 0 { + filesDir = "." + } + ignoredFiles := []string{ ".", ".DS_Store", } - dirTemplate, err := template.ParseGlob("./templates/dir.html") + dirTemplate, err := template.New("dir").Parse(dirHTML) if err != nil { fmt.Fprintf(os.Stderr, "fatal: failed to parse directory template: %v\n", err) os.Exit(1) From 55f6878727f7db0da6ad6efb2b5dac4e1af35a7e Mon Sep 17 00:00:00 2001 From: ari melody Date: Fri, 25 Jul 2025 18:26:05 +0100 Subject: [PATCH 2/2] css improvements for mobile --- templates/dir.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/templates/dir.html b/templates/dir.html index 7d0ac2b..7c26cfb 100644 --- a/templates/dir.html +++ b/templates/dir.html @@ -9,6 +9,7 @@ html { background: #101010; color: #f0f0f0; font-family: 'Monaspace Argon', monospace; + font-size: 16px; } body { @@ -55,6 +56,21 @@ a:hover { footer { padding: 1em 0; } + +@media screen and (max-width: 700px) { + body { + font-size: 12px; + } + + td { + width: auto; + } + + td:last-of-type, + th:last-of-type { + display: none; + } +}