HOME
        TheInfoList






Could a module be written to take a list of dates, link them, and indicate the next coming date? This would be useful for templates like Template:Lunar eclipses which need to be constantly updated by editors. Thanks — Martin (MSGJ · talk) 12:36, 25 March 2015 (UTC)

@MSGJ: Is there a formula that the dates can be calculated from? I assume there must be something, but I'm a complete beginner regarding such calcuations. — Mr. Stradivarius ♪ talk ♪ 14:50, 25 March 2015 (UTC)
I guess there is a formula somewhere, but I'm not asking for that. Just to put a marker (like ) next to the next occurrence. — Martin (MSGJ · talk) 14:54, 25 March 2015 (UTC)
The request is that a module be used to implement Template:Lunar eclipses. There would be a data page somewhere that contains the items to be displayed. The module would output exactly what the template does now, except that it would highlight, in each of two lists, the date that is the first after today + 1 (I would add 1 or even 2 or 3 so the highlight does not move until a couple of days have passed). The current template feeds a bunch of stuff into {{Navbox}}, and the module would do essentially the same. That would all be do-able but unless the functionality is needed in several other places as well, it looks a lot easier to me to just edit the template which needs five minutes of editing in the next two years, whereas the module would need a lot more than that! Johnuniq (talk) 01:01, 26 March 2015 (UTC)
Actually, we don't need to bother with the navbox part, or with making data modules for all the different templates. I've just finished making {{highlighted date list}}, which takes parameters like |item1= and |date1=, sorts them by date, adds a highlighter and outputs them as an unordered list. MSGJ: will that do the job? — Mr. Stradivarius ♪ talk ♪ 04:52, 26 March 2015 (UTC)
Amazing, well done! Johnuniq (talk) 05:39, 26 March 2015 (UTC)
Thank you very much! I've started using it already. — Martin (MSGJ · talk) 09:32, 26 March 2015 (UTC)

Module:Message box: sidebox option

See Template:Convert, especially the documentation as it shows.

It has a big "Translate this template into Swahili" messagebox in top. But the editors who visit this page are not translators. So I'd like to have this box miniaturized into a side-box (just like the {{Lua}} box already in there). Upstream, it has the Ombox and module:Message box. Where to set which switch? (at the moment, I'm not in to learning that; so just do it please. I'll see). -DePiep (talk) 21:47, 25 March 2015 (UTC)

@DePiep: With this edit you can now pass |small=yes to {{transwiki guide}} to output a small template. — Mr. Stradivarius ♪ talk ♪ 06:43, 26 March 2015 (UTC)
Yes. -DePiep (talk) 11:02, 26 March 2015 (UTC)

Visualization modules

Hi, can anyone give me a quick greatest-hits of visualization modules that have been built on-wiki here? I'm aware of Module:Chart for starters. ResMar 20:47, 28 March 2015 (UTC)

Template:Chess diagram is using Module:Chessboard (i think). i believe this falls under "visualization". as a side, i'll mention that for a long time i't trying to entice someone to create a lua wrapper that will make working with mw:Extension:EasyTimeline easier, but so far, no takers. if you find something in some other wikipedia that does it, i'll be grateful to hear. peace - קיפודנחש (aka kipod) (talk) 15:46, 30 March 2015 (UTC)
Tut. ResMar 13:25, 31 March 2015 (UTC)

Help debuging

I wrote a module that one of it's functions returns text formatted using a template. When invoking the function the template doesn't get expanded.

What am I doing wrong?

Thanks, אלישיב ליפא (talk) 08:44, 31 March 2015 (UTC)

A few links:

A link to the module: https://he.wikisource.org/wiki/%D7%99%D7%97%D7%99%D7%93%D7%94:%D7%A4%D7%A8%D7%A9%D7%9F_%D7%A9%D7%95%D7%9C%D7%97%D7%9F_%D7%A2%D7%A8%D7%95%D7%9A

An example is (currently) in the sandbox of he.wikisource

The idea of a module is to eliminate templates, so the quick answer is that you cannot return a template as the result of a module. A slightly longer answer would explain some details that I'm not familiar with concerning the fact that MediaWiki invokes modules at a point where it is too late for templates to be processed. I believe you can workaround the issue with expandTemplate, but what should be done is to redesign the module. Preferably, the module should emulate the template and return the wikitext that the template would return. Next option would be to redesign the template to invoke a module to help with the work that the template wants done. Johnuniq (talk) 09:15, 31 March 2015 (UTC)
(edit conflict) @אלישיב ליפא: Output from Lua modules isn't preprocessed automatically, as that might lead to some things being preprocessed twice. (The arguments are preprocessed automatically when you access them from inside Lua.) To expand templates, parser functions and extension tags, you need to preprocess them yourself using one of the methods of the frame object. In your case, the best one to use would be frame:expandTemplate. — Mr. Stradivarius ♪ talk ♪ 09:17, 31 March 2015 (UTC)

