Added a few search engines.

Thu, 02 Jun 2011 20:43:06 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 02 Jun 2011 20:43:06 +0200
changeset 1104
029fde1585ed
parent 1102
aae999261983
child 1106
3e57cd52e0f6

Added a few search engines.

Helpviewer/OpenSearch/OpenSearchDefaultEngines.py file | annotate | diff | comparison | revisions
Helpviewer/OpenSearch/OpenSearchEngine.py file | annotate | diff | comparison | revisions
Helpviewer/OpenSearch/OpenSearchEngineModel.py file | annotate | diff | comparison | revisions
Helpviewer/OpenSearch/OpenSearchManager.py file | annotate | diff | comparison | revisions
--- a/Helpviewer/OpenSearch/OpenSearchDefaultEngines.py	Thu Jun 02 17:29:13 2011 +0200
+++ b/Helpviewer/OpenSearch/OpenSearchDefaultEngines.py	Thu Jun 02 20:43:06 2011 +0200
@@ -16,14 +16,33 @@
             <Image width="16" height="16">http://www.amazon.com/favicon.ico</Image>
         </OpenSearchDescription>""",
     
+    "Beolingus": """<?xml version="1.0" encoding="UTF-8"?>
+        <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+            <ShortName>De-En Beolingus</ShortName>
+            <Description>Beolingus: German-English Dictionary</Description>
+            <Url method="get" template="http://dict.tu-chemnitz.de/?query={searchTerms}"/>
+            <Url method="get" type="application/x-suggestions+json" template="http://dict.tu-chemnitz.de/sugg.php?json=1;s={searchTerms}"/>
+            <Image width="16" height="16">http://dict.tu-chemnitz.de/pics/beo-de.png</Image>
+        </OpenSearchDescription>""",
+
     "Bing": """<?xml version="1.0" encoding="UTF-8"?>
         <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
             <ShortName>Bing</ShortName>
             <Description>Bing Web Search</Description>
             <Url method="get" type="text/html" template="http://www.bing.com/search?cc={language}&amp;q={searchTerms}" />
+            <Url method="get" type="application/x-suggestions+xml" template="http://api.search.live.com/qsml.aspx?query={searchTerms}"/>
             <Image width="16" height="16">http://www.bing.com/s/wlflag.ico</Image>
         </OpenSearchDescription>""",
     
+    "Facebook": """<?xml version="1.0" encoding="UTF-8"?>
+        <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+            <ShortName>Facebook</ShortName>
+            <Description>Search Facebook</Description>
+            <Url method="get" template="http://www.facebook.com/search/?src=os&amp;q={searchTerms}"/>
+            <Url method="get" type="application/x-suggestions+xml" template="http://www.facebook.com/search/opensearch_typeahead.php?format=xml&amp;q={searchTerms}"/>
+            <Image width="16" height="16">http://www.facebook.com/favicon.ico</Image>
+        </OpenSearchDescription>""",
+    
     "Google": """<?xml version="1.0" encoding="UTF-8"?>
         <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
             <ShortName>Google</ShortName>
@@ -42,6 +61,14 @@
             <Image width="16" height="16">http://www.google.com/favicon.ico</Image>
         </OpenSearchDescription>""",
     
+    "Leo_de_en": """<?xml version="1.0" encoding="UTF-8"?>
+        <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+            <ShortName>LEO Deu-Eng</ShortName>
+            <Description>Deutsch-Englisch Woerterbuch von LEO</Description>
+            <Url method="get" type="text/html" template="http://dict.leo.org/?lp=ende&amp;search={searchTerms}"/>
+            <Image width="16" height="16">http://dict.leo.org/favicon_en.ico</Image>
+        </OpenSearchDescription>""",
+
     "LinuxMagazin_de": """<?xml version="1.0" encoding="UTF-8"?>
         <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
             <ShortName>Linux-Magazin</ShortName>
@@ -58,20 +85,47 @@
             <Image width="16" height="16">http://www.reddit.com/favicon.ico</Image>
         </OpenSearchDescription>""",
     
-    "Wikipedia_en": """<?xml version="1.0" encoding="UTF-8"?>
+    "Wikia": """<?xml version="1.0" encoding="UTF-8"?>
+        <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+            <ShortName>Wikia</ShortName>
+            <Description>Wikia Site Search</Description>
+            <Url method="get" template="http://{country}.wikia.com/index.php?title=Special:Search&amp;search={searchTerms}"/>
+            <Url method="get" type="application/x-suggestions+json" template="http://{country}.wikia.com/api.php?action=opensearch&amp;search={searchTerms}&amp;namespace=0"/>
+            <Image width="16" height="16">http://images.wikia.com/wikiaglobal/images/6/64/Favicon.ico</Image>
+        </OpenSearchDescription>""",
+
+    "Wikia_en": """<?xml version="1.0" encoding="UTF-8"?>
         <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
-            <ShortName>Wikipedia (en)</ShortName>
-            <Description>Full text search in the English Wikipedia</Description>
-            <Url method="get" type="text/html" template="http://en.wikipedia.org/wiki/Special:Search?search={searchTerms}&amp;fulltext=Search" />
-            <Url method="get" type="application/x-suggestions+json" template="http://en.wikipedia.org/w/api.php?action=opensearch&amp;search={searchTerms}&amp;namespace=0" />
+            <ShortName>Wikia (en)</ShortName>
+            <Description>Wikia Site Search English</Description>
+            <Url method="get" template="http://www.wikia.com/index.php?title=Special:Search&amp;search={searchTerms}"/>
+            <Url method="get" type="application/x-suggestions+json" template="http://www.wikia.com/api.php?action=opensearch&amp;search={searchTerms}&amp;namespace=1"/>
+            <Image width="16" height="16">http://images.wikia.com/wikiaglobal/images/6/64/Favicon.ico</Image>
+        </OpenSearchDescription>""",
+
+    "Wikipedia": """<?xml version="1.0" encoding="UTF-8"?>
+        <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+            <ShortName>Wikipedia</ShortName>
+            <Description>Full text search in Wikipedia</Description>
+            <Url method="get" type="text/html" template="http://{country}.wikipedia.org/wiki/Special:Search?search={searchTerms}&amp;fulltext=Search" />
+            <Url method="get" type="application/x-suggestions+json" template="http://{country}.wikipedia.org/w/api.php?action=opensearch&amp;search={searchTerms}&amp;namespace=0" />
             <Image width="16" height="16">http://en.wikipedia.org/favicon.ico</Image>
         </OpenSearchDescription>""",
     
