search shmearch
This commit is contained in:
parent
b54250f2fb
commit
c0669602dd
@ -40,6 +40,10 @@ html[theme='f0ck'] {
|
||||
--scroller-bg: #424242;
|
||||
}
|
||||
|
||||
html[theme="f0ck"] .admin-search button {
|
||||
color: var(--black)!important;
|
||||
}
|
||||
|
||||
html[theme='p1nk'] {
|
||||
--accent: #ff00d0;
|
||||
--bg: #171717;
|
||||
@ -146,6 +150,23 @@ html[theme='amoled'] {
|
||||
--scroller-bg: #424242;
|
||||
}
|
||||
|
||||
html[theme="amoled"] .admin-search button {
|
||||
color: var(--black)!important;
|
||||
}
|
||||
|
||||
html[theme="amoled"] table.table tbody tr:nth-of-type(2n+1) a {
|
||||
color: var(--white) !important;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
html[theme="amoled"] table.table tbody tr:nth-of-type(2n+1) {
|
||||
color: var(--white) !important;
|
||||
}
|
||||
|
||||
html[theme="amoled"] table.table a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
html[theme="paper"] {
|
||||
--accent: #000;
|
||||
--bg: #fff;
|
||||
@ -265,6 +286,28 @@ html[theme="paper"] span#favs {
|
||||
border: 1px solid var(--white);
|
||||
}
|
||||
|
||||
html[theme="paper"] .admin-search button {
|
||||
color: var(--white)!important;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
html[theme="paper"] table.table tbody tr:nth-of-type(2n+1) a {
|
||||
color: var(--white) !important;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
html[theme="paper"] table.table tbody tr:nth-of-type(2n+1) {
|
||||
color: var(--white) !important;
|
||||
}
|
||||
|
||||
html[theme="paper"] table.table a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
html[theme="paper"] a {
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
html[theme="atmos"] {
|
||||
--accent: #1fb2b0;
|
||||
--bg: #161618;
|
||||
@ -438,7 +481,7 @@ html, body {
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--accent) !important;
|
||||
color: var(--accent) /* !important */;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
@ -616,7 +659,7 @@ span.f0ck {
|
||||
border-radius: 3px;
|
||||
background-image: linear-gradient(to bottom,var(--nav-link-background-linear-gradient));
|
||||
box-shadow: var(--nav-link-box-shadow);
|
||||
color: transparent;
|
||||
/* color: transparent; */
|
||||
}
|
||||
|
||||
.navbar-expand-lg .navbar-nav .nav-link, .pagination > a, .pagination > span {
|
||||
@ -1729,4 +1772,13 @@ a[data-mime^="audio"] {
|
||||
|
||||
.admin-search input {
|
||||
padding: 15px;
|
||||
border: 1px solid var(--accent);
|
||||
}
|
||||
|
||||
table img {
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
.results {
|
||||
padding: 5px;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import db from "../sql.mjs";
|
||||
import lib from "../lib.mjs";
|
||||
import { exec } from "child_process";
|
||||
import search from "../routeinc/search.mjs";
|
||||
|
||||
const auth = async (req, res, next) => {
|
||||
if(!req.session) {
|
||||
@ -120,43 +119,6 @@ export default (router, tpl) => {
|
||||
}, req)
|
||||
});
|
||||
});
|
||||
|
||||
router.get(/^\/admin\/test(\/)?$/, auth, async (req, res) => {
|
||||
let ret;
|
||||
if(Object.keys(req.url.qs).length > 0) {
|
||||
let tag = req.url.qs.tag;
|
||||
let rows;
|
||||
|
||||
if(tag.startsWith('src:')) {
|
||||
tag = tag.substring(4);
|
||||
ret = await db`
|
||||
select *
|
||||
from "items"
|
||||
where src ilike ${'%' + tag + '%'}
|
||||
limit 500
|
||||
`;
|
||||
}
|
||||
else {
|
||||
rows = await db`
|
||||
select "items".id, "items".username, "tags".tag
|
||||
from "tags"
|
||||
left join "tags_assign" on "tags_assign".tag_id = "tags".id
|
||||
left join "items" on "items".id = "tags_assign".item_id
|
||||
where "tags".tag ilike ${'%' + tag + '%'}
|
||||
limit 500
|
||||
`;
|
||||
ret = search(rows, tag);
|
||||
}
|
||||
}
|
||||
|
||||
res.reply({
|
||||
body: tpl.render("admin/search", {
|
||||
result: ret,
|
||||
totals: await lib.countf0cks(),
|
||||
session: req.session
|
||||
}, req)
|
||||
});
|
||||
});
|
||||
|
||||
router.get(/^\/admin\/log(\/)?$/, auth, async (req, res) => {
|
||||
exec("journalctl -qeu f0ck --no-pager", (err, stdout) => {
|
||||
|
44
src/inc/routes/search.mjs
Normal file
44
src/inc/routes/search.mjs
Normal file
@ -0,0 +1,44 @@
|
||||
import db from "../sql.mjs";
|
||||
import lib from "../lib.mjs";
|
||||
import search from "../routeinc/search.mjs";
|
||||
|
||||
export default (router, tpl) => {
|
||||
router.get(/^\/search(\/)?$/, lib.auth, async (req, res) => {
|
||||
let ret;
|
||||
let tag = req.url.qs?.tag;
|
||||
if(Object.keys(req.url.qs).length > 0) {
|
||||
let rows;
|
||||
|
||||
if(tag.startsWith('src:')) {
|
||||
tag = tag.substring(4);
|
||||
ret = await db`
|
||||
select *
|
||||
from "items"
|
||||
where src ilike ${'%' + tag + '%'}
|
||||
limit 500
|
||||
`;
|
||||
}
|
||||
else {
|
||||
rows = await db`
|
||||
select "items".id, "items".username, "items".mime, "tags".tag
|
||||
from "tags"
|
||||
left join "tags_assign" on "tags_assign".tag_id = "tags".id
|
||||
left join "items" on "items".id = "tags_assign".item_id
|
||||
where "tags".tag ilike ${'%' + tag + '%'}
|
||||
limit 500
|
||||
`;
|
||||
ret = search(rows, tag);
|
||||
}
|
||||
}
|
||||
|
||||
res.reply({
|
||||
body: tpl.render("search", {
|
||||
result: ret,
|
||||
totals: await lib.countf0cks(),
|
||||
searchstring: tag,
|
||||
session: req.session,
|
||||
tmp: null
|
||||
}, req)
|
||||
});
|
||||
});
|
||||
};
|
@ -1,27 +0,0 @@
|
||||
@include(snippets/header_admin)
|
||||
<form action="/admin/test" style="margin-top: 15px;">
|
||||
<input type="text" name="tag" /><button type="submit">search</button>
|
||||
</form>
|
||||
<hr />
|
||||
@if(result)
|
||||
<h1>{{ result.length }} f0cks given</h1>
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="text-align: center;">Thumbnail</td>
|
||||
<td style="text-align: center;">ID</td>
|
||||
<td style="text-align: center;">Tag</td>
|
||||
<td style="text-align: center;">Username</td>
|
||||
<td style="text-align: center;">Score</td>
|
||||
</tr>
|
||||
@each(result as line)
|
||||
<tr>
|
||||
<td style="width: 128px;"><a href="/{{ line.id }}" target="_blank"><img src="/t/{{ line.id }}.webp" /></a></td>
|
||||
<td style="text-align: center;"><a href="/{{ line.id }}" target="_blank">{{ line.id }}</a></td>
|
||||
<td style="text-align: center;"><a href="/admin/test?tag={{ line.tag?.replace(/\s/g, "+") }}">{{ line.tag }}</a></td>
|
||||
<td style="text-align: center;">{{ line.username }}</td>
|
||||
<td style="text-align: center;">{{ line.score }}</td>
|
||||
</tr>
|
||||
@endeach
|
||||
</table>
|
||||
@endif
|
||||
@include(snippets/footer)
|
31
views/search.html
Normal file
31
views/search.html
Normal file
@ -0,0 +1,31 @@
|
||||
@include(snippets/header)
|
||||
<h1 style="text-align: center">f0ckgle</h1>
|
||||
<form action="/search" class="admin-search">
|
||||
<input type="text" name="tag" value="{!! searchstring !!}" /><button type="submit"><b>f0ck</b></button>
|
||||
</form>
|
||||
<div class="results">
|
||||
@if(result)
|
||||
<h1>{{ result.length }} f0cks given:</h1>
|
||||
<table style="width: 100%;" class="table">
|
||||
<tr>
|
||||
<th>Thumbnail</th>
|
||||
<th>ID</th>
|
||||
<th>Tag</th>
|
||||
<th>Mime</th>
|
||||
<th>Username</th>
|
||||
<th>Score</th>
|
||||
</tr>
|
||||
@each(result as line)
|
||||
<tr>
|
||||
<td style="width: 128px;"><a href="/tag/{!! line.tag !!}/{{ line.id }}" target="_blank"><img src="/t/{{ line.id }}.webp" /></a></td>
|
||||
<td style="text-align: center;"><a href="/tag/{!! line.tag !!}/{{ line.id }}" target="_blank">{{ line.id }}</a></td>
|
||||
<td style="text-align: center;"><a href="/tag/{!! line.tag !!}">{!! line.tag !!}</a></td>
|
||||
<td style="text-align: center;">{{ line.mime }}</td>
|
||||
<td style="text-align: center;"><a href="/user/{!! line.username !!}/f0cks/{{ line.id }}">{!! line.username !!}</a></td>
|
||||
<td style="text-align: center;">{{ line.score.toFixed(2) }}</td>
|
||||
</tr>
|
||||
@endeach
|
||||
</table>
|
||||
@endif
|
||||
</div>
|
||||
@include(snippets/footer)
|
@ -12,6 +12,7 @@
|
||||
<li><a href="/user/{{ session.user.toLowerCase() }}/f0cks">my f0cks</a></li>
|
||||
<li><a href="/user/{{ session.user.toLowerCase() }}/favs">my favs</a></li>
|
||||
<li><a href="/settings">settings</a></li>
|
||||
<li><a href="/search">search</a></li>
|
||||
<li><a href="/about">About</a></li>
|
||||
<li><a href="/ranking">Ranking</a></li>
|
||||
<li><a href="/logout">logout</a></li>
|
||||
|
@ -15,11 +15,6 @@
|
||||
<span class="nav-link-identifier">sessions</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/admin/test">
|
||||
<span class="nav-link-identifier">search (wip)</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/admin/log">
|
||||
<span class="nav-link-identifier">Log</span>
|
||||
|
Loading…
Reference in New Issue
Block a user