Switch to unified view

a/webui.py b/webui.py
...
...
163
        query.execute(qs, config['stem'], config['stemlang'])
163
        query.execute(qs, config['stem'], config['stemlang'])
164
    except:
164
    except:
165
        pass
165
        pass
166
    return query
166
    return query
167
#}}}
167
#}}}
168
#{{{ HlMeths
169
class HlMeths:
170
    def startMatch(self, idx):
171
        return '<span class="search-result-highlight">'
172
    def endMatch(self):
173
        return '</span>'
174
#}}}
168
#{{{ recoll_search
175
#{{{ recoll_search
169
def recoll_search(q):
176
def recoll_search(q):
170
    config = get_config()
177
    config = get_config()
171
    tstart = datetime.datetime.now()
178
    tstart = datetime.datetime.now()
172
    results = []
179
    results = []
...
...
186
        if type(query.next) == int:
193
        if type(query.next) == int:
187
            query.next = offset
194
            query.next = offset
188
        else:
195
        else:
189
            query.scroll(offset, mode='absolute')
196
            query.scroll(offset, mode='absolute')
190
197
198
    highlighter = HlMeths()
191
    for i in range(config['perpage']):
199
    for i in range(config['perpage']):
192
        try:
200
        try:
193
            doc = query.fetchone()
201
            doc = query.fetchone()
194
        except:
202
        except:
195
            break
203
            break
...
...
201
            else:
209
            else:
202
                d[f] = ''
210
                d[f] = ''
203
        d['label'] = select([d['title'], d['filename'], '?'], [None, ''])
211
        d['label'] = select([d['title'], d['filename'], '?'], [None, ''])
204
        d['sha'] = hashlib.sha1(d['url']+d['ipath']).hexdigest()
212
        d['sha'] = hashlib.sha1(d['url']+d['ipath']).hexdigest()
205
        d['time'] = timestr(d['mtime'], config['timefmt'])
213
        d['time'] = timestr(d['mtime'], config['timefmt'])
206
        d['snippet'] = query.makedocabstract(doc).encode('utf-8')
214
        d['snippet'] = query.makedocabstract(doc, highlighter).encode('utf-8')
207
        results.append(d)
215
        results.append(d)
208
    tend = datetime.datetime.now()
216
    tend = datetime.datetime.now()
209
    return results, nres, tend - tstart
217
    return results, nres, tend - tstart
210
#}}}
218
#}}}
211
#}}}
219
#}}}