From 234c13ca9a4f111382b9167e647f6ca05da8f1d1 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Mon, 25 Dec 2023 09:54:07 +0100 Subject: Cleanup --- public/gallery.js | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'public') 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}))), ]) }, } -- cgit v1.2.3-70-g09d2