Wikipedia:Lua requests
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.
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. Davykamanzi → talk • contribs • alter 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)
- 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)
- 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)
- 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. Davykamanzi → talk • contribs • alter 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)
- @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. Davykamanzi → talk • contribs • alter ego 17:13, 23 July 2014 (UTC)
Lua library to implement Javascript regexes?
[edit]I just got a question about using the alternation operator from Javascript in a Module:Highlight I slapped together in a hurry in response to a VPT thread. It would be wonderful if someone could code up Lua functions that work like the present Lua regex functions, but using standard Javascript regexes. It seems possible (though probably a bit slow), and obvious enough that I shouldn't have to reinvent the wheel... I bet someone can point me right at a free-licensed library routine we can just out and out steal and be done with this. Wnt (talk) 01:57, 5 August 2014 (UTC)
- @Wnt: I can't find any such library, and the people in freenode #lua don't know of any either. I doubt one exists. (Note that there's plenty of libraries that call out to C functions to do it, but for MediaWiki we'd need one written in pure Lua.) Jackmcbarn (talk) 02:44, 5 August 2014 (UTC)
- Thanks for trying! I suppose the next question to ask is whether anyone has proposed some extended syntax for Lua to handle the Javascript-like features that it lacks. I'm thinking we'd want to first convert from Javascript syntax to Lua syntax - sometimes quite simply, /d to %d and such, but other times requiring new "Lua-like" syntax to deal with the extra features; then have a module that can deal with the extended syntax in a way that is hopefully fairly efficient. That way the same module could handle either the Javascript syntax or a Lua syntax with non-standard features almost exactly the same way. But without defining any new special characters for such regexes coming up with that syntax might be rather tricky. Certainly if anyone has proposed a standard for it already it would be best to stick by it. Wnt (talk) 08:25, 5 August 2014 (UTC)
Hi Jack ... this was my request, and it's been frustrating because it's necessary for my copyediting project (I can explain why if you like), and what I want is a tiny change, but I haven't been able to find help ... my bugzilla request has been assigned a "low" priority and has no takers. I know a little more now thx to Wnt: "I see ... some version (I don't know if it's the most recent for sure) of the highlightText at [2] with the infamous split-on-space at line 12." That's exactly it ... what I need is a function (in or outside of Mediawiki) identical to highlightText, with (I'm guessing) the space in pat.split(" ") in line 12 replaced ... a tab character would work. (Or, getting rid of the parsing entirely so I can pass an array of strings would be fine.) - Dank (push to talk) 17:22, 5 August 2014 (UTC)