|
a/views/results.tpl |
|
b/views/results.tpl |
1 |
%import shlex, unicodedata
|
|
|
2 |
%def strip_accents(s): return ''.join((c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn'))
|
|
|
3 |
%include header title=": " + query['query']+" ("+str(nres)+")"
|
1 |
%include header title=": " + query['query']+" ("+str(nres)+")"
|
4 |
%include search query=query, dirs=dirs, sorts=sorts
|
2 |
%include search query=query, dirs=dirs, sorts=sorts
|
5 |
<div id="status">
|
3 |
<div id="status">
|
6 |
<div id="found">
|
4 |
<div id="found">
|
7 |
Found <b>{{nres}}</b> matching: <b><i>{{qs}}</i></b>
|
5 |
Found <b>{{nres}}</b> matching: <b><i>{{qs}}</i></b>
|
|
... |
|
... |
16 |
<br style="clear: both">
|
14 |
<br style="clear: both">
|
17 |
</div>
|
15 |
</div>
|
18 |
%include pages query=query, config=config, nres=nres
|
16 |
%include pages query=query, config=config, nres=nres
|
19 |
<div id="results">
|
17 |
<div id="results">
|
20 |
%for i in range(0, len(res)):
|
18 |
%for i in range(0, len(res)):
|
21 |
%d = res[i]
|
19 |
%include result d=res[i], i=i, query=query, config=config,
|
22 |
<div class="search-result">
|
|
|
23 |
%number = (query['page'] - 1)*config['perpage'] + i + 1
|
|
|
24 |
<div class="search-result-number"><a href="#r{{d['sha']}}">#{{number}}</a></div>
|
|
|
25 |
%url = d['url'].replace('file://', '')
|
|
|
26 |
%for dr, prefix in config['mounts'].items():
|
|
|
27 |
%url = url.replace(dr, prefix)
|
|
|
28 |
%end
|
|
|
29 |
<div class="search-result-title" id="r{{d['sha']}}" title="{{d['abstract']}}"><a href="{{url}}">{{d['label']}}</a></div>
|
|
|
30 |
%if len(d['ipath']) > 0:
|
|
|
31 |
<div class="search-result-ipath">[{{d['ipath']}}]</div>
|
|
|
32 |
%end
|
|
|
33 |
%if len(d['author']) > 0:
|
|
|
34 |
<div class="search-result-author">{{d['author']}}</div>
|
|
|
35 |
%end
|
|
|
36 |
<div class="search-result-url">
|
|
|
37 |
%urllabel = d['url'].replace('/'+d['filename'],'').replace('file://','')
|
|
|
38 |
%for r in config['dirs']:
|
|
|
39 |
%urllabel = urllabel.replace(r.rsplit('/',1)[0] + '/' , '')
|
|
|
40 |
%end
|
|
|
41 |
<a href="{{url.replace('/'+d['filename'],'')}}">{{urllabel}}</a>
|
|
|
42 |
</div>
|
|
|
43 |
<div class="search-result-date">{{d['time']}}</div>
|
|
|
44 |
%for q in shlex.split(query['query'].replace("'","\\'")):
|
|
|
45 |
%if not q == "OR":
|
|
|
46 |
% w = strip_accents(q.decode('utf-8').lower()).encode('utf-8')
|
|
|
47 |
% d['snippet'] = d['snippet'].replace(w,'<span class="search-result-highlight">'+w+'</span>')
|
|
|
48 |
%end
|
|
|
49 |
%end
|
|
|
50 |
<div class="search-result-snippet">{{!d['snippet']}}</div>
|
|
|
51 |
</div>
|
|
|
52 |
%end
|
20 |
%end
|
53 |
</div>
|
21 |
</div>
|
54 |
%include pages query=query, config=config, nres=nres
|
22 |
%include pages query=query, config=config, nres=nres
|
55 |
%include footer
|
23 |
%include footer
|
56 |
<!-- vim: fdm=marker:tw=80:ts=4:sw=4:sts=4:et:ai
|
24 |
<!-- vim: fdm=marker:tw=80:ts=4:sw=4:sts=4:et:ai
|