Wikipedia:Lua requests

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Project talk
  To do
en: m: mw: external

Lua scripts on Wikipedia are similar to templates but useful for performing more complex tasks for which templates are too complex or slow. Common examples include numeric computations, string manipulation and parsing, and decision trees. You can use this page to request help from Lua developers in writing a Lua module for a specific task on Wikipedia or another Wikimedia Foundation project. Both debugging help and full implementation are available.

To start a request, just make a new section below and describe what you need. You may wish to first check Special:PrefixIndex/Module: to see if you can find a suitable existing script.

It may help developers to provide examples of where the task is likely to be useful within Wikipedia. If the proposal would replace or improve upon existing templates, please note which ones.


Could someone make that Module:it-conj in Wiktionary gives every page which uses any third parameter (e.g. leggere) the Category Italian irregular verbs? Compare this discussion. Thank you --Bigbossfarin (talk) 19:54, 3 July 2014 (UTC)

@Bigbossfarin: I'm not totally sure what you're asking for, but would
if args[3] and mw.text.trim(args[3]) ~= '' then
	table.insert(data.categories, 'Italian irregular verbs')
work? Jackmcbarn (talk) 20:23, 3 July 2014 (UTC)
Thank you for you help Jackmcbarn, but I think that doesn't work if any special parameter like "pastp=letto" appears. Is there any way to make that any additional parameter is filtered by this category?--Bigbossfarin (talk) 23:23, 4 July 2014 (UTC)
@Bigbossfarin: What about this?
for k,v in pairs(args) do
	if k ~= 1 and k ~= 2 and mw.text.trim(v) ~= '' then
		table.insert(data.categories, 'Italian irregular verbs')
Jackmcbarn (talk) 23:48, 4 July 2014 (UTC)
Thank you I will try it! --Bigbossfarin (talk) 12:25, 5 July 2014 (UTC)
It works! Thank you you very much for your help --Bigbossfarin (talk) 12:38, 5 July 2014 (UTC)

Module:Infobox NCAA team season[edit]

