Add search bar

Add a search bar to the index page.
This commit is contained in:
Robin Malley 2020-12-29 19:10:35 +00:00
parent f58e7b958c
commit dae0f7b4bf
2 changed files with 4 additions and 3 deletions

View File

@ -25,14 +25,15 @@ local function get_site_home(req)
log(LOG_DEBUG,"Cache miss, rendering site index")
stmnt_index:bind_names{}
local latest = {}
for tagsr, idr, title, iar, dater, author in util.sql_rows(stmnt_index) do
for idr, title, iar, dater, author in util.sql_rows(stmnt_index) do
print("got:",tagsr,idr,title,iar,dater,author)
table.insert(latest,{
url = util.encode_id(idr),
title = title,
isanon = tonumber(iar) == 1,
posted = os.date("%B %d %Y",tonumber(dater)),
author = author,
tags = libtags.get(tagsr),
tags = libtags.get(idr),
})
end
return pages.index{

View File

@ -49,7 +49,7 @@
</td><td>
<ul class="row tag-list">
<% for i = 1,math.min(#v.tags, 5) do %>
<li><a class="tag button button-outline" href="https://<%= domain %>/_search?q=+<%= v.tags[i] %>"><%= v.tags[i] %></a></li>
<li><a class="tag button button-outline" href="https://<%= domain %>/_search?q=%2B<%= v.tags[i] %>"><%= v.tags[i] %></a></li>
<% end %>
<% if #v.tags > 5 then %>
<li>+<%= #v.tags - 5 %></li>