Site-wide usernames for namespace pages
bandali0 opened this issue · 2 comments
bandali0 commented
I've noticed that pages in a namespace use username local to that namespace. It would be nice to have the option to link to site-wide (top-level) username pages instead.
kensanata commented
How about this...
Put the code below into your config file. It’s a copy of the GetAuthorLink
code with the following changes:
- where we match $InterSitePattern it removes the Namespace prefix (if any)
- it assumes that you want to link usernames (ignoring $RecentLink) and locally sets $ScriptName to the root namespace
sub GetAuthorLink {
my ($username, $host) = @_;
$username = FreeToNormal($username);
$username =~ s/^(?:$InterSitePattern:)?$FreeLinkPattern/$1/;
my $name = NormalToFree($username);
if (ValidId($username) ne '') { # ValidId() returns error string
$username = ''; # Just pretend it isn't there.
}
if ($username) {
local $ScriptName = $NamespacesRoot;
return ScriptLink(UrlEncode($username), $name, 'author');
}
return T('Anonymous') if $host eq 'Anonymous';
return ColorCode($host);
}
I've added it to the end of Comments on Namespaces Extension.
This is somewhat tested: looking at Recent Changes of the main namespace, looking at Recent Changes of another namespace, looking at the footer of a page in another namespace.
bandali0 commented
Sorry for the slow reply. Just got around to trying this, and works great as expected, many thanks!