]> git.openstreetmap.org Git - osqa.git/commitdiff
moved opensearch into its own module and put it in the settings menu
authorqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 12 May 2010 19:51:28 +0000 (19:51 +0000)
committerqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 12 May 2010 19:51:28 +0000 (19:51 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@237 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum_modules/OpenSearch/__init__.py [new file with mode: 0644]
forum_modules/OpenSearch/settings.py [new file with mode: 0644]
forum_modules/OpenSearch/urls.py [new file with mode: 0644]

diff --git a/forum_modules/OpenSearch/__init__.py b/forum_modules/OpenSearch/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/forum_modules/OpenSearch/settings.py b/forum_modules/OpenSearch/settings.py
new file mode 100644 (file)
index 0000000..0c89ae8
--- /dev/null
@@ -0,0 +1,21 @@
+from forum.settings.base import Setting, SettingSet
+from django.forms.widgets import Textarea
+from forum import settings as django_settings
+
+OPEN_SEARCH_SET = SettingSet('OpenSearch', 'OpenSearch', "Set up the open_search.xml file.", 3000)
+
+OPEN_SEARCH_FILE = Setting('OPEN_SEARCH_FILE',
+("""
+<?xml version="1.0" encoding="UTF-8"?>
+ <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+   <ShortName>%s Web Search</ShortName>
+   <Description>Use %s to search the Web.</Description>
+   <Tags>%s</Tags>
+   <Url type="application/rss+xml"
+        template="%s/?q={searchTerms}&pw={startPage?}"/>
+ </OpenSearchDescription>
+""" % (django_settings.APP_SHORT_NAME, django_settings.APP_URL, django_settings.APP_KEYWORDS, django_settings.APP_URL)),
+OPEN_SEARCH_SET,
+dict(label = "open_search.xml file",
+     help_text = "The open_search.xml file.",
+     widget=Textarea(attrs={'rows': '20', 'cols' : '70'})))
\ No newline at end of file
diff --git a/forum_modules/OpenSearch/urls.py b/forum_modules/OpenSearch/urls.py
new file mode 100644 (file)
index 0000000..38f1693
--- /dev/null
@@ -0,0 +1,7 @@
+from django.conf.urls.defaults import *
+from django.http import  HttpResponse
+import settings
+
+urlpatterns = patterns('',
+    (r'^open_search.xml$',  lambda r: HttpResponse(settings.OPEN_SEARCH_FILE.value)),
+)