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

Add an 'Add to browser' option

This commit is contained in:
Laurent Defert 2013-07-14 16:19:46 +02:00
parent 248b293ddd
commit 10809d70c5
4 changed files with 34 additions and 0 deletions

View file

@ -8,3 +8,15 @@ $(document).ready(function(){
$('input[name="after"]').jdPicker({}); $('input[name="after"]').jdPicker({});
$('input[name="before"]').jdPicker(); $('input[name="before"]').jdPicker();
}) })
function addOpenSearch()
{
if (window.external && ("AddSearchProvider" in window.external)) {
/* Build the url of the form http://host/osd.xml */
var url = document.URL;
var prefix = RegExp("^https\?://[^/]*/").exec(url);
window.external.AddSearchProvider(prefix + "osd.xml");
} else {
alert("Your browser does not support OpenSearch search plugins.");
}
}

10
views/osd.tpl Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Recoll</ShortName>
<Description>Recoll</Description>
<Url type="text/html" template="{{url}}/results?query={searchTerms}"/>
<Image width="48" height="48">{{url}}/static/recoll.png</Image>
<InputEncoding>UTF-8</InputEncoding>
<moz:SearchForm>{{url}}/</moz:SearchForm>
</OpenSearchDescription>

View file

@ -21,6 +21,10 @@
%for d in dirs: %for d in dirs:
<small>{{d}}</small><input name="mount_{{d}}" value={{mounts[d]}}> <small>{{d}}</small><input name="mount_{{d}}" value={{mounts[d]}}>
%end %end
<hr>
<b>Add to browser</b>
<br>
<a href="#" onClick="addOpenSearch();return false">Register recoll into browser search engines</a>
<br><br><hr> <br><br><hr>
<input type="submit" value="Save"> <input type="submit" value="Save">
<a href="./"><input type="button" value="Cancel"></a> <a href="./"><input type="button" value="Cancel"></a>

View file

@ -357,5 +357,13 @@ def set():
bottle.response.set_cookie(cookie_name, str(bottle.request.query.get('mount_%s' % d)), max_age=3153600000) bottle.response.set_cookie(cookie_name, str(bottle.request.query.get('mount_%s' % d)), max_age=3153600000)
bottle.redirect('./') bottle.redirect('./')
#}}} #}}}
#{{{ osd
@bottle.route('/osd.xml')
@bottle.view('osd')
def main():
#config = get_config()
url = bottle.request.urlparts
url = '%s://%s' % (url.scheme, url.netloc)
return {'url': url}
#}}} #}}}
# vim: fdm=marker:tw=80:ts=4:sw=4:sts=4:et # vim: fdm=marker:tw=80:ts=4:sw=4:sts=4:et