Page MenuHomePhabricator

VisualEditor: When getting TemplateData, VE automatically adds "Template:" even if another namespace is provided
Closed, ResolvedPublic

Description

If you want to add a "template" that is not in the template namespace, for example: "User:UBX"; VE will make an API request like: "GET https://en.wikipedia.org/w/api.php?format=json&action=templatedata&titles=Template%3AUser%3AUBX".

It should automatically detect that "User:" is a valid namespace, and not add the "Template:" prefix.


Version: unspecified
Severity: minor

Details

Reference
bz52609

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:57 AM
bzimport set Reference to bz52609.

It looks like we can just pass the title to mw.Title.newFromText with mw.config.get( 'wgNamespaceIds' ).template as the (default) namespace.

(Okay, it's not as simple as I was hoping)

Change 140875 had a related patch set uploaded by Alex Monk:
Handle transcluding templates outside of the template namespace properly

https://gerrit.wikimedia.org/r/140875

This was also hiding another problem (templates outside of the Template namespace ended up prefixed with ':', breaking them). This patch should fix that too (and hopefully not break any other link suggesting things).

The commit says the purpose of the colon is "to create a link to something that would normally be included as a File/Category".

That's true, but it also plays a role in transclusion. It's used to transclude things in the main namespace.

E.g. on English Wikipedia {{Main Page}} transcludes https://en.wikipedia.org/wiki/Template:Main_Page , whereas {{:Main Page}} transcludes https://en.wikipedia.org/wiki/Main_Page

For other namespaces (e.g. {{Wikipedia:Community Portal}} / {{:Wikipedia:Community Portal}} ), it works either way.

Full demo: https://en.wikipedia.org/w/index.php?title=User:Superm401/Sandbox&oldid=614564227

This may be handled somewhere (e.g. Parsoid), but it needs to be tested.

What Matt pointed out is handled correctly except for main namespace titles (e.g. :Foo), where the input widget trips over itself and you always end up with Template:Foo.

Change 140875 merged by jenkins-bot:
Handle transcluding templates outside of the template namespace properly

https://gerrit.wikimedia.org/r/140875