root/django/trunk/utils/googlesearch/docs.txt

Revision 117, 3.3 kB (checked in by verbosus, 4 months ago)

Changed Google Business Search to Google Site Search (again)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1Django Google Search
2--------------------
3
4Django Google Search is a simple wrapper around Google Site
5Search. You can use it to add a custom, Google-powered search engine
6to your Web site by using Google Site Search XML service.
7
8Even though this application is free, a key for Google Site Search is
9needed to make it work.
10
11http://www.google.com/sitesearch/
12
13
14REQUIREMENTS
15------------
16
17Django Google Search requires at least Django 0.96 running on Python
182.3+.
19
20The ElementTree library for XML parsing is also required for Python
212.3 and 2.4, whereas Python 2.5+ have ElementTree built-in and Django
22Google Search knows how to find it.
23
24
25INSTALL
26-------
27
28Put the googlesearch directory anywhere in your PYTHONPATH and add
29"googlesearch" to your Django INSTALLED_APPS.
30
31You’ll need to add a key to your per-project settings file with this
32entry:
33
34  G_BUSINESS_KEY = '<your Google business key here>'
35
36You’ll also need to wire the app in your global urls.py:
37
38  (r'^search/$', 'googlesearch.views.search'),
39
40Assuming you have a base.html master template this is all you need to
41do for now. If not, create one with a basic HTML page skeleton, a
42block called “title”, and another called “content” in the spots you
43find best and Django Google Search will pick it up.
44
45
46CONFIGURATION
47-------------
48
49There are other parameters you can configure:
50
51- G_LANGUAGE_CODE, which specifies how Google replies to your queries
52
53- G_NUM_RESULTS, how many results you want on each page
54
55
56TEMPLATES
57---------
58
59- goooglesearch/search.html
60
61As stated above, by default Django Google Search has a few custom
62templates. The main one is googlesearch/search.html, the other two
63extend this.
64
65You may override googlesearch/search.html with your own, just remember
66to create a block called “results” for the other two templates to
67write into.
68
69- googlesearch/no_results.html
70
71Default template for “no results” scenario.
72
73- googlesearch/not_available.html
74
75Default template displayed when the Google XML service is down.
76
77
78VIEWS
79-----
80
81- googlesearch.views.search
82
83Django Google Search has a single view, “search”, that receives the
84GET parameter “q”, calls Google XML service, parses the XML response
85and finally renders it via the googlesearch/search.html template.
86
87This view also accepts the “page” parameter, for pagination. It
88doesn’t use the default Django pagination system because Google’s
89pagination results are unpredictable.
90
91The “search” view instantiates a RequestContext by default, so you
92have access to all the request objects from the template, including
93“request.user”.
94
95It takes three parameters, all optional:
96
97- G_BUSINESS_KEY (str), defaults to the business key specified in the
98  settings, but can be overridden in case you want to work with
99  multiple keys for any reason.
100
101- extra_context (dict), stuff you may want to pass as extra variables
102  in the template context
103
104- extra_query_params (dict), extra query parameters you may want to
105  pass to Google, like a custom site:http://example.org/ filter to
106  provide sub-site search support
107
108
109ACKNOWLEDGEMENTS
110----------------
111
112For all the bugs in the current version of Django Google Search blame
113its original writer, Antonio Cavedoni <http://cavedoni.com/>
114
115Other people that have helped with suggestions and fixes:
116
117- Marco Beri <http://beri.it/>
118- Your Name Here
119
120
121$Id$
Note: See TracBrowser for help on using the browser.