Page MenuHomePhabricator

[Task] Introduce HTML templates infrastructure for Wikibase Lexeme
Closed, ResolvedPublic

Description

From T160524#3140490:

  • [Task] Introduce HTML templates infrastructure
    • Key element is a new templates.php file, and a RessourceLoader module. Copy-paste from Wikibase.git.
    • Try to reuse code from Wikibase.git if it makes sense.
    • The templates list is (almost) empty, and the templating is unused at this point. Do not touch existing view code in this patch.
    • Add a comment that suggests a clean naming scheme, e.g. each template name starts with "wikibase-lexeme-…".

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
daniel renamed this task from [Task] Introduce HTML templates infrastructure to [Task] Introduce HTML templates infrastructure for Wikibase Lexeme.Mar 30 2017, 1:24 PM

@Ladsgroup I have an alternative proposal. Here's how I understand the need:

  • we want a file defining templates for WikibaseRepo, and a factory service for getting these templates in PHP
  • we want a file defining templates for WikibaseLexeme, and a factory service for getting these templates in PHP

So:

  • remove the static singleton field from TemplateFactory
  • For WikibaseRepo, create a TemplateFactory instance that loads the template definitions for repo.
  • For WikibaseLexeme, create a TemplateFactory instance that loads the template definitions for lexeme.

The question is now where to get the right TemplateFactory instance from. TemplateFactory will have to be injected into services, so it has has to be available to wiring code. So the natural place for the repo instance is the WikibaseRepo top level factory. Managing a singleton in a static field, as we do now, will also work, but it annoying for testing etc.

Similarly, we could manage the TemplateFactory instance for lexeme in a static field of some class (which probably doesn't do anything else, and doesn't need to subclass TemplateFactory). However, we'll have to introduce a top level factory for WikibaseLexeme anyway, or at least some static front for accessing services, like MediaInfoServices.

So, my proposal is:

  • create a WikibaseLexemeServices class.
  • WikibaseLexemeServices manages a TemplateFactory instance in a static field for now.
  • WikibaseLexemeServices can eventually become a proper top level factory
  • Optionally, remove the singleton from TemplateFactory, and move it to the WikibaseRepo top level factory

This sound like an incredible amount of overhead for a thing that can't be much more trivial: templates are basically nothing but an array of strings. We only need something like this (preferably not as complicated as outlined above) if LexemeView needs access to Wikibase templates, which is not the case right now. I strongly suggest to stick to the most trivial solution right now: a LexemeTemplateFactory with no singleton.

Change 345514 abandoned by Ladsgroup:
Change $instance attribute visiblity in Template factory to protected

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

@thiemowmde you seem to be misunderstanding my suggestion. It boils down to literally just new TemplateFactory( '.....lexeme-templates.php' );. That instances needs to be accessible somehow, so you need a "singleton" (really, a default instance). Can be a static member, but of which class? My suggestion is a class called LexemeServices, since we'll need that anyway. It comes down to a 10 line class called LexemeServices. I don't see the incredible overhead.

Change 345515 merged by Jonas Kress (WMDE):
[mediawiki/extensions/WikibaseLexeme@master] Introduce LexemeTemplateFactory and templates.php file

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

Ladsgroup triaged this task as Medium priority.
Ladsgroup moved this task from Blocked on others to Done on the User-Ladsgroup board.

Change 347337 had a related patch set uploaded (by Thiemo Mättig (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Remove subclassing and unused code from LexemeTemplateFactory

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

thiemowmde moved this task from Done to Review on the Wikidata-Former-Sprint-Board board.

@daniel, see https://gerrit.wikimedia.org/r/347337 for what I meant. No singleton, no subclassing, super super simple.

Change 347337 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Remove subclassing and unused code from LexemeTemplateFactory

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

Ladsgroup moved this task from Review to Done on the Wikidata-Former-Sprint-Board board.