Page MenuHomePhabricator

Add ability to link by URL to namespaces by their number
Open, LowPublicFeature

Description

If there is tool which is supposed to link to various pages and it is supposed to be crossproject, then although it can link to basic namespaces (-2 - 14) via canonical names, further namespaces can't be linked otherwise than obtaining current namespacelist from API. This is not practical for example in cases when tools run offline etc.

Therefore it would be practical to have ability to link by URL to namespaces via their numbers.

On wiki you can of course do [[{{ns:10}}:Foo]] to get Template:Foo, but you can not construct URL on external tools this way.

There are two possible solutions coming to my mind:

  1. mywiki.example/wiki/10:Foo
  2. mywiki.example/wiki/Special:CanonicalLink/10:Foo

I would personaly prefer the first solution because it is shorter and more intuitive. However I assume there could be some issues with existing page titles starting with numbers. So actually allowing the parser function to expand in URL might work:

  1. mywiki.example/wiki/{{ns:10}}:Foo

If none of those above are possible, I would welcome even any other solution which would allow linking to namespaces via their numbers.


Version: unspecified
Severity: enhancement

Details

Reference
bz37825

Related Objects

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:29 AM
bzimport set Reference to bz37825.
bzimport added a subscriber: Unknown Object (MLST).

Or [10]:Foo?

In this way it can be used in URL only and avoid any conflict with existing title.

Or [10]:Foo?

In this way it can be used in URL only and avoid any conflict with existing title.

Yeah, pretty much does the same as mywiki.example/wiki/{{ns:10}}:Foo - that also avoids conflicts and is consistent with wikitext...

What about, in Setup.php' establishing that, for every namespace, an entry in $wgNamespaceAliases is added?

For 10:Foo
$nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
foreach ( array_keys( $this->getCanonicalNamespaces() ) as $ns ) {
	$wgNamespaceAliases[] = [ (string)$ns => $ns ];
}
For [10]:Foo
$nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
foreach ( array_keys( $this->getCanonicalNamespaces() ) as $ns ) {
	$wgNamespaceAliases[] = [ ( '[' . (string)$ns . ']' ) => $ns ];
}
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:14 AM