1
0
Fork 0
mirror of https://github.com/koniu/recoll-webui.git synced 2025-10-03 09:49:25 +02:00

py: disable pagination for json/csv

This commit is contained in:
koniu 2012-12-23 10:08:10 +00:00
parent 753f35de80
commit 375800bbf6

View file

@ -149,7 +149,7 @@ def get_query():
'dir': select([bottle.request.query.get('dir'), '', '<all>'], [None, '']), 'dir': select([bottle.request.query.get('dir'), '', '<all>'], [None, '']),
'sort': select([bottle.request.query.get('sort'), SORTS[0][0]]), 'sort': select([bottle.request.query.get('sort'), SORTS[0][0]]),
'ascending': int(select([bottle.request.query.get('ascending'), 0])), 'ascending': int(select([bottle.request.query.get('ascending'), 0])),
'page': int(select([bottle.request.query.get('page'), 1])), 'page': int(select([bottle.request.query.get('page'), 0])),
} }
return query return query
#}}} #}}}
@ -180,8 +180,9 @@ def recoll_search(q):
config['maxresults'] = nres config['maxresults'] = nres
if nres > config['maxresults']: if nres > config['maxresults']:
nres = config['maxresults'] nres = config['maxresults']
if config['perpage'] == 0: if config['perpage'] == 0 or q['page'] == 0:
config['perpage'] = nres config['perpage'] = nres
q['page'] = 1
offset = (q['page'] - 1) * config['perpage'] offset = (q['page'] - 1) * config['perpage']
query.next = offset query.next = offset
while query.next >= 0 and query.next < offset + config['perpage'] and query.next < nres: while query.next >= 0 and query.next < offset + config['perpage'] and query.next < nres:
@ -232,6 +233,7 @@ def results():
@bottle.route('/json') @bottle.route('/json')
def get_json(): def get_json():
query = get_query() query = get_query()
query['page'] = 0
qs = query_to_recoll_string(query) qs = query_to_recoll_string(query)
bottle.response.headers['Content-Type'] = 'application/json' bottle.response.headers['Content-Type'] = 'application/json'
bottle.response.headers['Content-Disposition'] = 'attachment; filename=recoll-%s.json' % normalise_filename(qs) bottle.response.headers['Content-Disposition'] = 'attachment; filename=recoll-%s.json' % normalise_filename(qs)
@ -243,6 +245,7 @@ def get_json():
@bottle.route('/csv') @bottle.route('/csv')
def get_csv(): def get_csv():
query = get_query() query = get_query()
query['page'] = 0
qs = query_to_recoll_string(query) qs = query_to_recoll_string(query)
bottle.response.headers['Content-Type'] = 'text/csv' bottle.response.headers['Content-Type'] = 'text/csv'
bottle.response.headers['Content-Disposition'] = 'attachment; filename=recoll-%s.csv' % normalise_filename(qs) bottle.response.headers['Content-Disposition'] = 'attachment; filename=recoll-%s.csv' % normalise_filename(qs)