Switch to unified view

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