aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/gallery.js42
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}))),
])
},
}