I'd like to talk about replacing {{Infobox NCAA team season}} with a proper LUA module. I feel a little like a tail wagging a dog, because my main concern is how kludgy the process is to identify whether the season name should include "Men's", Women's" or neither (which is not as simple as it might sound. For example, the recent Arkansas men's basketball team title should be "2013–14 Arkansas Razorbacks men's basketball team" but the Central Arkansas title should be "2013–14 Central Arkansas Bears basketball team".)

I note that the existing templates use a lot of switching to deal with the fact that they are covering six sports. Would it make sense to have a different version of each module for each sport? I'm thinking yes, but I'll defer to those with more expertise. If the answer is yes, the obvious question is whether to further subdivide between sex? I'm thinking no, but again, will defer to experts. Even if it makes sense to have nine separate modules, several still need to identify whether "Men's", Women's" or neither should be included, but I think that can be done simply, by having a sex parameter allowing "none" as a variable. (Unless that parameter drives anything else, in which case we need a second parameter, such as sextitle.)

What can I do to help write specs?

FYI, this template has 8296 transclusions.--S Philbrick(Talk) 21:55, 14 July 2014 (UTC)

This looks like a good candidate for Lua conversion. However, I'm a little reluctant to convert infoboxes to Lua right now, as once mw:Extension:Capiunto is released we will have to redo them. I suppose I should try and contribute to the Capiunto code myself to speed things along - it's been being written for quite a while now. — Mr. Stradivarius on tour ♪ talk ♪ 08:04, 23 July 2014 (UTC)

We need a simple, straightforward, Wiki-wide syntax to put a mark on a damn map. (Aside from raw html/css that is)[edit]

I was just appalled by a situation with July 2014 Al-Wadi Al-Gedid attack, where the editors had put in an image coloring the entire province after some militants massacred people at a border checkpoint with Libya. The item was profiled site-wide from "In the news", and I feel like by coloring this in, we distracted from the actual coordinates it occurred at rather than highlighting them, and gave the militants an unwanted little boost by making it look like they control a huge chunk of Egypt.

The root of it is that Template:Infobox military conflict has some byzantine syntax required to use a location map, referring to the documentation of other templates to explain its own documentation, and at least in any short period of time I can't figure out how to put a mark on it. Judging by a dozen battles I picked out, nobody else seems to know either, because none use the feature. It's impossible to simply import a map from, say, Farafra, Egypt and move the mark, because Template:Infobox settlement uses a whole different set of parameters. Now I realize that in the end we can just go with Template:Location map and try to ignore the rest, or better yet, just set up a div and set the mark about where it looks right ... but what we want really is a standard interface. I see that Module:Location map has made some heroic strides in this direction e.g. Module:Location map/data/Abkhazia (unfortunately we don't have one for Egypt, which may be part of the problem). But I'm thinking maybe what we really need is some way to make things more modular overall, i.e. a standard parameter that allows you to pass in the entire innards of the image frame preformatted, whether by transclusion or by calling another template etc., that bypasses more specialized (and variable) syntax. Maybe not - my thinking on this is admittedly confused, and I'm sure some here have tackled these situations often. But I want someone to come up with some kind of general philosophy to organize the approach rather than just diving in and making yet another divergent template or module. Wnt (talk) 15:43, 22 July 2014 (UTC)

National football team rankings[edit]

Updating rankings on individual national football team articles has become an overly tedious task and I think it would be easier if {{Infobox national football team}} drew rankings from a single module and returned them on individual articles depending on the infobox's |Name= parameter (the value given in the parameter is always the same as "[name] national football team" in the article's title). Users, preferably members of the national teams task force, can then update these rankings every time new revisions are released. There should be a separate list for women's national teams, which would return rankings if |type=women in the infobox is active.

So basically, one central module should pull data from separate lists containing men's and women's rankings. For men, there should be two lists for FIFA World Rankings and World Football Elo Ratings, and for women one list containing FIFA Women's World Rankings. Davykamanzitalkcontribsalter ego 04:28, 23 July 2014 (UTC)

It would be bad for the job queue to have all soccer pages pull rankings from the same page. Jackmcbarn (talk) 04:33, 23 July 2014 (UTC)
With only 1237 articles using {{Infobox national football team}}, it wouldn't be that bad on the job queue. Another option though might be a wikidata item. Would still mean having to update a number of pages, but the rankings could then be used over all languages. Another thought is that the rankings could be done with a normal template #switch statement rather than needing to use lua and just placed as subpages of the template. -- WOSlinker (talk) 07:08, 23 July 2014 (UTC)
It can quite easily be done on different subpages in Lua as well. Storing the data in Wikidata sounds like the best idea to me, though. — Mr. Stradivarius on tour ♪ talk ♪ 07:57, 23 July 2014 (UTC)
Well, I'm absolutely stunned to see that a few days ago action was taken that might permit this to be possible (Bugzilla, merge) - still, my understanding is that Wikidata doesn't just let you add any old thing you want, everything takes approval. Also, I don't think it's live yet, because the examples from [1] (,) still don't produce any text. It would be a lot easier to do it with a WP based data file first, and then if someone cares he can look into coordinating the data files later. Wnt (talk) 13:28, 23 July 2014 (UTC)
Some broader issues concern this. First, WP:NOTNEWS is usually misapplied in support of deleting anything that might compete with commercial news outlets, such as articles about recent events; but it actually does say that we shouldn't value the rankings for, say, July 17 more than we value those for some time in June. This is an encyclopedia and our goal isn't actually to produce continually-updated rankings. Also, there could be copyright issues over taking every single judgment call FIFA has ever made and putting it into a database. I ended up losing List of Forbes Global 2000 companies to such concerns and this seems pretty similar. So while we can write the module I don't know if you should really use it. Wnt (talk) 13:34, 23 July 2014 (UTC)
@Wnt: The point isn't to produce continually-updated rankings. FIFA rankings are updated once every month or so anyway. Elo ratings however are updated almost everyday, but we could just update them the same time new FIFA rankings are released. Besides that I don't see how copyright issues would affect this. Davykamanzitalkcontribsalter ego 17:13, 23 July 2014 (UTC)
Have you considered using the FIFA API (See PDF )? I am thinking someone could design a Wikidata standard for the necessary information, populate on regular intervals using the API, then populate Wikipedia articles with links to the Wikidata elements.--S Philbrick(Talk) 18:29, 23 July 2014 (UTC)