Re: [Wikitech-l] Reproducing localurl by python urllib.quote()

2011-06-29 Thread Ashar Voultoiz
On 27/06/11 23:14, Platonides wrote:
 See wfUrlEncode in GlobalFunctions.php

I have added tests for this function with r91108. Feel free to propose 
additional tests :)

http://www.mediawiki.org/wiki/Special:Code/MediaWiki/91108

-- 
Ashar Voultoiz


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Reproducing localurl by python urllib.quote()

2011-06-29 Thread Alex Brollo
2011/6/29 Ashar Voultoiz hashar+...@free.fr

 On 27/06/11 23:14, Platonides wrote:
  See wfUrlEncode in GlobalFunctions.php

 I have added tests for this function with r91108. Feel free to propose
 additional tests :)

 http://www.mediawiki.org/wiki/Special:Code/MediaWiki/91108

 --
 Ashar Voultoiz


 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Reproducing localurl by python urllib.quote()

2011-06-29 Thread Alex Brollo
I tested too mediaWiki encoding with js encodeURI()  function. I found a
difference, only one, since mediaWiki encodes apostrophe while encodeURI()
doesn't. Obviously the second, great difference is the conversion of spaces
into underlines.

So, in js so far I got a good simulation of localurl: Mediawiki encoding
with this:
encodeURI(string.replace(/ /g,_)).replace(/%27/g,') )

(the last string is an apostrophe between double quotes)

Is there some reason why wiki encoding is different from js encodeURI (that,
I presume, is founded on a standard)? I found this a little confusing.

Alex
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Reproducing localurl by python urllib.quote()

2011-06-29 Thread Helder
On Wed, Jun 29, 2011 at 19:42, Alex Brollo alex.bro...@gmail.com wrote:

 Is there some reason why wiki encoding is different from js encodeURI
 (that,
 I presume, is founded on a standard)? I found this a little confusing.

Me too. And it gets more confusing with the addition of mw.util.rawurlencode
and mw.util.wikiUrlencode:
http://www.mediawiki.org/wiki/ResourceLoader/Default_modules#rawurlencode
http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/resources/mediawiki/mediawiki.util.js?annotate=90729#l110

Helder
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Reproducing localurl by python urllib.quote()

2011-06-28 Thread Alex Brollo
2011/6/27 Platonides platoni...@gmail.com


 The relevant function is Title::getLocalURL()
 I think that in your quote function you need to skip '@$*(),' as well,
 and .-_ wouldn't be needed there (but urllib.quote could differ from
 php urlencode).
 See wfUrlEncode in GlobalFunctions.php


Thanks Platonidea, I'll test localurl for your character list. In the
meantime, I found that my one was a rather silly question  since any html
link to wiki pages from mediawiki software has this kind of code:

a href=/wiki/Portal:Children%27s_literature title=Portal:Children's
literaturePortal:Children's literature/a.

t.i., there is both the escaped version of the title of the page into href
attribute, and the not-escaped version of the name of the page, inside the
title attribute; the latter being mush simpler as a key  to select links.
:-)

Alex
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


[Wikitech-l] Reproducing localurl by python urllib.quote()

2011-06-27 Thread Alex Brollo
I found a number of troubles when trying to replicate localurl: parser
function by python urllib.quote(), with a number of annoying bugs.

Is this correct-complete?

/wiki/+urllib.quote(name-of-page.replace( ,_),/!,;:.-_)
where name-of-page is utf-8 encoded.

Thanks! I apologyze for so a banal question.

Alex brollo
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Reproducing localurl by python urllib.quote()

2011-06-27 Thread Platonides
  Alex Brollo wrote:
 I found a number of troubles when trying to replicate localurl: parser
 function by python urllib.quote(), with a number of annoying bugs.

 Is this correct-complete?

 /wiki/+urllib.quote(name-of-page.replace( ,_),/!,;:.-_)
 where name-of-page is utf-8 encoded.

 Thanks! I apologyze for so a banal question.

 Alex brollo

The relevant function is Title::getLocalURL()
I think that in your quote function you need to skip '@$*(),' as well, 
and .-_ wouldn't be needed there (but urllib.quote could differ from 
php urlencode).
See wfUrlEncode in GlobalFunctions.php



___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l