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 project: User-Ladsgroup. · View Herald TranscriptMar 30 2017, 8:22 AM
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
daniel added a subscriber: daniel.Mar 30 2017, 1:47 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 closed this task as Resolved.Apr 9 2017, 9:30 AM
Ladsgroup triaged this task as Normal 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 reopened this task as Open.Apr 12 2017, 6:34 PM
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.

thiemowmde moved this task from incoming to in progress on the Wikidata board.Apr 12 2017, 6:34 PM
Ladsgroup reassigned this task from Ladsgroup to thiemowmde.Apr 12 2017, 6:41 PM
Ladsgroup removed a project: User-Ladsgroup.

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

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

Ladsgroup closed this task as Resolved.Apr 25 2017, 7:34 AM
Ladsgroup moved this task from Review to Done on the Wikidata-Former-Sprint-Board board.