Lokal Profil has uploaded a new change for review.
https://gerrit.wikimedia.org/r/290215
Change subject: Allow non-urlencoded permalink
......................................................................
Allow non-urlencoded permalink
With browsers increasing their support for non-ascii urls the need
for the urlencode of the title is not always guaranteed. Adding an
optional parameter to permalink ensures this option becomes
available.
Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
---
M pywikibot/page.py
1 file changed, 5 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/15/290215/1
diff --git a/pywikibot/page.py b/pywikibot/page.py
index faf693b..f914e1d 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -460,16 +460,19 @@
# TODO: what about redirects, errors?
return self._revisions[oldid].text
- def permalink(self, oldid=None):
+ def permalink(self, oldid=None, encode=True):
"""Return the permalink URL of an old revision of this page.
@param oldid: The revid of the revision desired.
@rtype: unicode
"""
+ title = self.title(asUrl=True)
+ if not encode:
+ title = self.title(asUrl=False).replace(' ', '_')
return "//%s%s/index.php?title=%s&oldid=%s" \
% (self.site.hostname(),
self.site.scriptpath(),
- self.title(asUrl=True),
+ title,
(oldid if oldid is not None else self.latest_revision_id))
@property
--
To view, visit https://gerrit.wikimedia.org/r/290215
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits