ikibooru/search.html.l
2024-06-01 17:40:11 +03:00

46 lines
1.6 KiB
Plaintext

{%
local tagids = {}
if request.querystring.t then
for tagid in string.gmatch(Escapes.urlunescape(request.querystring.t), "%d+") do
table.insert(tagids, tonumber(tagid))
end
end
local namefilter = request.querystring.n and Escapes.urlspunescape(request.querystring.n) or ""
if namefilter and namefilter:match"^%s*$" then namefilter = nil end
local offset = request.querystring.off and DB.objshowid(Escapes.urlunescape(request.querystring.off)) or 0
local adultcontent = BigGlobe.cfg.enable18plus and tonumber(request.querystring.a) or -1
title = BigGlobe.cfg.sitename .. " - search"
%}
{% function content() %}
<div style="text-align:center;width:90%;margin-left:5%;margin-top:10%;">
{% local found = DB.searchobjs(tagids, namefilter, offset, adultcontent) %}
{% if #found == 0 then %}
<p>No results.</p>
{% else %}
{% for i=#found,1,-1 do local o = found[i] %}
{% local pub = DB.objhideid(o.id) %}
<a href="/obji/{{ pub }}" class="searchitem"><div>
<img loading="lazy" src="/objd/{{ pub }}/.thumb.jpg" />
<p>{{ Escapes.htmlescape(o.name) }}</p>
</div></a>
{% end %}
{% if #found >= 50 then %}
<form action="/search" method="GET" style="margin-top:2em;">
<input type="hidden" name="n" value="{{ Escapes.htmlescape(namefilter) }}" />
<input type="hidden" name="t" value="{{ Escapes.htmlescape(table.concat(tagids, ",")) }}" />
<input type="hidden" name="off" value="{{ DB.objhideid(found[#found].id) }}" />
<input type="submit" value="Next" />
</form>
{% end %}
{% end %}
</div>
{% end %}
{# base.inc