|
a/webui.py |
|
b/webui.py |
|
... |
|
... |
147 |
'before': select([bottle.request.query.get('before'), '']),
|
147 |
'before': select([bottle.request.query.get('before'), '']),
|
148 |
'after': select([bottle.request.query.get('after'), '']),
|
148 |
'after': select([bottle.request.query.get('after'), '']),
|
149 |
'dir': select([bottle.request.query.get('dir'), '', '<all>'], [None, '']),
|
149 |
'dir': select([bottle.request.query.get('dir'), '', '<all>'], [None, '']),
|
150 |
'sort': select([bottle.request.query.get('sort'), SORTS[0][0]]),
|
150 |
'sort': select([bottle.request.query.get('sort'), SORTS[0][0]]),
|
151 |
'ascending': int(select([bottle.request.query.get('ascending'), 0])),
|
151 |
'ascending': int(select([bottle.request.query.get('ascending'), 0])),
|
152 |
'page': int(select([bottle.request.query.get('page'), 1])),
|
152 |
'page': int(select([bottle.request.query.get('page'), 0])),
|
153 |
}
|
153 |
}
|
154 |
return query
|
154 |
return query
|
155 |
#}}}
|
155 |
#}}}
|
156 |
#{{{ query_to_recoll_string
|
156 |
#{{{ query_to_recoll_string
|
157 |
def query_to_recoll_string(q):
|
157 |
def query_to_recoll_string(q):
|
|
... |
|
... |
178 |
nres = 0
|
178 |
nres = 0
|
179 |
if config['maxresults'] == 0:
|
179 |
if config['maxresults'] == 0:
|
180 |
config['maxresults'] = nres
|
180 |
config['maxresults'] = nres
|
181 |
if nres > config['maxresults']:
|
181 |
if nres > config['maxresults']:
|
182 |
nres = config['maxresults']
|
182 |
nres = config['maxresults']
|
183 |
if config['perpage'] == 0:
|
183 |
if config['perpage'] == 0 or q['page'] == 0:
|
184 |
config['perpage'] = nres
|
184 |
config['perpage'] = nres
|
|
|
185 |
q['page'] = 1
|
185 |
offset = (q['page'] - 1) * config['perpage']
|
186 |
offset = (q['page'] - 1) * config['perpage']
|
186 |
query.next = offset
|
187 |
query.next = offset
|
187 |
while query.next >= 0 and query.next < offset + config['perpage'] and query.next < nres:
|
188 |
while query.next >= 0 and query.next < offset + config['perpage'] and query.next < nres:
|
188 |
doc = query.fetchone()
|
189 |
doc = query.fetchone()
|
189 |
d = {}
|
190 |
d = {}
|
|
... |
|
... |
230 |
#}}}
|
231 |
#}}}
|
231 |
#{{{ json
|
232 |
#{{{ json
|
232 |
@bottle.route('/json')
|
233 |
@bottle.route('/json')
|
233 |
def get_json():
|
234 |
def get_json():
|
234 |
query = get_query()
|
235 |
query = get_query()
|
|
|
236 |
query['page'] = 0
|
235 |
qs = query_to_recoll_string(query)
|
237 |
qs = query_to_recoll_string(query)
|
236 |
bottle.response.headers['Content-Type'] = 'application/json'
|
238 |
bottle.response.headers['Content-Type'] = 'application/json'
|
237 |
bottle.response.headers['Content-Disposition'] = 'attachment; filename=recoll-%s.json' % normalise_filename(qs)
|
239 |
bottle.response.headers['Content-Disposition'] = 'attachment; filename=recoll-%s.json' % normalise_filename(qs)
|
238 |
res, nres, timer = recoll_search(query)
|
240 |
res, nres, timer = recoll_search(query)
|
239 |
|
241 |
|
|
... |
|
... |
241 |
#}}}
|
243 |
#}}}
|
242 |
#{{{ csv
|
244 |
#{{{ csv
|
243 |
@bottle.route('/csv')
|
245 |
@bottle.route('/csv')
|
244 |
def get_csv():
|
246 |
def get_csv():
|
245 |
query = get_query()
|
247 |
query = get_query()
|
|
|
248 |
query['page'] = 0
|
246 |
qs = query_to_recoll_string(query)
|
249 |
qs = query_to_recoll_string(query)
|
247 |
bottle.response.headers['Content-Type'] = 'text/csv'
|
250 |
bottle.response.headers['Content-Type'] = 'text/csv'
|
248 |
bottle.response.headers['Content-Disposition'] = 'attachment; filename=recoll-%s.csv' % normalise_filename(qs)
|
251 |
bottle.response.headers['Content-Disposition'] = 'attachment; filename=recoll-%s.csv' % normalise_filename(qs)
|
249 |
res, nres, timer = recoll_search(query)
|
252 |
res, nres, timer = recoll_search(query)
|
250 |
si = StringIO.StringIO()
|
253 |
si = StringIO.StringIO()
|