Switch to unified view

a/webui.py b/webui.py
...
...
11
import csv
11
import csv
12
import StringIO
12
import StringIO
13
import ConfigParser
13
import ConfigParser
14
import string
14
import string
15
import shlex
15
import shlex
16
import urllib
16
from pprint import pprint
17
from pprint import pprint
17
#}}}
18
#}}}
18
#{{{ settings
19
#{{{ settings
19
# recoll settings
20
# recoll settings
20
RECOLL_CONFS = [ '~/.recoll/recoll.conf', '/etc/recoll.conf' ]
21
RECOLL_CONFS = [ '~/.recoll/recoll.conf', '/etc/recoll.conf' ]
...
...
109
    # get useful things from recoll.conf
110
    # get useful things from recoll.conf
110
    config['dirs'] = shlex.split(rc['main']['topdirs'])
111
    config['dirs'] = shlex.split(rc['main']['topdirs'])
111
    # get config from cookies or defaults
112
    # get config from cookies or defaults
112
    for k, v in DEFAULTS.items():
113
    for k, v in DEFAULTS.items():
113
        config[k] = select([bottle.request.get_cookie(k), v])
114
        config[k] = select([bottle.request.get_cookie(k), v])
115
    # get mountpoints
116
    config['mounts'] = {}
117
    for d in config['dirs']:
118
        name = 'mount_%s' % urllib.quote(d,'')
119
        config['mounts'][d] = select([bottle.request.get_cookie(name), 'file://%s' % d], [None, ''])
114
    return config
120
    return config
115
#}}}
121
#}}}
116
#{{{ get_dirs
122
#{{{ get_dirs
117
def get_dirs(tops, depth):
123
def get_dirs(tops, depth):
118
    v = []
124
    v = []
...
...
235
def settings():
241
def settings():
236
    return get_config()
242
    return get_config()
237
243
238
@bottle.route('/set')
244
@bottle.route('/set')
239
def set():
245
def set():
246
    config = get_config()
240
    for k, v in DEFAULTS.items():
247
    for k, v in DEFAULTS.items():
241
        bottle.response.set_cookie(k, str(bottle.request.query.get(k)), max_age=3153600000)
248
        bottle.response.set_cookie(k, str(bottle.request.query.get(k)), max_age=3153600000)
249
    for d in config['dirs']:
250
        cookie_name = 'mount_%s' % urllib.quote(d, '')
251
        bottle.response.set_cookie(cookie_name, str(bottle.request.query.get('mount_%s' % d)), max_age=3153600000)
242
    bottle.redirect('..')
252
    bottle.redirect('..')
243
#}}}
253
#}}}
244
#}}}
254
#}}}
245
# vim: fdm=marker:tw=80:ts=4:sw=4:sts=4:et
255
# vim: fdm=marker:tw=80:ts=4:sw=4:sts=4:et