Jump to content

Wikipedia:Lua/Requests: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Line 106: Line 106:


::Yes. [[User:Knife-in-the-drawer|Knife-in-the-drawer]] ([[User talk:Knife-in-the-drawer|talk]]) 18:14, 28 June 2015 (UTC)
::Yes. [[User:Knife-in-the-drawer|Knife-in-the-drawer]] ([[User talk:Knife-in-the-drawer|talk]]) 18:14, 28 June 2015 (UTC)

== An Infobox feature request is ready for Lua encoding ==

I've made a feature request for [[:module:Infobox]] here:
[[Template_talk:Infobox#Parameter_.22header-when-not-empty.22|Infobox, header-when-not-empty]]. Basically, it adds a parameter {{para|header''n''-cond}} that only shows when its section contains data (consider how it has to be encoded today).

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

Revision as of 18:51, 28 June 2015

Template:WikiProject Lua/header

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

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

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

Wrap new Graph tag

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

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

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

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

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

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

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

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

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

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

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

 Atlasowa: Can't tell you how happy I am to see this; we need to port it over immediately. @DerHexer: you know anyone that would be willing to translate the documentation? ResMar 14:58, 12 June 2015 (UTC)[reply]
See also. ResMar 14:59, 12 June 2015 (UTC)[reply]
I went ahead and imported two bits: Module:Graph and Template:GraphChart. ResMar 18:04, 12 June 2015 (UTC)[reply]
absolutely awesome. now, we just have to wait for "someone" to add "pie" capability (the graph extension has it, but the module does not support it [yet?] ), and we can retire Module:Chart entirely. this is much better and more appealing. peace - קיפודנחש (aka kipod) (talk) 15:41, 16 June 2015 (UTC)[reply]

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

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

There is an extension which provides some assistance, see Help:Category#Displaying category trees and page counts. In general, there might be over a million pages in a category, so listing them all would not be useful, and may not be possible in a module. Johnuniq (talk) 01:30, 26 May 2015 (UTC)[reply]
@Johnuniq: I don't need all. Just some of the pages, say, maximum 20 to 50 at once. And thanks for the link. I think "http://en.wikipedia.org/w/api.php?cmtitle=Category:Category_name&action=query&list=categorymembers&cmlimit=500&cmprop=title%7Csortkey%7Ctimestamp" will do this task but I don't know how to insert the result of this query on a page. Please help. It will be very kind of you if you write this program to populate my sandbox by 20 articles from the category:Geography (sort if possible by date to show recent most). Thanks !--Satyam Mishra --talk-- 04:19, 26 May 2015 (UTC)[reply]
Sorry, generating a list of pages in a category is outside my area. A quick look at the documentation at mw:Extension:CategoryTree indicates that the following would list up to a certain number of articles in Category:Geography, but the list is not in alphabetical order, and uses italics for some reason unknown to me, and you can't set the number. I'm confident that doing something like determining the date of last edit or of creation would be difficult and time consuming. That's the sort of thing which is best done by a bot.
{{#categorytree:Geography|hideroot|mode=pages|namespaces=0}}
Bear in mind also that the list would not be dynamic—it would not necessarily change when articles in the category change. That is because everything displayed is cached, and the page would need a WP:PURGE to update.
I think the proper procedure would be to use a bot if someone to write and maintain one were available, or more likely, use categorytree to display a list which a user can expand by clicking (I think they need Javascript enabled for that). The help page I linked earlier should lead to an example of that. Johnuniq (talk) 04:54, 26 May 2015 (UTC)[reply]
@सत्यम् मिश्र: One of the DynamicPageList extensions will do what you want, but you will need to ask for it to be enabled on your wiki before you can use it. It isn't possible to display the members of a category using only the standard version of Scribunto enabled on Wikimedia wikis. — Mr. Stradivarius ♪ talk ♪ 07:33, 26 May 2015 (UTC)[reply]
@Johnuniq and Mr. Stradivarius: Thanks a lot to both of you! I think for the time being my task can be done by "categorytree" (I tested) and I will try to get this extension on my wiki too. Thanks again for your kind help!--Satyam Mishra --talk-- 08:30, 26 May 2015 (UTC)[reply]

Replacement for Template:Val

See Template talk:Val § Behaviour on substitution. – Wbm1058 (talk) 15:12, 2 June 2015 (UTC)[reply]

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

Re-write Template:World topic as a Lua module

The source code of this template is verbose, redundant, and difficult to read. It should be re-written as a Lua module so that it can be maintained more easily. Jarble (talk) 01:27, 19 June 2015 (UTC)[reply]

lua may make life easier a tad (though i actually doubt it), but there is no real need for lua in order to make this more manageable: the template is extremely repetitive, and lends itself easily to improvement by simple use of some helper template (say, one that will accept prefix, suffix, noredlinks and the actual country name, and will do the right thing). the main template then will look something like
{{helper| {{{prefix|}}} | {{{suffix|}}} | {{{noredlinks|}}} | Angola }}
{{helper| {{{prefix|}}} | {{{suffix|}}} | {{{noredlinks|}}} | Denmark }}
... (repeat for all countries)
this may still look a bit cumbersome, but it's a dramatic improvement over current state: all the #if and #ifexist are delegated to the helper template, and of course, the helper is not at all repetitive - it only does whatever it needs to do once.
as a side, i'll mention that #ifexist is in the list of "expensive parser functions" (using lua will make no difference here - calling an expensive function from lua is just as expensive...), and its usage in this template seems to me to be sailing very close to the wind (i did not count, but there's a*lot* of countries...).
peace - קיפודנחש (aka kipod) (talk) 16:00, 19 June 2015 (UTC)[reply]

String parsing and concatenating

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

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

It should display in the article as follows:

SBN IT\ICCU\MIL\0205279

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

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

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

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

This can be done in either Lua or template syntax (using the string manipulation templates). Lua will probably be a little bit more work to implement, but would certainly be easier to read. For the record, what is "{{{1}}}" above, is that meant to be "IT\ICCU\MIL\0205279" in the example? Dragons flight (talk) 16:47, 28 June 2015 (UTC)[reply]
Yes. Knife-in-the-drawer (talk) 18:14, 28 June 2015 (UTC)[reply]

An Infobox feature request is ready for Lua encoding

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

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