git.ithinksw.org
/
philo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8a7ab75
)
Set GoogleSearch to allow default args and to default to a search within the current...
author
Stephen Burrows
<stephen.r.burrows@gmail.com>
Thu, 14 Apr 2011 17:04:05 +0000
(13:04 -0400)
committer
Stephen Burrows
<stephen.r.burrows@gmail.com>
Thu, 14 Apr 2011 17:12:42 +0000
(13:12 -0400)
contrib/sobol/search.py
patch
|
blob
|
history
diff --git
a/contrib/sobol/search.py
b/contrib/sobol/search.py
index
8c695c6
..
39b93c7
100644
(file)
--- a/
contrib/sobol/search.py
+++ b/
contrib/sobol/search.py
@@
-300,10
+300,21
@@
class JSONSearch(URLSearch):
class GoogleSearch(JSONSearch):
search_url = "http://ajax.googleapis.com/ajax/services/search/web"
class GoogleSearch(JSONSearch):
search_url = "http://ajax.googleapis.com/ajax/services/search/web"
- query_format_str = "?v=1.0&q=%s"
# TODO: Change this template to reflect the app's actual name.
result_template = 'search/googlesearch.html'
_cache_timeout = 60
# TODO: Change this template to reflect the app's actual name.
result_template = 'search/googlesearch.html'
_cache_timeout = 60
+ verbose_name = "Google search (current site)"
+
+ @property
+ def query_format_str(self):
+ default_args = self.default_args
+ if default_args:
+ default_args += " "
+ return "?v=1.0&q=%s%%s" % urlquote_plus(default_args).replace('%', '%%')
+
+ @property
+ def default_args(self):
+ return "site:%s" % Site.objects.get_current().domain
def parse_response(self, response, limit=None):
responseData = json.loads(response.read())['responseData']
def parse_response(self, response, limit=None):
responseData = json.loads(response.read())['responseData']