Page MenuHomePhabricator

Allow skin developers access to URIs in SkinMustache
Open, Stalled, MediumPublic

Description

It's proposed that SkinMustache options are extended to allow generation of URIs
For now, it is recommended that query string parameters are not supported.

It's proposed that a skin should be able to register links to use in the Mustache template like so:

	"ValidSkinNames": {
		"myskin": {
			"class": "SkinMustache",
			"args": [
				{
					"name" : "myskin",
					"templateDirectory": "skins/MySkin/templates/",
					"messages": [ "mainpage" ],
					"links": {
						"mainpage": "mainpage",
						"create-account": "Special:CreateAccount"
					}
				}
			]
		}
	}

An associate array of links will be given. The keys are mapped to link- prefixed template keys that contain the URI. When combined with the existing messages option, this can be used to generate links. In the above example, a template can render a link like so:

<a href="{{link-mainpage}}">{{msg-mainpage}}</a>

Link values will be first treated as message keys and if no message exists, will be treated as Title objects.

This will be needed to port CologneBlue to SkinMustache, as CologneBlue contains custom menus linking to the aboutpage for example.

Acceptance criteria

  • It should be possible to generate a URI from a MediaWiki message
  • It should be possible to generate a URI from a specified Title.
  • All links generated are prefixed with link-
  • All links generated are in the current content language

Developer notes

foreach ( $links as $key => $pageOrMessage ) {
  $msgObj = $this->msg( $pageOrMessage );
  if ( $msgObj->exists() ) {
     $url = Skin::makeInternalOrExternalUrl( $msgObj->inContentLanguage()->text() );
  } else {
    $url = Title::newFromText( $pageOrMessage )->getLocalURL();
  }
}

Event Timeline

this would be helpful in the new ContentTranslation skin: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ContentTranslation/+/627982

It would also allow us to remove main-page-href from SkinVector for a more standard method of access.

Jdlrobson triaged this task as Medium priority.Sep 24 2020, 3:20 PM

Change 633041 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/core@master] It is possible for SkinMustache skins to declare links

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

Change 599972 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/skins/Vector@master] Use links SkinMustache option

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

Change 637537 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/skins/Example@master] Use new links feature for sourcing main page URL

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

Change 633041 abandoned by Jdlrobson:
[mediawiki/core@master] It is possible for SkinMustache skins to declare links

Reason:
Per patch discussion, it seems like it's not clear if this is actually useful to skin developers. Thanks for the input. Bumping this back to discussion. We can revisit if and when we see a pattern emerging of skins extending the SkinMustache class just to add links. It does sound like an obvious next step however would be to put the main page url in the template data somewhere - maybe as part of the logo.

Feedback fom @Mainframe98:
"I'm a bit conflicted on this - it feels very overspecialized. Only CologneBlue is really using the feature for more than one link.

I see that mainpage is a common shared link - that link could be provided by SkinMustache out of the box, in my opinion, since any skin has a use for that.

from @Ammarpad:
I share this sentiment. I think the mainpage link should be in template data, it will probably always be needed. I commented in the CologneBlue patch, as T262729 made it clear query strings are not supported, this link feature will not suffice the skin either, it will slightly degrades it actually."

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

Change 639614 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/core@master] Expose main page to template

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

Change 639614 merged by jenkins-bot:
[mediawiki/core@master] Expose main page to template

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

Change 599972 abandoned by Jdlrobson:
[mediawiki/skins/Vector@master] Use links SkinMustache option

Reason:

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

Jdlrobson changed the task status from Open to Stalled.Nov 16 2020, 9:18 PM

To be re-reviewed in June 2021 based on the experience of skin developers. If this doesn't seem useful when reviewing then we can decline this.

Change 637537 merged by jenkins-bot:
[mediawiki/skins/Example@master] Use main page link provided by SkinMustache

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