Kushal Koolwal wrote:
MediaWiki: 1.12
Host OS: Linux
Most of our intranet mediawiki users are very non-technical. We link to a lot of file
that resides on Windows shared network drive in our mediawiki articles. There are hundreds
and hundreds of such files. These files and their paths have "spaces" in them
which needs to be converted into their ASCII equivalent of "%20".
Using {{urlencode}} does not work because it converts "spaces" into
"+" character according to RFC1738.
Right now I am using string replacement extension and created a template called
"Delspace" with following function:
{{#replace:{{{1}}}| |%20}}
and I am using the template in our wiki articles like this (for example):
[{{delspace|file///Z:/my project/final results.pdf}} Link to results.pdf]
The above works but as I mentioned before, most of the users are non-technical (word doc
types) and it is kind of cumbersome for them to use the above template every time they
need to put a link to a document.
So my question(s) is:
1. Basically I am looking for is a way in which the users won't have to
use the template manually every time they need to put a link to a
document which have "spaces".
You could have them use {{file|results.pdf}} and provide a template
which expands to the whole url.
2. Alternatively, is there a way by which all the
file:/// urls in a wiki article which have "spaces" get automatically converted
into proper urls (with %20 instead of "spaces") when the user hits the
"Save Page" button?
No, since a space marks the end of the url. You'd need something else to
mark its end (like passing it to a template, like you're doing).
Plase note that file urls don't work on some browsers, like Firefox.
There're workarounds, and extensions but file:/// urls usually give
problems.