lua module breaks lines.

Hi. I'm using a Lua module to create some functionality, and the call to the module seems to break lines. I have no Idea why this is happening, and I hope someone can help me.

The module: https://he.wikisource.org/wiki/%D7%99%D7%97%D7%99%D7%93%D7%94:%D7%A4%D7%A8%D7%A9%D7%9F_%D7%A9%D7%95%D7%9C%D7%97%D7%9F_%D7%A2%D7%A8%D7%95%D7%9A

Example for a break: https://he.wikisource.org/wiki/%D7%A9%D7%95%D7%9C%D7%97%D7%9F_%D7%A2%D7%A8%D7%95%D7%9A_%D7%97%D7%95%D7%A9%D7%9F_%D7%9E%D7%A9%D7%A4%D7%98_%D7%A4%D7%95

אלישיב ליפא (Template:Convert, especially the documentation as it shows.

It has a big "Translate this template into Swahili" messagebox in top. But the editors who visit this page are not translators. So I'd like to have this box miniaturized into a side-box (just like the {{Lua}} box already in there). Upstream, it has the Ombox and module:Message box. Where to set which switch? (at the moment, I'm not in to learning that; so just do it please. I'll see). -DePiep (talk) 21:47, 25 March 2015 (UTC)

@DePiep: With this edit you can now pass |small=yes to {{transwiki guide}} to output a small template. — Mr. Stradivarius ♪ talk ♪ 06:43, 26 March 2015 (UTC)
Yes. -DePiep (talk) 11:02, 26 March 2015 (UTC)

Visualization modules

Hi, can anyone give me a quick greatest-hits of visualization modules that have been built on-wiki here? I'm aware of Module:Chart for starters. ResMar 20:47, 28 March 2015 (UTC)

Template:Chess diagram is using Module:Chessboard (i think). i believe this falls under "visualization". as a side, i'll mention that for a long time i't trying to entice someone to create a lua wrapper that will make working with mw:Extension:EasyTimeline easier, but so far, no takers. if you find something in some other wikipedia that does it, i'll be grateful to hear. peace - קיפודנחש (aka kipod) (talk) 15:46, 30 March 2015 (UTC)
Tut. ResMar 13:25, 31 March 2015 (UTC)
It has a big "Translate this template into Swahili" messagebox in top. But the editors who visit this page are not translators. So I'd like to have this box miniaturized into a side-box (just like the {{Lua}} box already in there). Upstream, it has the Ombox and module:Message box. Where to set which switch? (at the moment, I'm not in to learning that; so just do it please. I'll see). -DePiep (talk) 21:47, 25 March 2015 (UTC)

Hi, can anyone give me a quick greatest-hits of visualization modules that have been built on-wiki here? I'm aware of Module:Chart for starters. ResMar 20:47, 28 March 2015 (UTC)

Template:Chess diagram is using Module:Chessboard (i think). i believe this falls under "visualization". as a side, i'll mention that for a long time i't trying to entice someone to create a lua wrapper that will make working with mw:Extension:EasyTimeline easier, but so far, no takers. if you find something in some other wikipedia that does it, i'll be grateful to hear. peace - קיפודנחש (aka kipod) (talk) 15:46, 30 March 2015 (UTC)
Tut. ResI wrote a module that one of it's functions returns text formatted using a template. When invoking the function the template doesn't get expanded.

What am I doing wrong?

Thanks, אלישיב ליפא (talk) 08:44, 31 March 2015 (UTC)

A few links:

A link to the module: https://he.wikisource.org/wiki/%D7%99%D7%97%D7%99%D7%93%D7%94:%D7%A4%D7%A8%D7%A9%D7%9F_%D7%A9%D7%95%D7%9C%D7%97%D7%9F_%D7%A2%D7%A8%D7%95%D7%9A

An example is (currently) in the sandbox of he.wikisource

The idea of a module is to eliminate templates, so the quick answer is that you cannot return a template as the result of a module. A slightly longer answer would explain some details that I'm not familiar with concerning the fact that MediaWiki invokes modules at a point where it is too late for templates to be processed. I believe you can workaround the issue with What am I doing wrong?

Thanks, אלישיב ליפא (talk) 08:44, 31 March 2015 (UTC)

A few links:

A link to the module: https://he.wikisource.org/wiki/%D7%99%D7%97%D7%99%D7%93%D7%94:%D7%A4%D7%A8%D7%A9%D7%9F_%D7%A9%D7%95%D7%9C%D7%97%D7%9F_%D7%A2%D7%A8%D7%95%D7%9A

An example is (currently) in the sandbox of he.wikisource

Hi. I'm using a Lua module to create some functionality, and the call to the module seems to break lines. I have no Idea why this is happening, and I hope someone can help me.

The module: https://he.wikisource.org/wiki/%D7%99%D7%97%D7%99%D7%93%D7%94:%D7%A4%D7%A8%D7%A9%D7%9F_%D7%A9%D7%95%D7%9C%D7%97%D7%9F_%D7%A2%D7%A8%D7%95%D7%9A

Example for a break: https://he.wikisource.org/wiki/%D7%A9%D7%95%D7%9C%D7%97%D7%9F_%D7%A2%D7%A8%D7%95%D7%9A_%D7%97%D7%95%D7%A9%D7%9F_%D7%9E%D7%A9%D7%A4%D7%98_%D7%A4%D7%95

אלישיב ליפא (talk) 20:18, 31 March 2015 (UTC)

Looking at the template source it looks like it may be the problem I was having here: Wikipedia talk:Lua/Archive 2#Odd problem with new template/module. Basically if you have a category at the end of a template it inserts a new line after it. Move the category anywhere else and it fixes it.--JohnBlackburnewordsdeeds 21:12, 31 March 2015 (UTC)

Move request (map)

I have a page User:Ahmetyal/sandbox/2 which I wan't to move from a template to a module, because I have reached the limit with locations. --Ahmetyal (talk) 09:28, 19 April 2015 (UTC)

@https://he.wikisource.org/wiki/%D7%99%D7%97%D7%99%D7%93%D7%94:%D7%A4%D7%A8%D7%A9%D7%9F_%D7%A9%D7%95%D7%9C%D7%97%D7%9F_%D7%A2%D7%A8%D7%95%D7%9A

Example for a break: https://he.wikisource.org/wiki/%D7%A9%D7%95%D7%9C%D7%97%D7%9F_%D7%A2%D7%A8%D7%95%D7%9A_%D7%97%D7%95%D7%A9%D7%9F_%D7%9E%D7%A9%D7%A4%D7%98_%D7%A4%D7%95

אלישיב ליפא (talk) 20:18, 31 March 2015 (UTC)

I have a page User:Ahmetyal/sandbox/2 which I wan't to move from a template to a module, because I have reached the limit with locations. --Ahmetyal (talk) 09:28, 19 April 2015 (UTC)

@Ahmetyal: What would you like the name of the module to be? (By the way, this is actually a conversion request rather than a move request.) Jackmcbarn (talk) 02:02, 20 April 2015 (UTC)
Oh I see, sorry but I thought it was on this page. Lets call the page "Latest Turkish election results in South-Eastern Turkey". Which page is it you make a request then? --Ahmetyal (talk) 09:33, 20 April 2015 (UTC)
Just forget the last thing. Now I understand what you meant.. --Is it possible to add another Archive title here (line 92)? So, By default (without adding any prefix) module will show Archive title 1 or Archive title 2 or both If archive title exist. I need this option for bengali wikipedia because on bn.wiki some user use their archive title as 'User:name/Songkolon 1' & some user use their archive title as 'User:name/Songrohoshala 1'. Here i tried to do this. Feel free to edit or make any changes here or here. Please help, Thanks --Aftabuzzaman (talk) 00:16, 26 April 2015 (UTC)

I have not studied this module or how it is used so my reply might not be accurate. I think the problem is that at bnwiki some users would like one name for "Archive", while other users would like another. My guess is that handling that automatically, or handling both if both are used, would require a lot of mucking around that would not be worthwhile. It would be much better to get people organized so one user has all their archive pages named in a consistent manner. You can change line 92 to replace "Archive" with the one most commonly used name. Users who want to use another name can simply add |prefix=whatever when invoking the module (that replaces "Archive" with "whatever"). They would probably want to also use |prefixspace=yes which adds a space to the end of "whatever". If wanted, prefixspace can be omitted, and prefix can be set like this: |prefix=whatever . Johnuniq (talk) 11:27, 5 May 2015 (UTC)
Thank you for reply. --Aftabuzzaman (talk) 12:08, 5 May 2015 (UTC)

Need a template to make and show list of pages in a category

Hi, I am from Bhojpuri wikipedia (bhwiki). I am designing our community portal and I need a template which can enlist and show all the pages in a category on the page where it is inserted. is it possible to get somthing like this?--Satyam Mishra --talk-- 18:58, 25 May 2015 (UTC)

There is an extension which provides some assistance, see Help:Category#Displaying category trees and page counts. In general, there might be over a million pages in a category, so listing them all would not be useful, and may not be possible in a module. Johnuniq (talk) 01:30, 26 May 2015 (UTC)
@Johnuniq: I don't need all. Just some of the pages, say, maximum 20 to 50 at once. And thanks for the link. I think "http://en.wikipedia.org/w/api.php?cmtitle=Category:Category_name&action=query&list=categorymembers&cmlimit=500&cmprop=title%7Csortkey%7Ctimestamp" will do this task but I don't know how to insert the result of this query on a page. Please help. It will be very kind of you if you write this program to populate my sandbox by 20 articles from the category:Geography (sort if possible by date to show recent most). Thanks !--Satyam Mishra --talk-- 04:19, 26 May 2015 (UTC)
Sorry, generating a list of pages in a category is outside my area. A quick look at the documentation at mw:Extension:CategoryTree indicates that the following would list up to a certain number of articles in Category:Geography, but the list is not in alphabetical order, and uses italics for some reason unknown to me, and you can't set the number. I'm confident that doing something like determining the date of last edit or of creation would be difficult and time consuming. That's the sort of thing which is best done by a bot.
{{#categorytree:Geography|hideroot|mode=pages|namespaces=0}}
Bear in mind also that the list would not be dynamic—it would not necessarily change when articles in the category change. That is because everything displayed is cached, and the page w

Hi, I am from Bhojpuri wikipedia (bhwiki). I am designing our community portal and I need a template which can enlist and show all the pages in a category on the page where it is inserted. is it possible to get somthing like this?--Satyam Mishra --talk-- 18:58, 25 May 2015 (UTC)

There is an extension which provides some assistance, see Help:Category#Displaying category trees and page counts. In general, there might be over a million pages in a category, so listing them all would not be useful, and may not be possible in a module. Johnuniq (talk) 01:30, 26 May 2015 (UTC)
@Johnuniq: I don't need all. Just some of the pages, say, maximum 20 to 50 at once. And thanks for the link. I think "http://en.wikipedia.org/w/api.php?cmtitle=Category:Category_name&action=query&list=categorymembers&cmlimit=500&cmprop=title%7Csortkey%7Ctimestamp" will do this task but I don't know how to insert the result of this query on a page. Please help. It will be very kind of you if you write this program to populate my Template talk:Val § Behaviour on substitution. – Wbm1058 (talk) 15:12, 2 June 2015 (UTC)

There is an module in alpha stage at Module:Val. If you are willing to test it, then it will replace the wikicode sooner rather than later.--Snaevar (talk) 14:51, 10 June 2015 (UTC)

Wrap new Graph tag

in one of the recent software updates, we received a new extension: mw:Extension:Graph. this can and should replace everythig we do, for instance, in Module:Chart: it can do barbraphs, pie charts, and so much more.

the problem with this extension is somewhat similar to the problem with mw:Extension:Timeline, which was the previous charting tool (it still exists, but is obsolete): it does not use syntax which is familiar and convenient to wikipedia editors.

now, some time ago i wrote Module:Chart, which plots pie charts and bar graphs. the implementation is disgusting, if i say so myself, because of the very limited support vanilla html provides for charting: the bars are generated by "div" elements with absolute positioning, and the pie chart is based on some obscure features of the way html renders borders (the exploitation itself is ingenious, IMO, and is taken from Template:Pie chart).

i kinda like the syntax used by Module:Chart - i think it lets the editors provide the meaningful data, and hides from them all the mundane details. i asked on this page, several times, for suggestions to make the syntax even better, but there was not much response.

the request here is simple: create a module that will receive parameters in the same syntax used by Module:Chart, but instead of using obscure and perverse methods to draw the graph, will use then new Graph tag.

as a second round, we should use this extension to support more chart types: line chart, scatter chart, horizontal bar graph, and if someone will gets really ambitious, maybe 3-d bar chart.

as a side, i'll mention that the graph extension can do more than just charts - this should be left as an exercise for other modules.

i believe the extension supports all the charts that can be found here: here, but i cant guarantee this is the case.

peace - קיפודנחש (aka kipod) (talk) 17:00, 8 May 2015 (UTC)

I saw your work and was totally amazed at the brilliant result and excellent usability, but I haven't needed to use the module. The new graph extension is a typical triumph over common sense requiring mumbo-jumbo for the input, and this demo advises that external tools should be used. The first step in your idea of a module to generate the graph wikitext would be to do a simple test of what happens if a module outputs one of the demos—would it render as a graph, or is module processing too late for that? Johnuniq (talk) 23:23, 8 May 2015 (UTC)
You'll probably need to use frame:extensionTag to get the graph to render. Anomie 23:29, 8 May 2015 (UTC)
yes, i assumed as much... peace - קיפודנחש (aka kipod) (talk) 23:00, 11 May 2015 (UTC)
This is the biggest front-end development since Lua implementation, in my humble opinion. But, indeed—working with the tags directly is impossible. I don't think that's a bad thing necessarily, though: by going as verbose as possible the visualization engine is as extensible as possible, and once everything is neatly standardized and parametrized via templates, it'll be quite beautiful, I think. ResMar 03:20, 16 May 2015 (UTC)

Hi קיפודנחש (aka kipod), Anomie, Resident Mario, have a look at this by Mps:

  • de:Modul:Graph
    • mw:Extension:Graph. this can and should replace everythig we do, for instance, in Module:Chart: it can do barbraphs, pie charts, and so much more.

      the problem with this extension is somewhat similar to the problem with mw:Extension:Timeline, which was the previous charting tool (it still exists, but is obsolete): it does not use syntax which is familiar and convenient to wikipedia editors.

      now, some time ago i wrote Module:Chart<

      the problem with this extension is somewhat similar to the problem with mw:Extension:Timeline, which was the previous charting tool (it still exists, but is obsolete): it does not use syntax which is familiar and convenient to wikipedia editors.

      now, some time ago i wrote Module:Chart, which plots pie charts and bar graphs. the implementation is disgusting, if i say so myself, because of the very limited support vanilla html provides for charting: the bars are generated by "div" elements with absolute positioning, and the pie chart is based on some obscure features of the way html renders borders (the exploitation itself is ingenious, IMO, and is taken from Template:Pie chart).

      i kinda like the syntax used by Module:Chart - i think it lets the editors provide the meaningful data, and hides from them all the mundane details. i asked on this page, several times, for suggestions to make the syntax even better, but there was not much response.

      the request here is simple: create a module that will receive parameters in the same syntax used by Module:Chart, but instead of using obscure and perverse methods to draw the graph, will use then new Graph tag.

      as a second round, we should use this extension to support more chart types: line chart, scatter chart, horizontal bar graph, and if someone will gets really ambitious, maybe 3-d bar chart.

      as a side, i'll mention that the graph extension can do more than just charts - this should be left as an exercise for other modules.

      i believe the extension supports all the charts that can be found here: here, but i cant guarantee this is the case.

      peace - קיפודנחש (aka kipod) (talk) 17:00, 8 May 2015 (UTC)

      Hi קיפודנחש (aka kipod), Anomie, Resident Mario, have a look at this by Mps:

      Pong ball in flight.svg Atlasowa: Can't tell you how happy I am to see this; we need to port it over immediately. @DerHexer: you know anyone that would be will

      I want to write a new template that will be invoked as follows:

      {{SBN | IT\ICCU\MIL\0205279}}

      It should display in the article as follows:

      SBN IT\ICCU\MIL\0205279

      IT\ICCU\MIL\0205279 should be a clickable external link coded as follows:

      [http://opac.sbn.it/bid/MIL0205279 {{{1}}}]

      My problem...I don't know how to parse the template's parameter to get "MIL" and "0205279", how to concatenate "MIL" and "0205279" to produce "MIL0205279", and how to stick "MIL0205279" into the middle of the external link's definition. I'm guessing Lua.

      If you would please help me this first time, citing relevant Wiki pages along the way, I'll be able to handle it myself in the future. Thanks. Knife-in-the-drawer (talk) 16:13, 28 June 2015 (UTC)

      This can be done in either Lua or template syntax (using the string manipulation templates). Lua will probably be a little bit more work to implement, but would certainly be easier to read. For the record, what is "{{{1}}}" above, is that meant to be "IT\ICCU\MIL\0205279" in the example? Dragons flight (talk) 16:47, 28 June 2015 (UTC)
      Yes. Knife-in-the-drawer (talk) 18:14, 28 June 2015 (UTC)
      Ok, I went a bit over-the-top and wrote two different templates for this. :P The first is at Module:Sbn (and Template:Sbn) and the second is at Template:Sbn/sandbox. The sandbox is the wikitext version - this uses Module:String#match to parse the template parameter. The module uses string.match for the parsing. (They do the same thing - Module:String#match is just a wikitext interface for string.match.) These both use Lua patterns, which you will need to understand to see how this works. The module also uses string.format to join the strings together, but you could just as easily use .., Lua's concatenation operator. ('ab' .. 'cd' will give you the string "abcd".) The sandbox is simpler, but it isn't as elegant if something goes wrong - try putting a bad code into both of them to see what I mean. And please ask if you have any questions about the code. — Mr. Stradivarius ♪ talk ♪ 00:45, 29 June 2015 (UTC)
      (module:SBN) Christian75 (talk) 15:08, 29 June 2015 (UTC)

      An Infobox feature request is ready for Lua encoding

      I've made a feature request for module:Infobox here: Infobox, header-when-not-empty. Basically, it adds a parameter |headern-cond= that only shows when its section contains data (consider how it has to be encoded today).

      There is some good support, it's 'only' needs to be encoded in Lua. Anyone interested? -DePiep (talk) 18:51, 28 June 2015 (UTC)

      Nothing wrong with doing that, but it's not that hard to code this in template syntax. Just test for whatever parameter that fills data under the header is essential to that little section being there. Or test for all of the parameters in that section if they're all of equal weight, and the section and its heading need to be there for any of them but be absent if they're all empty. Template:Infobox cat breed takes the latter approach, and hides the breed standards section for landraces or traditional breeds with no published standards. I agree it's more efficient in Lua, though.  — SMcCandlish

      It should display in the article as follows:

      SBN IT\ICCU\MIL\0205279

      IT\

      IT\ICCU\MIL\0205279 should be a clickable external link coded as follows:

      [http://opac.sbn.it/bid/MIL0205279

      My problem...I don't know how to parse the template's parameter to get "MIL" and "0205279", how to concatenate "MIL" and "0205279" to produce "MIL0205279", and how to stick "MIL0205279" into the middle of the external link's definition. I'm guessing Lua.

      If you would please help me this first time, citing relevant

      If you would please help me this first time, citing relevant Wiki pages along the way, I'll be able to handle it myself in the future. Thanks. Knife-in-the-drawer (talk) 16:13, 28 June 2015 (UTC)

      I've made a feature request for module:Infobox here: Infobox, header-when-not-empty. Basically, it adds a parameter |headern-cond= that only shows when its section contains data (consider how it has to be encoded today).

      There is some good support, it's 'only' needs to be encoded in Lua. Anyone interested? -DePiep (talk) 18:51, 28 June 2015 (UTC)

      Nothing wrong with doing that, but it's not that hard to code this in template syntax. Just test for whatever parameter that fills data under the header is essential to that little section being there. Or test for all of the parameters in that section if they're all of equal weight, and the section and its heading need to be there for any of them but be absent if they're all empty. Template:Infobox cat breed takes the latter approach, and hides the breed standards section for landraces or traditional breeds with no published standards. I agree it's more efficient in Lua, though.  — SMcCandlish ¢ ≽ʌⱷ҅ʌ≼  14:45, 18 July 2015 (UTC)

      String parsing: Extract number (with decimal, neg) from arbitrary text

      I'm taking first baby steps in Lua. What I want to do I could do in minutes in perl with regular expressions, but even the online Lua help materials aren't much help, because Scribunto's requirements for how it does thing are so rigid. I've barely gotten it to return (sometimes) a valid result for the first part of this I'm testing (just numerals, and without need to <nowiki>...</nowiki> the input). I haven't figure out how to use boolean operators with Lua string manipulation, as in "look for this OR that".

      All I really need right now is a tiny one-function module that can be invoked directly to do the following to one string of input:
      • Drop all characters other than -, . and numerals.

      My immediate need for this is converting sloppy CSS-related input like -10px, 2.2em; or even style="font-size: 70% ;" to -10, 2.2, or 70, respectively, and return that number. My assumption is that I should be able to wrap the input in <nowiki>...</nowiki>, in case someone inputs something daft like |style=font-size: 70%, with a | symbol, but that's not essential. The #1 use would be conversion of percentile values in particular, like 70%, to bare numbers, like 70. Need a variant function that divides the result by two and rounds to two decimal places, but I'm sure I can add that myself after I see how the main part works.

      A more advanced version that could be invoked directly or required by other modules, might do something like this:
      • For any arbitrary input, trim all leading material until it hits any of:
        • a numeral; or
        • a . foll

          There is some good support, it's 'only' needs to be encoded in Lua. Anyone interested? -DePiep (talk) 18:51, 28 June 2015 (UTC)

          I'm taking first baby steps in Lua. What I want to do I could do in minutes in perl with regular expressions, but even the online Lua help materials aren't much help, because Scribunto's requirements for how it does thing are so rigid. I've barely gotten it to return (sometimes) a valid result for the first part of this I'm testing (just numerals, and without need to <nowiki>...</nowiki> the input). I haven't figure out how to use boolean operators with Lua string manipulation, as in "look for this OR that".

          All I really need right now is a tiny one-function module that can be invoked directly to do the following to one string of input:
          • Drop all characters other than -, . and numerals.

          My immediate need for this is converting sloppy CSS-related input like -10px, 2.2em; or even style="font-size: 70% ;" to -10, 2.2, or 70, respectively, and return that number. My assumption is that I should be able to wrap the input in <nowiki>...</nowiki>, in case someone inputs something daft like |style=font-size: 70%, with a | symbol, but that's not essential. The #1 use would be conversion of percentile values in particular, like 70%, to bare numbers, like 70. Need a variant function that divides the result by two and rounds to two decimal places, but I'm sure I can add that myself after I see how the main part works.

          A more advanced version that could be invoked directly or required by other modules, might do something like this:
          • For any arbitrary input, trim all leading material until it hits any of:
            • a numeral; or
            • a . followed by a numeral; or
            • a My immediate need for this is converting sloppy CSS-related input like -10px, 2.2em; or even style="font-size: 70% ;" to -10, 2.2, or 70, respectively, and return that number. My assumption is that I should be able to wrap the input in <nowiki>...</nowiki>, in case someone inputs something daft like |style=font-size: 70%, with a | symbol, but that's not essential. The #1 use would be conversion of percentile values in particular, like 70%, to bare numbers, like 70. Need a variant function that divides the result by two and rounds to two decimal places, but I'm sure I can add that myself after I see how the main part works.

              A more advanced version that could be invoked directly or required by other modules, might do something like this:
              • For any arbitrary input, trim all leading material until it hits any of:
                • a numeral; or
                • Any help on the basic request at the top would be much appreciated, the rest is more of a "what if...?" proposition.  — SMcCandlish ¢ ≽ʌⱷ҅ʌ≼  22:33, 17 July 2015 (UTC)

                  I'm no Lua expert, so here is a starting point that could probably be done better:
some of the developers frequenting this page may scoff at this style, but i find it preferable, and it is very common among lua programmers, so even if you do not want to write this way, it's at least a good idea getting used to reading it.
peace. — Preceding unsigned comment added by קיפודנחש (talkcontribs) 20:08, 13 October 2015 (UTC)
Small nitpick: only false and nil are falsy in Lua. There is no distinction between null and undefined as there is in JavaScript, and in Lua the spelling is nil, never null. — Mr. Stradivarius ♪ talk ♪ 10:12, 16 October 2015 (UTC)

Requesting Module:Location map/data/Pyongyang

I'm requesting Module:Location map/data/Pyongyang (cf. Module:Location map/data/Istanbul). The map image can be found at File:Map Pyongyang.jpg. The relevant country level location map template is at Template:Location map North Korea. For reference, the requested module already exists on the French (fr:Modèle:Géolocalisation/Pyongyang) and Polish (pl:Szablon:Mapa dane Pjongjang) language Wikipedias. Finnusertop (talk | guestbook | contribs) 12:51, 15 October 2015 (UTC)

Module is now up and running. MrPenguin20 (talk) 16:02, 18 October 2015 (UTC)

Is it possible to get the dates of modification for files (in this case, files on Commons)?

Previously, I pinged some users to bring attention to this discussion. Their attention was no longer needed after the reply below. Sorry for the inconvenience.
Right now, Commons has pinged some users to bring attention to this discussion. Their attention was no longer needed after the reply below. Sorry for the inconvenience.
Right now, Commons has a collection of war maps which are frequently updated using data from collaboration which happens on the English Wikipedia for each map. A problem exists where the date these war map images were last updated needs to be distributed to articles which use the maps, so that users can know how up-to-date they are ("current as of 10 Nov 2015" or something). This problem is currently being solved using this module which might as well be a template and has to be manually updated. Is it possible, using Lua, to automate the retrieval of this date, or possibly generalise it to any file so that future maps can also have this convention applied to them? If it isn't possible using lua, I'm strongly considering writing a bot which does this automatically. Thanks in advance. --BurritoBazooka (talk) 02:07, 10 November 2015 (UTC)

@BurritoBazooka: No, this isn't possible at the moment. You can see the file metadata available to Lua here, but the time of last update isn't in there. The closest we have is {{REVISIONTIMESTAMP: File:filename}}, but that on

I'm curious to know what the p stands for? Is it program? public? --Psychoslave (talk) 12:50, 25 November 2015 (UTC)

I think it might be "package", as used in PIL here, but I might be wrong. — Mr. Stradivarius ♪ talk ♪ 14:04, 25 November 2015 (UTC)
"package" would be my guess too. Anomie 14:41, 25 November 2015 (UTC)

Is Lua the right way to do a table lookup?

The current {{Zodiac date}} gives wrong answers for 2015. The approach of finding an empirical formula to predict dates of astronomical events is both not feasible and original research. I'm thinking of creating a Lua program that would have 12 tables, one for each sign of the zodiac. Each table would have a list of years from 2015 through 2050 (which is as far as my reliable source will predict). The index of the table would be the year, and the result from the table would be a day of the year (e.g "Feb. 18". Each table would have 35 rows.

I haven't programmed in Lua before, but I've programmed in many other languages from System/370 assembler to C#, so I'm not worried about figuring out the language. But I am concerned that having such a large template might be detrimental to the articles that include the template. Am I on the right track? — Preceding unsigned comment a

The current {{Zodiac date}} gives wrong answers for 2015. The approach of finding an empirical formula to predict dates of astronomical events is both not feasible and original research. I'm thinking of creating a Lua program that would have 12 tables, one for each sign of the zodiac. Each table would have a list of years from 2015 through 2050 (which is as far as my reliable source will predict). The index of the table would be the year, and the result from the table would be a day of the year (e.g "Feb. 18". Each table would have 35 rows.

I haven't programmed in Lua before, but I've programmed in many other languages from System/370 assembler to C#, so I'm not worried about figuring out the language. But I am concerned that having such a large template might be detrimental to the articles that include the template. Am I on the right track? — Preceding unsigned comment added by Jc3s5h (talkcontribs) 14:30, 29 November 2015 (UTC)

Yes. Module:Citation/CS1/Configuration, for example, is nothing but tab

I haven't programmed in Lua before, but I've programmed in many other languages from System/370 assembler to C#, so I'm not worried about figuring out the language. But I am concerned that having such a large template might be detrimental to the articles that include the template. Am I on the right track? — Preceding unsigned comment added by Jc3s5h (talkcontribs) 14:30, 29 November 2015 (UTC)

Is it possible to scan the contents of articles for specific text strings (actually template) based on a list of articles in a category and its sub-categories? I would like to make these table numbers dynamic. --Traveler100 (talk) 18:03, 4 January 2016 (UTC)

It would help if you were to spell out the operation required for an example, but I suspect the answer is that it is too complex to be achieved with a module. I think you need to list the articles in various categories, then read the wikitext from each page and work out if a certain template is used. I don't think "what links here" is available to a module so using that as a workaround wouldn't work. Some kind of bot would be needed. Johnuniq (talk) 22:16, 4 January 2016 (UTC)
On Wikivoyage the categories are very hierarchical and clean and the articles a standard format so not as risky as with Wikipedia. Task, take a category (say a country), progress through all sub-categories, for each article n categories do a text search for use of specific templates ({{outlinecity}}, {{guideregion}}, .. {{sleep , ..) if found at to count expression. Return count values. --Traveler100 (talk) 06:01, 5 January 2016 (UTC)
Modules don't have access to category members, so this is not possible in Lua at the moment. It is possible to load the wikitext of a given page, but then parsing that wikitext to find a list of templates is hard. You need to take into account things like nowiki tags, HTML comments, template redirects, capitalisation and whitespace allowed for template names/arguments, etc. (This kind of thing is the reason that we have Parsoid, but that data is not available from Lua by design.) The only practical way at the moment to do what you are proposing is to use a bot to update the table. — If anyone has some spare time then perhaps do a code review of Module:Timing? And the doc page needs a spell check too! I believe the precision in the produced numbers are about as they get, but there could be other ideas out there. Note that this solution are for those that develop code on their own, without a debugger running in a controlled environment. Note also that the test cases are written for another library, and that it does not work as of this writing. Hopefully it will work later on. Jeblad (talk) 18:03, 18 January 2016 (UTC)

The code is good but since you asked here are some thoughts from a quick look.
  • Line 37–38: Empty for loop with no purpose?
  • Line 44: Nothing wrong with math.pow but it is the same as v^2.
  • Line 46: I don't know if the timing table could ever be empty, but I would test for #timing == 0 even if I thought it couldn't happen.
  • Line 59/63: With a loop like that I would just have time[i] on the lhs.
  • Line 74: Is there a reason p.combine is part of p? Why not just a local function, if module users don't need to access it? Similar for other functions.
  • Line 124: Could be "local function dummy()" as I don't think a global is needed.
It would be pretty rare for a module to need timing, although I happened to do some crude testing of a module I'm working on the other day. Johnuniq (talk) 08:36, 19 January 2016 (UTC)
Thanks for the reviw!
  • p.combine was an access point for testing, could be put inline instead
  • function dummy() is used for baseline timing, and usually you will not test local functions
You will probably never add this to an ordinary module, it is only for crude testing to figure out which kind of code actually works well in this Lua environment. Jeblad (talk) 09:42, 19 January 2016 (UTC)
I think the only effect of putting "local" in front of "function dummy()" would be to change the scope of where dummy can be accessed (along with the fact that a global dummy would be added to the _G globals table). As the code is now, executing dummy = 'hello' would wipe out the dummy function. By "pretty rare" I meant that it would be rare to need to test the timing of a module. I understand that you don't use Module:Timing in another module, but nearly all modules run very fast and don't need to be optimized. I would think any modules that are too slow are just trying to do too much work, and only a very small number of modules would benefit from measuring the time taken by various functions. As mentioned, I had one of those rare exceptions a few days ago where I found a bottleneck that was removed by using a different method. However, I was doing a ridiculously large number of tests just from interest to see how long it would take. Johnuniq (talk) 10:24, 19 January 2016 (UTC)
If you use this module to test load in modules you probably know that executing dummy = 'hello' would have some implications. I haven't checked timing for local lookup, but usually that is much faster in other languages. Often by a factor ten or more. I can put the dummy function in the exported lib, that would be close enough.
The module was written as part of a larger testing framework, which had some timing issues. It was also used for testing FSMs. Jeblad (talk)
I'm sorry to be argumentative and the issue is trivial and can be ignored, but a user would test the timing of a function by executing something like =require 'Module:Timing'(p.hello). In the timing module, timing for the following would then be obtained:
self.runner(dummy, ...)
self.runner(func, ...)
That compares the time to access and execute dummy with the time to access and execute func. The former is a global variable which needs to be looked up in the _G globals table, while the latter is a function parameter which has the same fast access time as a local variable. Therefore using a global for dummy is not adding any accuracy. I'm just mentioning that as something I noticed, but it is unimportant and if there are reasons for having dummy a global for use in another situation, that's good too. Johnuniq (
Normal Exit PeriodicService.php