Page MenuHomePhabricator

Improve file description syntax configurability
Closed, ResolvedPublic

Description

Currently, the uploader assumes the target wiki uses the same set of templates as Commons, which is not… ideal, as the number of required templates is rather large. The various parts of the file description syntax should be made configurable and we should provide a few ready configuration sets for wikis to use.

This should be a large tracking task, but for now the goals are listed here. Feel free to split them up into separate tasks.

  • Make the {{own}} syntax configurable
  • Make all kinds of Information-related syntax configurable
  • Make file description headers configurable
  • Make the Location template syntax somewhat configurable
  • Allow (or document how to do this if it is possible) disabling of adding a tracking category to campaign-uploaded files
  • Prepare a few ready-to-use configuration sets. Some ideas:
    • Original Commons-style syntax from UploadWizard
    • Commons-style, but with removed multilingual support
    • Some default config that should be simple to use, with minimal templates
    • Even simpler config with no templates?

See also the configuration manual for core's upload dialog, it has some of these capabilities. It could serve as an inspiration.

Event Timeline

Solution draft:

Make a config setting for setting the wikitext formatting the final file description page. It can include subst: and parser functions to allow for arbitrarily complex behavior when constructing the output. The values would be substituted before saving on fake {{{name}}}-style arguments, with argument names corresponding to the name of the field in the form. The triple-brace syntax would be limited to not allow specifying default values (that can be already done in field config) and will be just a simple substitution.

Some variable names may be reserved for special purposes, such as license. The configurable fields will be in the details step.

Example:

{{Information|caption= {{{caption}}} |license= {{{license}}} }}

{{subst:#if: {{{location}}} | {{location| {{{location}}} }} }}

When saved this would evaluate to e.g.:

{{Information|caption= Look at the shtupid look on the cat's face! |license={{cc-by-sa-3.0}} }}

{{location|51.123;29.123}}

This should cover ~100% (+-5%) of use cases. It's not the prettiest, but will be probably easiest for users, as they are already very familiar with the curly, curly MW syntax.

Note: this will be a bit frustrating when you just want to add an extra line in a campaign. One solution would be to allow adding pre-/postfixes to the description template, but what about e.g. extra arguments to {{Information}}?

I don't have a good solution to this for now, but thankfully it's not a blocker, just an inconvenience. We should open a follow-up task related to this when the first version is finished. I think that T275027 will have a very similar problem with small changes in field specification.

We should probably validate the keys of the fields. There should be some reserved names and things like }}}#DROPTABLE should be disallowed. Not that they would work.

Note that #if and friends are in the ParserFunctions extensions, which, although popular, is not installed everywhere. Thus, the defaults will need to avoid it. In the docs add other (better) configurations that do use this extension.

Change 826903 had a related patch set uploaded (by Ostrzyciel; author: Ostrzyciel):

[mediawiki/extensions/MediaUploader@master] WIP: Improve file description syntax configurability

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

It works, but the licenses are just like in UW. That's something to fix later in T278871.

Change 826903 merged by jenkins-bot:

[mediawiki/extensions/MediaUploader@master] Improve file description syntax configurability

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

Ostrzyciel claimed this task.