Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[djangoproject.com] Fixed #8723: added search, via a Google coop sear…
…ch. Thanks to frasern for figuring this out and providing detailed instructions. git-svn-id: http://code.djangoproject.com/svn/djangoproject.com@8844 bcc190cf-cafb-0310-a4f2-bffc1f526a37
- Loading branch information
jacob
committed
Sep 2, 2008
1 parent
92bad69
commit 6ee18a6
Showing
9 changed files
with
159 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django import newforms as forms | ||
|
||
AS_Q_CHOICES = ( | ||
('more:dev_docs', 'Latest'), | ||
('more:1.0_docs', '1.0'), | ||
('more:0.96_docs', '0.96'), | ||
('more:all_docs', 'All'), | ||
) | ||
|
||
class SearchForm(forms.Form): | ||
q = forms.CharField(widget=forms.TextInput({'class': 'query'})) | ||
as_q = forms.ChoiceField(choices=AS_Q_CHOICES, widget=forms.RadioSelect, initial='more:dev_docs') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{% extends "docs/doc.html" %} | ||
|
||
{% load docs %} | ||
|
||
{% block title %}Search | Django Docuemtation{% endblock %} | ||
|
||
{% block extrahead %} | ||
{{ block.super }} | ||
<style type="text/css" media="screen"> | ||
#cse-search-results iframe { | ||
width: 100%; | ||
} | ||
</style> | ||
{% endblock %} | ||
|
||
{% block toc-wrapper %}{% endblock %} | ||
|
||
{% block breadcrumbs-wrapper %}{% endblock %} | ||
|
||
{% block last-update-wrapper %}{% endblock %} | ||
|
||
{% block body %} | ||
{% if query %} | ||
<h1>Search Results</h1> | ||
<div id="cse-search-results"> | ||
<div id="cse-search-results-js-required"> | ||
The Django Documentation search uses a Google Custom Search, which | ||
requires Javascript. If your results don't appear here shortly, please | ||
<a href="http://www.google.com/cse?{{ query_string|escape }}">view the results on Google's site</a>. | ||
</div> | ||
</div> | ||
<script type="text/javascript"> | ||
var googleSearchMessage = document.getElementById("cse-search-results-js-required"); | ||
googleSearchMessage.parentNode.removeChild(googleSearchMessage); | ||
|
||
var googleSearchIframeName = "cse-search-results"; | ||
var googleSearchFormName = "cse-search-box"; | ||
var googleSearchDomain = "www.google.com"; | ||
var googleSearchPath = "/cse"; | ||
</script> | ||
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script> | ||
{% else %} | ||
<h1>Search</h1> | ||
{% search_form "search_page" %} | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<form action="{{ action|escape }}" id="{{ search_form_id|escape }}" class="search"> | ||
<div> | ||
<input type="hidden" name="cx" value="009763561546736975936:e88ek0eurf4" /> | ||
<input type="hidden" name="cof" value="FORID:11" /> | ||
<input type="hidden" name="ie" value="UTF-8" /> | ||
<input type="hidden" name="hl" value="{{ lang|escape }}" /> | ||
{{ form.q }} | ||
<input type="submit" name="sa" class="submit" value="Search" /> | ||
{{ form.as_q }} | ||
</div> | ||
</form> | ||
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form={{ search_form_id|escape }}&lang={{ lang|escape }}"></script> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.template import Library | ||
|
||
from djangodocs.forms import SearchForm | ||
|
||
|
||
register = Library() | ||
|
||
@register.inclusion_tag('docs/search_form.html', takes_context=True) | ||
def search_form(context, search_form_id='search'): | ||
request = context['request'] | ||
auto_id = 'id_%s_%%s' % search_form_id | ||
return { | ||
'form': SearchForm(initial=request.GET, auto_id=auto_id), | ||
'search_form_id': search_form_id, | ||
'action': context['search'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters