Last modified: 2014-10-27 09:48:04 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T54581, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 52581 - TemplateData: Implement inferred templatedata as fallback based on the contents of the template
TemplateData: Implement inferred templatedata as fallback based on the conten...
Status: ASSIGNED
Product: MediaWiki extensions
Classification: Unclassified
TemplateData (Other open bugs)
unspecified
All All
: Low enhancement with 1 vote (vote)
: ---
Assigned To: Editing team bugs – take if you're interested!
:
Depends on:
Blocks: ve-nonenglish
  Show dependency treegraph
 
Reported: 2013-08-06 16:00 UTC by kipod
Modified: 2014-10-27 09:48 UTC (History)
11 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description kipod 2013-08-06 16:00:54 UTC
if the template does not contain explicit "templatedata", the API call should return auto-generated "templatedata" structure, distilled from the template itself.


it's trivial to do - basically parse the template, extract parameter names (including order based, aka 1,2,3), and return "default" templatedata where every param is of type string, without any special attributes (default, required, etc.)

this 15-line enhancement will make VE suddenly useful for templates, without detracting anything from current functionality.

we did this in hewiki with "template param wizard" (the equivalent of VE template editor, for the old wikitext editor), and it enhanced the wizard's functionality tenfold.

regretfully i can't submit a patch - hopefully someone else will be able to do so.

peace.
Comment 1 Roan Kattouw 2013-08-08 03:03:49 UTC
I very much look forward to a link to the part of the hewiki wizard that implements this logic. I very much doubt it can be done (or done well) in 15 lines of code, and I very much doubt it's trivial or even easy to do it well.
Comment 2 kipod 2013-08-08 06:09:21 UTC
https://he.wikipedia.org/wiki/Mediawiki:Gadget-TemplateParamWizard.js

the function is called buildParamsRaw() ("data" is the raw template page).

i cannot guarantee that it always works flawlessly, but the wizard works on hewiki  for a while now (more than a year), and i did not get any bug reports (i did have some bug reports for previous versions).

i think it is possible to intentionally create a legal template that will give bad results there: specifically, this function does not take "nowiki" and "noinclude" tags into account.

OTOH, it uses only 9 out of the budget of 15, so you have 6 lines to augment those shortcomings...

more seriously: i assumed the codebase already have non-negligible amount of logic that can be used to distill the parameter list of a template. 

