diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-12-23 07:59:19 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-12-23 08:24:22 +0100 |
commit | d945fe936d250877e141fce748783d4fc7d591de (patch) | |
tree | 444c722ad7ec0f62b96c1eb2a4e804998d7208b4 | |
parent | d7c775a7d2df82316255a42475f7a58bdd79c7ea (diff) | |
download | gallery-d945fe936d250877e141fce748783d4fc7d591de.tar.gz gallery-d945fe936d250877e141fce748783d4fc7d591de.tar.xz gallery-d945fe936d250877e141fce748783d4fc7d591de.zip |
WIP: Orphans
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | main.go | 17 | ||||
-rw-r--r-- | public/gallery.js | 39 | ||||
-rwxr-xr-x | test.sh | 6 |
4 files changed, 61 insertions, 3 deletions
@@ -1,5 +1,3 @@ -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= github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI= github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4= @@ -686,6 +686,22 @@ func handleAPIDuplicates(w http.ResponseWriter, r *http.Request) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +func handleAPIOrphans(w http.ResponseWriter, r *http.Request) { + var params struct{} + if err := json.NewDecoder(r.Body).Decode(¶ms); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + // TODO + result := false + if err := json.NewEncoder(w).Encode(result); err != nil { + log.Println(err) + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // cmdRun runs a web UI against GD on ADDRESS. func cmdRun(args []string) error { if len(args) != 2 { @@ -708,6 +724,7 @@ func cmdRun(args []string) error { http.HandleFunc("/api/info", handleAPIInfo) http.HandleFunc("/api/similar", handleAPISimilar) http.HandleFunc("/api/duplicates", handleAPIDuplicates) + http.HandleFunc("/api/orphans", handleAPIOrphans) host, port, err := net.SplitHostPort(address) if err != nil { diff --git a/public/gallery.js b/public/gallery.js index 970a3bf..222bde5 100644 --- a/public/gallery.js +++ b/public/gallery.js @@ -363,6 +363,44 @@ let Duplicates = { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +let OrphansModel = { + entries: [], + + async reload() { + this.entries = await call('orphans', {}) + }, +} + +let OrphansList = { + // See BrowseView. + oncreate(vnode) { vnode.dom.focus() }, + + view(vnode) { + let children = (DuplicatesModel.entries.length == 0) + ? "No orphans" + : OrphansModel.entries.map(group => + m('.row', "TODO")) + return m('.orphans[tabindex=0]', {}, children) + }, +} + +let Orphans = { + oninit(vnode) { + OrphansModel.reload() + }, + + view(vnode) { + return m('.container', {}, [ + m('.header', {}, [ + "Orphans", + ]), + m('.body', {}, m(OrphansList)), + ]) + }, +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + window.addEventListener('load', () => { m.route(document.body, "/browse/", { // The path doesn't need to be escaped, perhaps change that (":key..."). @@ -371,6 +409,7 @@ window.addEventListener('load', () => { "/view/:key": View, "/similar/:key": Similar, "/duplicates": Duplicates, + "/orphans": Orphans, "/tags": undefined, "/tags/:space": undefined, @@ -10,7 +10,7 @@ cp -ra $HOME/Pictures/Anime $input #./gallery import $target $input ./gallery sync $target $input ./gallery thumbnail $target -./gallery dhash $target $HOME/Projects/fiv/build/hash +./gallery dhash $target ./gallery tag $target autotagger "DanBooru autotagger" \ < ../build-db/autotagger.tsv @@ -23,6 +23,10 @@ echo '{"sha1":"d53fc82162fd19a6e7b92b401b08b7505dbf3dfd"}' | \ curl http://localhost:8080/api/info -X POST --data-binary @- echo '{"sha1":"9539d9895ab8c25d76c321b23b8a327801a496bb"}' | \ curl http://localhost:8080/api/similar -X POST --data-binary @- +echo '{}' | \ +curl http://localhost:8080/api/duplicates -X POST --data-binary @- +echo '{}' | \ +curl http://localhost:8080/api/orphans -X POST --data-binary @- kill $web wait $web |