[Mediawiki-i18n] How to create login / signup links cleanly?

S Page spage at wikimedia.org
Mon Jun 16 22:58:18 UTC 2014


If I want to show anonymous users a message including "You can _login_ or
_create an account_ " with returnto support, what's the best way to do it?


Background:

All over MediaWiki we display messages to anonymous users with "_login_ or
_create an account_" links in them. In most cases we want the user to
easily get back to what they were doing, so Special:UserLogin supports
returnto and returntoquery parameters which after login or signup make it
display a link to go back to the page the user was on, or silently redirect
back to it.

The display of login/signup links seems haphazard:

1) Many messages don't bother with returnto, and just have wiki links to
the special page.  E.g. anontalkpagetext has:

please [[Special:UserLogin/signup|create an account]] or
[[Special:UserLogin|log in]] ...

2) Some messages try to handle returnto with complicated magic word
processing, , e.g. https://en.wikipedia.org/wiki/MediaWiki:Anoneditwarning
has:

If you '''[{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}} log
in]''' or
'''[{{fullurl:Special:UserLogin/signup|campaign=anoneditwarning&returnto={{FULLPAGENAMEE}}}}
create an account]''' ...

This is fiddly, the magic words don''t work in JavaScript, and the
resulting HTML requires you put class=plainlinks on the enclosing tag to
disable the display of the external link icon. On the plus side it's
generated entirely in the message string, and wiki admins can tweak
parameters, like the signup campaign parameter in this example.

3) Often code builds the login/signup links in PHP and passes them to the
message.

3a) OutputPage-> showPermissionsPage() builds a login URL with
Linker:LinkKnown. It doesn't provide a sign up link, and the code to build
the login link can't be reused. Which may be why
WatchAction->checkCanExecute() and SpecialPage::requireLogin copy and paste
the code.

3b) SkinTemplate.php generates the Login / Create account URLs at the top
right of most skins using Skin::makeSpecialUrl. But you can't pass this to
a message because it may not start with //myserver.com and if it doesn't
then it won't work in a [$1 link text] link.

Thanks for any advice,

-- 
=S Page  Features engineer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wikimedia.org/pipermail/mediawiki-i18n/attachments/20140616/b5797c93/attachment.html>


More information about the Mediawiki-i18n mailing list