Skip to content

Commit 4d4caf1

Browse files
committed
From Tony: Search plugin for Firefox/IE/etc.
- Legacy-Id: 2138
1 parent b5223b4 commit 4d4caf1

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

ietf/idrfc/views_search.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from django.views.decorators.cache import cache_page
3939
from ietf.idtracker.models import IDState, IESGLogin, IDSubState, Area, InternetDraft, Rfc, IDInternal, IETFWG
4040
from ietf.idrfc.models import RfcIndex
41-
from django.http import Http404, HttpResponse
41+
from django.http import Http404, HttpResponse, HttpResponsePermanentRedirect
4242
from ietf.idrfc.idrfc_wrapper import IdWrapper,RfcWrapper,IdRfcWrapper
4343
from ietf.utils import normalize_draftname
4444

@@ -47,6 +47,7 @@ class SearchForm(forms.Form):
4747
rfcs = forms.BooleanField(required=False,initial=True)
4848
activeDrafts = forms.BooleanField(required=False,initial=True)
4949
oldDrafts = forms.BooleanField(required=False,initial=False)
50+
lucky = forms.BooleanField(required=False,initial=False)
5051

5152
by = forms.ChoiceField(choices=[(x,x) for x in ('author','group','area','ad','state')], required=False, initial='wg', label='Foobar')
5253
author = forms.CharField(required=False)
@@ -262,6 +263,12 @@ def search_results(request):
262263
meta['by'] = form.cleaned_data['by']
263264
if 'ajax' in request.REQUEST and request.REQUEST['ajax']:
264265
return render_to_response('idrfc/search_results.html', {'docs':results, 'meta':meta}, context_instance=RequestContext(request))
266+
elif form.cleaned_data['lucky'] and len(results)==1:
267+
doc = results[0]
268+
if doc.id:
269+
return HttpResponsePermanentRedirect(doc.id.get_absolute_url())
270+
else:
271+
return HttpResponsePermanentRedirect(doc.rfc.get_absolute_url())
265272
else:
266273
return render_to_response('idrfc/search_main.html', {'form':form, 'docs':results,'meta':meta}, context_instance=RequestContext(request))
267274

ietf/templates/idrfc/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
{% else %}
5353
<link rel="icon" href="/images/ietf-icon-blue.bmp" />
5454
{% endifnotequal %}
55+
<link rel="search" href="/js/datatracker-search.xml" type="application/opensearchdescription+xml" title="IETF Datatracker Search" />
5556
</head>
5657
<body class="yui-skin-sam" {% block bodyAttrs %}{%endblock%}>
5758
<div style="background-color:{% if server_mode %}{% ifnotequal server_mode "production" %}#c00000{% else %}#313163{% endifnotequal %}{%else %}#313163{%endif%};color:white;font-size:150%;height:35px;">

static/js/datatracker-search.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
3+
<ShortName>IETF Datatracker Search</ShortName>
4+
<Description>Use datatracker.ietf.org to search for Internet-Drafts and RFCs</Description>
5+
<Tags>Requests For Comments</Tags>
6+
<Url type="text/html"
7+
template="http://datatracker.ietf.org/doc/search/?name={searchTerms}&amp;activeDrafts=on&amp;rfcs=on&amp;lucky=on"/>
8+
<LongName>datatracker.ietf.org RFC and Internet-Draft Search</LongName>
9+
<Image height="16" width="16" type="image/vnd.microsoft.icon">http://datatracker.ietf.org/images/ietf-icon-blue.bmp</Image>
10+
<Developer>Tony Hansen</Developer>
11+
<Language>en-us</Language>
12+
</OpenSearchDescription>
13+

0 commit comments

Comments
 (0)