on master help sign in
[enh] gettext in self ip plugin
commit13ea0a20ae222c51d7aac6f751124e484bc1cae3 authorAdam Tauber <asciimoo@gmail.com> dateSat 14 Mar 2015, 19:45 (12 years ago) parent80ba6f2
1 file changed+6−2
searx/plugins/self_ip.py+6−2
searx/plugins/self_ip.py+6−2
@@ -1,9 +1,12 @@
1−
1+from flask.ext.babel import gettext
22name = "Self IP"
3−description = "Display your source IP address"
3+description = gettext('Display your source IP address if the query expression is "ip"')
44default_on = True
55
66
7+# attach callback to the pre search hook
8+# request: flask request object
9+# ctx: the whole local context of the pre search hook
710def pre_search(request, ctx):
811 if ctx['search'].query == 'ip':
912 x_forwarded_for = request.headers.getlist("X-Forwarded-For")
@@ -13,5 +16,6 @@ def pre_search(request, ctx):
1316 ip = request.remote_addr
1417 ctx['search'].answers.clear()
1518 ctx['search'].answers.add(ip)
19+ # return False prevents exeecution of the original block
1620 return False
1721 return True