aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.sum2
-rw-r--r--main.go17
-rw-r--r--public/gallery.js39
-rwxr-xr-xtest.sh6
4 files changed, 61 insertions, 3 deletions
diff --git a/go.sum b/go.sum
index 59d9ac4..8562c23 100644
--- a/go.sum
+++ b/go.sum
@@ -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=
diff --git a/main.go b/main.go
index c9fef9a..0c8dd32 100644
--- a/main.go
+++ b/main.go
@@ -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(&params); 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,
diff --git a/test.sh b/test.sh
index 3609de4..84d4016 100755
--- a/test.sh
+++ b/test.sh
@@ -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