Wikidata:WikidataCon 2017/Notes/Lua for beginners

Title: Lua for beginners WikidataCon 2017, 2017-10-27, 15:00–16:00

Speaker(s) edit

Name or username: Marius Hoch, Thiemo Kreuz

Contact (email, Twitter, etc.): @mariushoch, @maettig

Useful links

Documentation:

https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua

Lua documentation: https://www.mediawiki.org/wiki/Lua_reference_manual

Community modules: https://en.wikipedia.org/wiki/Module:Wikidata

Used test wiki pages:

Test article: https://en.wikipedia.beta.wmflabs.org/wiki/Draft:WikidataCon_2017

The item connected to the article: https://wikidata.beta.wmflabs.org/wiki/Q356266

The (almost empty) infobox template: https://en.wikipedia.beta.wmflabs.org/wiki/Template:Infobox_event

The actual Lua module: https://en.wikipedia.beta.wmflabs.org/wiki/Module:Infobox_event

English slides: https://docs.google.com/presentation/d/1NWX3lxstAmIjlLsUHudW6zei8Bv5Wpi1PqkJpKwU_fI/edit#slide=id.g25376d2e52_0_0

Original German slides: https://docs.google.com/presentation/d/1sPK1ZrkSynoUyrGx5xzGKhrPVt_mg6BuDslv3EHME-Y/edit#slide=id.g2537c655f7_0_7

German Etherpad from WikiCon Leipzig: https://etherpad.wikimedia.org/p/Wikidata_in_Vorlagen

Collaborative notes of the session edit

When MediaWiki was started there were no templates.

Templates are added through transclusion.

Content of template page is then pasted at that position.

Templates take parameters.

There are built-in fuctins they start with # and separated by |

With Lua there is an additional level of indirection

Right now many communities combine article, template and Lua module

Lua provides sophisticated access to Wikidata data

Possible to use maintenance code in Lua modules- this can help reduce concern about data from Wikidata getting vandalized/ inadvertently removed or altered

The frame can control coordination between WD and WP versions

Debug
mw.log ()
mw.logObject ()

An function invocation looks like {{#invoke:<Module name>|<Function name>|<parameters}}

To make a function accessible from a module: ```

local exports = {}
function exports.my_method( frame )
   return "Wikitext"
end
return exports

```