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") log(LOG_DEBUG,"Cache miss, rendering site index")
stmnt_index:bind_names{} stmnt_index:bind_names{}
local latest = {} 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,{ table.insert(latest,{
url = util.encode_id(idr), url = util.encode_id(idr),
title = title, title = title,
isanon = tonumber(iar) == 1, isanon = tonumber(iar) == 1,
posted = os.date("%B %d %Y",tonumber(dater)), posted = os.date("%B %d %Y",tonumber(dater)),
author = author, author = author,
tags = libtags.get(tagsr), tags = libtags.get(idr),
}) })
end end
return pages.index{ return pages.index{

View File

@ -49,7 +49,7 @@
</td><td> </td><td>
<ul class="row tag-list"> <ul class="row tag-list">
<% for i = 1,math.min(#v.tags, 5) do %> <% 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 %> <% end %>
<% if #v.tags > 5 then %> <% if #v.tags > 5 then %>
<li>+<%= #v.tags - 5 %></li> <li>+<%= #v.tags - 5 %></li>