This page is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Currently,
Module:Infobox requires HTML Tidy for child infoboxes and fails to render properly if there are more than two child infoboxes in one table cell and the child infoboxes are separated by line breaks (
example). This is because using child infoboxes nests <tr>...</tr>
inside <td>...</td>
, which would probably have worked with normal wikitable syntax (although this would have generated an extra blank table row) but not with HTML tags. The best fix would probably be to prevent the generation of the <tr>
and <td>
tags in the parent infobox row if <tr>
but not <table>
is detected inside a table cell with colspan=2, and to add <table>...</table>
for all other instances. I don't know how to do this with the syntax style used in the module, so asking for help here. Regexes could be </?tr[ >
etc.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 11:05, 24 May 2017 (UTC)
The module might also need to handle wikitext tables with HTML table tags used in them (or a mixture of wikitext and HTML tables in the same data cell). I'm not sure whether it's better to handle them or just remove wikitext tables from child infoboxes.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 11:13, 24 May 2017 (UTC)
In addition, {{
Collapsed infobox section begin}} and {{
Collapsed infobox section end}} can cut off ending tags which are in the infobox template but not in the parameter. For example, in the two incident infoboxes on
Watford Junction railway station, the </caption>
ending tag is split by the begin template and ends up in the collapsed table. I'm not sure whether to handle this in the module, or if this causes any actual problems.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 12:26, 24 May 2017 (UTC)
<div>...</div>
instead of using infobox|child=yes, you could probably avoid these issues, and reduce the overall complexity of the child modules.
Frietjes (
talk) 15:31, 24 May 2017 (UTC)
|data1=
. However, the rendering error is due to HTML Tidy and has nothing to do with the extra HTML tags, as all of them display well in
Special:ExpandTemplates. The rendering error persists even after the extra tags are removed.
Jc86035 (
talk) Use {{
re|Jc86035}}also should remove any spurious blank cells generated by the embeddingwhen I described (1) and (2) above. I would think that stripping empty rows would be a good in feature in general, but I could imagine someone using empty rows with background colouring to create a visual gap between sections. we could (a) go for the more aggressive version 2 and see if any problems are reported, or (b) be more conservative and go with version 1 (which is basically how child boxes function right now after tidy). I, personally, think that either one is probably ready for deployment, but I would welcome feedback from Jackmcbarn, Mr. Stradivarius, Johnuniq, etc. since I may be doing something boneheaded in the lua code that could be improved. Frietjes ( talk) 14:05, 27 May 2017 (UTC)
mw.ustring.match(mw.ustring.sub(data, 1, 3), '<tr')
for each data cell, or is this unnecessary?
Jc86035 (
talk) Use {{
re|Jc86035}} Merged changes to main version.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 13:50, 29 May 2017 (UTC)
@
Frietjes: It doesn't seem to be working properly, although this might be due to a delay in the propagation of the change. For example,
Fleetwood Mac (1975 album) only contains the infobox templates {{
Infobox album}} and {{
Singles}}, both of which use {{
Infobox}}.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 14:00, 29 May 2017 (UTC)
{{Infobox/sandbox|data1= {{S-start}} {{s-rail|title=PM}} {{s-line|system=PM|line=1|previous=Saint-Paul|next=Gare de Lyon}} {{S-end}} }}
An editor has asked for a discussion regarding Module:Linguistic and Module:Fallback. Input from those familiar with modules is welcome at Wikipedia:Miscellany for deletion/Module:Linguistic. Thanks, — Godsy ( TALK CONT) 03:10, 17 June 2017 (UTC)
An editor has asked for a discussion regarding Module:Formatnum. Input from those familiar with modules is welcome at Wikipedia:Miscellany for deletion/Module:Formatnum. Thanks, — Godsy ( TALK CONT) 04:10, 18 June 2017 (UTC)
Hi,
We had to split the intensively used Module:Syrian_Civil_War_detailed_map into a detailed map and an overview map.
Because the huge middle eastern conflict map could no longer include the whole detailed map because it had become to large.
After a lot of work Module:Syrian_Civil_War_detailed_map now successfully inlcudes Module:Syrian_Civil_War_overview_map with all the large towns and strategic places and the huge middle eastern conflict map succesfully includes the new Module:Syrian_Civil_War_overview_map instead of the Module:Syrian_Civil_War_detailed_map
Yet a new problem occurred with the Module:Syrian_Civil_War_detailed_map that I don't understand can't solve.
All villages after +- line 2700 won't display. While before it displayed more than 7000 lines.
Can anyone look at it and try to solve it?
The module is intensively monitored by large amount of people and it should be remain out of fully working order for to long.
Kind regards, -- Niele~enwiki ( talk) 20:13, 26 July 2017 (UTC)
Hi, Could someone please help me to fix
Module:Location map's coord2text
problem on Bengali wikipedia. See the problem
here. Because of this, 200+ pages showing
script error. --
Aftabuzzaman (
talk) 16:42, 22 April 2017 (UTC)
local moduletitle = mw.title.new('Module:Location map/data/' .. map)
local moduletitle = mw.title.new('মডিউল:অবস্থান মানচিত্র/উপাত্ত/' .. map)
mw.log
lines in the module. I wonder if they show any useful information when the module is somehow invoked while editing the module.
Johnuniq (
talk) 05:40, 23 April 2017 (UTC)
22.467°N 92.117°E
, in bnwiki the equivalent text generated by {{
Coord}} is <span dir="ltr">২২.৪৬৭°</span> উত্তর <span dir="ltr">৯২.১১৭°</span> পূর্ব
. I cannot read the text and don't really know how Lua handles this, so alternatively the module could search for <span class="geo">22.467; 92.117</span>
.
Jc86035 (
talk) Use {{
re|Jc86035}}<span dir="ltr"></span><span dir="ltr"></span>
tags from module. I set up test pages for you. Please use
Module:Location map/sandbox,
Module:Coordinates/sandbox &
Template:Location map/sandbox (for testing module). Do whatever you need to do. --
Aftabuzzaman (
talk) 17:08, 23 April 2017 (UTC)Preliminary results follow. I might be able to think more in a day or two. Pasting {{Coord|44|26|N|15|3|E}}
into
bn:Special:ExpandTemplates shows a long result. Some of that is:
At enwiki, the corresponding text is:
The module fails with the "Malformed coordinates" error because it looks for the exact format used at enwiki, namely
<number>°N<space><number>°E
where <number> consists of enwiki digits or a dot. This is due to the regex mentioned by Jc86035 above. Johnuniq ( talk) 11:39, 24 April 2017 (UTC)
coord2 or ''
but that comes too late.@ Aftabuzzaman: Please briefly bring me up to date about the current status. Do the three pages you mentioned at "test pages for you" above contain the current wikitext, and are they are ready for me to experiment? I'm wondering about your "I think i found a solution" above. Did that solution get implemented and did it work? It seems bn:মধ্যমগ্রাম is showing the "Malformed coordinates" error due to what I said at 11:39, 24 April 2017 above. I should be able to have a look when you reply, although it won't be quick. Johnuniq ( talk) 05:48, 4 August 2017 (UTC)
Despite this removal of code "ç" from Module:IPAc-en/phonemes, it still persists in pages that use it. Before the code was added, the error "[invalid input: 'ç']" showed at Mary Hamilton#Lyrics amidst the pronunciation spelling of note 3. Why does this error not show again now the code has been removed? Is this a caching issue? — Sebastian 08:42, 9 August 2017 (UTC)
{{IPAc-en|n|i|ç|t}}
→
/ni[invalid input: 'ç']t/{{IPAc-en|n|i|t}}
→
/nit/{{IPAc-en|n|i|ç|t}}
to Mary Hamilton with
with this edit. And all was good; no errors. Half-hour later, Editor Nardog rises to object and
reverts. The question was: Why does this error not show again now the code has been removed?(emphasis added). The error did not show because the job queue had not yet got round to refreshing all of the pages that use Module:IPAc-en/phonemes. The error shows now because someone purged or null edited Mary Hamilton or because the job queue got round to refreshing it.
Last I knew, eval() was disabled for security reasons and seemed highly unlikely ever to be available. I ran across a comment on the Refdesk that "The metabolic cost of walking (Cw) in J/(Kg *m) was empirically determined to be 280.5i5-58.7i4-76.8i3+51.9i2+19.6i+2.5 where i is the incline..." which is when I remembered that I'd meant to write some kind of function to evaluate math expressions input as text. I'd probably want to access it indirectly from my old prototype Module:Plotter to do something like {{#invoke:Plotter|eval|280.5*i^5-58.7*i^4-76.8*i^3+51.9*i^2+19.6*i+2.5|left=0|right=0.9|step=0.05}} So I'd want to chunk the text according to at least five basic arithmetic operators and have a pass-through for Math. and Module:Math functions. Anyway, it would be a big project if done right, so I should check to see if anyone has done it. Also I think there was some magic word to do it in wikipedia format and maybe it can be sent out as a call also; I'm not sure how that would compare with just doing it by Lua. I won't ask anyone to write this since it seems like a good exercise to refresh my memory, and not urgent. Wnt ( talk) 20:30, 11 August 2017 (UTC)
{{#expr:}}
would do what you want, you could use
mw.ext.ParserFunctions.expr to do it.
Anomie
⚔ 23:05, 11 August 2017 (UTC)0.9144^3/3600
. It does not support unary operators (negation). I mention that for anyone interested but WOSlinker is correct that #expr should be used. Try this in a module:
return frame:callParserFunction{ name = '#expr', args = { '0.9144^3/3600' } }
I want to extend / refine the nowrap=off
argument of the dts template in such a way, that only the year is wrapable, (for rationale see here
Template talk:Dts). Best way is probably to create a new argument like wrap=year
, however I leave that to the implementer. The Lua code for dts is here:
Module:Dts. Any help greatly appreciated, thanks.
Wikiinger (
talk) 10:05, 17 August 2017 (UTC)
Would someone familiar with Lua and Wikidata please take a look at Template talk:Authority control#Tracking categories. Thanks. — JJMC89 ( T· C) 17:43, 18 August 2017 (UTC)
Hey, I just wanted to make 100% sure that I'm not going to break anything by closing this MfD as delete. I trust Pppery's judgement as a Lua user but since no one else weighed in on the MfD I just want to make absolutely sure that there's no one who needs this who somehow didn't see the MfD. ♠ PMC♠ (talk) 04:08, 30 October 2017 (UTC)
Hi everybody! Google Code-in (GCI) will soon take place again - a seven week long contest for 13-17 year old students to contribute to free software projects. Tasks should take an experienced contributed about two or three hours and can be of the categories Code, Documentation/Training, Outreach/Research, Quality Assurance, and User Interface/Design. Do you have any Lua / template related idea for a task (needs documentation, or some code / code changes) and can imagine enjoying mentoring such a task to help a new contributor? If yes, please check out mw:Google Code-in/2017 and become a mentor! Thanks in advance! -- AKlapper (WMF) ( talk) 19:50, 16 October 2017 (UTC)
|id=
parameter would be made more "bulletproof"; I did a little work on that earlier today, but it's still fairly easy to break it, either by producing invalid output or just not useful output (it should produce a "clean" word to serve as a link target, like "break" or "stakehorse", without any extraneous markup, even if people don't read the docs and just put something they shouldn't in there, like a bunch of markup: {{small|'[[Stake (gambling)|Stakehorse]]'}}
. —
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 10:01, 17 October 2017 (UTC)
Hello, I am having trouble understanding Lua and would like some help. I'm trying to underline the 'Shortcuts' text in Template:Shortcut, as shown here:
In wikicode I just place the text inside a div block as follows: <div style="display: inline-block; border-bottom: 1px solid #aaa;">[[Wikipedia:Shortcut|Shortcuts]]</div>
. But I have no idea how to translate this into Lua.
Could anyone please show me how to do it, or give me a hint about how it could be done? Thank you. Atón ( talk) 17:55, 10 November 2017 (UTC)
:wikitext(shortcutHeading)with something like
:tag('div'):css('display','inline-block'):css('border-bottom','1px solid #aaa'):wikitext(shortcutHeading), you should get closer to what you want. Frietjes ( talk) 19:04, 10 November 2017 (UTC)
{{
Shortcut}}
output and underline the word "Shortcuts", which doesn't trigger the concern I had at all. —
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 19:50, 10 November 2017 (UTC)I started {{ Pop row wikidata}} for use in World population#Largest populations by country. at the moment, it's not entirely correct since the percentages are calculated using different points in time. the current table in World population#Largest populations by country uses extrapolation, so I was thinking we could probably take the last two wikidata population values and extrapolate automatically. is this a reasonable idea, or is it too much work (or too expensive)? an alternative would be to keep all the population data for the countries of the world in one module, and then extrapolate from that. Frietjes ( talk) 21:25, 2 November 2017 (UTC)
{{data China}}
.
Frietjes (
talk) 21:27, 2 November 2017 (UTC)
{{Worldpop}}
, {{worldpop-base}}
and {{worldpop-daily-inc}}
. I agree the percentage of world population is tricky, but it's not usually going to be off that far. But Wikidata certainly seems the way to go. If you always update to the last two data points to get the next year's growth for the world and each country, that makes sense to me. -
Mnnlaxer |
talk |
stalk 21:48, 2 November 2017 (UTC)
Hello. el:Module:FIFARankingMin This module is finding the most recent value of values of a wikidata property. Can anyone change it to show the lowest value/values with the date in bracket? Just to change the most recent value with the min value. For example for d:Q79800, now is showing 4 (16 October 2017). Is must show 2 (1 August 2017). Check the result here. Xaris333 ( talk) 17:13, 18 November 2017 (UTC)
min
is used, and is the worst ranking if parameter max
is used. I need to read the code more slowly to check it is ok, but I won't do that until you have had a look at it.
Johnuniq (
talk) 10:00, 20 November 2017 (UTC)
min
is used, and is the worst ranking if parameter max
is used."? I changed that
[2]. It seems OK. One more thing. The data in wikidata has source. How can the module show the source of the data? By fetching data from wikidata with
el:Module:Wikidata and
el:Module:Wikidata/cite is possible. Why is not with Module:FIFARanking?
Xaris333 (
talk) 12:58, 20 November 2017 (UTC)
There is a discussion about the proper venue for deletion discussions of Module pages at Wikipedia talk:Templates for discussion#Should pages in the "Module:" namespace be discussed at TfD instead of MfD? that might be of interest to Module editors here. ♠ PMC♠ (talk) 04:29, 22 November 2017 (UTC)
It's been requested that
Template:Reign be changed so that when neither {{{1}}}
or {{{2}}}
contain whitespace (i.e., when they both contain only simple dates like "983" or "2017", rather than something like "c. 983" or "2017 BCE"), that the template emit no spacing around the en dash between the two date parameters. That might be feasible to do in some
blecherous manner with parser functions, but this really sounds like a job for Lua. —
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 06:09, 24 November 2017 (UTC)
{{Reign/sandbox |1207|1272}}
→
r. 1207–1272 {{Reign/sandbox |1 October 1207|1272}}
→
r. 1 October 1207 – 1272 {{Reign/sandbox |1207|16 November 1272}}
→
r. 1207 – 16 November 1272 {{Reign/sandbox |c. 1207|1272}}
→
r. c. 1207 – 1272 {{Reign/sandbox |1207 |1272}}
→
r. 1207–1272 {{Reign/sandbox |1207| 1272}}
→
r. 1207–1272 {{Reign/sandbox |c.1207|1272}}
→
r. c.1207–1272 Forgive me, but all this is a little unclear for me; I don't completely understand what SMcCandlish requested or the replies, but you don't have to explain. If you'll look at my comment at User talk:SMcCandlish#Reign that begins "By the way", you'll see that I had asked for an additional option at the Template:Reign. I'm not sure why there is an option (at Template:Reign) for a thin space to follow "r." Maybe that is what is used in publishing, but I think a simple, regular space after "r." looks nice. I just wanted it to be non-breaking, and with no spaces either side of the years; it looks like the first one in the list above is the one I was looking for. If you want to get rid of the thin space option (at Template:Reign), that would be fine with me, but maybe some editors prefer it; that's why I asked for an additional option. I kind of understand the list of items above; I understand that there may be times when "r. c." before the first year should be used, and that there may be times when a complete date is known and should be used. In the one with "r. c.", I hope it is non-breaking between both the "r." and the "c." and after the "c.". Well, I very much appreciate your help with this. – Corinne ( talk) 16:09, 24 November 2017 (UTC)
Forget what I wrote here. I just looked at the template page ( Template:Reign), and it looks really good now. (Why would you want to let the line break after "r.", though? It's just one letter.) – Corinne ( talk) 17:05, 24 November 2017 (UTC)
{{reign}} 1207–2172
; the undesirability of this result is the primary reason to fix the template to just parse different sorts of data in {{{1}}}
and {{{2}}}
and ti not emit a spaced en dash when the unspaced one is needed.
RexxS's sandbox version is already an improvement, and I think the first two red X cases in his output above are fixable by pre-processing the input with {{
Trim}}
, while the third is a markup error, so we don't care much. That said, I looked at
Template:Reign/sandbox and a) it is forcing display of {{{2}}}
even if it's empty, which it should not ("Elizabeth II,
r. 1952– ") and it has a hard-coded date in it somewhere with an unspaced "c.", which looks like some temporary test code.
Johnuniq, in answer to your questions, we need no. 2, as no. 1 would unnecessarily space the en dash in the case of {{
reign|1952|present}}
(it should render as
r. 1952–present), which is the most common use case for living monarchs.Anyway, we might not need to use Lua after all; I suppose a call to {{
trim}}
and another to {{#invoke:String}}
are not terribly burdensome. :-)
PS: The italicization option can just be removed; it's against
MOS:NUM and
MOS:ABBR and
MOS:ITALICS, so there is no legit use case for it. I'm going to go remove it now from the extant template.
—
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 20:23, 24 November 2017 (UTC)
{{Reign/sandbox |1207}}
? Are you expecting 1207
or 1207–
? Here are the test cases as currently implemented:
{{Reign/sandbox |1207}}
→
r. 1207– {{Reign/sandbox |1207}}
→
r. 1207–present{{Reign/sandbox |1207}}
to give just 1207
, so I've ditched any further output if parameter 2 is missing. It still works (I think) when parameter 1 is empty.
{{Reign/sandbox ||1207}}
→
r. ?–1207{{Reign/sandbox |2=1207}}
→
r. ?–1207{{
Reign}}
(you may need to purge the page to see the new documentation) can encompass all the functionality of {{
Circa}}
and {{
Floruit}}
and move to a meta-template, with those three templates being shells that just pass stuff to it. I've made a proposal to this effect at
Template talk:Reign and notified the other two templates' talk pages. The end result could be generalized enough to handle number ranges, period, without them being date-specific, so the underlying "engine" could be used to make additional templates for things like sports scores and whatever. After being Lua-ized (if we do that) it could also test for specific common input errors like "c.1312" and "ca. 1312" (errors from a
MOS:NUM perspective, anyway – both are attested styles), and issue some kind of warning. It could also do my laundry and bring me coffee. >;-) —
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 09:39, 26 November 2017 (UTC)Hello. Let me ask bit complicated question here, which relates to both Lua and Wikidata.
subclass of |
| |||||||||||||||||||
+ add value |
In such situation, is it possible to know "giraffe brain" or "elephant brain" from "brain" page by Lua. In other words, can I know "What uses this item as value of subclass of"?
More technically speaking,
Only from " Q1073" (ID of brain) and " P279" (ID of subclass of), can I get " Q25685967" (ID of giraffe brain) or " Q25683977" (ID of elephant brain) by Lua?
SQID service provides this at this URL https://tools.wmflabs.org/sqid/#/view?id=Q1073 (at middle of the page, Classification -> Direct subclasses -> All. That section lists up 7 pages). But as far as I see mw:Extension:Wikibase Client/Lua, there seem to be no such function which afford reverse lookup. I want to know whether there is function or technique/trick to do this. Thanks.
(This question is splited from discussion at d:Wikidata talk:WikiProject Anatomy) -- Was a bee ( talk) 11:00, 26 November 2017 (UTC)
Hi, could someone hack together a Lua module which does what {{ Alexa}} does, but using {{ IncreaseNegative}}, {{ DecreasePositive}} and {{ Steady}} and calling data from the article's Wikidata item? (Since the only bot on Wikimedia sites updating this information is on Wikidata and the information changes all the time there's not much point in allowing data to be locally added, but the bot doesn't seem to be perfect yet so it'd probably still be needed.) Jc86035 ( talk) 16:06, 16 December 2017 (UTC)
{{#invoke:Sandbox/RexxS/Alexa|main}}
, particularly in some articles that may be edge cases, please?|df=
parameter with dmy as default. --
RexxS (
talk) 22:33, 17 December 2017 (UTC)
lnk=""
(which of course becomes " ... lnk='' .. "
when quoted as a string constant) as I find it makes the code more readable when I look back later – I'm not left scanning the line for what the value of lnk
is set to. But that's trivial.[[File: ... ]]
inline construction can use the caption as the html title, and hence the tooltip, so there's no point in trying to set it explicitly.|ref=no
/|ref=yes
(equal to |ref=CS1
), with case-insensitive options |ref=CS2
, |ref=harvard
, |ref=author-title
etc. and default to either no or CS1, though using parenthetical citations would mean that a second template (or the same template with |ref=text
/inline
or something) would have to be added at the bottom of the page. Unless there's something objectionable about even that?
Jc86035 (
talk) 14:17, 22 December 2017 (UTC)
Hello, as the title says, I need to know if there is a way to display different content according to geolocation provided by user IP address, and/or OS country settings, and/or browser language settings.
If it's not, which technical hurdles should be overcome to be able to use it in the Wikipedia through a template/module?
I have zero knowledge about coding. But I've looked into the Lua reference manual from mediawiki.org, and haven't found anything useful. I left a similar message in the support page there. [3]
Thanks in advance. Mapep ( talk) 21:35, 8 January 2018 (UTC)
Is there a way to only load data with mw.loadData if certain conditions are met? My module only uses it occasionally and it would seem inefficient to always load a large table. Szqecs ( talk) 03:34, 11 January 2018 (UTC)
Hi. I need help with a problem at line 60 of my module Module:Sandbox/Szqecs/New Taiwan dollar that uses lang:formatNum(), as shown in User:Szqecs/sandbox. Thanks. Szqecs ( talk) 05:17, 12 January 2018 (UTC)
lang
. That means you have to use the provided function to create the object. The idea is that you might want the formatting as done at enwiki, or the formatting as done somewhere else, and the language object specifies what language is wanted.
Johnuniq (
talk) 06:18, 12 January 2018 (UTC)
Hi. I'd like to request some feedback on Template:New Taiwan dollar. Thanks. Szqecs ( talk) 13:38, 12 January 2018 (UTC)
Hi all
I can't find a place for a Lua requests on Wikidata like here so I'm hoping someone can help me out, I want to create a very easy to use form for the Wikidata Data Import Hub for people to record new datasets. Currently there is a prefilled template which uses Source Editor which many non Wikimedian's find confusing and hard to fill out (one of the key demographics I'm trying to reach). All I want is a when you click a button you get a pop up box with a few fields with a short desciption next to them. I would really love something similar to when you click this link, chose any section and then click add new resource, I understand this is all done in Lua. The fields I would like are (with guidance after the colon):
These fields then then populate a new section on the main Wikidata Import Hub page like so:
==NAME==
Description of dataset | Create and import data into spreadsheet | Structure of data within Wikidata | Format the data to be imported | Match the data to existing data | Importing data into Wikidata | Date import complete and notes |
---|---|---|---|---|---|---|
Name:NAME
Source:SOURCE Link: [LINK here] Description: DESCRIPTION |
Link:
Done: To do: Notes: |
Structure:
Example item: Done: To do: |
Done:
To do: Notes: |
Done:
To do: Notes: |
Done:
To do: Notes: |
Date complete:
Notes: |
Is this possible/easy for someone to set up? Note: I also asked this request on Wikidata project chat here
Thanks
John Cummings ( talk) 23:01, 16 January 2018 (UTC)
There are some templates at Wikisource whose logic has become highly convoluted and where a cleaner LUA version may be better for performance reasons.
The first of these would be https://en.wikisource.org/?title=Template:Cl-act-paragraph&action=edit which only just works..
It would be appreciated if this could be converted to a cleaner LUA version, at some point for performance reasons.
I have a few other complex templates that may also benefit from being re-written.
I was advised to ask in here, because there are not necessarily many people with LUA experience on Wikisource. ShakespeareFan00 ( talk) 21:00, 21 January 2018 (UTC)
I'd like to edit TreeChart so that boxes use more or less than three spaces. As you can see at Template:Chart, a given box takes up three cells in the table. I'd like to use more or less than three cells so that a timeline can better be presented, for something like Template:CIEC merge history. Unfortunately, I don't really know Lua. Any suggestions/help would be greatly appreciated. :) Banaticus ( talk) 18:12, 20 February 2018 (UTC)
_____ raw example
Grandma | Grandpa | ||||||||||||||||||||||||
Mom | Dad | Aunt Daisy | |||||||||||||||||||||||
My brother Joe | Me! | My little sister | |||||||||||||||||||||||
________ with colspan=7 on last row (brother-me-sister)
Grandma | Grandpa | |||||||||||||||||||||||||||
Mom | Dad | Aunt Daisy | ||||||||||||||||||||||||||
My brother Joe | Me! | My little sister | ||||||||||||||||||||||||||
I actually doesn't know how to work with Lua. I have seen a script error in one of the pages. I couldn't correct it due to lack of knowledge in lua. The page is: User:Masti/100wikidaysCEEwomen Just scroll down to see that error. Adithyak1997 ( talk) 17:06, 21 February 2018 (UTC)
Thank you. I will mention this in the talk page of that article. Adithyak1997 ( talk) 17:20, 21 February 2018 (UTC)
Hello again. A user edit Module:FIFARanking so it can show current FIFA Ranking, Man and Min values from wikidata items. (You can see Wikipedia talk:Lua/Archive 6#Module help. Last few days I was adding (and still do) all FIFA Ranking for 1992 to 2017 with sources to Wikidata. Its a lot of work. I think all Wikipedias can use this data. For example see Spain national association football team (Q42267) ( d:Property:P1352 ). I am planning to suggest the module to all Wikipedias that are using the template Template:Infobox national football team.
But there are some problems with the module. You are my last hope :)
1) Big problem. If a team no longer exist ( Serbia and Montenegro national football team (Q1131732) or Netherlands Antilles national football team (Q1037645) ), the module shows as current ranking the last one they had. But this is wrong. The module must show nothing. If a team no longer exist I thought to use d:Property:P576 as a condition. If the item has P576 then there is no current ranking (after 4 years of the dissolved). But a better solution is to have a condition that the module shows the most recent ranking only if there are not 4 years before the current date. For example, If the last ranking is 4/12/2013 will show the current ranking. If it is 30/11/2013 it will not show it. (Teams inactive for more than four years do not appear on the ranking table). Example: [4]
2) Big problem: Max, Min: the module shows only one date. For example, Spain was at the first place many times. So after the max they must show many dates. But it only shows the first one that appears in the item. The module must show all the dates. Do you have any other more practical idea? Example: [5]
3) Small problem: Wikipedia templates show the dates in brackets in smaller letters/numbers.
4) The module don't show the source. In Greek Wikipedia we are using el:Module:Wikidata/cite but it is working only if we take the information with el:Module:Wikidata.
Can anyone solve any of these 4 problems? Thanks. Xaris333 ( talk) 10:51, 2 December 2017 (UTC)
preprocess_equals()
—blank to start until you or I figure out what output should be and add it there inside quotes) –
ASiplas (
talk) 00:41, 23 February 2018 (UTC){{template|min}}
, etc.
BSicon | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Cross-posted from
Template talk:Routemap#Possible bug. For context,
Template:Routemap/doc deals with the placement of
BSicons, or route diagram icons, with the file naming format "File:BSicon xxx.svg". Basically, these icons are placed in square or rectangular "boxes" spread out among a field of rows and columns, e.g.
(STR
). It is possible to overlay two, three, or more BSicons into the same "box", as seen in the second example.
The documentation page says that to link a BSicon to another page, you use the code !@
after the BSicon When using icon overlay and icon link for the same icon cell, the icon link separator (!@) must follow the last (top) overlaying icon ID.
I noticed that when I try to link an icon that has more than one overlay, the link doesn't work (as shown in the box). How can this be fixed?
epicgenius (
talk) 18:07, 23 March 2018 (UTC)
Hi. I'm making a Lua version of {{ S-line}}. However I can't figure out why the table is wider ( Module:L-rail/LUL). Help is appreciated. Szqecs ( talk) 03:12, 25 March 2018 (UTC)
{{S-rail-start}} {{S-rail|title=LUL}} {{S-line|system=LUL|line=Central|previous=Foo|next=Bar}} {{S-end}}
Preceding station | London Underground | Following station | ||
---|---|---|---|---|
Foo towards
Ealing Broadway or
West Ruislip
|
Central line | Bar |
{{#invoke:Sandbox/Szqecs/L-rail|main|system=LUL|line1=Central|left1=Foo|right1=Bar}}
<br>
tags in the text. Since there is nothing stopping the table from expanding, the table expands. I would put a max-width:
in ems on the whole table instead of requiring editors to use <br>
tags by trial and error to avoid a very wide table (as the current template does); see if that works.
Jc86035 (
talk) 05:44, 25 March 2018 (UTC)hi all.
some years ago, i've written Module:Chart, to plot bar graphs and pie charts using html (as oppose to other techniques, such as svg). until then, charts on wikipedia were generated either by the timeline extension ( mw:Extension:EasyTimeline), which creates an image, or by one of several special "chart" templates, that produce HTML code (from one of which i "stole" its ingenious and bizarre way of creating pie charts using <almost> straight html - amazing trick!).
these tools are cumbersome to use, so more commonly, people create charts externally, using, e.g., excel, and upload the images. this is unsatisfactory, because it's practically impossible for other editors to update the numerical data, and such charts are incompatible with the spirit of wikipedia.
the main reason i created the module was to build a tool that squirts out "reasonably attractive" charts, using sane syntax - something that can't be said about either timeline or the specialized chart templates.
my main focus then, was ease of use, i.e., convenient way to pass the numerical data (so the series of numbers were passed as "10 : 20 : 30...", instead of the templates way of "culumn1=10 | column2 = 20 | column3 = 30..."), and i think i succeeded in creating a tool with sane syntax, where it's relatively easy and straightforward to create, and easy to update the numerical data displayed.
this all was in 2013-2014. since then, a few other editors added and improved the module, but to a large extent it remained as i left it in 2014.
a couple of years later, other/better tools arrived, specifically mw:Extension:Graph, Module:Graph which uses the extension, and Template:Graph:Chart that uses the module (developed on dewiki).
i expected the uses of "my" Module:Chart to be ported to the new tools, but apparently, its use continues, and even expands. over the years there were requests for fixes and enhancements in Module talk:Chart. i did respond to bug reports, but usually not to enhancement requests.
seeing that the module is still used, pretty widely, i think it will be good if someone would take ownership of it, maybe even act on some of the requests in the talk page, so i call for volunteers here.
peace - קיפודנחש (aka kipod) ( talk) 01:14, 14 February 2018 (UTC)
After conferring with a few editors I was encouraged to post here for a template to succeed the old method used here. I posted a brief summary of what the behaviour should be at Requested templates but later decided that a Lua module would be more suited for this task. Jon Kolbert ( talk) 02:00, 26 February 2018 (UTC)
Hello,
If you’re regularly using Lua modules, creating and improving some of them, we need your feedback!
The Wikidata development team would like to provide more Lua functions, in order to improve the experience of people who write Lua scripts to reuse Wikidata's data on the Wikimedia projects. Our goals are to help harmonizing the existing modules across the Wikimedia projects, to make coding in Lua easier for the communities, and to improve the performance of the modules.
We would like to know more about your habits, your needs, and what could help you. We have a few questions for you on this page.
Thanks a lot for your help, Lea Lacroix (WMDE) ( talk) 08:50, 27 March 2018 (UTC)
I saw the message "Lua error in Module:Navbar at line 66: Tried to write global div. Lua error in Module:Navbar at line 66: Tried to write global div." appear on varius pages. Since I lck any clue where the problem is, I think it's best toreport it here. Examples: WP:CIVIL and Jacobite Syrian Christian Church (navbars "Indian Christianity" and "Nasrani people" removed by yours truly in leu of a solution). Please help. Thanks. Kleuske ( talk) 13:03, 9 April 2018 (UTC)
Hello, is it possible to integrate Module:Check for unknown parameters to Module:Infobox itself? Would anyone like to help? Capankajsmilyo ( talk) 19:06, 11 April 2018 (UTC)
Hello, I'm looking for help with an article table, I'd like to add a numbers column to rank all the entries. The problem with current wiki-tables is if you add this column, when you change one of the entries or rows of the table, you have to manually re-number every entry/row after it. I'm looking for a way to have that done automatically, the way '#' characters will number entries in a list and automatically keep all the list entries numbered consecutively, even if you make changes. It was suggested at Village Pump/Technical that this could be accomished with a Lua code. If anyone here is able to help out with this, it would be appreciated. Thanks - theWOLFchild 14:35, 10 April 2018 (UTC)
I don't know how a module could help unless it were to write the table for you or were to wrap a table. In either of these cases, the table would need some sort of carefully chosen specific keyword in each row of the table (the #
should probably not be used because that character also appears in section links thus: [[Wikipedia talk:Lua/Archive 6#Seeking assistance]]
) which the module would replace with n+1
where n
is initially 0.
Here is the result of a wrapping experiment:
{{row counter| <nowiki>{| class="wikitable" |+test incrementor !counting |- |_row_count |- |_row_count |- |_row_count |- |_row_count |- |_row_count |}</nowiki>}}
note that the <nowiki>...</nowiki>
tags wrapping the table markup are required so that the module doesn't confuse the pipes used in the table as pipes used in the module call.
counting |
---|
1 |
2 |
3 |
4 |
5 |
A keyword than row_count should probably be devised.
— Trappist the monk ( talk) 15:56, 10 April 2018 (UTC)
Well, it mostly works; see my sandbox. But, references are broken. Not sure how to fix that. Ideas?
Is it necessary to parse apart each <ref>...</ref>
to get the attributes and content, build a table of the attributes, and then replace the <ref attributes>content</ref>
with the return from
frame:extensionTag{ name = "ref", args = attributes_table, content=content };
— Trappist the monk ( talk) 12:31, 11 April 2018 (UTC)
<
' with <
and '>
' with >
. So, replacing these character entities with their actual characters 'fixes' the referencing problem; mw.text.decode()
is rather a brute-force way of restoring the character entities: '<
', '>
', '&
', '"
', and '
' because it will restore them everywhere in the table. Not sure that that is the best approach. Perhaps the best approach is to simply and only replace '<
' and '>
'.Moved out of the sandbox and uses template {{
row counter}}
. If it breaks, let me know.
— Trappist the monk ( talk) 12:22, 12 April 2018 (UTC)
rank | name |
---|---|
1 | a |
2 | b |
3 | c |
4 | d |
5 | e |
<nowiki>...</nowiki>
tags in use on this page at the time of this writing so the decimal/hexadecimal change should not matter. I also replaced the trailing `\"\'
with [^\127]*
but am at a loss to see how that would have remedied the issue.Would someone mind looking over Module:Italian provinces and Module:Italian provinces/data which are designed to replace the functions of Template:ProvinciaIT and its subtemplates. Any suggestions would be welcome. Thanks — Martin ( MSGJ · talk) 19:36, 23 April 2018 (UTC)
require('Module:No globals');
at the top of
Module:Italian provinces; it can trap unexpected use of globals.local data = mw.loadData('Module:Italian provinces/data');
at the top of Module:Italian provinces and replacing this kind of use:
local p_data = mw.loadData('Module:Italian provinces/data')[args[1]]
local p_data = data[args[1]];
return
statement in p.region()
?local p_data = mw.loadData('Module:Italian provinces/data')[args[1]]
at the top and then using p_data['short']
in a function, but didn't get that to work. Your suggestion is working nicely though. I also see there is no benefit in returning an empty string. — Martin (
MSGJ ·
talk) 21:18, 23 April 2018 (UTC)config["link"]
(Python) with config.link
(Lua convention for alphanumeric keys).p_data['full']
is clearer as p_data.full
.p.short
should be a single line like:
return lookup(frame, 'short')
lookup
would do all the work for each of the p
functions to avoid code duplication.|link=true
and |link=false
but I found that Lua did not recognise those as booleans, and false was being evaluated to true. So I am just comparing the text values instead now. Is this normal? — Martin (
MSGJ ·
talk) 07:39, 24 April 2018 (UTC)
|link=true
the 'true' is a string, not a boolean. I saw your code and it was fine. A more general method is to have a function to translate the string parameter into a boolean. I don't like supporting more options than required so I am inclined to write my own helper functions that permit parameters that are needed for the job, and do not permit more. For an example, search
Module:Football manager history for function yes
. The modular approach would be to use
Module:Yesno.
Johnuniq (
talk) 08:14, 24 April 2018 (UTC)
|link=
), then your module gets the empty string; if they omit the parameter altogether, your module gets the value nil. If you want to pass a boolean, I suggest that you decide on a default (which will be either true or false) and then accept a few likely alternatives as the opposite. I often use something like this:local link = frame.args.link or "" link = link:lower() if link == "true" or link == "yes" or link == 1 then link = true else link = false end
Would someone be willing to help with this? – Srdjan m ( talk) 09:10, 1 May 2018 (UTC)
@ Srdjan m: I need more translations and answers to questions about the bosnian language in order to do this properly, but yes, I can adjust it. There are a few arguments missing from bs:Šablon:Ambox/test. Could you please translate the following arguments (I have put each one on it´s own line) and answer the questions below ? Within parentheses is an explaination of what the argument does.
Translate the following category names. These are categories which the module itself places pages in when they belong in them. If there are existing categories for those, then please use those. "Article message templates", "Article message templates with missing parameters", "File message boxes" and "Talk message boxes". You could translate those category names in the configuration module file, instead of letting me do that, if you want to.-- Snaevar ( talk) 19:06, 3 May 2018 (UTC)
Hi, we have this module on bnwiki which help us to detect english letter. You can see it's example of use here or here. This module have a problem and need improvement. I wrote everything here (#Problem 2). Please help. Thank you. -- আফতাব ( talk) 23:01, 12 May 2018 (UTC)
One possibility:
p={}
function p.tag (text)
local t= {}; -- table of html-like tags removed from text
local no_tag_string;
local restored_string;
for tag in text:gmatch ('%b<>') do -- look an html-like substring
table.insert (t, tag); -- save a copy
text = text:gsub (tag, '~', 1) -- replace the substring with a 'special character'
end -- tilde used here because it was handy and isnt in the '%a' character set
no_tag_string = text; -- no_tag string is text with all tags replaced with the 'special character'
-- highlighting stuff happens here
restored_string = no_tag_string; -- initial restored_string is the highlighted text
for _, tag in ipairs(t) do -- get each tag from the table of tags
restored_string = restored_string:gsub ('~', tag, 1); -- and replace each 'special character' in order
end
return no_tag_string, restored_string
end
return p;
Copy/paste the above into the code editor and in the debug console put:
=p.tag ('some <big>big</big> text, <small>small</small> text, and <s>struckout</s> text.')
you should get back:
some ~big~ text, ~small~ text, and ~struckout~ text. some <big>big</big> text, <small>small</small> text, and <s>struckout</s> text.
— Trappist the monk ( talk) 00:25, 13 May 2018 (UTC)
Please see Template talk:Abbr#Link error detection; I'm not entirely sure about this one. — SMcCandlish ☏ ¢ 😼 01:58, 13 June 2018 (UTC)
Does anyone know how {{ Routemap}} could be made to run more efficiently without sacrificing functionality? The module caused Select Bus Service to exceed the template limits earlier this month. (Maybe the module could be split into subpages, although this would also have to be done on about 28 other wikis which also have the module.) Jc86035 ( talk) 16:23, 16 June 2018 (UTC)
It's not immediately obvious how to do this, and I've tried (probably incorrectly due to the lack of examples
here) string.format
& mw.language:formatNum
, but couldn't get either to work 'out of the box'. ~
Tom.Reding (
talk ⋅
dgaf) 00:29, 18 June 2018 (UTC)
=mw.language.getContentLanguage():formatNum (123456789.123)
→ 123,456,789.123=mw.language.getContentLanguage():formatNum (123456789.123, {['noCommafy']=true})
→ 123456789.123mw.language:formatNum( n )
, as implicitly suggested in the MediaWiki doc, wasn't working... getContentLanguage()
was the unintuitive (to me) bit missing. I'll try to make the instructions more clear. ~
Tom.Reding (
talk ⋅
dgaf) 12:16, 18 June 2018 (UTC)
formatNum
works is as a method on a language object, so if you already have a language object available for the language you want to use to format a number, you can write myLangObject:formatNum( number, options )
. If you are working on enwiki, which is a monolingual wiki, then mw.language.getContentLanguage()
will give you a language object for English. if you're interested in other language formats as well, there's an example call in
Module:WikidataIB:
{{#invoke:WikidataIB |formatNumber | 123456780.123}}
→ 123,456,780.123{{#invoke:WikidataIB |formatNumber | 123456780.123 |lang=de}}
→ 123.456.780,123{{#invoke:WikidataIB |formatNumber | 123456780.123 |lang=hi}}
→ १२,३४,५६,७८०.१२३Hello, is there any limit in table data ? I'm working on Module:IATA and ICAO code/Data and wondering if it would block if too large file? Thanks Bouzinac ( talk) 07:36, 9 June 2018 (UTC)
local p= {}
p.codetbl = {
--Australia/New Zeland/Oceania
{ 'AAA', 'NTGA', 'Anaa Airport', 'Anaa' },
--Italy
{ 'AHO', 'LIEA', 'Alghero-Fertilia Airport', 'Alghero' },
{ 'ALL', 'LIMG', 'Riviera Airport', 'Albenga, Savona' },
{ 'AOI', 'LIPY', 'Marche Airport', 'Ancona' },
-- and so on
}
p.IATA = {}
p.ICAO = {}
p.WikiName = {}
for k, v in ipairs(p.codetbl) do
p.IATAv1]] = v3
p.ICAOv2]] = v3
p.WikiNamev1]] = v4
p.WikiNamev2]] = v4
end
codetbl
a local variable if you have no need to export it. This sort of scheme ought to be far easier to maintain and troubleshoot in any case. All of this is probably a bit late considering the amount of work you've already done, but it is something to bear in mind for the future. HTH --
RexxS (
talk) 12:36, 9 June 2018 (UTC)p.IATA = {}
p.ICAO = {}
p.WikiName = {}
for k, v in ipairs(p.codetbl) do
if '' ~= v1 then -- if iata code is defined for this airport
p.IATAv1]] = v3
p.WikiNamev1]] = v4
end
if '' ~= v2 then -- if icao code is defined for this airport
p.ICAOv2]] = v3
p.WikiNamev2]] = v4
end
end
{ 'AAA', 'NTGA', 'Anaa Airport', 'Anaa' }
p.IATA
, p.ICAO
and p.WikiName
which are exported to the module that uses them. That means that they are constructed once per page load and are then available in as many modules or functions you want to use them in. I think that
Module:IATA and ICAO code/data/sandbox on line 3 has 'WikiName' and 'airportCityName' transposed compared with what you wrote at
Module:IATA and ICAO code/data.master
. So master.IATA["LSS"]
contains "Les Saintes Airport" for example. I've done a few tests for you to look at at
Module talk:IATA and ICAO code/sandbox1. Hopefully that will give you a start in whatever functionality you want to create. Cheers --
RexxS (
talk) 17:16, 10 June 2018 (UTC)
TODO
s: what should the table assembly code do when it encounters empty-string iata or icao codes in the tables in master? I think that nil or empty string values should be skipped.recode()
but that doesn't seem like a very sensible function name to me; the name should either be specific to what the function does (it makes a wikilink) or very generic like main()
– not a good choice if you elect to include Editor
RexxS's functions.IATA
, ICAO
) and a wkilink label (WikiName
). The airport name is used as a wikilink target so the documentation in
Module:IATA and ICAO code/sandbox should say that index[3] of the tables in master is the name of a wikipedia article about the airport. Similarly, index[4] is a the airport's city name used as a wikilink label. And this all leads me to suggest that perhaps renaming of the tables is in order, perhaps: IATA
→ IATA_airport
, ICAO
→ ICAO_airport
, and WikiName
→ wikilink_label
(and yeah, written this way because I find underscored names easier to read than CamelCase, especially as the the names get longer)..
to concatenate strings rather than table.concat
but I guess that's a style issue and doesn't matter. I would hope there is a more efficient way to look up information. At the moment the module loops over 600 items in a table to find what it needs. How many times would this module be used in one article? Roughly how many articles?
Johnuniq (
talk) 10:40, 11 June 2018 (UTC)
mw.loadData
only cares about what they data module returns; it can compute that data any way it wants as long as it doesn't try to do things with frame objects.
{{3x|p}}ery (
talk) 11:28, 11 June 2018 (UTC)mw.loadData()
, particularly these two bullet points:
mw.loadData()
call, the data tables are created only once per page rendering, not at every {{#invoke:IATA and ICAO code/sandbox}}
in that page...
v. table.concat()
is a style choice, but since Lua is 'optimized' for table operations, I have taken to using table.concat
except for very simple things.Hello, so that everyone are aware, so far as I know, there is roughly ~12,000 ICAO and when known, ~5,600 IATA codes in the world. It would be specified in a wikipedia airport destination list table as many times as airports flown from this airport. I feel the sandbox module functionning very quick, but there are only France+USA codes in the sandbox data. Would the performance still good with 12000 lines in data ? Thanks again, Bouzinac ( talk) 13:52, 11 June 2018 (UTC)
{{
lang}}
and {{lang-??}}
templates use several individual data modules, seven of which are massaged in one way or another in the mw.loadData (
Module:Language/name/data)
call. These several modules add up to about 16k lines. In a blank sandbox page I previewed these and took the results from the parser profiling data (drop-down at the bottom of the previewed page):
{{lang|es|casa}}
– 8.78 MB/50 MB, 0.108/10.000 seconds{{#invoke:IATA and ICAO code/sandbox|recode|AAA}}
– 1.04 MB/50 MB, 0.010/10.000 seconds@Pppery and Trappist: Thanks for the correction above, I was bitten by mw.loadData years ago but did not learn that detail which makes sense. It is counter-intuitive because a key design concept for Scribunto is that it should be possible to translate the wikitext at one point of a page to rendered output without any knowledge of any other wikitext on the page (there is no context). I wonder if the first call to a module that uses mw.loadData could pass a parameter that caused it to change the returned data. A second call would get mw's cache of the data and would therefore have context information from the first call. Johnuniq ( talk) 00:04, 12 June 2018 (UTC)
@ Bouzinac: I put a new version of the code in the sandbox ( Module:IATA and ICAO code/sandbox + Module:IATA and ICAO code/data/sandbox). With this arrangement, the data is ready for use without the need for code to rearrange it. I guess it doesn't matter because the original version is very fast, but the new version is more efficient!
I noticed the following issues while extracting the data:
Examples:
{{#invoke:IATA and ICAO code|main|LSZM}}
→ {{#invoke:IATA and ICAO code|main|LSZM}}
{{#invoke:IATA and ICAO code/sandbox|main|LSZM}}
→ {{#invoke:IATA and ICAO code/sandbox|main|LSZM}}
Johnuniq ( talk) 10:12, 12 June 2018 (UTC)
{{#invoke:IATA and ICAO code/sandbox|recode|AAA}}
Hello, I've build data from Wikidata. I might have to check for duplicates inside the data. How fares the quickness of the code? Bouzinac ( talk) 22:34, 12 June 2018 (UTC)
show
function displays all the data
here using {{#invoke:Countries|show}}
. You can copy/paste a table into Excel although Excel has an annoying habit of "fixing" your data so it cannot be relied on. In due course I may be able to help either on the input or the output side but probably not right now.
Johnuniq (
talk) 07:29, 13 June 2018 (UTC)duplicate_check()
that scans the raw content of
Module:IATA and ICAO code/data looking for improper iata and icao code lengths and for duplicates.
{{#invoke:IATA and ICAO code|duplicate_check}}
{{#invoke:IATA and ICAO code|duplicate_check}}
Hello, I might have another thing to ask you : let's suppose we code {{IATA and ICAO code|GRU|PEK|other codes etc}}, it would produce following result: Beijing–Capital, São Paulo–Guarulhos (Beijing being put alphabetical first, other airports sorted by alphabetical name). Would it be possible ? Bouzinac ( talk) 09:34, 19 June 2018 (UTC)
{{#invoke:IATA and ICAO code|main|{{{1}}}}}
, write {{#invoke:IATA and ICAO code|main}}
. In the module, take all inputs from the parent frame, process each code and store the results in a table, write a sort function to sort the results table according to the wikilink label, and output the result as a comma separated string.First, in the sandbox, start with a clean copy of the working live module using the live data set (we won't be changing that). I moved p.count()
. Why is that function in the sandbox?
I created {{
IATA and ICAO code/sandbox}}
which invokes
Module:IATA and ICAO code/sandbox but does not pass it any parameters. I then modifier the module sandbox to take the single argument from the parent frame. These should work correctly:
{{IATA and ICAO code/sandbox|KORD}}
{{IATA and ICAO code/sandbox|ORD}}
{{IATA and ICAO code/sandbox|AA A}}
{{IATA and ICAO code/sandbox|AAA}}
{{IATA and ICAO code/sandbox|AHO}}
— Trappist the monk ( talk) 13:43, 20 June 2018 (UTC)
{{IATA and ICAO code/sandbox|KORD|ORD|AAA|AHO}}
This page is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Currently,
Module:Infobox requires HTML Tidy for child infoboxes and fails to render properly if there are more than two child infoboxes in one table cell and the child infoboxes are separated by line breaks (
example). This is because using child infoboxes nests <tr>...</tr>
inside <td>...</td>
, which would probably have worked with normal wikitable syntax (although this would have generated an extra blank table row) but not with HTML tags. The best fix would probably be to prevent the generation of the <tr>
and <td>
tags in the parent infobox row if <tr>
but not <table>
is detected inside a table cell with colspan=2, and to add <table>...</table>
for all other instances. I don't know how to do this with the syntax style used in the module, so asking for help here. Regexes could be </?tr[ >
etc.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 11:05, 24 May 2017 (UTC)
The module might also need to handle wikitext tables with HTML table tags used in them (or a mixture of wikitext and HTML tables in the same data cell). I'm not sure whether it's better to handle them or just remove wikitext tables from child infoboxes.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 11:13, 24 May 2017 (UTC)
In addition, {{
Collapsed infobox section begin}} and {{
Collapsed infobox section end}} can cut off ending tags which are in the infobox template but not in the parameter. For example, in the two incident infoboxes on
Watford Junction railway station, the </caption>
ending tag is split by the begin template and ends up in the collapsed table. I'm not sure whether to handle this in the module, or if this causes any actual problems.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 12:26, 24 May 2017 (UTC)
<div>...</div>
instead of using infobox|child=yes, you could probably avoid these issues, and reduce the overall complexity of the child modules.
Frietjes (
talk) 15:31, 24 May 2017 (UTC)
|data1=
. However, the rendering error is due to HTML Tidy and has nothing to do with the extra HTML tags, as all of them display well in
Special:ExpandTemplates. The rendering error persists even after the extra tags are removed.
Jc86035 (
talk) Use {{
re|Jc86035}}also should remove any spurious blank cells generated by the embeddingwhen I described (1) and (2) above. I would think that stripping empty rows would be a good in feature in general, but I could imagine someone using empty rows with background colouring to create a visual gap between sections. we could (a) go for the more aggressive version 2 and see if any problems are reported, or (b) be more conservative and go with version 1 (which is basically how child boxes function right now after tidy). I, personally, think that either one is probably ready for deployment, but I would welcome feedback from Jackmcbarn, Mr. Stradivarius, Johnuniq, etc. since I may be doing something boneheaded in the lua code that could be improved. Frietjes ( talk) 14:05, 27 May 2017 (UTC)
mw.ustring.match(mw.ustring.sub(data, 1, 3), '<tr')
for each data cell, or is this unnecessary?
Jc86035 (
talk) Use {{
re|Jc86035}} Merged changes to main version.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 13:50, 29 May 2017 (UTC)
@
Frietjes: It doesn't seem to be working properly, although this might be due to a delay in the propagation of the change. For example,
Fleetwood Mac (1975 album) only contains the infobox templates {{
Infobox album}} and {{
Singles}}, both of which use {{
Infobox}}.
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 14:00, 29 May 2017 (UTC)
{{Infobox/sandbox|data1= {{S-start}} {{s-rail|title=PM}} {{s-line|system=PM|line=1|previous=Saint-Paul|next=Gare de Lyon}} {{S-end}} }}
An editor has asked for a discussion regarding Module:Linguistic and Module:Fallback. Input from those familiar with modules is welcome at Wikipedia:Miscellany for deletion/Module:Linguistic. Thanks, — Godsy ( TALK CONT) 03:10, 17 June 2017 (UTC)
An editor has asked for a discussion regarding Module:Formatnum. Input from those familiar with modules is welcome at Wikipedia:Miscellany for deletion/Module:Formatnum. Thanks, — Godsy ( TALK CONT) 04:10, 18 June 2017 (UTC)
Hi,
We had to split the intensively used Module:Syrian_Civil_War_detailed_map into a detailed map and an overview map.
Because the huge middle eastern conflict map could no longer include the whole detailed map because it had become to large.
After a lot of work Module:Syrian_Civil_War_detailed_map now successfully inlcudes Module:Syrian_Civil_War_overview_map with all the large towns and strategic places and the huge middle eastern conflict map succesfully includes the new Module:Syrian_Civil_War_overview_map instead of the Module:Syrian_Civil_War_detailed_map
Yet a new problem occurred with the Module:Syrian_Civil_War_detailed_map that I don't understand can't solve.
All villages after +- line 2700 won't display. While before it displayed more than 7000 lines.
Can anyone look at it and try to solve it?
The module is intensively monitored by large amount of people and it should be remain out of fully working order for to long.
Kind regards, -- Niele~enwiki ( talk) 20:13, 26 July 2017 (UTC)
Hi, Could someone please help me to fix
Module:Location map's coord2text
problem on Bengali wikipedia. See the problem
here. Because of this, 200+ pages showing
script error. --
Aftabuzzaman (
talk) 16:42, 22 April 2017 (UTC)
local moduletitle = mw.title.new('Module:Location map/data/' .. map)
local moduletitle = mw.title.new('মডিউল:অবস্থান মানচিত্র/উপাত্ত/' .. map)
mw.log
lines in the module. I wonder if they show any useful information when the module is somehow invoked while editing the module.
Johnuniq (
talk) 05:40, 23 April 2017 (UTC)
22.467°N 92.117°E
, in bnwiki the equivalent text generated by {{
Coord}} is <span dir="ltr">২২.৪৬৭°</span> উত্তর <span dir="ltr">৯২.১১৭°</span> পূর্ব
. I cannot read the text and don't really know how Lua handles this, so alternatively the module could search for <span class="geo">22.467; 92.117</span>
.
Jc86035 (
talk) Use {{
re|Jc86035}}<span dir="ltr"></span><span dir="ltr"></span>
tags from module. I set up test pages for you. Please use
Module:Location map/sandbox,
Module:Coordinates/sandbox &
Template:Location map/sandbox (for testing module). Do whatever you need to do. --
Aftabuzzaman (
talk) 17:08, 23 April 2017 (UTC)Preliminary results follow. I might be able to think more in a day or two. Pasting {{Coord|44|26|N|15|3|E}}
into
bn:Special:ExpandTemplates shows a long result. Some of that is:
At enwiki, the corresponding text is:
The module fails with the "Malformed coordinates" error because it looks for the exact format used at enwiki, namely
<number>°N<space><number>°E
where <number> consists of enwiki digits or a dot. This is due to the regex mentioned by Jc86035 above. Johnuniq ( talk) 11:39, 24 April 2017 (UTC)
coord2 or ''
but that comes too late.@ Aftabuzzaman: Please briefly bring me up to date about the current status. Do the three pages you mentioned at "test pages for you" above contain the current wikitext, and are they are ready for me to experiment? I'm wondering about your "I think i found a solution" above. Did that solution get implemented and did it work? It seems bn:মধ্যমগ্রাম is showing the "Malformed coordinates" error due to what I said at 11:39, 24 April 2017 above. I should be able to have a look when you reply, although it won't be quick. Johnuniq ( talk) 05:48, 4 August 2017 (UTC)
Despite this removal of code "ç" from Module:IPAc-en/phonemes, it still persists in pages that use it. Before the code was added, the error "[invalid input: 'ç']" showed at Mary Hamilton#Lyrics amidst the pronunciation spelling of note 3. Why does this error not show again now the code has been removed? Is this a caching issue? — Sebastian 08:42, 9 August 2017 (UTC)
{{IPAc-en|n|i|ç|t}}
→
/ni[invalid input: 'ç']t/{{IPAc-en|n|i|t}}
→
/nit/{{IPAc-en|n|i|ç|t}}
to Mary Hamilton with
with this edit. And all was good; no errors. Half-hour later, Editor Nardog rises to object and
reverts. The question was: Why does this error not show again now the code has been removed?(emphasis added). The error did not show because the job queue had not yet got round to refreshing all of the pages that use Module:IPAc-en/phonemes. The error shows now because someone purged or null edited Mary Hamilton or because the job queue got round to refreshing it.
Last I knew, eval() was disabled for security reasons and seemed highly unlikely ever to be available. I ran across a comment on the Refdesk that "The metabolic cost of walking (Cw) in J/(Kg *m) was empirically determined to be 280.5i5-58.7i4-76.8i3+51.9i2+19.6i+2.5 where i is the incline..." which is when I remembered that I'd meant to write some kind of function to evaluate math expressions input as text. I'd probably want to access it indirectly from my old prototype Module:Plotter to do something like {{#invoke:Plotter|eval|280.5*i^5-58.7*i^4-76.8*i^3+51.9*i^2+19.6*i+2.5|left=0|right=0.9|step=0.05}} So I'd want to chunk the text according to at least five basic arithmetic operators and have a pass-through for Math. and Module:Math functions. Anyway, it would be a big project if done right, so I should check to see if anyone has done it. Also I think there was some magic word to do it in wikipedia format and maybe it can be sent out as a call also; I'm not sure how that would compare with just doing it by Lua. I won't ask anyone to write this since it seems like a good exercise to refresh my memory, and not urgent. Wnt ( talk) 20:30, 11 August 2017 (UTC)
{{#expr:}}
would do what you want, you could use
mw.ext.ParserFunctions.expr to do it.
Anomie
⚔ 23:05, 11 August 2017 (UTC)0.9144^3/3600
. It does not support unary operators (negation). I mention that for anyone interested but WOSlinker is correct that #expr should be used. Try this in a module:
return frame:callParserFunction{ name = '#expr', args = { '0.9144^3/3600' } }
I want to extend / refine the nowrap=off
argument of the dts template in such a way, that only the year is wrapable, (for rationale see here
Template talk:Dts). Best way is probably to create a new argument like wrap=year
, however I leave that to the implementer. The Lua code for dts is here:
Module:Dts. Any help greatly appreciated, thanks.
Wikiinger (
talk) 10:05, 17 August 2017 (UTC)
Would someone familiar with Lua and Wikidata please take a look at Template talk:Authority control#Tracking categories. Thanks. — JJMC89 ( T· C) 17:43, 18 August 2017 (UTC)
Hey, I just wanted to make 100% sure that I'm not going to break anything by closing this MfD as delete. I trust Pppery's judgement as a Lua user but since no one else weighed in on the MfD I just want to make absolutely sure that there's no one who needs this who somehow didn't see the MfD. ♠ PMC♠ (talk) 04:08, 30 October 2017 (UTC)
Hi everybody! Google Code-in (GCI) will soon take place again - a seven week long contest for 13-17 year old students to contribute to free software projects. Tasks should take an experienced contributed about two or three hours and can be of the categories Code, Documentation/Training, Outreach/Research, Quality Assurance, and User Interface/Design. Do you have any Lua / template related idea for a task (needs documentation, or some code / code changes) and can imagine enjoying mentoring such a task to help a new contributor? If yes, please check out mw:Google Code-in/2017 and become a mentor! Thanks in advance! -- AKlapper (WMF) ( talk) 19:50, 16 October 2017 (UTC)
|id=
parameter would be made more "bulletproof"; I did a little work on that earlier today, but it's still fairly easy to break it, either by producing invalid output or just not useful output (it should produce a "clean" word to serve as a link target, like "break" or "stakehorse", without any extraneous markup, even if people don't read the docs and just put something they shouldn't in there, like a bunch of markup: {{small|'[[Stake (gambling)|Stakehorse]]'}}
. —
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 10:01, 17 October 2017 (UTC)
Hello, I am having trouble understanding Lua and would like some help. I'm trying to underline the 'Shortcuts' text in Template:Shortcut, as shown here:
In wikicode I just place the text inside a div block as follows: <div style="display: inline-block; border-bottom: 1px solid #aaa;">[[Wikipedia:Shortcut|Shortcuts]]</div>
. But I have no idea how to translate this into Lua.
Could anyone please show me how to do it, or give me a hint about how it could be done? Thank you. Atón ( talk) 17:55, 10 November 2017 (UTC)
:wikitext(shortcutHeading)with something like
:tag('div'):css('display','inline-block'):css('border-bottom','1px solid #aaa'):wikitext(shortcutHeading), you should get closer to what you want. Frietjes ( talk) 19:04, 10 November 2017 (UTC)
{{
Shortcut}}
output and underline the word "Shortcuts", which doesn't trigger the concern I had at all. —
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 19:50, 10 November 2017 (UTC)I started {{ Pop row wikidata}} for use in World population#Largest populations by country. at the moment, it's not entirely correct since the percentages are calculated using different points in time. the current table in World population#Largest populations by country uses extrapolation, so I was thinking we could probably take the last two wikidata population values and extrapolate automatically. is this a reasonable idea, or is it too much work (or too expensive)? an alternative would be to keep all the population data for the countries of the world in one module, and then extrapolate from that. Frietjes ( talk) 21:25, 2 November 2017 (UTC)
{{data China}}
.
Frietjes (
talk) 21:27, 2 November 2017 (UTC)
{{Worldpop}}
, {{worldpop-base}}
and {{worldpop-daily-inc}}
. I agree the percentage of world population is tricky, but it's not usually going to be off that far. But Wikidata certainly seems the way to go. If you always update to the last two data points to get the next year's growth for the world and each country, that makes sense to me. -
Mnnlaxer |
talk |
stalk 21:48, 2 November 2017 (UTC)
Hello. el:Module:FIFARankingMin This module is finding the most recent value of values of a wikidata property. Can anyone change it to show the lowest value/values with the date in bracket? Just to change the most recent value with the min value. For example for d:Q79800, now is showing 4 (16 October 2017). Is must show 2 (1 August 2017). Check the result here. Xaris333 ( talk) 17:13, 18 November 2017 (UTC)
min
is used, and is the worst ranking if parameter max
is used. I need to read the code more slowly to check it is ok, but I won't do that until you have had a look at it.
Johnuniq (
talk) 10:00, 20 November 2017 (UTC)
min
is used, and is the worst ranking if parameter max
is used."? I changed that
[2]. It seems OK. One more thing. The data in wikidata has source. How can the module show the source of the data? By fetching data from wikidata with
el:Module:Wikidata and
el:Module:Wikidata/cite is possible. Why is not with Module:FIFARanking?
Xaris333 (
talk) 12:58, 20 November 2017 (UTC)
There is a discussion about the proper venue for deletion discussions of Module pages at Wikipedia talk:Templates for discussion#Should pages in the "Module:" namespace be discussed at TfD instead of MfD? that might be of interest to Module editors here. ♠ PMC♠ (talk) 04:29, 22 November 2017 (UTC)
It's been requested that
Template:Reign be changed so that when neither {{{1}}}
or {{{2}}}
contain whitespace (i.e., when they both contain only simple dates like "983" or "2017", rather than something like "c. 983" or "2017 BCE"), that the template emit no spacing around the en dash between the two date parameters. That might be feasible to do in some
blecherous manner with parser functions, but this really sounds like a job for Lua. —
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 06:09, 24 November 2017 (UTC)
{{Reign/sandbox |1207|1272}}
→
r. 1207–1272 {{Reign/sandbox |1 October 1207|1272}}
→
r. 1 October 1207 – 1272 {{Reign/sandbox |1207|16 November 1272}}
→
r. 1207 – 16 November 1272 {{Reign/sandbox |c. 1207|1272}}
→
r. c. 1207 – 1272 {{Reign/sandbox |1207 |1272}}
→
r. 1207–1272 {{Reign/sandbox |1207| 1272}}
→
r. 1207–1272 {{Reign/sandbox |c.1207|1272}}
→
r. c.1207–1272 Forgive me, but all this is a little unclear for me; I don't completely understand what SMcCandlish requested or the replies, but you don't have to explain. If you'll look at my comment at User talk:SMcCandlish#Reign that begins "By the way", you'll see that I had asked for an additional option at the Template:Reign. I'm not sure why there is an option (at Template:Reign) for a thin space to follow "r." Maybe that is what is used in publishing, but I think a simple, regular space after "r." looks nice. I just wanted it to be non-breaking, and with no spaces either side of the years; it looks like the first one in the list above is the one I was looking for. If you want to get rid of the thin space option (at Template:Reign), that would be fine with me, but maybe some editors prefer it; that's why I asked for an additional option. I kind of understand the list of items above; I understand that there may be times when "r. c." before the first year should be used, and that there may be times when a complete date is known and should be used. In the one with "r. c.", I hope it is non-breaking between both the "r." and the "c." and after the "c.". Well, I very much appreciate your help with this. – Corinne ( talk) 16:09, 24 November 2017 (UTC)
Forget what I wrote here. I just looked at the template page ( Template:Reign), and it looks really good now. (Why would you want to let the line break after "r.", though? It's just one letter.) – Corinne ( talk) 17:05, 24 November 2017 (UTC)
{{reign}} 1207–2172
; the undesirability of this result is the primary reason to fix the template to just parse different sorts of data in {{{1}}}
and {{{2}}}
and ti not emit a spaced en dash when the unspaced one is needed.
RexxS's sandbox version is already an improvement, and I think the first two red X cases in his output above are fixable by pre-processing the input with {{
Trim}}
, while the third is a markup error, so we don't care much. That said, I looked at
Template:Reign/sandbox and a) it is forcing display of {{{2}}}
even if it's empty, which it should not ("Elizabeth II,
r. 1952– ") and it has a hard-coded date in it somewhere with an unspaced "c.", which looks like some temporary test code.
Johnuniq, in answer to your questions, we need no. 2, as no. 1 would unnecessarily space the en dash in the case of {{
reign|1952|present}}
(it should render as
r. 1952–present), which is the most common use case for living monarchs.Anyway, we might not need to use Lua after all; I suppose a call to {{
trim}}
and another to {{#invoke:String}}
are not terribly burdensome. :-)
PS: The italicization option can just be removed; it's against
MOS:NUM and
MOS:ABBR and
MOS:ITALICS, so there is no legit use case for it. I'm going to go remove it now from the extant template.
—
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 20:23, 24 November 2017 (UTC)
{{Reign/sandbox |1207}}
? Are you expecting 1207
or 1207–
? Here are the test cases as currently implemented:
{{Reign/sandbox |1207}}
→
r. 1207– {{Reign/sandbox |1207}}
→
r. 1207–present{{Reign/sandbox |1207}}
to give just 1207
, so I've ditched any further output if parameter 2 is missing. It still works (I think) when parameter 1 is empty.
{{Reign/sandbox ||1207}}
→
r. ?–1207{{Reign/sandbox |2=1207}}
→
r. ?–1207{{
Reign}}
(you may need to purge the page to see the new documentation) can encompass all the functionality of {{
Circa}}
and {{
Floruit}}
and move to a meta-template, with those three templates being shells that just pass stuff to it. I've made a proposal to this effect at
Template talk:Reign and notified the other two templates' talk pages. The end result could be generalized enough to handle number ranges, period, without them being date-specific, so the underlying "engine" could be used to make additional templates for things like sports scores and whatever. After being Lua-ized (if we do that) it could also test for specific common input errors like "c.1312" and "ca. 1312" (errors from a
MOS:NUM perspective, anyway – both are attested styles), and issue some kind of warning. It could also do my laundry and bring me coffee. >;-) —
SMcCandlish
☏
¢ >ʌⱷ҅ᴥⱷʌ< 09:39, 26 November 2017 (UTC)Hello. Let me ask bit complicated question here, which relates to both Lua and Wikidata.
subclass of |
| |||||||||||||||||||
+ add value |
In such situation, is it possible to know "giraffe brain" or "elephant brain" from "brain" page by Lua. In other words, can I know "What uses this item as value of subclass of"?
More technically speaking,
Only from " Q1073" (ID of brain) and " P279" (ID of subclass of), can I get " Q25685967" (ID of giraffe brain) or " Q25683977" (ID of elephant brain) by Lua?
SQID service provides this at this URL https://tools.wmflabs.org/sqid/#/view?id=Q1073 (at middle of the page, Classification -> Direct subclasses -> All. That section lists up 7 pages). But as far as I see mw:Extension:Wikibase Client/Lua, there seem to be no such function which afford reverse lookup. I want to know whether there is function or technique/trick to do this. Thanks.
(This question is splited from discussion at d:Wikidata talk:WikiProject Anatomy) -- Was a bee ( talk) 11:00, 26 November 2017 (UTC)
Hi, could someone hack together a Lua module which does what {{ Alexa}} does, but using {{ IncreaseNegative}}, {{ DecreasePositive}} and {{ Steady}} and calling data from the article's Wikidata item? (Since the only bot on Wikimedia sites updating this information is on Wikidata and the information changes all the time there's not much point in allowing data to be locally added, but the bot doesn't seem to be perfect yet so it'd probably still be needed.) Jc86035 ( talk) 16:06, 16 December 2017 (UTC)
{{#invoke:Sandbox/RexxS/Alexa|main}}
, particularly in some articles that may be edge cases, please?|df=
parameter with dmy as default. --
RexxS (
talk) 22:33, 17 December 2017 (UTC)
lnk=""
(which of course becomes " ... lnk='' .. "
when quoted as a string constant) as I find it makes the code more readable when I look back later – I'm not left scanning the line for what the value of lnk
is set to. But that's trivial.[[File: ... ]]
inline construction can use the caption as the html title, and hence the tooltip, so there's no point in trying to set it explicitly.|ref=no
/|ref=yes
(equal to |ref=CS1
), with case-insensitive options |ref=CS2
, |ref=harvard
, |ref=author-title
etc. and default to either no or CS1, though using parenthetical citations would mean that a second template (or the same template with |ref=text
/inline
or something) would have to be added at the bottom of the page. Unless there's something objectionable about even that?
Jc86035 (
talk) 14:17, 22 December 2017 (UTC)
Hello, as the title says, I need to know if there is a way to display different content according to geolocation provided by user IP address, and/or OS country settings, and/or browser language settings.
If it's not, which technical hurdles should be overcome to be able to use it in the Wikipedia through a template/module?
I have zero knowledge about coding. But I've looked into the Lua reference manual from mediawiki.org, and haven't found anything useful. I left a similar message in the support page there. [3]
Thanks in advance. Mapep ( talk) 21:35, 8 January 2018 (UTC)
Is there a way to only load data with mw.loadData if certain conditions are met? My module only uses it occasionally and it would seem inefficient to always load a large table. Szqecs ( talk) 03:34, 11 January 2018 (UTC)
Hi. I need help with a problem at line 60 of my module Module:Sandbox/Szqecs/New Taiwan dollar that uses lang:formatNum(), as shown in User:Szqecs/sandbox. Thanks. Szqecs ( talk) 05:17, 12 January 2018 (UTC)
lang
. That means you have to use the provided function to create the object. The idea is that you might want the formatting as done at enwiki, or the formatting as done somewhere else, and the language object specifies what language is wanted.
Johnuniq (
talk) 06:18, 12 January 2018 (UTC)
Hi. I'd like to request some feedback on Template:New Taiwan dollar. Thanks. Szqecs ( talk) 13:38, 12 January 2018 (UTC)
Hi all
I can't find a place for a Lua requests on Wikidata like here so I'm hoping someone can help me out, I want to create a very easy to use form for the Wikidata Data Import Hub for people to record new datasets. Currently there is a prefilled template which uses Source Editor which many non Wikimedian's find confusing and hard to fill out (one of the key demographics I'm trying to reach). All I want is a when you click a button you get a pop up box with a few fields with a short desciption next to them. I would really love something similar to when you click this link, chose any section and then click add new resource, I understand this is all done in Lua. The fields I would like are (with guidance after the colon):
These fields then then populate a new section on the main Wikidata Import Hub page like so:
==NAME==
Description of dataset | Create and import data into spreadsheet | Structure of data within Wikidata | Format the data to be imported | Match the data to existing data | Importing data into Wikidata | Date import complete and notes |
---|---|---|---|---|---|---|
Name:NAME
Source:SOURCE Link: [LINK here] Description: DESCRIPTION |
Link:
Done: To do: Notes: |
Structure:
Example item: Done: To do: |
Done:
To do: Notes: |
Done:
To do: Notes: |
Done:
To do: Notes: |
Date complete:
Notes: |
Is this possible/easy for someone to set up? Note: I also asked this request on Wikidata project chat here
Thanks
John Cummings ( talk) 23:01, 16 January 2018 (UTC)
There are some templates at Wikisource whose logic has become highly convoluted and where a cleaner LUA version may be better for performance reasons.
The first of these would be https://en.wikisource.org/?title=Template:Cl-act-paragraph&action=edit which only just works..
It would be appreciated if this could be converted to a cleaner LUA version, at some point for performance reasons.
I have a few other complex templates that may also benefit from being re-written.
I was advised to ask in here, because there are not necessarily many people with LUA experience on Wikisource. ShakespeareFan00 ( talk) 21:00, 21 January 2018 (UTC)
I'd like to edit TreeChart so that boxes use more or less than three spaces. As you can see at Template:Chart, a given box takes up three cells in the table. I'd like to use more or less than three cells so that a timeline can better be presented, for something like Template:CIEC merge history. Unfortunately, I don't really know Lua. Any suggestions/help would be greatly appreciated. :) Banaticus ( talk) 18:12, 20 February 2018 (UTC)
_____ raw example
Grandma | Grandpa | ||||||||||||||||||||||||
Mom | Dad | Aunt Daisy | |||||||||||||||||||||||
My brother Joe | Me! | My little sister | |||||||||||||||||||||||
________ with colspan=7 on last row (brother-me-sister)
Grandma | Grandpa | |||||||||||||||||||||||||||
Mom | Dad | Aunt Daisy | ||||||||||||||||||||||||||
My brother Joe | Me! | My little sister | ||||||||||||||||||||||||||
I actually doesn't know how to work with Lua. I have seen a script error in one of the pages. I couldn't correct it due to lack of knowledge in lua. The page is: User:Masti/100wikidaysCEEwomen Just scroll down to see that error. Adithyak1997 ( talk) 17:06, 21 February 2018 (UTC)
Thank you. I will mention this in the talk page of that article. Adithyak1997 ( talk) 17:20, 21 February 2018 (UTC)
Hello again. A user edit Module:FIFARanking so it can show current FIFA Ranking, Man and Min values from wikidata items. (You can see Wikipedia talk:Lua/Archive 6#Module help. Last few days I was adding (and still do) all FIFA Ranking for 1992 to 2017 with sources to Wikidata. Its a lot of work. I think all Wikipedias can use this data. For example see Spain national association football team (Q42267) ( d:Property:P1352 ). I am planning to suggest the module to all Wikipedias that are using the template Template:Infobox national football team.
But there are some problems with the module. You are my last hope :)
1) Big problem. If a team no longer exist ( Serbia and Montenegro national football team (Q1131732) or Netherlands Antilles national football team (Q1037645) ), the module shows as current ranking the last one they had. But this is wrong. The module must show nothing. If a team no longer exist I thought to use d:Property:P576 as a condition. If the item has P576 then there is no current ranking (after 4 years of the dissolved). But a better solution is to have a condition that the module shows the most recent ranking only if there are not 4 years before the current date. For example, If the last ranking is 4/12/2013 will show the current ranking. If it is 30/11/2013 it will not show it. (Teams inactive for more than four years do not appear on the ranking table). Example: [4]
2) Big problem: Max, Min: the module shows only one date. For example, Spain was at the first place many times. So after the max they must show many dates. But it only shows the first one that appears in the item. The module must show all the dates. Do you have any other more practical idea? Example: [5]
3) Small problem: Wikipedia templates show the dates in brackets in smaller letters/numbers.
4) The module don't show the source. In Greek Wikipedia we are using el:Module:Wikidata/cite but it is working only if we take the information with el:Module:Wikidata.
Can anyone solve any of these 4 problems? Thanks. Xaris333 ( talk) 10:51, 2 December 2017 (UTC)
preprocess_equals()
—blank to start until you or I figure out what output should be and add it there inside quotes) –
ASiplas (
talk) 00:41, 23 February 2018 (UTC){{template|min}}
, etc.
BSicon | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Cross-posted from
Template talk:Routemap#Possible bug. For context,
Template:Routemap/doc deals with the placement of
BSicons, or route diagram icons, with the file naming format "File:BSicon xxx.svg". Basically, these icons are placed in square or rectangular "boxes" spread out among a field of rows and columns, e.g.
(STR
). It is possible to overlay two, three, or more BSicons into the same "box", as seen in the second example.
The documentation page says that to link a BSicon to another page, you use the code !@
after the BSicon When using icon overlay and icon link for the same icon cell, the icon link separator (!@) must follow the last (top) overlaying icon ID.
I noticed that when I try to link an icon that has more than one overlay, the link doesn't work (as shown in the box). How can this be fixed?
epicgenius (
talk) 18:07, 23 March 2018 (UTC)
Hi. I'm making a Lua version of {{ S-line}}. However I can't figure out why the table is wider ( Module:L-rail/LUL). Help is appreciated. Szqecs ( talk) 03:12, 25 March 2018 (UTC)
{{S-rail-start}} {{S-rail|title=LUL}} {{S-line|system=LUL|line=Central|previous=Foo|next=Bar}} {{S-end}}
Preceding station | London Underground | Following station | ||
---|---|---|---|---|
Foo towards
Ealing Broadway or
West Ruislip
|
Central line | Bar |
{{#invoke:Sandbox/Szqecs/L-rail|main|system=LUL|line1=Central|left1=Foo|right1=Bar}}
<br>
tags in the text. Since there is nothing stopping the table from expanding, the table expands. I would put a max-width:
in ems on the whole table instead of requiring editors to use <br>
tags by trial and error to avoid a very wide table (as the current template does); see if that works.
Jc86035 (
talk) 05:44, 25 March 2018 (UTC)hi all.
some years ago, i've written Module:Chart, to plot bar graphs and pie charts using html (as oppose to other techniques, such as svg). until then, charts on wikipedia were generated either by the timeline extension ( mw:Extension:EasyTimeline), which creates an image, or by one of several special "chart" templates, that produce HTML code (from one of which i "stole" its ingenious and bizarre way of creating pie charts using <almost> straight html - amazing trick!).
these tools are cumbersome to use, so more commonly, people create charts externally, using, e.g., excel, and upload the images. this is unsatisfactory, because it's practically impossible for other editors to update the numerical data, and such charts are incompatible with the spirit of wikipedia.
the main reason i created the module was to build a tool that squirts out "reasonably attractive" charts, using sane syntax - something that can't be said about either timeline or the specialized chart templates.
my main focus then, was ease of use, i.e., convenient way to pass the numerical data (so the series of numbers were passed as "10 : 20 : 30...", instead of the templates way of "culumn1=10 | column2 = 20 | column3 = 30..."), and i think i succeeded in creating a tool with sane syntax, where it's relatively easy and straightforward to create, and easy to update the numerical data displayed.
this all was in 2013-2014. since then, a few other editors added and improved the module, but to a large extent it remained as i left it in 2014.
a couple of years later, other/better tools arrived, specifically mw:Extension:Graph, Module:Graph which uses the extension, and Template:Graph:Chart that uses the module (developed on dewiki).
i expected the uses of "my" Module:Chart to be ported to the new tools, but apparently, its use continues, and even expands. over the years there were requests for fixes and enhancements in Module talk:Chart. i did respond to bug reports, but usually not to enhancement requests.
seeing that the module is still used, pretty widely, i think it will be good if someone would take ownership of it, maybe even act on some of the requests in the talk page, so i call for volunteers here.
peace - קיפודנחש (aka kipod) ( talk) 01:14, 14 February 2018 (UTC)
After conferring with a few editors I was encouraged to post here for a template to succeed the old method used here. I posted a brief summary of what the behaviour should be at Requested templates but later decided that a Lua module would be more suited for this task. Jon Kolbert ( talk) 02:00, 26 February 2018 (UTC)
Hello,
If you’re regularly using Lua modules, creating and improving some of them, we need your feedback!
The Wikidata development team would like to provide more Lua functions, in order to improve the experience of people who write Lua scripts to reuse Wikidata's data on the Wikimedia projects. Our goals are to help harmonizing the existing modules across the Wikimedia projects, to make coding in Lua easier for the communities, and to improve the performance of the modules.
We would like to know more about your habits, your needs, and what could help you. We have a few questions for you on this page.
Thanks a lot for your help, Lea Lacroix (WMDE) ( talk) 08:50, 27 March 2018 (UTC)
I saw the message "Lua error in Module:Navbar at line 66: Tried to write global div. Lua error in Module:Navbar at line 66: Tried to write global div." appear on varius pages. Since I lck any clue where the problem is, I think it's best toreport it here. Examples: WP:CIVIL and Jacobite Syrian Christian Church (navbars "Indian Christianity" and "Nasrani people" removed by yours truly in leu of a solution). Please help. Thanks. Kleuske ( talk) 13:03, 9 April 2018 (UTC)
Hello, is it possible to integrate Module:Check for unknown parameters to Module:Infobox itself? Would anyone like to help? Capankajsmilyo ( talk) 19:06, 11 April 2018 (UTC)
Hello, I'm looking for help with an article table, I'd like to add a numbers column to rank all the entries. The problem with current wiki-tables is if you add this column, when you change one of the entries or rows of the table, you have to manually re-number every entry/row after it. I'm looking for a way to have that done automatically, the way '#' characters will number entries in a list and automatically keep all the list entries numbered consecutively, even if you make changes. It was suggested at Village Pump/Technical that this could be accomished with a Lua code. If anyone here is able to help out with this, it would be appreciated. Thanks - theWOLFchild 14:35, 10 April 2018 (UTC)
I don't know how a module could help unless it were to write the table for you or were to wrap a table. In either of these cases, the table would need some sort of carefully chosen specific keyword in each row of the table (the #
should probably not be used because that character also appears in section links thus: [[Wikipedia talk:Lua/Archive 6#Seeking assistance]]
) which the module would replace with n+1
where n
is initially 0.
Here is the result of a wrapping experiment:
{{row counter| <nowiki>{| class="wikitable" |+test incrementor !counting |- |_row_count |- |_row_count |- |_row_count |- |_row_count |- |_row_count |}</nowiki>}}
note that the <nowiki>...</nowiki>
tags wrapping the table markup are required so that the module doesn't confuse the pipes used in the table as pipes used in the module call.
counting |
---|
1 |
2 |
3 |
4 |
5 |
A keyword than row_count should probably be devised.
— Trappist the monk ( talk) 15:56, 10 April 2018 (UTC)
Well, it mostly works; see my sandbox. But, references are broken. Not sure how to fix that. Ideas?
Is it necessary to parse apart each <ref>...</ref>
to get the attributes and content, build a table of the attributes, and then replace the <ref attributes>content</ref>
with the return from
frame:extensionTag{ name = "ref", args = attributes_table, content=content };
— Trappist the monk ( talk) 12:31, 11 April 2018 (UTC)
<
' with <
and '>
' with >
. So, replacing these character entities with their actual characters 'fixes' the referencing problem; mw.text.decode()
is rather a brute-force way of restoring the character entities: '<
', '>
', '&
', '"
', and '
' because it will restore them everywhere in the table. Not sure that that is the best approach. Perhaps the best approach is to simply and only replace '<
' and '>
'.Moved out of the sandbox and uses template {{
row counter}}
. If it breaks, let me know.
— Trappist the monk ( talk) 12:22, 12 April 2018 (UTC)
rank | name |
---|---|
1 | a |
2 | b |
3 | c |
4 | d |
5 | e |
<nowiki>...</nowiki>
tags in use on this page at the time of this writing so the decimal/hexadecimal change should not matter. I also replaced the trailing `\"\'
with [^\127]*
but am at a loss to see how that would have remedied the issue.Would someone mind looking over Module:Italian provinces and Module:Italian provinces/data which are designed to replace the functions of Template:ProvinciaIT and its subtemplates. Any suggestions would be welcome. Thanks — Martin ( MSGJ · talk) 19:36, 23 April 2018 (UTC)
require('Module:No globals');
at the top of
Module:Italian provinces; it can trap unexpected use of globals.local data = mw.loadData('Module:Italian provinces/data');
at the top of Module:Italian provinces and replacing this kind of use:
local p_data = mw.loadData('Module:Italian provinces/data')[args[1]]
local p_data = data[args[1]];
return
statement in p.region()
?local p_data = mw.loadData('Module:Italian provinces/data')[args[1]]
at the top and then using p_data['short']
in a function, but didn't get that to work. Your suggestion is working nicely though. I also see there is no benefit in returning an empty string. — Martin (
MSGJ ·
talk) 21:18, 23 April 2018 (UTC)config["link"]
(Python) with config.link
(Lua convention for alphanumeric keys).p_data['full']
is clearer as p_data.full
.p.short
should be a single line like:
return lookup(frame, 'short')
lookup
would do all the work for each of the p
functions to avoid code duplication.|link=true
and |link=false
but I found that Lua did not recognise those as booleans, and false was being evaluated to true. So I am just comparing the text values instead now. Is this normal? — Martin (
MSGJ ·
talk) 07:39, 24 April 2018 (UTC)
|link=true
the 'true' is a string, not a boolean. I saw your code and it was fine. A more general method is to have a function to translate the string parameter into a boolean. I don't like supporting more options than required so I am inclined to write my own helper functions that permit parameters that are needed for the job, and do not permit more. For an example, search
Module:Football manager history for function yes
. The modular approach would be to use
Module:Yesno.
Johnuniq (
talk) 08:14, 24 April 2018 (UTC)
|link=
), then your module gets the empty string; if they omit the parameter altogether, your module gets the value nil. If you want to pass a boolean, I suggest that you decide on a default (which will be either true or false) and then accept a few likely alternatives as the opposite. I often use something like this:local link = frame.args.link or "" link = link:lower() if link == "true" or link == "yes" or link == 1 then link = true else link = false end
Would someone be willing to help with this? – Srdjan m ( talk) 09:10, 1 May 2018 (UTC)
@ Srdjan m: I need more translations and answers to questions about the bosnian language in order to do this properly, but yes, I can adjust it. There are a few arguments missing from bs:Šablon:Ambox/test. Could you please translate the following arguments (I have put each one on it´s own line) and answer the questions below ? Within parentheses is an explaination of what the argument does.
Translate the following category names. These are categories which the module itself places pages in when they belong in them. If there are existing categories for those, then please use those. "Article message templates", "Article message templates with missing parameters", "File message boxes" and "Talk message boxes". You could translate those category names in the configuration module file, instead of letting me do that, if you want to.-- Snaevar ( talk) 19:06, 3 May 2018 (UTC)
Hi, we have this module on bnwiki which help us to detect english letter. You can see it's example of use here or here. This module have a problem and need improvement. I wrote everything here (#Problem 2). Please help. Thank you. -- আফতাব ( talk) 23:01, 12 May 2018 (UTC)
One possibility:
p={}
function p.tag (text)
local t= {}; -- table of html-like tags removed from text
local no_tag_string;
local restored_string;
for tag in text:gmatch ('%b<>') do -- look an html-like substring
table.insert (t, tag); -- save a copy
text = text:gsub (tag, '~', 1) -- replace the substring with a 'special character'
end -- tilde used here because it was handy and isnt in the '%a' character set
no_tag_string = text; -- no_tag string is text with all tags replaced with the 'special character'
-- highlighting stuff happens here
restored_string = no_tag_string; -- initial restored_string is the highlighted text
for _, tag in ipairs(t) do -- get each tag from the table of tags
restored_string = restored_string:gsub ('~', tag, 1); -- and replace each 'special character' in order
end
return no_tag_string, restored_string
end
return p;
Copy/paste the above into the code editor and in the debug console put:
=p.tag ('some <big>big</big> text, <small>small</small> text, and <s>struckout</s> text.')
you should get back:
some ~big~ text, ~small~ text, and ~struckout~ text. some <big>big</big> text, <small>small</small> text, and <s>struckout</s> text.
— Trappist the monk ( talk) 00:25, 13 May 2018 (UTC)
Please see Template talk:Abbr#Link error detection; I'm not entirely sure about this one. — SMcCandlish ☏ ¢ 😼 01:58, 13 June 2018 (UTC)
Does anyone know how {{ Routemap}} could be made to run more efficiently without sacrificing functionality? The module caused Select Bus Service to exceed the template limits earlier this month. (Maybe the module could be split into subpages, although this would also have to be done on about 28 other wikis which also have the module.) Jc86035 ( talk) 16:23, 16 June 2018 (UTC)
It's not immediately obvious how to do this, and I've tried (probably incorrectly due to the lack of examples
here) string.format
& mw.language:formatNum
, but couldn't get either to work 'out of the box'. ~
Tom.Reding (
talk ⋅
dgaf) 00:29, 18 June 2018 (UTC)
=mw.language.getContentLanguage():formatNum (123456789.123)
→ 123,456,789.123=mw.language.getContentLanguage():formatNum (123456789.123, {['noCommafy']=true})
→ 123456789.123mw.language:formatNum( n )
, as implicitly suggested in the MediaWiki doc, wasn't working... getContentLanguage()
was the unintuitive (to me) bit missing. I'll try to make the instructions more clear. ~
Tom.Reding (
talk ⋅
dgaf) 12:16, 18 June 2018 (UTC)
formatNum
works is as a method on a language object, so if you already have a language object available for the language you want to use to format a number, you can write myLangObject:formatNum( number, options )
. If you are working on enwiki, which is a monolingual wiki, then mw.language.getContentLanguage()
will give you a language object for English. if you're interested in other language formats as well, there's an example call in
Module:WikidataIB:
{{#invoke:WikidataIB |formatNumber | 123456780.123}}
→ 123,456,780.123{{#invoke:WikidataIB |formatNumber | 123456780.123 |lang=de}}
→ 123.456.780,123{{#invoke:WikidataIB |formatNumber | 123456780.123 |lang=hi}}
→ १२,३४,५६,७८०.१२३Hello, is there any limit in table data ? I'm working on Module:IATA and ICAO code/Data and wondering if it would block if too large file? Thanks Bouzinac ( talk) 07:36, 9 June 2018 (UTC)
local p= {}
p.codetbl = {
--Australia/New Zeland/Oceania
{ 'AAA', 'NTGA', 'Anaa Airport', 'Anaa' },
--Italy
{ 'AHO', 'LIEA', 'Alghero-Fertilia Airport', 'Alghero' },
{ 'ALL', 'LIMG', 'Riviera Airport', 'Albenga, Savona' },
{ 'AOI', 'LIPY', 'Marche Airport', 'Ancona' },
-- and so on
}
p.IATA = {}
p.ICAO = {}
p.WikiName = {}
for k, v in ipairs(p.codetbl) do
p.IATAv1]] = v3
p.ICAOv2]] = v3
p.WikiNamev1]] = v4
p.WikiNamev2]] = v4
end
codetbl
a local variable if you have no need to export it. This sort of scheme ought to be far easier to maintain and troubleshoot in any case. All of this is probably a bit late considering the amount of work you've already done, but it is something to bear in mind for the future. HTH --
RexxS (
talk) 12:36, 9 June 2018 (UTC)p.IATA = {}
p.ICAO = {}
p.WikiName = {}
for k, v in ipairs(p.codetbl) do
if '' ~= v1 then -- if iata code is defined for this airport
p.IATAv1]] = v3
p.WikiNamev1]] = v4
end
if '' ~= v2 then -- if icao code is defined for this airport
p.ICAOv2]] = v3
p.WikiNamev2]] = v4
end
end
{ 'AAA', 'NTGA', 'Anaa Airport', 'Anaa' }
p.IATA
, p.ICAO
and p.WikiName
which are exported to the module that uses them. That means that they are constructed once per page load and are then available in as many modules or functions you want to use them in. I think that
Module:IATA and ICAO code/data/sandbox on line 3 has 'WikiName' and 'airportCityName' transposed compared with what you wrote at
Module:IATA and ICAO code/data.master
. So master.IATA["LSS"]
contains "Les Saintes Airport" for example. I've done a few tests for you to look at at
Module talk:IATA and ICAO code/sandbox1. Hopefully that will give you a start in whatever functionality you want to create. Cheers --
RexxS (
talk) 17:16, 10 June 2018 (UTC)
TODO
s: what should the table assembly code do when it encounters empty-string iata or icao codes in the tables in master? I think that nil or empty string values should be skipped.recode()
but that doesn't seem like a very sensible function name to me; the name should either be specific to what the function does (it makes a wikilink) or very generic like main()
– not a good choice if you elect to include Editor
RexxS's functions.IATA
, ICAO
) and a wkilink label (WikiName
). The airport name is used as a wikilink target so the documentation in
Module:IATA and ICAO code/sandbox should say that index[3] of the tables in master is the name of a wikipedia article about the airport. Similarly, index[4] is a the airport's city name used as a wikilink label. And this all leads me to suggest that perhaps renaming of the tables is in order, perhaps: IATA
→ IATA_airport
, ICAO
→ ICAO_airport
, and WikiName
→ wikilink_label
(and yeah, written this way because I find underscored names easier to read than CamelCase, especially as the the names get longer)..
to concatenate strings rather than table.concat
but I guess that's a style issue and doesn't matter. I would hope there is a more efficient way to look up information. At the moment the module loops over 600 items in a table to find what it needs. How many times would this module be used in one article? Roughly how many articles?
Johnuniq (
talk) 10:40, 11 June 2018 (UTC)
mw.loadData
only cares about what they data module returns; it can compute that data any way it wants as long as it doesn't try to do things with frame objects.
{{3x|p}}ery (
talk) 11:28, 11 June 2018 (UTC)mw.loadData()
, particularly these two bullet points:
mw.loadData()
call, the data tables are created only once per page rendering, not at every {{#invoke:IATA and ICAO code/sandbox}}
in that page...
v. table.concat()
is a style choice, but since Lua is 'optimized' for table operations, I have taken to using table.concat
except for very simple things.Hello, so that everyone are aware, so far as I know, there is roughly ~12,000 ICAO and when known, ~5,600 IATA codes in the world. It would be specified in a wikipedia airport destination list table as many times as airports flown from this airport. I feel the sandbox module functionning very quick, but there are only France+USA codes in the sandbox data. Would the performance still good with 12000 lines in data ? Thanks again, Bouzinac ( talk) 13:52, 11 June 2018 (UTC)
{{
lang}}
and {{lang-??}}
templates use several individual data modules, seven of which are massaged in one way or another in the mw.loadData (
Module:Language/name/data)
call. These several modules add up to about 16k lines. In a blank sandbox page I previewed these and took the results from the parser profiling data (drop-down at the bottom of the previewed page):
{{lang|es|casa}}
– 8.78 MB/50 MB, 0.108/10.000 seconds{{#invoke:IATA and ICAO code/sandbox|recode|AAA}}
– 1.04 MB/50 MB, 0.010/10.000 seconds@Pppery and Trappist: Thanks for the correction above, I was bitten by mw.loadData years ago but did not learn that detail which makes sense. It is counter-intuitive because a key design concept for Scribunto is that it should be possible to translate the wikitext at one point of a page to rendered output without any knowledge of any other wikitext on the page (there is no context). I wonder if the first call to a module that uses mw.loadData could pass a parameter that caused it to change the returned data. A second call would get mw's cache of the data and would therefore have context information from the first call. Johnuniq ( talk) 00:04, 12 June 2018 (UTC)
@ Bouzinac: I put a new version of the code in the sandbox ( Module:IATA and ICAO code/sandbox + Module:IATA and ICAO code/data/sandbox). With this arrangement, the data is ready for use without the need for code to rearrange it. I guess it doesn't matter because the original version is very fast, but the new version is more efficient!
I noticed the following issues while extracting the data:
Examples:
{{#invoke:IATA and ICAO code|main|LSZM}}
→ {{#invoke:IATA and ICAO code|main|LSZM}}
{{#invoke:IATA and ICAO code/sandbox|main|LSZM}}
→ {{#invoke:IATA and ICAO code/sandbox|main|LSZM}}
Johnuniq ( talk) 10:12, 12 June 2018 (UTC)
{{#invoke:IATA and ICAO code/sandbox|recode|AAA}}
Hello, I've build data from Wikidata. I might have to check for duplicates inside the data. How fares the quickness of the code? Bouzinac ( talk) 22:34, 12 June 2018 (UTC)
show
function displays all the data
here using {{#invoke:Countries|show}}
. You can copy/paste a table into Excel although Excel has an annoying habit of "fixing" your data so it cannot be relied on. In due course I may be able to help either on the input or the output side but probably not right now.
Johnuniq (
talk) 07:29, 13 June 2018 (UTC)duplicate_check()
that scans the raw content of
Module:IATA and ICAO code/data looking for improper iata and icao code lengths and for duplicates.
{{#invoke:IATA and ICAO code|duplicate_check}}
{{#invoke:IATA and ICAO code|duplicate_check}}
Hello, I might have another thing to ask you : let's suppose we code {{IATA and ICAO code|GRU|PEK|other codes etc}}, it would produce following result: Beijing–Capital, São Paulo–Guarulhos (Beijing being put alphabetical first, other airports sorted by alphabetical name). Would it be possible ? Bouzinac ( talk) 09:34, 19 June 2018 (UTC)
{{#invoke:IATA and ICAO code|main|{{{1}}}}}
, write {{#invoke:IATA and ICAO code|main}}
. In the module, take all inputs from the parent frame, process each code and store the results in a table, write a sort function to sort the results table according to the wikilink label, and output the result as a comma separated string.First, in the sandbox, start with a clean copy of the working live module using the live data set (we won't be changing that). I moved p.count()
. Why is that function in the sandbox?
I created {{
IATA and ICAO code/sandbox}}
which invokes
Module:IATA and ICAO code/sandbox but does not pass it any parameters. I then modifier the module sandbox to take the single argument from the parent frame. These should work correctly:
{{IATA and ICAO code/sandbox|KORD}}
{{IATA and ICAO code/sandbox|ORD}}
{{IATA and ICAO code/sandbox|AA A}}
{{IATA and ICAO code/sandbox|AAA}}
{{IATA and ICAO code/sandbox|AHO}}
— Trappist the monk ( talk) 13:43, 20 June 2018 (UTC)
{{IATA and ICAO code/sandbox|KORD|ORD|AAA|AHO}}