diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-12-08 02:16:04 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-12-08 02:16:04 +0100 |
commit | 941022bdd6c69de93f38992205b02ed95c6e8eb0 (patch) | |
tree | 510bfd9df7725e0e81b29ca0feb610dc986c37dd | |
download | gallery-941022bdd6c69de93f38992205b02ed95c6e8eb0.tar.gz gallery-941022bdd6c69de93f38992205b02ed95c6e8eb0.tar.xz gallery-941022bdd6c69de93f38992205b02ed95c6e8eb0.zip |
Initial commit
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | go.mod | 5 | ||||
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | main.go | 82 |
4 files changed, 101 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9c5bc80 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.POSIX: +.SUFFIXES: + +outputs = gallery public/mithril.js +all: $(outputs) + +gallery: main.go + go build -o $@ +public/mithril.js: + curl -Lo $@ https://unpkg.com/mithril/mithril.js +clean: + rm -f $(outputs) @@ -0,0 +1,5 @@ +module janouch.name/gallery + +go 1.21.4 + +require github.com/mattn/go-sqlite3 v1.14.18 @@ -0,0 +1,2 @@ +github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= @@ -0,0 +1,82 @@ +package main + +import ( + "database/sql" + "log" + "os" + + _ "github.com/mattn/go-sqlite3" +) + +// init GD - initialize a "gallery directory" that contains gallery.sqlite, +// images, thumbs. +func cmdInit(args []string) { + if len(args) != 1 { + log.Fatalln("usage: GD") + } + + gd := args[0] + + db, err := sql.Open("sqlite3", gd+"/foo.db") + if err != nil { + log.Fatalln(err) + } + + // TODO: Figure out a go generate to create a Go file to create the db. + _ = db +} + +// run GD ADDRESS - run a web UI against GD on ADDRESS +func cmdRun(args []string) { + // TODO: Use "public" from CWD for files. +} + +// import GD ROOT... - add files to the "entry" table +func cmdImport(args []string) { + // TODO +} + +// sync GD ROOT... - like import, but clear table beforehands +func cmdSync(args []string) { + // TODO +} + +// check GD - see if all files are accessible +func cmdCheck(args []string) { + // TODO +} + +// thumbnail GD [SHA1...] - generate missing thumbnails, in parallel +func cmdThumbnail(args []string) { + // TODO: Show progress. +} + +// dhash GD HASHER [SHA1...] - generate perceptual hash from thumbnails +func cmdDhash(args []string) { + // TODO +} + +var commands = map[string]struct { + handler func(args []string) +}{ + "init": {cmdInit}, + "run": {cmdRun}, + "import": {cmdImport}, + "sync": {cmdSync}, + "check": {cmdCheck}, + "thumbnail": {cmdThumbnail}, + "dhash": {cmdDhash}, +} + +func main() { + if len(os.Args) <= 2 { + log.Fatalln("Missing arguments") + } + + cmd, ok := commands[os.Args[1]] + if !ok { + log.Fatalln("Unknown command: " + os.Args[1]) + } + + cmd.handler(os.Args[2:]) +} |