Following the discussion on the Lua talk page, here is the roadmap for the template and module:
Task | Completion | Comments |
---|---|---|
Create Template talk:SeatsEUPPs | ✅ | |
Redirect module talk pages to Template talk:SeatsEUPPs | ✅ | |
Create Template:EUPP seats/sandbox so that it uses Module:EUPP seats/sandbox | ✅ | |
Create Template:EUPP seats/testcases | ✅ | |
Replace documentation for Template:SeatsEUPPs | ✅ | |
Create module testcases; see mw:Multilingual Templates and Modules#Testcases | ✅ | |
Make sure that at least one (probably both) of above testcases have a test for each of the error messages | ✅ | Done for Module:SeatsEUPPs/testcases |
Improve description text above functions seats() and seats_share() in both the live and sandbox modules | ✅ | |
Review all the comments in live and sandbox modules | ✅ | |
Review all error messages in Module:EUPP seats/config | ✅ | |
Make separate validation function for width | ✅ | |
Make separate validation function for institution and party | ✅ | |
Fix issues with error messages in Module:EUPP seats/sandbox | ✅ | |
Update documentation | ✅ | Ready (check after sandbox is moved to main module) |
Make documentation for Template:EUPP composition bar | ✅ | Ready |
Rename all module/template pages to names "EUPP seats" and "EUPP composition bar" | ✅ | |
Make separate validation function for percentage/reference | ✅ | Not needed, but might help fix issue further down |
Make Template:EUPP composition bar use Module:EUPP seats instead of Module:EUPP seats/sandbox | ✅ | |
Allow "ref=yes" alongside "yes" for references, error message for all other (same with "pc=" percentage) | ✅ | Done as part of broader change |
Allow different order to parameters 3, 4, and 5 | ✅ | Done as part of broader change |
Fix composition_bar calling "this party" from non-party page (show error but also attempts to make a composition bar) | ✅ | |
Allow to bypass colour with special parameter | ✅ | Done as part of broader change |
Deploy on relevant pages | ✅ | |
Make cosmetic tweaks to code | ⚠️ | Still relevant? Should we care that Template:EUPP composition bar or Template:EUPP seats shows an error at the top? |
Is there a way to made a testcases page for ModuleEUPPs/sandbox
to test the impact of the proposed code?
Note: "for the 'share' outputs, should the output have a '%' suffix?" -> I would say no, as my idea was to use this for charts that need a percentage value (as a number, not a string). Julius Schwarz (talk) 08:03, 25 March 2025 (UTC)
{{test case}}
templates at Template:SeatsEUPPs/testcases. I have also changed {{SeatsEUPPs/sandbox}}
to use Module:SeatsEUPPs/sandbox. From the ~/testcases results, you can see that the live template rarely agrees with Module:SeatsEUPPs/sandbox. At a glance, testing the live module against the live template in ~/testcases gives similar results. No doubt, the live template uses it parameters differently from the modules.{{SeatsEUPPs/sandbox}}
to {{SeatsEUPPs}}
. In {{SeatsEUPPs}}
, change the invoke to {{#invoke:SeatsEUPPs|main}}
. Save...'%'
@Trappist the monk as you can tell, I am rather new to modules. My idea was that, by creating the module, we would use it directly in relevant pages. But from your last comment about the way forward, I have a sense that we will keep using the template. Does this mean that we should rewrite the template to call the module? For instance, the revised template would be {{SeatsEUPPs|EP|EPP}}
and this would actually call {{#invoke:SeatsEUPPs|main|EP|EPP}}
? Is it just for writing convenience, then? Julius Schwarz (talk) 08:09, 25 March 2025 (UTC)
main
) from editors.{{#invoke:SeatsEUPPs|main}}
in the template will hand the parent frame parameters (from the template call in article wikitext) to the module. You can see this working in {{SeatsEUPPs/sandbox}}
:
{{SeatsEUPPs/sandbox|EP|EPP}}
→ {{SeatsEUPPs/sandbox}}Hi @Trappist the monk, before you bow out, allow me to ask one more thing. I started replacing raw calls to wikidata with the module and it hit me that, in most cases, this is being used as part of a composition bar. Not always, but super often.
And all of a sudden, it became a bit irresistible to make another module, based on Module:SeatsEUPPs that would spit out the composition bar :D Now, I got the gist of most of the process, but I could use a quick hand to write the part that actually writes the composition bar using our module. Would you mind having a look? It's at Module:Sandbox/Julius Schwarz/CompositionBarEUPPs Julius Schwarz (talk) 21:43, 25 March 2025 (UTC)
composition_bar()
at the bottom of ~/sandbox, added some comments and questions there. Improve on that.
{{#invoke:SeatsEUPPs/sandbox|composition_bar|EC|EPP}}
→ {{#invoke:SeatsEUPPs/sandbox|composition_bar|EC|EPP}}{{Composition bar}}
documentation, width specified as without units assumes px
. The documentation also says that the template will also accept %
and em
units. I've added a snippet of code to validate the width value. Should probably be a separate function. Also added '#' to the color.{{CompositionBarEUPPs}}
is going to mimic {{composition bar}}
, it seems to me that {{CompositionBarEUPPs}}
should use the same parameter names for the options:
|background-color=
|border=
|width=
|per=
|ref=
{{{3}}}
, {{{4}}}
, {{{5}}}
.{{{3}}}
for use as {{composition bar}}
uses it, or create a new option parameter |bar-color=
. This latter would be my preference. Of course, I would also spell-out |percent=
and |reference=
(and also rename {{CompositionBarEUPPs}}
to {{Composition bar EUPPs}}
or better, {{EUPP composition bar}}
because English is written with space characters between words; I might even suggest {{EUPP seats}}
as a better name).validate_institution_party()
. Seems to work, you might want to test it further.|width=
({{{3}}}
), |pc=
({{{4}}}
), and |ref=
({{{5}}}
). Still to do is to remove support for those positional parameters.get_colour()
. The hash prefix is added there because it should be possible to use named colors in |bar-color=
(which overrides the wikidata color). Other color parameters also appear to be working:
{{EUPP composition bar/sandbox|EC|EPP|bar-color=blue|border=red|background-color=#3a3}}
→ {{EUPP composition bar/sandbox}}|percent=
and |ref=
are now case-insensitive. Positional parameters {{{3}}}
, {{{4}}}
, and {{{5}}}
are now ignored.seats()
and seats_share()
. Template:EUPP seats/testcases seems to show that I did not break anything. If you agree then the live module should be updated from the sandbox.Just wanted to massively thank @Trappist the monk for their help on this. Given my own knowledge of Lua (or lack thereof), none of this would have been possible without them, and the code in the articles look much much neater now! I also learned a whole lot, which feels great. Admittedly, this does not impact too many pages per wiki, but it is directly applicable to many other wikis, so I look forward to working on translating it and replicating it! Julius Schwarz (talk) 14:38, 28 March 2025 (UTC)