On Thu, Aug 19, 2010 at 02:55:05AM +0300, Sergey Poznyakoff wrote: > ???? ???????? <aelmahmo...@sabily.org> ha escrit: > > > I thought that you first reverted those lines, because this is not a > > right thing to do in python > > It is questionable. I don't care whether it is right or wrong > from the point of view of Python purists. The truth is that this is > the only approach that works. ---end quoted text---
Marc, would you try the attached patch please ? -- أحمد المحمودي (Ahmed El-Mahmoudy) Digital design engineer GPG KeyID: 0xEDDDA1B7 GPG Fingerprint: 8206 A196 2084 7E6D 0DF8 B176 BC19 6A94 EDDD A1B7
diff --git a/app/python/mediawiki.py b/app/python/mediawiki.py index 7410c8c..e717c0c 100644 --- a/app/python/mediawiki.py +++ b/app/python/mediawiki.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of GNU Dico. -# Copyright (C) 2008, 2009 Wojciech Polak +# Copyright (C) 2008, 2009, 2010 Wojciech Polak # # GNU Dico is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,6 +24,17 @@ from htmlentitydefs import name2codepoint from xml.dom import minidom from wit import wiki2text +# Set utf-8 as the default encoding. +# Trying to do so using encode('utf_8')/unicode, which is +# supposed to be the right way, does not work. +# Simply calling sys.setdefaultencoding is not possible, +# because, for some obscure reason, Python chooses to delete +# this symbol from the namespace after setting its default +# encoding in site.py. That's why reload is needed. + +reload(sys) +sys.setdefaultencoding('utf-8') + try: import json except ImportError: @@ -31,7 +42,7 @@ except ImportError: import dico -__version__ = '1.01' +__version__ = '1.03' class DicoModule: user_agent = 'Mozilla/1.0' @@ -127,9 +138,9 @@ class DicoModule: def result_headers (self, rh, hdr): if dico.current_markup () != 'wiki': hdr['Content-Type'] = 'text/plain'; - elif self.wikihost.find ('.wikipedia.org') != -1: + elif '.wikipedia.org' in self.wikihost: hdr['Content-Type'] = 'text/x-wiki-wikipedia'; - elif self.wikihost.find ('.wiktionary.org') != -1: + elif '.wiktionary.org' in self.wikihost: hdr['Content-Type'] = 'text/x-wiki-wiktionary'; else: hdr['Content-Type'] = 'text/x-wiki'; diff --git a/dicoweb/templates/base.html b/dicoweb/templates/base.html index 33e4491..614b1e7 100644 --- a/dicoweb/templates/base.html +++ b/dicoweb/templates/base.html @@ -7,6 +7,7 @@ <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="keywords" content="gnu dico web search interface, dicoweb, dictionaries, dict protocol" /> <meta name="description" content="GNU Dico WebSearch Interface" /> +<meta name="robots" content="{{ page.robots }}" /> <link rel="stylesheet" type="text/css" href="{% media_prefix %}/dicoweb.css" /> <link rel="search" type="application/opensearchdescription+xml" title="GNU Dico WebSearch" href="{% url opensearch %}" /> <script type="text/javascript" src="{% media_prefix %}/dicoweb.js"></script> diff --git a/dicoweb/views.py b/dicoweb/views.py index 47b30cd..a696f2c 100644 --- a/dicoweb/views.py +++ b/dicoweb/views.py @@ -27,7 +27,9 @@ import dicoclient from wit import wiki2html def index (request): - page = {} + page = { + 'robots': 'index', + } selects = {} mtc = {} result = {} @@ -159,7 +161,9 @@ def index (request): break if database == 'dbinfo': q = '' - if q != '': page['title'] = q + ' - ' + if q != '': + page['title'] = q + ' - ' + page['robots'] = 'noindex,nofollow' if result.has_key ('definitions'): rx1 = re.compile ('{+(.*?)}+', re.DOTALL)
signature.asc
Description: Digital signature