diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-12-25 09:54:07 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-12-25 09:54:07 +0100 |
commit | 234c13ca9a4f111382b9167e647f6ca05da8f1d1 (patch) | |
tree | 0c15900490f71d0c70853d914c84f84e3bc9b165 | |
parent | 552c9f527a778443a593d11e5ce991a8513a18c1 (diff) | |
download | gallery-234c13ca9a4f111382b9167e647f6ca05da8f1d1.tar.gz gallery-234c13ca9a4f111382b9167e647f6ca05da8f1d1.tar.xz gallery-234c13ca9a4f111382b9167e647f6ca05da8f1d1.zip |
Cleanup
-rw-r--r-- | public/gallery.js | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/public/gallery.js b/public/gallery.js index 3c64bac..99bfe0b 100644 --- a/public/gallery.js +++ b/public/gallery.js @@ -89,6 +89,20 @@ let Thumbnail = { }, } +let ScoredTag = { + view(vnode) { + const {space, tagname, score} = vnode.attrs + return m('li', [ + m("meter[max=1.0]", {value: score, title: score}, score), + ` `, + m(m.route.Link, { + href: `/search/:key`, + params: {key: `${space}:${tagname}`}, + }, ` ${tagname}`), + ]) + }, +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - let BrowseModel = { @@ -439,20 +453,12 @@ let ViewBar = { m('ul', ViewModel.paths.map(path => m('li', m(ViewBarPath, {path})))), m('h2', "Tags"), - Object.entries(ViewModel.tags).map(([group, tags]) => [ - m("h3", m(m.route.Link, {href: `/tags/${group}`}, group)), + Object.entries(ViewModel.tags).map(([space, tags]) => [ + m("h3", m(m.route.Link, {href: `/tags/${space}`}, space)), m("ul.tags", Object.entries(tags) .sort(([t1, w1], [t2, w2]) => (w2 - w1)) - .map(([tag, weight]) => m("li", [ - // XXX: Duplicated with SearchRelated. - m("meter[max=1.0]", - {value: weight, title: weight}, weight), - ` `, - m(m.route.Link, { - href: `/search/:key`, - params: {key: `${group}:${tag}`}, - }, ` ${tag}`), - ]))), + .map(([tag, score]) => + m(ScoredTag, {space, tagname: tag, score}))), ]), ]) }, @@ -588,16 +594,8 @@ let SearchRelated = { m('h2', space), m('ul.tags', tags .sort((a, b) => (b.score - a.score)) - .map(({tag, score}) => m('li', [ - // XXX: Duplicated with ViewBar. - m("meter[max=1.0]", - {value: score, title: score}, score), - ` `, - m(m.route.Link, { - href: `/search/:key`, - params: {key: `${space}:${tag}`}, - }, ` ${tag}`), - ]))), + .map(({tag, score}) => + m(ScoredTag, {space, tagname: tag, score}))), ]) }, } |