summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-12-22 23:46:27 +0100
committerPřemysl Eric Janouch <p@janouch.name>2023-12-22 23:46:27 +0100
commit42a57b3271575fd323068bf8b9108d00f0b4a5b3 (patch)
tree0b5e3e25d68d1d49e1f533cb3a7e1141796b1d42 /public
parent0b5d388af213680d0def2c03d3c8814c3e2ceaa2 (diff)
downloadgallery-42a57b3271575fd323068bf8b9108d00f0b4a5b3.tar.gz
gallery-42a57b3271575fd323068bf8b9108d00f0b4a5b3.tar.xz
gallery-42a57b3271575fd323068bf8b9108d00f0b4a5b3.zip
WIP: Global duplicate search
Diffstat (limited to 'public')
-rw-r--r--public/gallery.js57
-rw-r--r--public/style.css3
2 files changed, 58 insertions, 2 deletions
diff --git a/public/gallery.js b/public/gallery.js
index ee11858..009eb1e 100644
--- a/public/gallery.js
+++ b/public/gallery.js
@@ -213,7 +213,7 @@ let View = {
m(m.route.Link, {
href: `/similar/:key`,
params: {key: ViewModel.sha1},
- }, "Similar")
+ }, "Similar"),
]),
m('.body', {}, [view, m(ViewBar)]),
])
@@ -302,7 +302,7 @@ let Similar = {
m(m.route.Link, {
href: `/view/:key`,
params: {key: SimilarModel.sha1},
- }, "View")
+ }, "View"),
]),
m('.body', {}, m(SimilarList)),
])
@@ -311,6 +311,58 @@ let Similar = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+let DuplicatesModel = {
+ entries: [],
+
+ async reload() {
+ this.entries = await call('duplicates', {})
+ },
+}
+
+let DuplicatesThumbnail = {
+ view(vnode) {
+ const info = vnode.attrs.info
+ return [
+ m(m.route.Link, {href: `/similar/${info.sha1}`},
+ m('img', {src: `/thumb/${info.sha1}`,
+ width: info.thumbW, height: info.thumbH})),
+ info.occurences,
+ ]
+ },
+}
+
+let DuplicatesList = {
+ view(vnode) {
+ if (DuplicatesModel.entries.length == 0)
+ return "No duplicates"
+
+ return m('.duplicates', {}, DuplicatesModel.entries.map(entry =>
+ m('.row', [
+ m(DuplicatesThumbnail, {info: entry.main}),
+ entry.similar.map(entry =>
+ m(DuplicatesThumbnail, {info: entry})),
+ ]),
+ ))
+ },
+}
+
+let Duplicates = {
+ oninit(vnode) {
+ DuplicatesModel.reload()
+ },
+
+ view(vnode) {
+ return m('.container', {}, [
+ m('.header', {}, [
+ "Duplicates",
+ ]),
+ m('.body', {}, m(DuplicatesList)),
+ ])
+ },
+}
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
window.addEventListener('load', () => {
m.route(document.body, "/browse/", {
// The path doesn't need to be escaped, perhaps change that (":key...").
@@ -318,6 +370,7 @@ window.addEventListener('load', () => {
"/browse/:key": Browse,
"/view/:key": View,
"/similar/:key": Similar,
+ "/duplicates": Duplicates,
"/tags": undefined,
"/tags/:space": undefined,
diff --git a/public/style.css b/public/style.css
index d6c2e3f..d18735d 100644
--- a/public/style.css
+++ b/public/style.css
@@ -54,3 +54,6 @@ ul.sidebar li.child a {
.similar h2 { margin: 1em 0 0.5em 0; padding: 0; font-size: 1.2rem; }
.similar .row { display: flex; }
.similar .row ul { margin: 0; padding: 0 0 0 1.25em; list-style-type: "- "; }
+
+.duplicates { padding: .5rem; flex-grow: 1; overflow: auto; }
+.duplicates .row { display: flex; }