author | Tero Marttila <terom@fixme.fi> |
Tue, 10 Feb 2009 00:19:56 +0200 | |
changeset 75 | c5ce145fdd70 |
parent 74 | 1ab95857d584 |
child 76 | cc3ab2c39ded |
permissions | -rw-r--r-- |
63 | 1 |
<%inherit file="channel.tmpl" /> |
2 |
||
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
3 |
<%def name="paginate(url, count, page_cur, page_max, _more=None, _last=False, **args)"> |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
4 |
<%doc> |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
5 |
Pagination works using page numbers, with a specific number of maximum pages displayed. If _more is True, |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
6 |
then instead of a "Next" button, we have a "More" button, which goes to the max+1'th page, unless _last is |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
7 |
True, whereupon it's not displayed |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
8 |
</%doc> |
73
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
9 |
<div class="paginate"> |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
10 |
<ul> |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
11 |
<li> |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
12 |
% if page_cur > 1 : |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
13 |
<a href="${h.build_url(url, count=count, page=page_cur-1, max=max, **args)}">« Prev</a> |
73
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
14 |
% else : |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
15 |
<span>« Prev</span> |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
16 |
%endif |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
17 |
</li> |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
18 |
% for page in xrange(1, page_max + 1) : |
73
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
19 |
<li> |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
20 |
% if page == page_cur : |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
21 |
<strong>${page}</strong> |
73
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
22 |
% else : |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
23 |
<a href="${h.build_url(url, count=count, page=page, max=page_max, **args)}">${page}</a> |
73
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
24 |
% endif |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
25 |
</li> |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
26 |
% endfor |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
27 |
<li> |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
28 |
% if _more and _last : |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
29 |
<span>More »</span> |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
30 |
% elif _more : |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
31 |
<a href="${h.build_url(url, count=count, page=page_max+1, **args)}">More »</a> |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
32 |
% elif page_cur == page_max : ## last page |
74
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
33 |
<span>Next »</span> |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
34 |
% else : |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
35 |
<a href="${h.build_url(url, count=count, page=page+1, **args)}">Next »</a> |
74
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
36 |
% endif |
73
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
37 |
</li> |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
38 |
</ul> |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
39 |
</div> |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
40 |
</%def> |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
41 |
|
65 | 42 |
% if not search_query : |
63 | 43 |
<div id="title">${channel.title} :: Search</div> |
44 |
||
68 | 45 |
<div id="search"> |
46 |
<form action="${h.build_url(urls.channel_search, channel=channel)}" method="GET"> |
|
63 | 47 |
<input type="text" name="q" /> |
48 |
<input type="submit" value="Search" /> |
|
68 | 49 |
|
50 |
Results/page: <select name="count"> |
|
73
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
51 |
% for cc, cc_label in config.SEARCH_LINE_COUNT_OPTIONS : |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
52 |
<option value="${cc if cc else ''}"${' selected="selected"' if cc == count else ''}>${cc_label}</option> |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
53 |
% endfor |
68 | 54 |
</select> |
55 |
</form> |
|
56 |
||
57 |
<div id="search-help"> |
|
58 |
<p>Search powered by <a href="http://hyperestraier.sourceforge.net/">Hyper Estraier</a>:</p> |
|
63 | 59 |
|
68 | 60 |
<ul> |
61 |
<li>Group words together using quotes: <tt>"united nations"</tt></li> |
|
62 |
<li>Searching for multiple words is AND: <tt>internet security</tt></li> |
|
63 |
<li>To exclude terms, use <strong>!</strong> : <tt>hacker ! cracker</tt></li> |
|
64 |
<li>Union (i.e. <q>or</q>) using <strong>|</strong> : <tt>proxy | firewall</tt></li> |
|
65 |
<li>Search is case-insensitive</li> |
|
66 |
</ul> |
|
67 |
</div> |
|
68 |
</div> |
|
63 | 69 |
|
70 |
% else : |
|
65 | 71 |
<div id="title">${channel.title} :: Search '${search_query}'</div> |
63 | 72 |
|
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
73 |
${paginate(urls.channel_search, count, page, max, channel=channel, q=search_query, _more=True, _last=not(bool(lines)))} |
74
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
74 |
% if lines : |
69 | 75 |
<%include file="lines.tmpl" /> |
74
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
76 |
% else : |
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
77 |
<div id="search-error">No results found</div> |
63 | 78 |
% endif |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
79 |
${paginate(urls.channel_search, count, page, max, channel=channel, q=search_query, _more=True, _last=not(bool(lines)))} |
74
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
80 |
% endif |