User:Wlgrin/Template/WikipediaURI-Protected/doc

Template produces slightly obsfuscated markup code that itself produces the linked URI of a Wikipedia page. It is useful to defeat not-too-smart scripts running on hostile Wikipedia mirrors that may attempt to strip source identification.

Basic usage
Template takes three named parameters, all optional:
 * server-name is the name of a Wikipedia server; for example, en for the English Wikipedia. By default, this parameter is set to www.
 * page-name is the full name of a page on the Wikipedia server; for example, User:MeMyselfEtMoi/My current projects.
 * This parameter will be automatically encoded (using ) to produce a valid wiki link, so there is no need to encode it before passing it to template . Only the copy used to create the link will be thus encoded; the copy used for display (if parameter link-name is not supplied; see below) will be shown unchanged.
 * By default, this parameter is set to a blank text string; template will then produce a URI to the base server.
 * link-name is the text that will be displayed and linked to the Wikipedia page; its value is not used to produce the URI. By default, it is the unencoded URI itself.

The use of magic words (such as  for the value of server-name or <tt>      </tt> for the value of <tt>page-name</tt>) must be avoided here, since the values of those magic words are dependent on the Mediawiki settings configured on the mirror server. The URI produced here must be independent of those settings, hence the need to hardcode its constituents in the calling page.


 * {| class="wikitable collapsible collapsed" style="min-width:30em;"

!style="text-align:left;"|Examples
 * style="padding:1em;"| For example, passing a server name, a page name and a link name like this:
 * style="padding:1em;"| For example, passing a server name, a page name and a link name like this:

will produce
 * <samp style="padding-left:1em; padding-right:1em; background-color:#F2FFE6;">My Wikipedia projects

Omitting the link name, like this:

will instead produce
 * <samp style="padding-left:1em; padding-right:1em; background-color:#F2FFE6;">http://en.wikipedia.org/wiki/User:MeMyselfEtMoi/My current projects

In the sample output above, notice that the page name in the link is properly encoded (spaces replaced with underscores), but is displayed unencoded on the page. Omitting the page name also, like this:

will produce
 * <samp style="padding-left:1em; padding-right:1em; background-color:#F2FFE6;">http://en.wikipedia.org/

And omitting the server name also, like this:

will produce
 * <samp style="padding-left:1em; padding-right:1em; background-color:#F2FFE6;">http://www.wikipedia.org/


 * }

Using substitution
Template can be safely substituted, since it uses the “safesubst” modifier to call parser functions and magic words, and it does not transclude any other page.

If you wish to substitute template instead of transcluding it, remember to also substitute any parser functions or magic words used in its parameter list. This is because the MediaWiki parser performs all substitutions before performing any transclusion.


 * {| class="wikitable collapsible collapsed" style="min-width:30em;"

!style="text-align:left;"|Examples
 * style="padding:1em;"| For example, using the following incorrect call on page <tt>“   :MeMyselfEtMoi/My current projects”</tt>:
 * style="padding:1em;"| For example, using the following incorrect call on page <tt>“   :MeMyselfEtMoi/My current projects”</tt>:

will produce the likely unintended output
 * <samp style="padding-left:1em; padding-right:1em; background-color:#FFF2E6;">http://en.wikipedia.org/wiki/User:MeMyselfEtMoi/My current projects

In the sample output above, notice that, while the URI is displayed as expected, the URI actually linked (hover over the link to see it) is truncated: the full page name <tt>User:MeMyselfEtMoi/My_current_projects</tt> is missing. This is because will be substituted before the instance of  used to produce the URI is resolved. By contrast,

will produce the expected URI within the link:
 * <samp style="padding-left:1em; padding-right:1em; background-color:#F2FFE6;">http://en.wikipedia.org/wiki/User:MeMyselfEtMoi/My current projects


 * }