(full disclosure: i too did not believe it can be done without tons of code - Eran Roz showed me the light)
Comment 3 Thomash Lee 2013-08-08 08:00:02 UTC
Hi kipod. I can't understand Hebrew language and I have some trouble to test it in Hebrew Wikipedia. Can you translate the gadget to English Wikipedia under your own userspace? Thank you.
Comment 4 kipod 2013-08-08 13:40:37 UTC
i did it long ago, and published it on [[en:Wikipedia:WikiProject_User_scripts/Scripts#Scripts]]. the script page on enwiki is [[en:User:קיפודנחש/TemplateParamWizard]]. the script source itself is practically identical to the hewiki one, except maybe some recent enhancement(s) to the hewiki script (for instance, by default, the wizard does not leave empty parameters on the page, but some users asked for this as an option, so now the hewiki script learned to support on more option).


the wizard uses a similar construct to "templatedata", but instead of having this information on the template page, it uses a subpage with a fixed name (in enwiki, this fixed name is "Parameters", so for Template:Foo, the templatedata equivalent will be in Template:Foo/Parameters).

when the subpage does not exist, the wizard extracts the list of parameter names from the template itself, with some fixed attributes (for instance, in this case it assumes that each parameter is "multiline")

i believe there are several people on enwiki who actually use this (at least there were) - you probably want to ask them about their experience (something like

https://en.wikipedia.org/w/index.php?title=Special%3ASearch&profile=advanced&search=TemplateParamWizard+intitle%3Ajs&fulltext=Search&ns2=1&redirs=1&profile=advanced



the wizard supports some attributes that, to the best of my knowledge, "templatedata"/VE do not support yet, which i think would be good ideas:

-- "Extended": this allows the designer to designate some fields as "secondary", which means they are not visible when the form opens. if there is at least one "Extended" parameter, the form will grow a new checkbox "Show all fields", which allows the user to show/hide the "Extended" fields.

-- "Choices": this allows the designer to declare that a certain parameter has a fixed set of "legal" values. very useful when the template uses a parameter as an input for {{#switch:

-- "Depends on": only expose this field if some other field is not empty. very useful for templates with many repetitions (e.g., [[en:Template:Track listing]]: you make "title4" depend on "title3", and then "note4", "writer4", "lyrics4", "music4", "extra4", "length4", and finally "title5" all depend on "title4"). without this feature, the wizard is much less useful for templates of this type.


peace.
Comment 5 Thomash Lee 2013-08-08 15:40:28 UTC
Thank you so much. It works beautifully. I couldn't test it in Hebrew WP because it is situated in the edit toolbar which was disabled by me because I feel more comfortable to type everything with my keyboard. But anyway, the gadget's performance is smooth even while editing large article like "United States" in English WP. The only few issues I can think of right now after tried it a bit are, I don't feel the toolbar is the proper place for the gadget icon. It deserves a more visible location in the edit page. The other thing I hope to improve is that I need to select the whole markups of existing template from "{{" to "}}" in order to edit it in the Wizard. For large infobox template which has lot of parameters filled, it could be little bit inefficient to trigger. I suggest the end of the selection of the markup extends to the first vertical bar near the template name, so only selecting like this "{{templatename|", works the same way as "{{templatename|foo|bar}}".
Comment 6 kipod 2013-08-08 15:50:47 UTC
Thanks so much for the nice words, but... 
This entry is about templatedata, not templatewizard.

the information i brought above relating to TW was meant as "what templatedata can learn from TW" - if you'd like to discuss TW and its use on enwiki, it should be discussed on enwiki, not here.

peace.
Comment 7 kipod 2013-08-29 15:35:01 UTC
The status was recently changed to "Assigned", but the "Assigned to" field was left as "Nobody". 
is Mr. (or Ms.) "Nobody" a new developer on the team?

peace.
Comment 8 Helder 2013-11-02 17:27:47 UTC
(In reply to comment #4)
> i did it long ago, and published it on
> [[en:Wikipedia:WikiProject_User_scripts/Scripts#Scripts]]. the script page on
> enwiki is [[en:User:קיפודנחש/TemplateParamWizard]].

See also
https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)/Archive_103#Template_Parameter_Wizard
(mentioned on bug 39598 comment 1)

> -- "Choices": this allows the designer to declare that a certain parameter
> has
> a fixed set of "legal" values. very useful when the template uses a parameter
> as an input for {{#switch:

Bug 51375.

> -- "Depends on": only expose this field if some other field is not empty.

Bug 50407.
Comment 9 Krinkle 2014-05-20 20:07:34 UTC
So this "guess template data" parser would be useful in two cases:

* Consumers of TemplateData (e.g. VisualEditor)

They could pass a parameter to the API of TemplateData to trigger this parser as fallback. The generated data would presumably be flagged in some way to allow consumers to identify them as such.

* TemplateDate editor

A button to prefill the template data (e.g. use the default data as a start and edit from there). This should not be misused to populate <templatedata> tags on a bunch of pages, this is only useful if users provide data beyond what is inferred (the inferred data is unlikely to ever be satisfactory as at best it can provide which parameters exist and maybe which are optional).
Comment 10 kipod 2014-05-22 21:35:05 UTC
for many many simple templates, just getting the list of parameter names is enough for even moderately experienced editors. 
the editor may even be well familiar with the template, but she does not necessarily remembers the exact name (case sensitive) of every parameters.


regarding your 2nd use case: are you aware that this tool (prepopulate templatedata editor) is already written and working?

written by wmf volunteer (intern? gsoc student? not sure), [[mw:. User:Mooeypoo]], and works on hewiki for quite some time. 
this tool already includes "import parameters from template" button - last time i checked, it was working quite well. 

see [[mw:MediaWiki:Gadget-templatedata-core.js]], function "importtemplateparams()"

if your comment meant to describe it rather than suggesting to build it, i apologize for the confusion.

bottom line: having templatedata is good, but when it does not exist, just seeing the list of parameters (including unpopulated) is hugely perferrable to not seeing them.

peace.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links