http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9037
Revision: 9037
Author: saper
Date: 2011-03-12 23:12:11 +0000 (Sat, 12 Mar 2011)
Log Message:
-----------
Handle Special:Mypage/skin.css and js files properly
* Allow the page owner to put custom styles and scripts
* Check editusercss or edituserjs permissions introduced in 1.16
in addition to the obsolete editusercssjs
https://bugzilla.wikimedia.org/show_bug.cgi?id=12110
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2011-03-12 23:09:14 UTC (rev 9036)
+++ trunk/pywikipedia/wikipedia.py 2011-03-12 23:12:11 UTC (rev 9037)
@@ -1690,11 +1690,18 @@
elif self.site().has_api() and self.namespace() in [2,3] \
and (self.title().endswith('.css') or \
self.title().endswith('.js')):
- # API enable: if title ends with .css or .js in ns2,3
- # it needs permission 'editusercssjs'
- sysop = self._getActionUser(action='editusercssjs',
- restriction=self.editRestriction,
- sysop=True)
+ titleparts = self.title().split("/")
+ userpageowner = titleparts[0].split(":")[1]
+ if userpageowner != username:
+ # API enable: if title ends with .css or .js in ns2,3
+ # it needs permission to edit user pages
+ if self.title().endswith('css'):
+ permission = 'editusercss'
+ else:
+ permission = 'edituserjs'
+ sysop = self._getActionUser(action=permission,
+ restriction=self.editRestriction,
+ sysop=True)
# If there is an unchecked edit restriction, we need to load the page
if self._editrestriction:
@@ -4940,6 +4947,10 @@
else:
self._load(sysop = sysop)
index = self._userIndex(sysop)
+ # Handle obsolete editusercssjs permission
+ if right in ['editusercss', 'edituserjs'] \
+ and right not in self._rights[index]:
+ return 'editusercssjs' in self._rights[index]
return right in self._rights[index]
def server_time(self):
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9034
Revision: 9034
Author: xqt
Date: 2011-03-10 06:49:58 +0000 (Thu, 10 Mar 2011)
Log Message:
-----------
change langcode fallback for tt and ku-wiki; update from rewrite r9031 (duplicate code stuff, sorry)
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/i18n.py
Modified: trunk/pywikipedia/pywikibot/i18n.py
===================================================================
--- trunk/pywikipedia/pywikibot/i18n.py 2011-03-10 06:44:32 UTC (rev 9033)
+++ trunk/pywikipedia/pywikibot/i18n.py 2011-03-10 06:49:58 UTC (rev 9034)
@@ -23,7 +23,7 @@
If no translation is available to a specified language, translate() will
try each of the specified fallback languages, in order, until it finds
one with a translation, with 'en' and '_default' as a last resort.
-
+
For example, if for language 'xx', you want the preference of languages
to be: xx > fr > ru > en, you let altlang return ['fr', 'ru'].
"""
@@ -123,9 +123,11 @@
return ['ro']
#Russian and Belarusian
if code in ['ab', 'av', 'ba', 'bxr', 'ce', 'cv', 'kk', 'koi', 'ky', 'lbe',
- 'mdf', 'mhr', 'mrj', 'myv', 'os', 'rue', 'sah', 'tg', 'tt',
- 'udm', 'uk', 'xal']:
+ 'mdf', 'mhr', 'mrj', 'myv', 'os', 'rue', 'sah', 'tg', 'udm',
+ 'uk', 'xal']:
return ['ru']
+ if code == 'tt':
+ return ['tt-cyrl', 'ru']
if code in ['be', 'be-x-old']:
return ['be', 'be-x-old', 'ru']
if code == 'kaa':
@@ -137,7 +139,7 @@
return ['sr-el', 'sh', 'hr', 'bs']
#Turkish and Kurdish
if code in ['diq', 'ku']:
- return ['ku', 'tr']
+ return ['ku', 'ku-latn', 'tr']
if code == 'gag':
return ['tr']
if code == 'ckb':
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9033
Revision: 9033
Author: xqt
Date: 2011-03-10 06:44:32 +0000 (Thu, 10 Mar 2011)
Log Message:
-----------
stripped trailing whitespace
Modified Paths:
--------------
branches/rewrite/pywikibot/i18n.py
Modified: branches/rewrite/pywikibot/i18n.py
===================================================================
--- branches/rewrite/pywikibot/i18n.py 2011-03-10 06:43:06 UTC (rev 9032)
+++ branches/rewrite/pywikibot/i18n.py 2011-03-10 06:44:32 UTC (rev 9033)
@@ -23,7 +23,7 @@
If no translation is available to a specified language, translate() will
try each of the specified fallback languages, in order, until it finds
one with a translation, with 'en' and '_default' as a last resort.
-
+
For example, if for language 'xx', you want the preference of languages
to be: xx > fr > ru > en, you let altlang return ['fr', 'ru'].
"""
@@ -228,7 +228,7 @@
# There are two possible failure modes: the translation dict might not have
# the language altogether, or a specific key could be untranslated. Both
# modes are caught with the KeyError.
-
+
trans = None
try:
trans = transdict[code][twtitle]