forked from f0ck/f0ckv2
add tag page
This commit is contained in:
parent
b29537d6d8
commit
69ca852379
@ -103,4 +103,25 @@ html[theme="f0ck"] .image-brand {
|
||||
|
||||
.v0ck_overlay {
|
||||
background-color: none !important;
|
||||
}
|
||||
|
||||
.tags {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
.tags { grid-template-columns: repeat(2, 1fr); }
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
.tags { grid-template-columns: repeat(3, 1fr); }
|
||||
}
|
||||
|
||||
.tag {
|
||||
box-shadow: 1px 1px 1px black;
|
||||
display: grid;
|
||||
grid-template-rows: auto;
|
||||
grid-template-columns: 1fr auto;
|
||||
margin: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
29
src/inc/routes/toptags.mjs
Normal file
29
src/inc/routes/toptags.mjs
Normal file
@ -0,0 +1,29 @@
|
||||
import db from "../../inc/sql.mjs";
|
||||
import cfg from "../../inc/config.mjs";
|
||||
import f0cklib from "../routeinc/f0cklib.mjs";
|
||||
|
||||
export default (router, tpl) => {
|
||||
router.get(/^\/tags$/, async (req, res) => {
|
||||
|
||||
const phrase = cfg.websrv.phrases[~~(Math.random() * cfg.websrv.phrases.length)];
|
||||
|
||||
const toptags = await db`
|
||||
SELECT t.id, t.tag, COUNT(DISTINCT ta.item_id) AS total_items
|
||||
FROM tags t
|
||||
LEFT JOIN tags_assign ta ON t.id = ta.tag_id
|
||||
GROUP BY t.id, t.tag
|
||||
ORDER BY total_items DESC
|
||||
LIMIT 500
|
||||
;
|
||||
`;
|
||||
|
||||
res.reply({
|
||||
body: tpl.render('tags', {
|
||||
toptags,
|
||||
phrase,
|
||||
tmp: null
|
||||
}, req)
|
||||
});
|
||||
});
|
||||
return router;
|
||||
};
|
15
views/tags.html
Normal file
15
views/tags.html
Normal file
@ -0,0 +1,15 @@
|
||||
@include(snippets/header)
|
||||
<div id="main">
|
||||
<div class="container">
|
||||
<h3 style="text-align: center;">{{ phrase }}</h3>
|
||||
<div class="tags">
|
||||
@each(toptags as toptag)
|
||||
<div class="tag badge badge-light mr-2">
|
||||
<span class="toptag_id">{!! toptag.tag !!}</span>
|
||||
<span class="toptag_tag"><a href="/tag/{!! toptag.tag !!}">{{ toptag.total_items }}</a></span>
|
||||
</div>
|
||||
@endeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@include(snippets/footer)
|
Loading…
x
Reference in New Issue
Block a user