+    "Wiktionary": """<?xml version="1.0" encoding="UTF-8"?>
+        <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+            <ShortName>Wiktionary</ShortName>
+            <Description>Wiktionary</Description>
+            <Url method="get" template="http://{country}.wiktionary.org/w/index.php?title=Special:Search&amp;search={searchTerms}"/>
+            <Url method="get" type="application/x-suggestions+xml" template="http://{country}.wiktionary.org/w/api.php?action=opensearch&amp;format=xml&amp;search={searchTerms}&amp;namespace=0"/>
+            <Image width="16" height="16">http://en.wiktionary.org/favicon.ico</Image>
+        </OpenSearchDescription>""",
+    
     "Yahoo": """<?xml version="1.0" encoding="UTF-8"?>
         <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
             <ShortName>Yahoo!</ShortName>
-            <Description>Yahoo Web Search</Description>
-            <Url method="get" type="text/html" template="http://search.yahoo.com/search?ei=utf-8&amp;fr=sfp&amp;iscqry=&amp;p={searchTerms}" />
+            <Description>Yahoo! Web Search</Description>
+            <Url method="get" type="text/html" template="http://{country}.search.yahoo.com/search?ei=utf-8&amp;fr=sfp&amp;iscqry=&amp;p={searchTerms}" />
             <Url method="get" type="application/x-suggestions+json" template="http://ff.search.yahoo.com/gossip?output=fxjson&amp;command={searchTerms}" />
             <Image width="16" height="16">http://m.www.yahoo.com/favicon.ico</Image>
         </OpenSearchDescription>""",
--- a/Helpviewer/OpenSearch/OpenSearchEngine.py	Thu Jun 02 17:29:13 2011 +0200
+++ b/Helpviewer/OpenSearch/OpenSearchEngine.py	Thu Jun 02 20:43:06 2011 +0200
@@ -17,6 +17,7 @@
 from UI.Info import Program
 
 import Preferences
+import Utilities
 
 
 class OpenSearchEngine(QObject):
@@ -39,6 +40,10 @@
         _language = ""
     else:
         _language = loc[:2]
+    _language = _language.replace("_", "-")
+    _country = _language
+    if "-" in _country:
+        _country = _country[_county.index["-"] + 1:]
     
     def __init__(self, parent=None):
         """
@@ -82,6 +87,7 @@
         result = result.replace("{startIndex}", "0")
         result = result.replace("{startPage}", "0")
         result = result.replace("{language}", cls._language)
+        result = result.replace("{country}", cls._country.lower())
         result = result.replace("{inputEncoding}", "UTF-8")
         result = result.replace("{outputEncoding}", "UTF-8")
         result = result.replace("{searchTerms}",
@@ -441,7 +447,8 @@
         """
         Private slot to receive the suggestions.
         """
-        response = str(self.__suggestionsReply.readAll(), "utf-8")
+        buffer = bytes(self.__suggestionsReply.readAll())
+        response = Utilities.decode(buffer)[0]
         response = response.strip()
         
         self.__suggestionsReply.close()
--- a/Helpviewer/OpenSearch/OpenSearchEngineModel.py	Thu Jun 02 17:29:13 2011 +0200
+++ b/Helpviewer/OpenSearch/OpenSearchEngineModel.py	Thu Jun 02 20:43:06 2011 +0200
@@ -131,9 +131,9 @@
                 description = self.trUtf8("<strong>Description:</strong> {0}")\
                               .format(engine.description())
                 if engine.providesSuggestions():
-                    description.append("<br/>")
-                    description.append(
-                        self.trUtf8("<strong>Provides contextual suggestions</strong>"))
+                    description += "<br/>"
+                    description += \
+                        self.trUtf8("<strong>Provides contextual suggestions</strong>")
                 
                 return description
         elif index.column() == 1:
--- a/Helpviewer/OpenSearch/OpenSearchManager.py	Thu Jun 02 17:29:13 2011 +0200
+++ b/Helpviewer/OpenSearch/OpenSearchManager.py	Thu Jun 02 20:43:06 2011 +0200
@@ -236,7 +236,7 @@
         
         engine = self.__engines[name]
         for keyword in [k for k in self.__keywords if self.__keywords[k] == engine]:
-            del self.__keywords[k]
+            del self.__keywords[keyword]
         del self.__engines[name]
         
         file_ = QDir(self.enginesDirectory()).filePath(self.generateEngineFileName(name))

eric ide

mercurial