Hello, I am trying to find a much easier way for people to use external file links in my wiki. Currently every space has to be replaced with a %20. Is there something like {{urlencode:}} that would work? The urlencode magic word converts spaces to +, how do i get %20 instead?
Hi Matt,
Have you tried the LinkSearch extension? http://www.mediawiki.org/wiki/Extension:LinkSearch
On Fri, Jul 25, 2008 at 5:55 AM, Matt Long mlong212@gmail.com wrote:
Hello, I am trying to find a much easier way for people to use external file links in my wiki. Currently every space has to be replaced with a %20. Is there something like {{urlencode:}} that would work? The urlencode magic word converts spaces to +, how do i get %20 instead?
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
I like that extension however isn't that for searching links that are already in the wiki. I'd like to be able to copy the file path from windows explorer, paste it into the wiki, in a way that changes all the spaces to %20 for everyone. It's a lot of work to do that for hundreds of links. I found that the urlencode gives you a + sign for every space, so there must be a way to get a %20 instead. Matt
Cameron wrote:
Hi Matt,
Have you tried the LinkSearch extension? http://www.mediawiki.org/wiki/Extension:LinkSearch
Matt Long wrote:
I found that the urlencode gives you a + sign for every space, so there must be a way to get a %20 instead.
If you use StringFunctions - an extension to ParserFunctions - you could do this with a template. Just create a template that takes an external link and uses the #replace function to replace all blanks with %20. By putting this in an extension, your users will not have to do much. Something like:
{{extlink|http://example.com/problem stuff|description}}
would pump out:
[http://example.com/problem%20stuff description]
The template would be:
[{{#replace:{{{1}}}||%20}} {{{2|}}}]
I tested it minimally and it seems to work.
Mike
Sweet! That works for me. I had already followed other directions to allow mediawiki to interpret the file:/// protocol. I installed Stringfunctions: http://www.mediawiki.org/wiki/Extension:StringFunctions#Installation. And i modified your code a little bit:
[{{#replace:file:///{{{1}}}||%20}} {{{2|}}}]
So now only the path is needed, and the template will add in the file:/// part for me. This doesn't have a dialog like the filelink extension: http://www.mediawiki.org/wiki/Extension:FileLink However, this one works the way it should the 1st time. Filelink doesn't seem to be getting very much love, maybe someone can fix it up a bit at somepoint and bring it inline with the current MW version.
Michael Daly wrote:
Matt Long wrote:
I found that the urlencode gives you a + sign for every space, so there must be a way to get a %20 instead.
If you use StringFunctions - an extension to ParserFunctions - you could do this with a template. Just create a template that takes an external link and uses the #replace function to replace all blanks with %20. By putting this in an extension, your users will not have to do much. Something like:
{{extlink|http://example.com/problem stuff|description}}
would pump out:
[http://example.com/problem%20stuff description]
The template would be:
[{{#replace:{{{1}}}||%20}} {{{2|}}}]
I tested it minimally and it seems to work.
Mike
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Matt Long wrote:
And i modified your code a little bit:
[{{#replace:file:///{{{1}}}||%20}} {{{2|}}}]
Haven't tested it, but this:
[file:///{{#replace:{{{1}}}||%20}} {{{2|}}}]
Might do the same while being infinitesimally faster (since there's no blank to replace in "file:///".
Mike
lol nice new word.. how does one judge the speed? Or see what might be eating up cpu power in a wiki?
Michael Daly wrote:
Matt Long wrote:
And i modified your code a little bit:
[{{#replace:file:///{{{1}}}||%20}} {{{2|}}}]
Haven't tested it, but this:
[file:///{{#replace:{{{1}}}||%20}} {{{2|}}}]
Might do the same while being infinitesimally faster (since there's no blank to replace in "file:///".
Mike
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Hi Matt,
have a look at the FileLink-extension:
http://www.mediawiki.org/wiki/Extension:FileLink
Regards K. Wolkwitz
Matt Long schrieb am 24.07.2008 19:55:
Hello, I am trying to find a much easier way for people to use external file links in my wiki. Currently every space has to be replaced with a %20. Is there something like {{urlencode:}} that would work? The urlencode magic word converts spaces to +, how do i get %20 instead?
The problem with that extension is that it grabs the filename only.. it cuts off the path info. In the browse for file window it shows the full path, but after clicking ok it truncates everything down to just the file name. Matt
Katharina Wolkwitz wrote:
Hi Matt,
have a look at the FileLink-extension:
http://www.mediawiki.org/wiki/Extension:FileLink
Regards K. Wolkwitz
Matt Long schrieb am 24.07.2008 19:55:
Hello, I am trying to find a much easier way for people to use external file links in my wiki. Currently every space has to be replaced with a %20. Is there something like {{urlencode:}} that would work? The urlencode magic word converts spaces to +, how do i get %20 instead?
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Hi Matt,
have a look at the bottom of the extension's talk page. The behaviour you describe is a bug with Firefox 3 and there's a fix that works...
Matt Long schrieb am 25.07.2008 18:39:
The problem with that extension is that it grabs the filename only.. it cuts off the path info. In the browse for file window it shows the full path, but after clicking ok it truncates everything down to just the file name. Matt
Katharina Wolkwitz wrote:
Hi Matt,
have a look at the FileLink-extension:
http://www.mediawiki.org/wiki/Extension:FileLink
Regards K. Wolkwitz
Matt Long schrieb am 24.07.2008 19:55:
Hello, I am trying to find a much easier way for people to use external file links in my wiki. Currently every space has to be replaced with a %20. Is there something like {{urlencode:}} that would work? The urlencode magic word converts spaces to +, how do i get %20 instead?
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Matt Long wrote:
Hello, I am trying to find a much easier way for people to use external file links in my wiki. Currently every space has to be replaced with a %20. Is there something like {{urlencode:}} that would work? The urlencode magic word converts spaces to +, how do i get %20 instead?
Edit includes/parser/CoreParserFunctions.php and change static function urlencode( $parser, $s = '' ) { return urlencode( $s ); } to static function urlencode( $parser, $s = '' ) { return rawurlencode( $s ); }
Then {{urlencode:}} will convert spaces to %20 (or you could create the rawurlencode parserfunction)
mediawiki-l@lists.wikimedia.org