Skip to content

Commit e2ec130

Browse files
committed
result page
1 parent 5cff055 commit e2ec130

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def search(query_string=dict()):
299299
pagejobs = list(getrows_byslice(res, pageQty))
300300
page = max(min(int(query_string.get('page', ['0'])[0]), len(pagejobs)-1),0)
301301
print('search pages=%d page=%d q=%s' % (len(pagejobs), page, plain))
302-
return ( template_lookup.get_template("/results.html").render(jobs=pagejobs[page], page=page, pages=len(pagejobs), query=plain), 'text/html')
302+
return ( template_lookup.get_template("/results.html").render(jobs=pagejobs, page=page, pages=len(pagejobs), query=plain), 'text/html')
303303

304304
def plain(query_string=dict()):
305305
job = getJob(query_string, returnLast=True)

web/results.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
<%inherit file="bootstrap.html"/>
3+
<%block name="title">- Recent</%block>
4+
<%block name="query_block">
5+
<input type="text" name="query" class="search-query span2" placeholder="Search" value="${query}"/>
6+
</%block>
7+
8+
<h3>Search Results ${query}</h3>
9+
10+
% if len(jobs) == 0:
11+
<h4>No search results!</h4>
12+
% elif page > len(jobs):
13+
<h4>Bad job page index ${page}</h4>
14+
% else:
15+
<% jobpage = jobs[page] %>
16+
17+
<table class="table table-striped table-condensed" style="width: 100%; white-space: nowrap; table-layout: fixed;">
18+
<colgroup>
19+
<col width="20%" />
20+
<col width="15%" />
21+
<col width="10%" />
22+
<col width="55%" />
23+
</colgroup>
24+
25+
<tr><th>Job</th><th>Time</th><th>Stationary</th><th>Preview</th></tr>
26+
<% xstr = lambda s: s or '' %>
27+
% for j in jobpage:
28+
<tr>
29+
<td>
30+
% if j['templ']:
31+
<a href="/pdf?name=${j['name']}">
32+
% else:
33+
<a href="/plaintext?name=${j['name']}">
34+
% endif
35+
${xstr(j['control'].get('H'))|h} ${j['doctype']|h}</a></td>
36+
<td>${str(j['ts'])[0:19]|h}</td>
37+
% if j['templ']:
38+
<td>${xstr(j['templ'])} (${len(j.get('parsed', {}).keys())})</td>
39+
% else:
40+
<td></td>
41+
% endif
42+
43+
<td style="overflow: hidden; text-overflow: ellipsis">${j['summary']|h}</td>
44+
</tr>
45+
% endfor
46+
</table>
47+
48+
% endif
49+
50+
<ul class="pager">
51+
% if page < pages-1:
52+
<li class="previous"> <a href="?page=${page+1}">&larr; Older</a> </li>
53+
% else:
54+
<li class="previous disabled"> <span>&larr; Older</span> </li>
55+
% endif
56+
% if page > 0:
57+
<li class="next"> <a href="?page=${page-1}">Newer &rarr;</a> </li>
58+
% else:
59+
<li class="next disabled"> <span>Newer &rarr;</span> </li>
60+
% endif
61+
</ul>
62+

0 commit comments

Comments
 (0)