![]() | This 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. |
Archive 1 | Archive 2 | Archive 3 | Archive 4 | Archive 5 |
For anyone interested in working with dates, I have created Module:Age. See Module talk:Age. I couldn't find a Scribunto library that implements date functions, but it would probably be desirable for one to be created eventually (or is there something I have overlooked?). Johnuniq ( talk) 10:16, 2 April 2013 (UTC)
lang:formatDate(U)
I get the error "attempt to index global 'lang' (a nil value)", and if I call it as mw.language:formatDate(U)
I get the error "attempt to call method 'formatDate' (a nil value)". Is the language library not available on the English Wikipedia yet? I've had a similar lack of success with other functions in the library. —
Mr. Stradivarius
♪ talk ♪
11:00, 2 April 2013 (UTC)
mw.getContentLanguage():formatDate("d M Y")
will work. --
WOSlinker (
talk)
12:38, 2 April 2013 (UTC)
Has anyone written a tedious function to delink multi-linked text of several external links or interwiki wikilinks, such as:
Note the need to delink several simple wikilinks, or interwiki links (such as "wikt:" for Wiktionary), plus external links with "http*". That delinking function would be copied into another Lua module. Thanks. - Wikid77 ( talk) 07:30, 30 March 2013 (UTC)
[[wikt:Wind|]]
, as
the parser processes the pipe trick before it processes #invoke. It should be enough just to support [[wikt:Wind|Wind]]
. I also agree that showing [[wikt:Wind]]
as wikt:Wind
makes more sense, as this is what readers will see displayed on the screen. —
Mr. Stradivarius
♪ talk ♪
04:16, 2 April 2013 (UTC)I think we should have a module that converts templates like that Albumchart and modules like (any one of my own written before the style guide) automatically into standard format.
I remember having some trouble with templates improperly expanded with "[[:Template:]]" showing up, though {{
#invoke:Page|getContent|Albumchart}}
(I won't include the whole mass here) seems to handle the current template fairly accurately to a glance. If we can reliably import the unparsed template code, we could write a module to put it all in a standard format with indents and colors that would make it much easier to read and understand, which would help with quickly coding Lua equivalents.
I'm thinking that it should be named something simple like Module:Format and have functions "lua" and "template" to handle the two kinds of code.
Of course, it would be necessary to come up with the full specification of how the Lua should be formatted first, which words to indent and unindent on, whether "else if x then" still gets a four+four-character indent beneath it rather than five+four, all the tricky little things, to make sure it does it right. (And it should be able to do tabs if/when the editor supports them)
It would be even more necessary with templates to be really careful that every added newline or space was safe for its operation! (Presumably this could be done with comments, even comments written in white font for purposes of display).
I feel like I could do this, eventually, but I don't think I'll get to programming it until after the holiday. Meanwhile, any suggestions? Wnt ( talk) 17:41, 27 March 2013 (UTC)
if condition then someAction() end
is perfectly fine, butif condition then action1(); action2(); action3(); end
is not.callFunc( param1, param2, { item1, item2 } )
a[i]
and not a[ i ]
.Anyone want to try their hand at taking an ISBN string and determining if it is valid (has the correct check digit)? Dragons flight ( talk) 06:30, 9 April 2013 (UTC)
For those of you who like to properly format their wikilinks, but who dislike separately copying and pasting page name and section name -- I have created
Module:UrlToWiki, which takes URLs of pages from most Wikimedia wikis and outputs wikilinks with appropriate interwiki prefixes for the local wiki. So {{#invoke:UrlToWiki|urlToWiki|1=/info/en/?search=Wikipedia:Village_pump_%28policy%29/Archive_102#Using_.7B.7BComment.7D.7D_on_articles}}
gives Script error: No such module "UrlToWiki".. Have a look at
Template:Urltowiki for usage instructions and more examples. —
Mr. Stradivarius
♪ talk ♪
22:43, 9 April 2013 (UTC)
I want to use a template without any arguments that evaluates to an autoincremented number something like this: "text {{inc}} more text, {{inc}}, {{inc}} {{inc}}{{inc}}... {{inc}}". And I want the result to be like this: "text 1 more text, 2, 3 45... 6". I have tried to call a template that calls some Lua script but all I can get is ones since the scripts resets for every instance it runs. It is to be used in a wikibook to number the exercises so it is possible to add one in the beginning and have all the rest automagically adjust their numbering. - Averater ( talk) 16:57, 7 April 2013 (UTC)
Item #2 is
in a big div
and should therefore respect the double-return though I'm not sure why
Wnt ( talk) 23:51, 17 April 2013 (UTC)
Can someone convert Template:Article history to Lua? The code would be made a lot more comprehensible. (By the way, I already suggested this a few weeks ago, but it got archived without a single response.) – Ypnypn ( talk) 23:43, 16 April 2013 (UTC)
It would be great to have a module for converting dates between different calendars. We have a lot of templates that may use it in Category:Time, date and calendar templates and its subcategories ( Category:Calendar templates, Category:Date-computing templates and so on). -- DixonD ( talk) 09:18, 17 April 2013 (UTC)
I have the following idea in my mind - to have a general module, let's say Module:Datetime, which would contain general functions that take a desired calendar option as an extra parameter. And then we create a separate submodule for each calendar. Thus adding new calendars wouldn't require to do big changes to the main module. So, for instance, in the beginning of Module:Datetime we load submodules Module:Datetime/Gregorian, Module:Datetime/Julian etc into some table, and then let's say we have function toStandardTime
. This function would take an extra parameter ("calendar" or the first unnamed) and then we just call toStandardTime
of a proper submodule judging on that extra parameter "calendar". Does it make any sense? Maybe I will try to do some stuff by myself, but I don't know when I have a chance for that. --
DixonD (
talk)
08:49, 18 April 2013 (UTC)
There are templates de:Vorlage:JULGREGDATUM or pl:Szablon:Data, which are localized variants of Template:OldStyleDate. Currently the DE and PL versions took onlyI'm lying but it is enough for explanation here. gregorian time (the standard one) as parameter and produce output in both the old (julian) and the new (gregorian) format calculating the proper julian date automatically. As I am the author of Polish version of the template, which is based on the German source, I was asked by one of wikipedians to expand the template with an argument to select the calendar type. In that case it was French Republican Calendar. However I rejected the request, explaining that it could make the template source too complicated. Introducing LUA gives an opportunity to create module that make such functionality for different historical calendars with better error checking for different variants. Different countries accepted gregorian calendar on different dates, and as I remember the New Year in the Old Style was not on 1st January. BTW The template is mostly used to format born dates of people i.e. George Washington. There is only a few events requiring it, maybe October Revolution however due to timezone shift the calculation might be still broken. Paweł Ziemian ( talk) 12:54, 22 April 2013 (UTC)
For those who are interested, some work is already done by some fellow Wikipedians in these modules: Module:Sandbox/DixonD/DateTemplates, Module:Sandbox/DixonD/Datetime, Module:Sandbox/DixonD/Datetime/Gregorian and Module:Sandbox/DixonD/Datetime/Julian. The testcases show the current state of development: Module talk:Sandbox/DixonD/DateTemplates/testcases Feel free to join and help finish this stuff. -- DixonD ( talk) 07:24, 25 April 2013 (UTC)
It should be also a good candidate for converting into Lua as inner templates are quite expensive and have limitations. -- DixonD ( talk) 07:11, 25 April 2013 (UTC)
Template:Loop15 has over 530,000 transclusions. It can probably be rewritten using a Lua module (or rather Template:Loop can probably be rewritten and Template:Loop15 can be turned into a redirect). -- MZMcBride ( talk) 21:25, 24 April 2013 (UTC)
function str.rep( frame )
return string.rep( frame.args1 or '', tonumber( frame.args2 ) or 0 )
end
{{#invoke:String|rep|{{{2|}}}|{{{1|0}}}}}
(100% untested, but modulo bugs, this illustrate how difficult the task is). i do not think creating a new module just because one function was forgotten outside of
Module:String makes sense.Can anything be done there with Lua in order to 1) improve performance 2) simplify the syntax and usage somehow? -- DixonD ( talk) 19:35, 11 April 2013 (UTC)
Hi everyone,
See: Module:Sandbox/Yaris678 and User:Yaris678/Sandbox
I am just trying to write a script that concatenates the word "test:" in front of the string that is input but I can't get it to work. I would really appreciate a pointer.
Yaris678 ( talk) 20:51, 1 May 2013 (UTC)
local z = {}
-- Module code
return z
function z.test( frame )
-- Function code
end
local z = {}
function z.test( frame )
return "test:" .. frame.args1
end
return z
local z = {}
function z.test(n)
return "test:" .. n.args1
end
return z
{{#invoke:Sandbox/Yaris678|test|foo="ABC"}}
, then you would need to use frame.args.foo instead of frame.args[1]. Hope all of this sheds some light on the situation. :) —
Mr. Stradivarius
♪ talk ♪
10:31, 2 May 2013 (UTC)mw.text.nowiki( string )
should give visually the same results as <nowiki>string</nowiki>
in most cases. One issue is that template and tag expansion happens before Lua is called, so one can't use Lua to nowiki a block that contains templates or tags (e.g. <ref>
).
Dragons flight (
talk)
17:28, 2 May 2013 (UTC)Markup | Renders as |
---|---|
[markup] |
rendering] |
If anyone is interested, I have documented some cases where this does and doesn't work. It can be seen at User:Yaris678/Markup. There is also some discussion at User talk:Yaris678/Markup. Yaris678 ( talk) 00:19, 8 May 2013 (UTC)
Is there any native support for json? Smallman12q ( talk) 02:14, 3 May 2013 (UTC)
Hello. Is it possible, to add a new function to this module, which counts the list items? This could be used in templates where before or behind the list appears an information about the number of list items. The function "count" could return the number of items. Greetings --Tlustulimu (talk) 11:57, 11 May 2013 (UTC)
{{#invoke:listify/sandbox|input|;|what is this; i don't even}} {{#invoke:listify/sandbox|count|;|what is this; i don't even}} {{#invoke:listify/sandbox|input| .. |1 .. 2 .. 3 .. 4 ..}} {{#invoke:listify/sandbox|count| .. |1 .. 2 .. 3 .. 4 ..}}
Script error: No such module "listify/sandbox". Script error: No such module "listify/sandbox".
Script error: No such module "listify/sandbox". Script error: No such module "listify/sandbox".
Is it feasible to create a Lua module that will judge (the best it can) a copyright status in different countries according to some parameters fed: the date of the first publication, the date of the author's death, the country of the first publication? -- DixonD ( talk) 13:58, 14 May 2013 (UTC)
Please see {{
infobox californium}}, using {{
infobox element}}. The input parameter requires the value (measure), the unit is added (like "K" for Kelvin). |boiling point K=1743<ref>...</ref>
→ Boiling point | 1743[3] K
. Not, as intended: 1743 K[3]
.
Is it possible to distinguish and separate the <ref></ref> from the value, so that we can set the sequence right (value -- unit -- reflink)? I guess separation (recognition) should happen for all possible ref forms (like {{
cite web}} too). Secondary, also <span> tags could be catched, to allow text additions same way: 1743 K (estimated)
. -
DePiep (
talk) 08:38, 14 May 2013 (UTC) (fixes -
DePiep (
talk)
09:16, 14 May 2013 (UTC))
I was thinking about a module that will allow creation of charts from templates. Currently, I can only think of a way to implement bar charts (e.g., using <div> elements, with absolute position, background color and forced dimensions). I thought of three types of graphs: one with a single data type (say, population in 1970, 1972, 1974...), and multiple data types: e.g. population of 4 different towns in 1972, 1974, 1976...
The 2nd case also divides into two sub-cases: whether all the data uses the same scale, or different scales: for instance, one may want to display a chart that will show population and phosphor concentration in the water, so two (or more?) separate Y-scales will be needed.
Implementation is not that difficult, the hard part is selecting a reasonable syntax that will be sane and convenient to use, yet powerful enough to allow creating useful charts.
This is what I have now. The idea is to use keys in the form of "Key n" or "Key n m" where n and m represent numbers.
So here goes:
{{ bar chart | width = | height = | value 1 1 = | value 1 2 = | value 1 3 = | value 2 1 = | value 2 2 = | value 2 3 = | color 1 = | color 2 = | title 2 1 = | x legend 1 = | x legend 2 = | x legend 3 = | y legend 1 = | y legend 2 = }}
so this example is for two different groups, with 3 data points each. each group has a color and y-legend, and each data-point has x-legend. mapping to the example above, the groups represent town A and town B, and the data points represent 1972, 1974 and 1976. in the 2nd example the groups represent population and phosphor concentration.
each bar has a tooltip. if there is a "title x y =" for this bar, this will be the tooltip. otherwise, the tooltip will be the numerical value of the bar.
I do not like the proposed syntax all that much, I just could not think of a better one. will love to hear a better proposal.
I would suggest that it would be much more friendly to editors to consolidate values as lists rather than adding a new key for each value. For example:
{{ bar chart | width = | height = | group 1 = value1, value2, value3 | group 2 = value1, value2, value3 | color 1 = | color 2 = | x legend = label1, label2, label3 | y legend = label1, label2 }}
That would require the module to parse the comma separated (or otherwise delimited) lists, but Lua is certainly capable of that, and it should be less of a pain for editors. Dragons flight ( talk) 18:35, 21 March 2013 (UTC)
There are quite a few examples of bar charts made with HTML/CSS here. As for the data format, I think comma-separated values would be a good starting point, as an editor with a large dataset is likely to already have it in CSV format, or be able to easily export it as CSV. We could write a general CSV parser module a la Apache Commons CSV that can be configured with different delimiter characters, escape characters, fixed-width formats, etc., as it could come in handy with other templates for displaying rich data sets. Toohool ( talk) 23:20, 21 March 2013 (UTC)
f({'s', {a, b, c}}) => {{'s', a}, {'s', b}, {'s', c}}
), but actually also a functional library with at least map and reduce/fold (I'm lost without map). I'm not sure if that sort of stuff should be somewhere in mw.something or in a local Module on en.wiki. Also, this is the first time in my life I named a function bar without it being a placeholder name ;). Anyway, play with it as you please, consider it CC-0 for licensing purposes (which means, if you get it working and want to upload you don't need any attribution, which is a lot easier on the edit summaries).
Martijn Hoekstra (
talk)
00:16, 27 March 2013 (UTC)so i think i'm close to finish on processing the parameters and drawing the graph itself, i.e. the bars. still missing placing the scales, validating the input with reasonable error messages, and testing.
currently 2 main modes are supported: regular barchart, and "stack", in which the different groups are stacked on each other, which can be used, e.g., to show market share distribution _and_ market growth.
in the "normal" mode, three scale systems are provided: uniform (i.e., one scale for all values), or per-group (which makes sense when the different groups are in different units - let's say town population vs. town budget over time). per group scale can be automatic or "manual", where the editor enters the scales.
you can see a demonstration by opening Special:TemplateSandbox, and feeding "User:קיפודנחש/sandbox" as Sandbox prefix, and "User:קיפודנחש/sandbox/testbar" as Render page. Here is a link.
peace - קיפודנחש (aka kipod) ( talk) 06:34, 27 March 2013 (UTC)
i think i'm pretty much done, modulo bugs. please see Module:Chart. peace - קיפודנחש (aka kipod) ( talk) 21:05, 30 March 2013 (UTC)
So the thing is more-or-less written, but i just discovered this pretty powerful-and-difficult-to-work-with extension, called mw:Extension:Timeline.
This extension is pretty powerful on one hand, but uses a very difficult and cryptic syntax: to some extent, it feels like going back to write in Assembly language all over again.
So here is what i think now: The main task of this page, is to come up with the best (i.e., most convenient and easy for the editors) syntax possible for providing the parameters. once we do this, writing a lua module that will translate this to something "Timeline" can consume should be a breeze.
I suggest at least 2 if not 3 dfferent chart types. First off, we have line vs. bar. then, we have single-data vs. multiple data. not sure if the timeline extension can do area charts also, but if it can, i suggest we do this too. personally, i ma not crazy about what seems to be enwiki standard mode of operation, which is to create one gargantuan template that can handle all cases based on dozens and dozens (in some cases hundreds) of parameters. i much prefer having one template per each specific task, or at least for each close enough set of tasks, with much more limited set of parameters.
either way, as i said above, i think the purpose of this page is to define and come up with good, sane and simple "syntax", i.e. defining the parameters that this template should accept, and defining clearly what each means and how it behaves. once good definition of syntax is achieved, we can go on to program. i will take the first shot defining the basis for line graph:
{{#invoke:Chart | line graph | y legend = 50 : 100 : 150 : 200 | x legend = 1920 : 1940 : 1960 : 1980 : 2000 : 2020 | line 1 = color:blue, thickness:2, points:* (1920 : 70 : description ) (1925 : 77 ) (1930 : 88 : bla bla ) (1936 : 60) ..... | line 2 = ditto }}
exaplain: data points appear in parenthesis, separated by colon (numbers can be given as 2000 or as 2,000, so separating the X and Y by a comma is unacceptable). each point is either a pair or a trinity, where the 3rd optional item is text to be either displayed or used as a hint (timeline graph is also an imagemap). optionally, we can allow separate definition for legend and tooltip: (xval : yval : legend : tooltip)
.
enclosing the tupples in parenthesis seems very natural, with the added benefit that unlike brackets and braces, parens have no special role in wiki syntax.
this is not a full fledged proposal - more like a teaser, to get the ball rolling. if someone thinks it's appropriate, we can move this whole discussion elsewhere, as long as i'm not the only one blabbering in this "elsewhere".
peace - קיפודנחש (aka kipod) ( talk) 19:29, 31 March 2013 (UTC)
Other editors have created several, very fast chart templates, such as Template:Bar_chart, which formats a bar chart in 1/14 second, or 7 charts per 0.5 second, with 1 or 2 or 4 columns of bars. There is not much need for faster charts. See also:
Previously, the <timeline> tag has been used, for charts with hard-coded numbers (no data from parameters) in an article page (see: Help:Bar_chart). - Wikid77 16:16, 4 April 2013 (UTC)
Medal distribution in some imaginary Olympic games |
---|
25
50
75
100
125
150
|
So i added "pie chart" capability to Module:Chart. it is not all that different from the pie chart Wnt created in Module:Plotter (i actually appropriated his submodule that gives default colors, namely Module:Plotter/DefaultColors ). the main difference is that i think my code is clearer and more readable (although it is very possible that Wnt will think *his* code is clearer...), and the way my module takes its parameters: i used "tupples", that provide the slice value, the slice name, optional color (otherwise the default will be used, at least for up to 26 slices - after that there's no more defaults...) and finally a link, so the whole thing looks more or less so:
| slices = ( Val1 : Name1 : Color1 : Link1 ) ( Val2 : Name2 : Color2 : Link2 ) ( Val3 : Name3 : Color3 : Link3 )
"Color" and "Link" are optional. in the example above i placed one tupple per line for readability, but this is not required, so it can be
| slices = (Val1:Name1)(Val2:Name2)(Val3:Name3)...
of course, both Wnt and myself owe the idea and the solution to the brilliant people who created Template:Pie chart, but i think the module has several advantages over the template:
The pie chart could use a bit more testing, but i think it is good to use. Currently this module is not used in the main space, but i think both the bar graph and the pie chart are now better than what's currently in use in enwiki, if i say so myself, both in appearance/functionality, and also in convenience and more sane syntax.
do you guys think it's ready for "big time", and if so, how do you suggest we can go about it?
regarding "what's next": i'm not sure i am interested in continuing with more charts, but i think it would be good if someone would create a nice horizontal bar-chart. the advantage of horizontal chart is that this makes room for large number of legends, and allows large number of bars - for some type of data it's very useful.
peace -
קיפודנחש (aka kipod) (
talk)
05:21, 13 April 2013 (UTC)
What would be the easiest way to get the file extension into a template? "jpg" if you are in "file:foo.jpg", etc. I do not think we can do it with parser functions so the next thing to try would be Lua. It probably can be done with string functions, but may be it is already written somewhere. -- Jarekt ( talk) 02:46, 21 May 2013 (UTC)
{{#invoke:string|match|s=file:foo.jpg|pattern=%.([^.]+)$}}
→ jpgHi. If anyone is looking for a silly project to pass the time, Module:RFX report could use a lot of love. It's an attempt to largely replace the need for a bot to update User:Cyberpower678/RfX Report. -- MZMcBride ( talk) 15:30, 31 May 2013 (UTC)
Hi. If anyone is bored, I think Template:Loop could use a rewrite. :-) -- MZMcBride ( talk) 13:57, 31 May 2013 (UTC)
Is there anyway to use a Loop template or a module inside of a template that calls other templates and knows what the loop counter is? I want to {{#expr:{{Loop|{{PAGESINCAT:Articles with a promotional tone from {{Months before now|<!-- current loop number -->}}|pages}} + |{{PAGESINCAT:Articles with a promotional tone|subcats}}}}0}}
to give me a count of all of the subpages in that category. Can this be done?
Technical 13 (
talk)
15:39, 31 May 2013 (UTC)
building a template that will allow creating graphs of boxes, such as {{ Family tree}}, with sane and convenient syntax
Currently, to use "Family tree", the editor is required to define successive series of templates, preceded by {{ Family tree/start}} and closed with {{ Family tree/end}}. this is both brittle and inconvenient. I am not criticising the people who made it: creating this with the limited tools available for template designers is no small achievement, and i applaud the people who created this template. However, i think we can do much better with lua, which is much more capable tool.
The challenge is to define a sane syntax that will let editors create graphs using clear and concise description.
Ideally, this is done in such a way that will allow the editors as much freedom as possible in defining the different element's style: for the lines it will be nice to allow solid, dashed, color, width, if possible arrows, etc. for the boxes it will be nice to allow defining box border, background color, text color, text size, allow using image for boxe's background, make boxes clickable etc.
However, none of this styling should be required, and the template should automatically select reasonable defaults for everthing.
Extra points: teach it to squirt out invisible strings to be used by screen readers to describe the graph to vision impaired readers.
{{Box Graph | globl param 1 = | global param 2 = | level 1 = (Node name: <Name> ; Legend: <Legend> ; Parents: Paretn1 Parent2 ; Pair: PairNode ; [more node attributes such as style] ) (Node ... ) (Node ... ) | level 2 = etc. etc. etc. }}
peace - קיפודנחש (aka kipod) ( talk) 19:28, 1 June 2013 (UTC)
Hi there, I operate WP:STiki, and of particular interest here, its derivative "leaderboard". Would it be possible to author a Lua function(s) that takes as its input a username, and returns: (1) the positional ranking, and (2) number of uses, per that table? Users want a userbox that displays their relative rank. Absent a scripting language, I would have to individually report table cells to separate pages for transclusion. Thanks, West.andrew.g ( talk) 16:37, 6 June 2013 (UTC)
Is there a way to use Lua, or parser functions to access information about files like URL to the actual full resolution images or image width and height? For this file the URL would be [2] and size 8150 × 6978. I need this functionality for a template to simplify KML creation for overlaying map files in Google Earth. See commons:template:Map. -- Jarekt ( talk) 03:00, 10 June 2013 (UTC)
Hi. If someone is looking for a fun activity, {{ user}} is used a lot and could definitely use a rewrite. For pages where it's called more than 1,000 times, it's painfully slow (e.g., Wikipedia:WikiProject Military history/Members/Active). -- MZMcBride ( talk) 03:14, 11 June 2013 (UTC)
I've started work on Module:UserLinks and hope to have some working code by the end of the day. I'm letting people know here in the hope that it might avoid duplication of effort. — Mr. Stradivarius ♪ talk ♪ 08:20, 12 June 2013 (UTC)
I've just written Module:IncrementParams, for those of you who don't like manually renumbering infobox parameters. Enjoy! — Mr. Stradivarius ♪ talk ♪ 08:37, 13 June 2013 (UTC)
Hello, could somebody help with converting this template to Lua? – sumone10154( talk) 20:04, 13 June 2013 (UTC)
{{#Invoke:String|replace|{{{1|}}}|%s%(.*%)||plain=false}}
does the bit that removes any text at the end in brackets so just the other part to sort out. {{#Invoke:String|replace|{{{1|}}}|.*%/||plain=false}}
should do that part, so combining gives:{{#Invoke:String|replace|{{#Invoke:String|replace|{{{1|{{SUBPAGENAME}}}}}|%s%(.*%)||plain=false}}|.*%/||plain=false}}
Hi all, I am from Bengali Wikipedia. We need your help. in T21412 Pavel Selitskas said that it can be possible to fix or use Scribunto and parse strings and match their pieces against month names and convert the original timestamp. So we need a script or help/guide. How to use at the template.The followings are the Bengali names of each English month
Thanks in Advance for your kind help.- Jayanta Nath ( Talk| Contrb) 07:38, 17 June 2013 (UTC)
{{#invoke:User:Mr. Stradivarius/convertTime|main|<!-- your text here -->}}
{{#invoke:User:Mr. Stradivarius/convertTime|main|১৬:২৫, ৩ এপ্রিল ২০১৩ (ইউটিসি)}}
produces "16:25, 3 April 2013 (ইউটিসি)". Best —
Mr. Stradivarius
♪ talk ♪
09:31, 17 June 2013 (UTC)Hi everyone. I'm in the early stages of writing Module:WikiProjectBanner, and I'd appreciate everyone's ideas for possible features. Please add your ideas over at Template talk:WPBannerMeta. Thanks! — Mr. Stradivarius ♪ talk ♪ 12:51, 18 June 2013 (UTC)
string.byte( "A" )
returns 65, and string.char( 65 )
returns "A". Scribunto also has functions that deal with UTF-8 codepoints in the same way: mw.ustring.codepoint( "á" )
returns 225, and mw.ustring.char( 225 )
returns "á".
Anomie
⚔
19:38, 22 June 2013 (UTC)
Hi. Template:Italic title currently has a bug where if the page title contains a non-disambiguation parenthetical (e.g., "Foo v. Bar (Baz) Bing") the title will be improperly italicized. The template currently only checks for the existence of "(". I'd like to switch the template to italicize the full string if there's no ")" at the end of the page title. Is there an equivalent to rfind? Or maybe regular find can be used for this? I'll post some input/outputs below. -- MZMcBride ( talk) 01:17, 14 June 2013 (UTC)
{{DISPLAYTITLE:{{#ifexpr: {{#invoke:String|find|{{PAGENAME}}|)}} = {{#invoke:String|len|{{PAGENAME}}}} |{{#if:{{NAMESPACE}}|{{NAMESPACE}}: }}''{{#Invoke:String|replace|{{PAGENAME}}| (|'' (}} |{{#if:{{NAMESPACE}}|{{NAMESPACE}}: }}''{{PAGENAME}}'' }} }}<noinclude> {{documentation}}<!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude>
|italics all=yes
parameter to cover this? Next issue then would be:
Everything You Always Wanted to Know About Sex (But Were Afraid to Ask) (book). It is a feature request, not a bug. -
DePiep (
talk)
09:38, 17 June 2013 (UTC)
Maybe someone can find joy in Luafying this related one:
Has anyone created a Lua version of parser function {urlencode:} to retain slashes, ampersand, '?' and the '=' equals sign? The current bug in web-links ("[http:____]") always appends a slash after the URL when urlencode has encoded other slashes as "%2F" which the web-link bug does not realize is a slash, and so appends a slash at end-of-URL. Instead, we need a Lua urlencode which retains slashes, so that typical weblinks of the form "[http:____]" do not append an invalid slash "/" at end of URL. I have written Template:Encodelink to properly encode some URLs, but it skips encoding the first 43 characters so that WP URLs can be encoded while retaining slashes, plus the first '?' and '='. A full Lua urlencode is needed to simplify web links. - Wikid77 ( talk) 12:40, 11 July 2013 (UTC)
<a rel="nofollow" class="external text" href="http://www.google.com%2Fsearch%3Fq%3Dxyz">googling xyz</a>
fullText
of the getCurrentTitle()
described
here. I tried various url enconding and nothing worked. I had to create a dedicated method to join optional namespace part with the title:partialUrl()
to achieve the result. I think the uri.encode
lacks some encoding and could be expanded with new enctype option for that purpose.
Paweł Ziemian (
talk)
11:20, 12 July 2013 (UTC)
wfUrlencode
for the specific implementation.
Anomie
⚔
18:21, 13 July 2013 (UTC)
There is property d:Property:P94 and d:Property:P281. the fist is name of image file on Commons and the second is just string. However both of them are identical in structure in LUA. I had to know what to do with the text i.e. whether to wrap it in [File:...] or display it as is. The wikidata knows something more, since there is difference in the property descriptions. Could be the database API expanded with function that provides the info? Paweł Ziemian ( talk) 20:06, 14 July 2013 (UTC)
frame:preprocess()
or similar in Lua. @
Paweł Ziemian: I think your suggestion might be better suited for Bugzilla, as the developers need to hear it, and the only dev I'm aware of who watches this page is
Anomie. —
Mr. Stradivarius
♪ talk ♪
08:45, 18 July 2013 (UTC)[p94] = { [0] = { ["mainsnak"] = { ["snaktype"] = "value" ["property"] = "p94" ["datavalue"] = { ["value"] = "POL Gdańsk COA.svg" ["type"] = "string" } } ["type"] = "statement" ["id"] = "q1792$297F63DF-B20B-42BC-BFFB-D79BC2B42604" ["rank"] = "normal" } ... [p281] = { [1] = { ["mainsnak"] = { ["snaktype"] = "value" ["property"] = "p281" ["datavalue"] = { ["value"] = "80-008" ["type"] = "string" } } ["type"] = "statement" ["id"] = "q1792$f14becf3-40ab-6ac1-469d-f53cee19b577" ["rank"] = "normal" } ...
There is not any hint telling that the [p94] is a file name on commons and [p281] is simple text. However I thought about it a while and realised that displaying pictures is rather complex process and needs additional attention due to many available properties formating the image. My conclusion is making the process automatically is hardly possible. So I revoke the requirement. Such properties shall never be displayed directly, rather formatted individually in target infobox according to their needs, and using only the raw property value as data reference. Paweł Ziemian ( talk) 09:15, 18 July 2013 (UTC)
claims
, which invoked in the article (in preview only of course) produces such list.
Paweł Ziemian (
talk)
11:36, 18 July 2013 (UTC)
If it's not kosher to add a request for a different project, please feel free to revert.
We are trying to get non-Latin scripts to show up without italics in the alt= and directions= fields of voy:Template:Listing, and the hunch is that a Lua module should be able to do this for us. But we don't have anyone with the expertise. If someone here is interested in helping, please see the discussion at voy:Template talk:Listing#Non-Latin scripts are italic. Thanks! -- Peter Talk 19:21, 21 July 2013 (UTC)
{{#ifeq:no|{{#invoke:IsLatin|IsLatin|{{{param}}}}}| (''{{{param}}}'')| ({{{param|}}})}}
At the Dutch Wikipedia we use nl:Sjabloon:Coördinaten for coordinates. The input is about the same as most Wikipedia's with one major difference: Underscores are used intead of pipes. So for example nl:Haarlem uses {{Coördinaten|52_22_49_N_4_38_26_E_type:city(146753)_region:NL-NH|52° 22′ 49″ N, 4° 38′ 26″ O}}. I would like to modify the coördinaten template to use #coordinates to fill nl:Special:Nearby. I'm trying at nl:Gebruiker:Multichill/Kladblok but I don't get it to work. Can someone assist me here or point me in the right direction? The problem seems to be in | as a special character and escaping it. Multichill ( talk) 10:05, 6 July 2013 (UTC)
function p.coordinates( frame )
return frame:callParserFunction( '#coordinates', mw.text.split( frame.args1], '_', true ) )
end
function m.C(frame)
return frame:callParserFunction('#coordinates', { '100', '200' } )
end
The result was a server error page with apologise and the following error details:
PHP fatal error in /usr/local/apache/common-local/php-1.22wmf8/includes/parser/Preprocessor_DOM.php line 955: Argument 1 passed to DOMXPath::__construct() must be an instance of DOMDocument, null given, called in /usr/local/apache/common-local/php-1.22wmf8/extensions/Scribunto/engines/LuaCommon/LuaCommon.php on line 500 and defined
However if I use {{#coordinates:...}} directly, a proper error is returned instead. So I give up of calling the coordinates directly from Lua until the method became more robust for invalid input. Paweł Ziemian ( talk) 05:52, 7 July 2013 (UTC)
It would be great to auto-detect the approximate aspect ratio of an image (width/height), especially for use in commons:Template:Assessments. Is this feasible? -- Ricordi samoa 23:04, 3 August 2013 (UTC)
In wikicode, parameters can have three way input: 1. straight text, 2. a <blank> (whitespace), and 3. not-defined at all (=not present in the template call). How can we pass these through the #invoke: step (or: how can the module detect these three)?
In wikicode, I can detect all three using the {#if:} parser function. - DePiep ( talk) 13:17, 26 July 2013 (UTC)
No. | Wikitext | Lua detection |
---|---|---|
1 | {{template|some text}} | if frame.args[1] == "some text" then |
2a | {{template|}} | if frame.args[1] == "" then |
2b | {{template| }} | if frame.args[1] == " " then |
3 | {{template}} | if frame.args[1] == nil then |
frame:argumentPairs()
which is the same as pairs(frame.args)
.{{Johnuniq/Testargs|}}
), and that is followed by a table which includes "Parent (arguments passed to template)" that shows the template arguments as seen by the module (for this example, an empty string).
Johnuniq (
talk)
00:52, 27 July 2013 (UTC)Thanks. I understand that Snaevar's table is defining. It could and should be in LUA help page. - DePiep ( talk) 19:11, 27 July 2013 (UTC)
tplX #invoke:....
But how to pass when I call that template from page? -
DePiep (
talk)
21:35, 1 August 2013 (UTC)
frame:getParent().args
to access parameters of the template that directly calls function from Lua module.
Paweł Ziemian (
talk)
20:04, 2 August 2013 (UTC)
I'm trying to make the rowclass# parameters apply to header rows in infoboxes. Here was my attempt to do that. I modified the testcases page to see if it worked, and it appears that it didn't (I expected testclass to be on the tr in the sandbox one, and it wasn't), and I don't know why. Can someone take a look at it for me? Thanks, Jackmcbarn ( talk) 18:02, 9 August 2013 (UTC)
Hi everyone. I've just created Module:Fixme, which searches Lua modules for the text "FIXME" in comments, and if present adds the page to the as-yet-uncreated Category:Lua modules with fixme tags. I thought that this would be a good way to encourage people to check and fix each other's code. We could check all modules automatically by adding Module:Fixme to MediaWiki:Scribunto-doc-page-show and MediaWiki:Scribunto-doc-page-does-not-exist. Do people think this is a good idea? And would you prefer a different name for the category? Let me know what you think. — Mr. Stradivarius ♪ talk ♪ 12:03, 20 August 2013 (UTC)
Hi I would like some help to create the module:documentation
I found these codes on fr wikipedia but translated some words here are the codes could someone help me change the words and to create a sillier copy of documentation but in lua scripting please I also need help translating and making the same version of Template:documentation but in lua scripting please this is some that have been done but I need help to do the rest like transformation template:documentation into module:documentation please
Extended content
|
---|
--This module implements {{Documentation}}.
--TODO: Implement a class 'ConcatBuilder' to reduce redundancy
--'table.insert(<MyTable>, <MyString>)' and 'table.concat(<MyTable>)'
local p = {}
function p.corps(frame)
args = frame:getParent().args
local page = mw.title.getCurrentTitle()
doc = p.docname(page)
local corps = {}
if page.subpageText == 'sandbox' then
table.insert(corps, '<div style="clear:both />')
table.insert(corps, frame:preprocess('{{Template sandbox notice}}'))
end
table.insert(corps, p.header(page))
table.insert(corps, p.content(frame, page))
table.insert(corps, p.footer(page))
if args.raw then
return frame:preprocess('<nowiki>' .. table.concat(corps) .. '</nowiki>\n:' .. os.clock())
end
return table.concat(corps)
end
function p.docname(page)
if not page.isSubpage then return page.subjectNsText .. ":" .. page.text .. "/doc" end
if page.subpageText == 'doc'
or page.subpageText == 'sandbox'
or page.subpageText == 'testcases' then
return page.subjectNsText .. ":" .. page.baseText .. "/doc"
else
return page.subjectNsText .. ":" .. page.text .. "/doc"
end
end
function p.ifexist(page)
if not page then return false end
if mw.title.new(page).exists then return true end
return false
end
function p.header(page)
local header = {'<div class="template-documentation"'}
if args.color then
table.insert(header, ' style="background:')
table.insert(header, args.color .. '"')
end
table.insert(header, '><div style="margin-bottom:1ex; border-bottom:1px solid #aaa; padding-bottom:3px;">')
table.insert(header, '[[File:Template-info.png|50px|alt=Template documentation|link=]]')
table.insert(header, '<span style="font-weight:bold; font-size:125%"> ')
if args.heading then table.insert(header, args.heading)
else table.insert(header, 'Template documentation') end
table.insert(header, '</span>')
if not args.content then
table.insert(header, '<span class="mw-editsection plainlinks">[[')
local arg = mw.title.new(args1 or doc)
if args1 and p.ifexist(args1]) or p.ifexist(doc) then
table.insert(header, arg:fullUrl('action=view') .. ' view]')
table.insert(header, '] [[')
table.insert(header, arg:fullUrl('action=edit') .. ' edit]')
table.insert(header, '] [[')
table.insert(header, arg:fullUrl('action=history') .. ' history]')
table.insert(header, '] [[')
table.insert(header, page:fullUrl('action=purge') .. ' purge]')
else
table.insert(header, arg:fullUrl({["action"="edit", "preload"="Template:Documentation/preload"}))
table.insert(header, ' create]')
end
table.insert(header, ']</span>')
end
table.insert(header, '</div>')
return table.concat(header)
end
function p.content(frame, page)
local content = {}
local arg = args1 or doc
if args.content then
table.insert(content, '\n')
table.insert(content, args.content)
else
table.insert(content, frame:preprocess('<nowiki />'))
table.insert(content, '\n')
if args1 and p.ifexist(args1]) or p.ifexist(doc) then
table.insert(content, frame:preprocess('{{' .. arg .. '}}'))
end
end
table.insert(content, '\n')
table.insert(content, frame:preprocess('<nowiki />'))
table.insert(content, '<div style="clear:both" />\n')
return table.concat(content)
end
function p.footer(page)
local footer = {}
local arg = mw.title.new(args1 or doc)
table.insert(footer, '</div><div class="template-documentation plainlinks" ')
table.insert(footer, 'style="font-style:italic; margin:2px 0px 0px; padding: 0.35em 0.9em')
if args.color then
table.insert(footer, '; background:')
table.insert(footer, args.color)
end
table.insert(footer, ';">\n')
if args.content then
if args"link box" then
table.insert(footer, args"link box"])
else
table.insert(footer, 'This documentation is directly included in this page.')
end
else
if args1 and p.ifexist(args1]) or p.ifexist(doc) then
table.insert(footer, 'The above [[Wikipedia:Template documentation|documentation]] is ')
table.insert(footer, '[[Wikipedia:Transclusion|transcluded]] from [[')
table.insert(footer, tostring(arg))
table.insert(footer, ']] <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, arg:fullUrl('action=edit'))
table.insert(footer, ' edit] | [')
table.insert(footer, arg:fullUrl('action=history') .. ' history])</span>.<br />')
end
table.insert(footer, 'Editors can experiment in this templates ')
local sandbox = arg.subjectNsText .. ":" .. arg.baseText .. "/sandbox"
local argsandbox = mw.title.new(sandbox)
if p.ifexist(sandbox) then
table.insert(footer, '[[' .. sandbox .. '|sandbox]]')
table.insert(footer, ' <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, argsandbox:fullUrl('action=edit'))
table.insert(footer, ' edit])</span>')
else
table.insert(footer, 'sandbox <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, argsandbox:fullUrl({["action"="edit", "preload"="Template:Documentation/preload-sandbox"}))
table.insert(footer, ' create])</span>')
end
table.insert(footer, ' and ')
local test = arg.subjectNsText .. ":" .. arg.baseText .. "/testcases"
local argtest = mw.title.new(test)
if p.ifexist(test) then
table.insert(footer, '[[' .. test .. '|testcases]]')
table.insert(footer, ' <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, argtest:fullUrl('action=edit'))
table.insert(footer, ' edit])</span>')
else
table.insert(footer, 'testcases <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, argtest:fullUrl({["action"="edit", "preload"="Template:Documentation/preload-testcases"}))
table.insert(footer, ' create])</span>')
end
table.insert(footer, ' pages.<br />Please add categories to the ')
table.insert(footer, '<span class="plainlinks">[')
if args1 and p.ifexist(args1]) or p.ifexist(doc) then
table.insert(footer, arg:fullUrl('action=edit'))
else
table.insert(footer, arg:fullUrl({["action"="edit", "preload"="Template:Documentation/preload"}))
end
table.insert(footer, ' /doc] subpage.')
end
table.insert(footer, '</div>')
return table.concat(footer)
end
return p
|
Hi could some help me to get it to look like template:documentation/start box and template:documentation/end box you can have a look at my test of it at simple:template:documentation/sandbox I had help to do it because doint know how to script but thought it was a good idea and this is we're I am testing the module on simple wiki simple:Module:Documentation 109.151.161.64 ( talk) 20:16, 29 July 2013 (UTC)
How can I add special pages in module so I use Special:ComparePages for diff 86.159.26.136 ( talk) 15:48, 10 August 2013 (UTC)
Currently it seems not to be possible to outsource squads to Wikidata and then to import them to (different language versions of) Wikipedia. There is currently a test quad at Wikidata that could be implemented to Template:FC Bayern Munich squad and FC Bayern Munich#Current squad in future. Sorting the players according to either the last name or the jersey no. is needed. See also WT:WPF#Outsourcing of squads to Wikidata. -- Leyo 10:48, 6 September 2013 (UTC)
![]() | This 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. |
Archive 1 | Archive 2 | Archive 3 | Archive 4 | Archive 5 |
For anyone interested in working with dates, I have created Module:Age. See Module talk:Age. I couldn't find a Scribunto library that implements date functions, but it would probably be desirable for one to be created eventually (or is there something I have overlooked?). Johnuniq ( talk) 10:16, 2 April 2013 (UTC)
lang:formatDate(U)
I get the error "attempt to index global 'lang' (a nil value)", and if I call it as mw.language:formatDate(U)
I get the error "attempt to call method 'formatDate' (a nil value)". Is the language library not available on the English Wikipedia yet? I've had a similar lack of success with other functions in the library. —
Mr. Stradivarius
♪ talk ♪
11:00, 2 April 2013 (UTC)
mw.getContentLanguage():formatDate("d M Y")
will work. --
WOSlinker (
talk)
12:38, 2 April 2013 (UTC)
Has anyone written a tedious function to delink multi-linked text of several external links or interwiki wikilinks, such as:
Note the need to delink several simple wikilinks, or interwiki links (such as "wikt:" for Wiktionary), plus external links with "http*". That delinking function would be copied into another Lua module. Thanks. - Wikid77 ( talk) 07:30, 30 March 2013 (UTC)
[[wikt:Wind|]]
, as
the parser processes the pipe trick before it processes #invoke. It should be enough just to support [[wikt:Wind|Wind]]
. I also agree that showing [[wikt:Wind]]
as wikt:Wind
makes more sense, as this is what readers will see displayed on the screen. —
Mr. Stradivarius
♪ talk ♪
04:16, 2 April 2013 (UTC)I think we should have a module that converts templates like that Albumchart and modules like (any one of my own written before the style guide) automatically into standard format.
I remember having some trouble with templates improperly expanded with "[[:Template:]]" showing up, though {{
#invoke:Page|getContent|Albumchart}}
(I won't include the whole mass here) seems to handle the current template fairly accurately to a glance. If we can reliably import the unparsed template code, we could write a module to put it all in a standard format with indents and colors that would make it much easier to read and understand, which would help with quickly coding Lua equivalents.
I'm thinking that it should be named something simple like Module:Format and have functions "lua" and "template" to handle the two kinds of code.
Of course, it would be necessary to come up with the full specification of how the Lua should be formatted first, which words to indent and unindent on, whether "else if x then" still gets a four+four-character indent beneath it rather than five+four, all the tricky little things, to make sure it does it right. (And it should be able to do tabs if/when the editor supports them)
It would be even more necessary with templates to be really careful that every added newline or space was safe for its operation! (Presumably this could be done with comments, even comments written in white font for purposes of display).
I feel like I could do this, eventually, but I don't think I'll get to programming it until after the holiday. Meanwhile, any suggestions? Wnt ( talk) 17:41, 27 March 2013 (UTC)
if condition then someAction() end
is perfectly fine, butif condition then action1(); action2(); action3(); end
is not.callFunc( param1, param2, { item1, item2 } )
a[i]
and not a[ i ]
.Anyone want to try their hand at taking an ISBN string and determining if it is valid (has the correct check digit)? Dragons flight ( talk) 06:30, 9 April 2013 (UTC)
For those of you who like to properly format their wikilinks, but who dislike separately copying and pasting page name and section name -- I have created
Module:UrlToWiki, which takes URLs of pages from most Wikimedia wikis and outputs wikilinks with appropriate interwiki prefixes for the local wiki. So {{#invoke:UrlToWiki|urlToWiki|1=/info/en/?search=Wikipedia:Village_pump_%28policy%29/Archive_102#Using_.7B.7BComment.7D.7D_on_articles}}
gives Script error: No such module "UrlToWiki".. Have a look at
Template:Urltowiki for usage instructions and more examples. —
Mr. Stradivarius
♪ talk ♪
22:43, 9 April 2013 (UTC)
I want to use a template without any arguments that evaluates to an autoincremented number something like this: "text {{inc}} more text, {{inc}}, {{inc}} {{inc}}{{inc}}... {{inc}}". And I want the result to be like this: "text 1 more text, 2, 3 45... 6". I have tried to call a template that calls some Lua script but all I can get is ones since the scripts resets for every instance it runs. It is to be used in a wikibook to number the exercises so it is possible to add one in the beginning and have all the rest automagically adjust their numbering. - Averater ( talk) 16:57, 7 April 2013 (UTC)
Item #2 is
in a big div
and should therefore respect the double-return though I'm not sure why
Wnt ( talk) 23:51, 17 April 2013 (UTC)
Can someone convert Template:Article history to Lua? The code would be made a lot more comprehensible. (By the way, I already suggested this a few weeks ago, but it got archived without a single response.) – Ypnypn ( talk) 23:43, 16 April 2013 (UTC)
It would be great to have a module for converting dates between different calendars. We have a lot of templates that may use it in Category:Time, date and calendar templates and its subcategories ( Category:Calendar templates, Category:Date-computing templates and so on). -- DixonD ( talk) 09:18, 17 April 2013 (UTC)
I have the following idea in my mind - to have a general module, let's say Module:Datetime, which would contain general functions that take a desired calendar option as an extra parameter. And then we create a separate submodule for each calendar. Thus adding new calendars wouldn't require to do big changes to the main module. So, for instance, in the beginning of Module:Datetime we load submodules Module:Datetime/Gregorian, Module:Datetime/Julian etc into some table, and then let's say we have function toStandardTime
. This function would take an extra parameter ("calendar" or the first unnamed) and then we just call toStandardTime
of a proper submodule judging on that extra parameter "calendar". Does it make any sense? Maybe I will try to do some stuff by myself, but I don't know when I have a chance for that. --
DixonD (
talk)
08:49, 18 April 2013 (UTC)
There are templates de:Vorlage:JULGREGDATUM or pl:Szablon:Data, which are localized variants of Template:OldStyleDate. Currently the DE and PL versions took onlyI'm lying but it is enough for explanation here. gregorian time (the standard one) as parameter and produce output in both the old (julian) and the new (gregorian) format calculating the proper julian date automatically. As I am the author of Polish version of the template, which is based on the German source, I was asked by one of wikipedians to expand the template with an argument to select the calendar type. In that case it was French Republican Calendar. However I rejected the request, explaining that it could make the template source too complicated. Introducing LUA gives an opportunity to create module that make such functionality for different historical calendars with better error checking for different variants. Different countries accepted gregorian calendar on different dates, and as I remember the New Year in the Old Style was not on 1st January. BTW The template is mostly used to format born dates of people i.e. George Washington. There is only a few events requiring it, maybe October Revolution however due to timezone shift the calculation might be still broken. Paweł Ziemian ( talk) 12:54, 22 April 2013 (UTC)
For those who are interested, some work is already done by some fellow Wikipedians in these modules: Module:Sandbox/DixonD/DateTemplates, Module:Sandbox/DixonD/Datetime, Module:Sandbox/DixonD/Datetime/Gregorian and Module:Sandbox/DixonD/Datetime/Julian. The testcases show the current state of development: Module talk:Sandbox/DixonD/DateTemplates/testcases Feel free to join and help finish this stuff. -- DixonD ( talk) 07:24, 25 April 2013 (UTC)
It should be also a good candidate for converting into Lua as inner templates are quite expensive and have limitations. -- DixonD ( talk) 07:11, 25 April 2013 (UTC)
Template:Loop15 has over 530,000 transclusions. It can probably be rewritten using a Lua module (or rather Template:Loop can probably be rewritten and Template:Loop15 can be turned into a redirect). -- MZMcBride ( talk) 21:25, 24 April 2013 (UTC)
function str.rep( frame )
return string.rep( frame.args1 or '', tonumber( frame.args2 ) or 0 )
end
{{#invoke:String|rep|{{{2|}}}|{{{1|0}}}}}
(100% untested, but modulo bugs, this illustrate how difficult the task is). i do not think creating a new module just because one function was forgotten outside of
Module:String makes sense.Can anything be done there with Lua in order to 1) improve performance 2) simplify the syntax and usage somehow? -- DixonD ( talk) 19:35, 11 April 2013 (UTC)
Hi everyone,
See: Module:Sandbox/Yaris678 and User:Yaris678/Sandbox
I am just trying to write a script that concatenates the word "test:" in front of the string that is input but I can't get it to work. I would really appreciate a pointer.
Yaris678 ( talk) 20:51, 1 May 2013 (UTC)
local z = {}
-- Module code
return z
function z.test( frame )
-- Function code
end
local z = {}
function z.test( frame )
return "test:" .. frame.args1
end
return z
local z = {}
function z.test(n)
return "test:" .. n.args1
end
return z
{{#invoke:Sandbox/Yaris678|test|foo="ABC"}}
, then you would need to use frame.args.foo instead of frame.args[1]. Hope all of this sheds some light on the situation. :) —
Mr. Stradivarius
♪ talk ♪
10:31, 2 May 2013 (UTC)mw.text.nowiki( string )
should give visually the same results as <nowiki>string</nowiki>
in most cases. One issue is that template and tag expansion happens before Lua is called, so one can't use Lua to nowiki a block that contains templates or tags (e.g. <ref>
).
Dragons flight (
talk)
17:28, 2 May 2013 (UTC)Markup | Renders as |
---|---|
[markup] |
rendering] |
If anyone is interested, I have documented some cases where this does and doesn't work. It can be seen at User:Yaris678/Markup. There is also some discussion at User talk:Yaris678/Markup. Yaris678 ( talk) 00:19, 8 May 2013 (UTC)
Is there any native support for json? Smallman12q ( talk) 02:14, 3 May 2013 (UTC)
Hello. Is it possible, to add a new function to this module, which counts the list items? This could be used in templates where before or behind the list appears an information about the number of list items. The function "count" could return the number of items. Greetings --Tlustulimu (talk) 11:57, 11 May 2013 (UTC)
{{#invoke:listify/sandbox|input|;|what is this; i don't even}} {{#invoke:listify/sandbox|count|;|what is this; i don't even}} {{#invoke:listify/sandbox|input| .. |1 .. 2 .. 3 .. 4 ..}} {{#invoke:listify/sandbox|count| .. |1 .. 2 .. 3 .. 4 ..}}
Script error: No such module "listify/sandbox". Script error: No such module "listify/sandbox".
Script error: No such module "listify/sandbox". Script error: No such module "listify/sandbox".
Is it feasible to create a Lua module that will judge (the best it can) a copyright status in different countries according to some parameters fed: the date of the first publication, the date of the author's death, the country of the first publication? -- DixonD ( talk) 13:58, 14 May 2013 (UTC)
Please see {{
infobox californium}}, using {{
infobox element}}. The input parameter requires the value (measure), the unit is added (like "K" for Kelvin). |boiling point K=1743<ref>...</ref>
→ Boiling point | 1743[3] K
. Not, as intended: 1743 K[3]
.
Is it possible to distinguish and separate the <ref></ref> from the value, so that we can set the sequence right (value -- unit -- reflink)? I guess separation (recognition) should happen for all possible ref forms (like {{
cite web}} too). Secondary, also <span> tags could be catched, to allow text additions same way: 1743 K (estimated)
. -
DePiep (
talk) 08:38, 14 May 2013 (UTC) (fixes -
DePiep (
talk)
09:16, 14 May 2013 (UTC))
I was thinking about a module that will allow creation of charts from templates. Currently, I can only think of a way to implement bar charts (e.g., using <div> elements, with absolute position, background color and forced dimensions). I thought of three types of graphs: one with a single data type (say, population in 1970, 1972, 1974...), and multiple data types: e.g. population of 4 different towns in 1972, 1974, 1976...
The 2nd case also divides into two sub-cases: whether all the data uses the same scale, or different scales: for instance, one may want to display a chart that will show population and phosphor concentration in the water, so two (or more?) separate Y-scales will be needed.
Implementation is not that difficult, the hard part is selecting a reasonable syntax that will be sane and convenient to use, yet powerful enough to allow creating useful charts.
This is what I have now. The idea is to use keys in the form of "Key n" or "Key n m" where n and m represent numbers.
So here goes:
{{ bar chart | width = | height = | value 1 1 = | value 1 2 = | value 1 3 = | value 2 1 = | value 2 2 = | value 2 3 = | color 1 = | color 2 = | title 2 1 = | x legend 1 = | x legend 2 = | x legend 3 = | y legend 1 = | y legend 2 = }}
so this example is for two different groups, with 3 data points each. each group has a color and y-legend, and each data-point has x-legend. mapping to the example above, the groups represent town A and town B, and the data points represent 1972, 1974 and 1976. in the 2nd example the groups represent population and phosphor concentration.
each bar has a tooltip. if there is a "title x y =" for this bar, this will be the tooltip. otherwise, the tooltip will be the numerical value of the bar.
I do not like the proposed syntax all that much, I just could not think of a better one. will love to hear a better proposal.
I would suggest that it would be much more friendly to editors to consolidate values as lists rather than adding a new key for each value. For example:
{{ bar chart | width = | height = | group 1 = value1, value2, value3 | group 2 = value1, value2, value3 | color 1 = | color 2 = | x legend = label1, label2, label3 | y legend = label1, label2 }}
That would require the module to parse the comma separated (or otherwise delimited) lists, but Lua is certainly capable of that, and it should be less of a pain for editors. Dragons flight ( talk) 18:35, 21 March 2013 (UTC)
There are quite a few examples of bar charts made with HTML/CSS here. As for the data format, I think comma-separated values would be a good starting point, as an editor with a large dataset is likely to already have it in CSV format, or be able to easily export it as CSV. We could write a general CSV parser module a la Apache Commons CSV that can be configured with different delimiter characters, escape characters, fixed-width formats, etc., as it could come in handy with other templates for displaying rich data sets. Toohool ( talk) 23:20, 21 March 2013 (UTC)
f({'s', {a, b, c}}) => {{'s', a}, {'s', b}, {'s', c}}
), but actually also a functional library with at least map and reduce/fold (I'm lost without map). I'm not sure if that sort of stuff should be somewhere in mw.something or in a local Module on en.wiki. Also, this is the first time in my life I named a function bar without it being a placeholder name ;). Anyway, play with it as you please, consider it CC-0 for licensing purposes (which means, if you get it working and want to upload you don't need any attribution, which is a lot easier on the edit summaries).
Martijn Hoekstra (
talk)
00:16, 27 March 2013 (UTC)so i think i'm close to finish on processing the parameters and drawing the graph itself, i.e. the bars. still missing placing the scales, validating the input with reasonable error messages, and testing.
currently 2 main modes are supported: regular barchart, and "stack", in which the different groups are stacked on each other, which can be used, e.g., to show market share distribution _and_ market growth.
in the "normal" mode, three scale systems are provided: uniform (i.e., one scale for all values), or per-group (which makes sense when the different groups are in different units - let's say town population vs. town budget over time). per group scale can be automatic or "manual", where the editor enters the scales.
you can see a demonstration by opening Special:TemplateSandbox, and feeding "User:קיפודנחש/sandbox" as Sandbox prefix, and "User:קיפודנחש/sandbox/testbar" as Render page. Here is a link.
peace - קיפודנחש (aka kipod) ( talk) 06:34, 27 March 2013 (UTC)
i think i'm pretty much done, modulo bugs. please see Module:Chart. peace - קיפודנחש (aka kipod) ( talk) 21:05, 30 March 2013 (UTC)
So the thing is more-or-less written, but i just discovered this pretty powerful-and-difficult-to-work-with extension, called mw:Extension:Timeline.
This extension is pretty powerful on one hand, but uses a very difficult and cryptic syntax: to some extent, it feels like going back to write in Assembly language all over again.
So here is what i think now: The main task of this page, is to come up with the best (i.e., most convenient and easy for the editors) syntax possible for providing the parameters. once we do this, writing a lua module that will translate this to something "Timeline" can consume should be a breeze.
I suggest at least 2 if not 3 dfferent chart types. First off, we have line vs. bar. then, we have single-data vs. multiple data. not sure if the timeline extension can do area charts also, but if it can, i suggest we do this too. personally, i ma not crazy about what seems to be enwiki standard mode of operation, which is to create one gargantuan template that can handle all cases based on dozens and dozens (in some cases hundreds) of parameters. i much prefer having one template per each specific task, or at least for each close enough set of tasks, with much more limited set of parameters.
either way, as i said above, i think the purpose of this page is to define and come up with good, sane and simple "syntax", i.e. defining the parameters that this template should accept, and defining clearly what each means and how it behaves. once good definition of syntax is achieved, we can go on to program. i will take the first shot defining the basis for line graph:
{{#invoke:Chart | line graph | y legend = 50 : 100 : 150 : 200 | x legend = 1920 : 1940 : 1960 : 1980 : 2000 : 2020 | line 1 = color:blue, thickness:2, points:* (1920 : 70 : description ) (1925 : 77 ) (1930 : 88 : bla bla ) (1936 : 60) ..... | line 2 = ditto }}
exaplain: data points appear in parenthesis, separated by colon (numbers can be given as 2000 or as 2,000, so separating the X and Y by a comma is unacceptable). each point is either a pair or a trinity, where the 3rd optional item is text to be either displayed or used as a hint (timeline graph is also an imagemap). optionally, we can allow separate definition for legend and tooltip: (xval : yval : legend : tooltip)
.
enclosing the tupples in parenthesis seems very natural, with the added benefit that unlike brackets and braces, parens have no special role in wiki syntax.
this is not a full fledged proposal - more like a teaser, to get the ball rolling. if someone thinks it's appropriate, we can move this whole discussion elsewhere, as long as i'm not the only one blabbering in this "elsewhere".
peace - קיפודנחש (aka kipod) ( talk) 19:29, 31 March 2013 (UTC)
Other editors have created several, very fast chart templates, such as Template:Bar_chart, which formats a bar chart in 1/14 second, or 7 charts per 0.5 second, with 1 or 2 or 4 columns of bars. There is not much need for faster charts. See also:
Previously, the <timeline> tag has been used, for charts with hard-coded numbers (no data from parameters) in an article page (see: Help:Bar_chart). - Wikid77 16:16, 4 April 2013 (UTC)
Medal distribution in some imaginary Olympic games |
---|
25
50
75
100
125
150
|
So i added "pie chart" capability to Module:Chart. it is not all that different from the pie chart Wnt created in Module:Plotter (i actually appropriated his submodule that gives default colors, namely Module:Plotter/DefaultColors ). the main difference is that i think my code is clearer and more readable (although it is very possible that Wnt will think *his* code is clearer...), and the way my module takes its parameters: i used "tupples", that provide the slice value, the slice name, optional color (otherwise the default will be used, at least for up to 26 slices - after that there's no more defaults...) and finally a link, so the whole thing looks more or less so:
| slices = ( Val1 : Name1 : Color1 : Link1 ) ( Val2 : Name2 : Color2 : Link2 ) ( Val3 : Name3 : Color3 : Link3 )
"Color" and "Link" are optional. in the example above i placed one tupple per line for readability, but this is not required, so it can be
| slices = (Val1:Name1)(Val2:Name2)(Val3:Name3)...
of course, both Wnt and myself owe the idea and the solution to the brilliant people who created Template:Pie chart, but i think the module has several advantages over the template:
The pie chart could use a bit more testing, but i think it is good to use. Currently this module is not used in the main space, but i think both the bar graph and the pie chart are now better than what's currently in use in enwiki, if i say so myself, both in appearance/functionality, and also in convenience and more sane syntax.
do you guys think it's ready for "big time", and if so, how do you suggest we can go about it?
regarding "what's next": i'm not sure i am interested in continuing with more charts, but i think it would be good if someone would create a nice horizontal bar-chart. the advantage of horizontal chart is that this makes room for large number of legends, and allows large number of bars - for some type of data it's very useful.
peace -
קיפודנחש (aka kipod) (
talk)
05:21, 13 April 2013 (UTC)
What would be the easiest way to get the file extension into a template? "jpg" if you are in "file:foo.jpg", etc. I do not think we can do it with parser functions so the next thing to try would be Lua. It probably can be done with string functions, but may be it is already written somewhere. -- Jarekt ( talk) 02:46, 21 May 2013 (UTC)
{{#invoke:string|match|s=file:foo.jpg|pattern=%.([^.]+)$}}
→ jpgHi. If anyone is looking for a silly project to pass the time, Module:RFX report could use a lot of love. It's an attempt to largely replace the need for a bot to update User:Cyberpower678/RfX Report. -- MZMcBride ( talk) 15:30, 31 May 2013 (UTC)
Hi. If anyone is bored, I think Template:Loop could use a rewrite. :-) -- MZMcBride ( talk) 13:57, 31 May 2013 (UTC)
Is there anyway to use a Loop template or a module inside of a template that calls other templates and knows what the loop counter is? I want to {{#expr:{{Loop|{{PAGESINCAT:Articles with a promotional tone from {{Months before now|<!-- current loop number -->}}|pages}} + |{{PAGESINCAT:Articles with a promotional tone|subcats}}}}0}}
to give me a count of all of the subpages in that category. Can this be done?
Technical 13 (
talk)
15:39, 31 May 2013 (UTC)
building a template that will allow creating graphs of boxes, such as {{ Family tree}}, with sane and convenient syntax
Currently, to use "Family tree", the editor is required to define successive series of templates, preceded by {{ Family tree/start}} and closed with {{ Family tree/end}}. this is both brittle and inconvenient. I am not criticising the people who made it: creating this with the limited tools available for template designers is no small achievement, and i applaud the people who created this template. However, i think we can do much better with lua, which is much more capable tool.
The challenge is to define a sane syntax that will let editors create graphs using clear and concise description.
Ideally, this is done in such a way that will allow the editors as much freedom as possible in defining the different element's style: for the lines it will be nice to allow solid, dashed, color, width, if possible arrows, etc. for the boxes it will be nice to allow defining box border, background color, text color, text size, allow using image for boxe's background, make boxes clickable etc.
However, none of this styling should be required, and the template should automatically select reasonable defaults for everthing.
Extra points: teach it to squirt out invisible strings to be used by screen readers to describe the graph to vision impaired readers.
{{Box Graph | globl param 1 = | global param 2 = | level 1 = (Node name: <Name> ; Legend: <Legend> ; Parents: Paretn1 Parent2 ; Pair: PairNode ; [more node attributes such as style] ) (Node ... ) (Node ... ) | level 2 = etc. etc. etc. }}
peace - קיפודנחש (aka kipod) ( talk) 19:28, 1 June 2013 (UTC)
Hi there, I operate WP:STiki, and of particular interest here, its derivative "leaderboard". Would it be possible to author a Lua function(s) that takes as its input a username, and returns: (1) the positional ranking, and (2) number of uses, per that table? Users want a userbox that displays their relative rank. Absent a scripting language, I would have to individually report table cells to separate pages for transclusion. Thanks, West.andrew.g ( talk) 16:37, 6 June 2013 (UTC)
Is there a way to use Lua, or parser functions to access information about files like URL to the actual full resolution images or image width and height? For this file the URL would be [2] and size 8150 × 6978. I need this functionality for a template to simplify KML creation for overlaying map files in Google Earth. See commons:template:Map. -- Jarekt ( talk) 03:00, 10 June 2013 (UTC)
Hi. If someone is looking for a fun activity, {{ user}} is used a lot and could definitely use a rewrite. For pages where it's called more than 1,000 times, it's painfully slow (e.g., Wikipedia:WikiProject Military history/Members/Active). -- MZMcBride ( talk) 03:14, 11 June 2013 (UTC)
I've started work on Module:UserLinks and hope to have some working code by the end of the day. I'm letting people know here in the hope that it might avoid duplication of effort. — Mr. Stradivarius ♪ talk ♪ 08:20, 12 June 2013 (UTC)
I've just written Module:IncrementParams, for those of you who don't like manually renumbering infobox parameters. Enjoy! — Mr. Stradivarius ♪ talk ♪ 08:37, 13 June 2013 (UTC)
Hello, could somebody help with converting this template to Lua? – sumone10154( talk) 20:04, 13 June 2013 (UTC)
{{#Invoke:String|replace|{{{1|}}}|%s%(.*%)||plain=false}}
does the bit that removes any text at the end in brackets so just the other part to sort out. {{#Invoke:String|replace|{{{1|}}}|.*%/||plain=false}}
should do that part, so combining gives:{{#Invoke:String|replace|{{#Invoke:String|replace|{{{1|{{SUBPAGENAME}}}}}|%s%(.*%)||plain=false}}|.*%/||plain=false}}
Hi all, I am from Bengali Wikipedia. We need your help. in T21412 Pavel Selitskas said that it can be possible to fix or use Scribunto and parse strings and match their pieces against month names and convert the original timestamp. So we need a script or help/guide. How to use at the template.The followings are the Bengali names of each English month
Thanks in Advance for your kind help.- Jayanta Nath ( Talk| Contrb) 07:38, 17 June 2013 (UTC)
{{#invoke:User:Mr. Stradivarius/convertTime|main|<!-- your text here -->}}
{{#invoke:User:Mr. Stradivarius/convertTime|main|১৬:২৫, ৩ এপ্রিল ২০১৩ (ইউটিসি)}}
produces "16:25, 3 April 2013 (ইউটিসি)". Best —
Mr. Stradivarius
♪ talk ♪
09:31, 17 June 2013 (UTC)Hi everyone. I'm in the early stages of writing Module:WikiProjectBanner, and I'd appreciate everyone's ideas for possible features. Please add your ideas over at Template talk:WPBannerMeta. Thanks! — Mr. Stradivarius ♪ talk ♪ 12:51, 18 June 2013 (UTC)
string.byte( "A" )
returns 65, and string.char( 65 )
returns "A". Scribunto also has functions that deal with UTF-8 codepoints in the same way: mw.ustring.codepoint( "á" )
returns 225, and mw.ustring.char( 225 )
returns "á".
Anomie
⚔
19:38, 22 June 2013 (UTC)
Hi. Template:Italic title currently has a bug where if the page title contains a non-disambiguation parenthetical (e.g., "Foo v. Bar (Baz) Bing") the title will be improperly italicized. The template currently only checks for the existence of "(". I'd like to switch the template to italicize the full string if there's no ")" at the end of the page title. Is there an equivalent to rfind? Or maybe regular find can be used for this? I'll post some input/outputs below. -- MZMcBride ( talk) 01:17, 14 June 2013 (UTC)
{{DISPLAYTITLE:{{#ifexpr: {{#invoke:String|find|{{PAGENAME}}|)}} = {{#invoke:String|len|{{PAGENAME}}}} |{{#if:{{NAMESPACE}}|{{NAMESPACE}}: }}''{{#Invoke:String|replace|{{PAGENAME}}| (|'' (}} |{{#if:{{NAMESPACE}}|{{NAMESPACE}}: }}''{{PAGENAME}}'' }} }}<noinclude> {{documentation}}<!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude>
|italics all=yes
parameter to cover this? Next issue then would be:
Everything You Always Wanted to Know About Sex (But Were Afraid to Ask) (book). It is a feature request, not a bug. -
DePiep (
talk)
09:38, 17 June 2013 (UTC)
Maybe someone can find joy in Luafying this related one:
Has anyone created a Lua version of parser function {urlencode:} to retain slashes, ampersand, '?' and the '=' equals sign? The current bug in web-links ("[http:____]") always appends a slash after the URL when urlencode has encoded other slashes as "%2F" which the web-link bug does not realize is a slash, and so appends a slash at end-of-URL. Instead, we need a Lua urlencode which retains slashes, so that typical weblinks of the form "[http:____]" do not append an invalid slash "/" at end of URL. I have written Template:Encodelink to properly encode some URLs, but it skips encoding the first 43 characters so that WP URLs can be encoded while retaining slashes, plus the first '?' and '='. A full Lua urlencode is needed to simplify web links. - Wikid77 ( talk) 12:40, 11 July 2013 (UTC)
<a rel="nofollow" class="external text" href="http://www.google.com%2Fsearch%3Fq%3Dxyz">googling xyz</a>
fullText
of the getCurrentTitle()
described
here. I tried various url enconding and nothing worked. I had to create a dedicated method to join optional namespace part with the title:partialUrl()
to achieve the result. I think the uri.encode
lacks some encoding and could be expanded with new enctype option for that purpose.
Paweł Ziemian (
talk)
11:20, 12 July 2013 (UTC)
wfUrlencode
for the specific implementation.
Anomie
⚔
18:21, 13 July 2013 (UTC)
There is property d:Property:P94 and d:Property:P281. the fist is name of image file on Commons and the second is just string. However both of them are identical in structure in LUA. I had to know what to do with the text i.e. whether to wrap it in [File:...] or display it as is. The wikidata knows something more, since there is difference in the property descriptions. Could be the database API expanded with function that provides the info? Paweł Ziemian ( talk) 20:06, 14 July 2013 (UTC)
frame:preprocess()
or similar in Lua. @
Paweł Ziemian: I think your suggestion might be better suited for Bugzilla, as the developers need to hear it, and the only dev I'm aware of who watches this page is
Anomie. —
Mr. Stradivarius
♪ talk ♪
08:45, 18 July 2013 (UTC)[p94] = { [0] = { ["mainsnak"] = { ["snaktype"] = "value" ["property"] = "p94" ["datavalue"] = { ["value"] = "POL Gdańsk COA.svg" ["type"] = "string" } } ["type"] = "statement" ["id"] = "q1792$297F63DF-B20B-42BC-BFFB-D79BC2B42604" ["rank"] = "normal" } ... [p281] = { [1] = { ["mainsnak"] = { ["snaktype"] = "value" ["property"] = "p281" ["datavalue"] = { ["value"] = "80-008" ["type"] = "string" } } ["type"] = "statement" ["id"] = "q1792$f14becf3-40ab-6ac1-469d-f53cee19b577" ["rank"] = "normal" } ...
There is not any hint telling that the [p94] is a file name on commons and [p281] is simple text. However I thought about it a while and realised that displaying pictures is rather complex process and needs additional attention due to many available properties formating the image. My conclusion is making the process automatically is hardly possible. So I revoke the requirement. Such properties shall never be displayed directly, rather formatted individually in target infobox according to their needs, and using only the raw property value as data reference. Paweł Ziemian ( talk) 09:15, 18 July 2013 (UTC)
claims
, which invoked in the article (in preview only of course) produces such list.
Paweł Ziemian (
talk)
11:36, 18 July 2013 (UTC)
If it's not kosher to add a request for a different project, please feel free to revert.
We are trying to get non-Latin scripts to show up without italics in the alt= and directions= fields of voy:Template:Listing, and the hunch is that a Lua module should be able to do this for us. But we don't have anyone with the expertise. If someone here is interested in helping, please see the discussion at voy:Template talk:Listing#Non-Latin scripts are italic. Thanks! -- Peter Talk 19:21, 21 July 2013 (UTC)
{{#ifeq:no|{{#invoke:IsLatin|IsLatin|{{{param}}}}}| (''{{{param}}}'')| ({{{param|}}})}}
At the Dutch Wikipedia we use nl:Sjabloon:Coördinaten for coordinates. The input is about the same as most Wikipedia's with one major difference: Underscores are used intead of pipes. So for example nl:Haarlem uses {{Coördinaten|52_22_49_N_4_38_26_E_type:city(146753)_region:NL-NH|52° 22′ 49″ N, 4° 38′ 26″ O}}. I would like to modify the coördinaten template to use #coordinates to fill nl:Special:Nearby. I'm trying at nl:Gebruiker:Multichill/Kladblok but I don't get it to work. Can someone assist me here or point me in the right direction? The problem seems to be in | as a special character and escaping it. Multichill ( talk) 10:05, 6 July 2013 (UTC)
function p.coordinates( frame )
return frame:callParserFunction( '#coordinates', mw.text.split( frame.args1], '_', true ) )
end
function m.C(frame)
return frame:callParserFunction('#coordinates', { '100', '200' } )
end
The result was a server error page with apologise and the following error details:
PHP fatal error in /usr/local/apache/common-local/php-1.22wmf8/includes/parser/Preprocessor_DOM.php line 955: Argument 1 passed to DOMXPath::__construct() must be an instance of DOMDocument, null given, called in /usr/local/apache/common-local/php-1.22wmf8/extensions/Scribunto/engines/LuaCommon/LuaCommon.php on line 500 and defined
However if I use {{#coordinates:...}} directly, a proper error is returned instead. So I give up of calling the coordinates directly from Lua until the method became more robust for invalid input. Paweł Ziemian ( talk) 05:52, 7 July 2013 (UTC)
It would be great to auto-detect the approximate aspect ratio of an image (width/height), especially for use in commons:Template:Assessments. Is this feasible? -- Ricordi samoa 23:04, 3 August 2013 (UTC)
In wikicode, parameters can have three way input: 1. straight text, 2. a <blank> (whitespace), and 3. not-defined at all (=not present in the template call). How can we pass these through the #invoke: step (or: how can the module detect these three)?
In wikicode, I can detect all three using the {#if:} parser function. - DePiep ( talk) 13:17, 26 July 2013 (UTC)
No. | Wikitext | Lua detection |
---|---|---|
1 | {{template|some text}} | if frame.args[1] == "some text" then |
2a | {{template|}} | if frame.args[1] == "" then |
2b | {{template| }} | if frame.args[1] == " " then |
3 | {{template}} | if frame.args[1] == nil then |
frame:argumentPairs()
which is the same as pairs(frame.args)
.{{Johnuniq/Testargs|}}
), and that is followed by a table which includes "Parent (arguments passed to template)" that shows the template arguments as seen by the module (for this example, an empty string).
Johnuniq (
talk)
00:52, 27 July 2013 (UTC)Thanks. I understand that Snaevar's table is defining. It could and should be in LUA help page. - DePiep ( talk) 19:11, 27 July 2013 (UTC)
tplX #invoke:....
But how to pass when I call that template from page? -
DePiep (
talk)
21:35, 1 August 2013 (UTC)
frame:getParent().args
to access parameters of the template that directly calls function from Lua module.
Paweł Ziemian (
talk)
20:04, 2 August 2013 (UTC)
I'm trying to make the rowclass# parameters apply to header rows in infoboxes. Here was my attempt to do that. I modified the testcases page to see if it worked, and it appears that it didn't (I expected testclass to be on the tr in the sandbox one, and it wasn't), and I don't know why. Can someone take a look at it for me? Thanks, Jackmcbarn ( talk) 18:02, 9 August 2013 (UTC)
Hi everyone. I've just created Module:Fixme, which searches Lua modules for the text "FIXME" in comments, and if present adds the page to the as-yet-uncreated Category:Lua modules with fixme tags. I thought that this would be a good way to encourage people to check and fix each other's code. We could check all modules automatically by adding Module:Fixme to MediaWiki:Scribunto-doc-page-show and MediaWiki:Scribunto-doc-page-does-not-exist. Do people think this is a good idea? And would you prefer a different name for the category? Let me know what you think. — Mr. Stradivarius ♪ talk ♪ 12:03, 20 August 2013 (UTC)
Hi I would like some help to create the module:documentation
I found these codes on fr wikipedia but translated some words here are the codes could someone help me change the words and to create a sillier copy of documentation but in lua scripting please I also need help translating and making the same version of Template:documentation but in lua scripting please this is some that have been done but I need help to do the rest like transformation template:documentation into module:documentation please
Extended content
|
---|
--This module implements {{Documentation}}.
--TODO: Implement a class 'ConcatBuilder' to reduce redundancy
--'table.insert(<MyTable>, <MyString>)' and 'table.concat(<MyTable>)'
local p = {}
function p.corps(frame)
args = frame:getParent().args
local page = mw.title.getCurrentTitle()
doc = p.docname(page)
local corps = {}
if page.subpageText == 'sandbox' then
table.insert(corps, '<div style="clear:both />')
table.insert(corps, frame:preprocess('{{Template sandbox notice}}'))
end
table.insert(corps, p.header(page))
table.insert(corps, p.content(frame, page))
table.insert(corps, p.footer(page))
if args.raw then
return frame:preprocess('<nowiki>' .. table.concat(corps) .. '</nowiki>\n:' .. os.clock())
end
return table.concat(corps)
end
function p.docname(page)
if not page.isSubpage then return page.subjectNsText .. ":" .. page.text .. "/doc" end
if page.subpageText == 'doc'
or page.subpageText == 'sandbox'
or page.subpageText == 'testcases' then
return page.subjectNsText .. ":" .. page.baseText .. "/doc"
else
return page.subjectNsText .. ":" .. page.text .. "/doc"
end
end
function p.ifexist(page)
if not page then return false end
if mw.title.new(page).exists then return true end
return false
end
function p.header(page)
local header = {'<div class="template-documentation"'}
if args.color then
table.insert(header, ' style="background:')
table.insert(header, args.color .. '"')
end
table.insert(header, '><div style="margin-bottom:1ex; border-bottom:1px solid #aaa; padding-bottom:3px;">')
table.insert(header, '[[File:Template-info.png|50px|alt=Template documentation|link=]]')
table.insert(header, '<span style="font-weight:bold; font-size:125%"> ')
if args.heading then table.insert(header, args.heading)
else table.insert(header, 'Template documentation') end
table.insert(header, '</span>')
if not args.content then
table.insert(header, '<span class="mw-editsection plainlinks">[[')
local arg = mw.title.new(args1 or doc)
if args1 and p.ifexist(args1]) or p.ifexist(doc) then
table.insert(header, arg:fullUrl('action=view') .. ' view]')
table.insert(header, '] [[')
table.insert(header, arg:fullUrl('action=edit') .. ' edit]')
table.insert(header, '] [[')
table.insert(header, arg:fullUrl('action=history') .. ' history]')
table.insert(header, '] [[')
table.insert(header, page:fullUrl('action=purge') .. ' purge]')
else
table.insert(header, arg:fullUrl({["action"="edit", "preload"="Template:Documentation/preload"}))
table.insert(header, ' create]')
end
table.insert(header, ']</span>')
end
table.insert(header, '</div>')
return table.concat(header)
end
function p.content(frame, page)
local content = {}
local arg = args1 or doc
if args.content then
table.insert(content, '\n')
table.insert(content, args.content)
else
table.insert(content, frame:preprocess('<nowiki />'))
table.insert(content, '\n')
if args1 and p.ifexist(args1]) or p.ifexist(doc) then
table.insert(content, frame:preprocess('{{' .. arg .. '}}'))
end
end
table.insert(content, '\n')
table.insert(content, frame:preprocess('<nowiki />'))
table.insert(content, '<div style="clear:both" />\n')
return table.concat(content)
end
function p.footer(page)
local footer = {}
local arg = mw.title.new(args1 or doc)
table.insert(footer, '</div><div class="template-documentation plainlinks" ')
table.insert(footer, 'style="font-style:italic; margin:2px 0px 0px; padding: 0.35em 0.9em')
if args.color then
table.insert(footer, '; background:')
table.insert(footer, args.color)
end
table.insert(footer, ';">\n')
if args.content then
if args"link box" then
table.insert(footer, args"link box"])
else
table.insert(footer, 'This documentation is directly included in this page.')
end
else
if args1 and p.ifexist(args1]) or p.ifexist(doc) then
table.insert(footer, 'The above [[Wikipedia:Template documentation|documentation]] is ')
table.insert(footer, '[[Wikipedia:Transclusion|transcluded]] from [[')
table.insert(footer, tostring(arg))
table.insert(footer, ']] <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, arg:fullUrl('action=edit'))
table.insert(footer, ' edit] | [')
table.insert(footer, arg:fullUrl('action=history') .. ' history])</span>.<br />')
end
table.insert(footer, 'Editors can experiment in this templates ')
local sandbox = arg.subjectNsText .. ":" .. arg.baseText .. "/sandbox"
local argsandbox = mw.title.new(sandbox)
if p.ifexist(sandbox) then
table.insert(footer, '[[' .. sandbox .. '|sandbox]]')
table.insert(footer, ' <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, argsandbox:fullUrl('action=edit'))
table.insert(footer, ' edit])</span>')
else
table.insert(footer, 'sandbox <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, argsandbox:fullUrl({["action"="edit", "preload"="Template:Documentation/preload-sandbox"}))
table.insert(footer, ' create])</span>')
end
table.insert(footer, ' and ')
local test = arg.subjectNsText .. ":" .. arg.baseText .. "/testcases"
local argtest = mw.title.new(test)
if p.ifexist(test) then
table.insert(footer, '[[' .. test .. '|testcases]]')
table.insert(footer, ' <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, argtest:fullUrl('action=edit'))
table.insert(footer, ' edit])</span>')
else
table.insert(footer, 'testcases <span style="font-size:89%; font-style:normal;">([')
table.insert(footer, argtest:fullUrl({["action"="edit", "preload"="Template:Documentation/preload-testcases"}))
table.insert(footer, ' create])</span>')
end
table.insert(footer, ' pages.<br />Please add categories to the ')
table.insert(footer, '<span class="plainlinks">[')
if args1 and p.ifexist(args1]) or p.ifexist(doc) then
table.insert(footer, arg:fullUrl('action=edit'))
else
table.insert(footer, arg:fullUrl({["action"="edit", "preload"="Template:Documentation/preload"}))
end
table.insert(footer, ' /doc] subpage.')
end
table.insert(footer, '</div>')
return table.concat(footer)
end
return p
|
Hi could some help me to get it to look like template:documentation/start box and template:documentation/end box you can have a look at my test of it at simple:template:documentation/sandbox I had help to do it because doint know how to script but thought it was a good idea and this is we're I am testing the module on simple wiki simple:Module:Documentation 109.151.161.64 ( talk) 20:16, 29 July 2013 (UTC)
How can I add special pages in module so I use Special:ComparePages for diff 86.159.26.136 ( talk) 15:48, 10 August 2013 (UTC)
Currently it seems not to be possible to outsource squads to Wikidata and then to import them to (different language versions of) Wikipedia. There is currently a test quad at Wikidata that could be implemented to Template:FC Bayern Munich squad and FC Bayern Munich#Current squad in future. Sorting the players according to either the last name or the jersey no. is needed. See also WT:WPF#Outsourcing of squads to Wikidata. -- Leyo 10:48, 6 September 2013 (UTC)