%import shlex, unicodedata %def strip_accents(s): return ''.join((c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn')) %include header title=": " + query['keywords']+" ("+str(len(res))+")" %include search query=query, dirs=dirs, sorts=sorts
Found {{len(res)}} matching: {{qs}} ({{time.seconds}}.{{time.microseconds/10000}}s)
%if len(res) > 0:
JSON CSV
%end
%for i in range(0, len(res)): %d = res[i]
%url = d['url'].replace('file://', '') %for dr, prefix in config['mounts'].items(): %url = url.replace(dr, prefix) %end %if len(d['ipath']) > 0:
[{{d['ipath']}}]
%end %if len(d['author']) > 0:
{{d['author']}}
%end
%urllabel = d['url'].replace('/'+d['filename'],'').replace('file://','') %for r in config['dirs']: %urllabel = urllabel.replace(r.rsplit('/',1)[0] + '/' , '') %end {{urllabel}}
{{d['time']}}
%for q in shlex.split(query['keywords'].replace("'","\\'")): %if not q == "OR": % w = strip_accents(q.decode('utf-8').lower()).encode('utf-8') % d['snippet'] = d['snippet'].replace(w,''+w+'') %end %end
{{!d['snippet']}}
%end
%include footer