Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jean-Francois Dockes
recoll-webui
Commits
699e7409
Commit
699e7409
authored
Dec 29, 2013
by
koniu
Browse files
Merge pull request #19 from medoc92/master
Use recoll highlighter instead of local one to properly handle stemming
parents
3e79c00d
10d4c62c
Changes
2
Hide whitespace changes
Inline
Side-by-side
views/result.tpl
View file @
699e7409
%import shlex, unicodedata
%def strip_accents(s): return ''.join((c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn'))
<div
class=
"search-result"
>
%number = (query['page'] - 1)*config['perpage'] + i + 1
<div
class=
"search-result-number"
><a
href=
"#r{
{
d
[
'sha'
]
}
}"
>
#{
{
number
}
}
</a></div>
...
...
@@ -28,12 +27,6 @@
</div>
%end
<div
class=
"search-result-date"
>
{
{
d
[
'time'
]
}
}
</div>
%for q in shlex.split(query['query'].replace("'","\\'")):
%if not q == "OR":
% w = strip_accents(q.decode('utf-8').lower()).encode('utf-8')
% d['snippet'] = d['snippet'].replace(w,'
<span
class=
"search-result-highlight"
>
'+w+'
</span>
')
%end
%end
<div
class=
"search-result-snippet"
>
{{!d['snippet']}}
</div>
</div>
<!-- vim: fdm=marker:tw=80:ts=4:sw=4:sts=4:et:ai
...
...
webui.py
View file @
699e7409
...
...
@@ -165,6 +165,13 @@ def recoll_initsearch(q):
pass
return
query
#}}}
#{{{ HlMeths
class
HlMeths
:
def
startMatch
(
self
,
idx
):
return
'<span class="search-result-highlight">'
def
endMatch
(
self
):
return
'</span>'
#}}}
#{{{ recoll_search
def
recoll_search
(
q
):
config
=
get_config
()
...
...
@@ -188,6 +195,7 @@ def recoll_search(q):
else
:
query
.
scroll
(
offset
,
mode
=
'absolute'
)
highlighter
=
HlMeths
()
for
i
in
range
(
config
[
'perpage'
]):
try
:
doc
=
query
.
fetchone
()
...
...
@@ -203,7 +211,7 @@ def recoll_search(q):
d
[
'label'
]
=
select
([
d
[
'title'
],
d
[
'filename'
],
'?'
],
[
None
,
''
])
d
[
'sha'
]
=
hashlib
.
sha1
(
d
[
'url'
]
+
d
[
'ipath'
]).
hexdigest
()
d
[
'time'
]
=
timestr
(
d
[
'mtime'
],
config
[
'timefmt'
])
d
[
'snippet'
]
=
query
.
makedocabstract
(
doc
).
encode
(
'utf-8'
)
d
[
'snippet'
]
=
query
.
makedocabstract
(
doc
,
highlighter
).
encode
(
'utf-8'
)
results
.
append
(
d
)
tend
=
datetime
.
datetime
.
now
()
return
results
,
nres
,
tend
-
tstart
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment