User:Keegan (WMF)/Lua blog

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search


Lua support for Structured Data on Commons – pulling data into templates

[edit]

As the first round of building structured data content for Commons comes to a close, support for the Lua programming language brings structured data front-and-center to file pages.

Structured data lives behind a tab on Commons; any given file’s templates — for example, {{Information}}, {{Artwork}}, {{Title}} — is where most users still get there information about a file. The information template is usually created during the upload process, and is stored and displayed as wikitext.


What Lua does with structured data is to pull information out from behind the tab on Commons, or from Wikidata directly, and puts it into templates on the file page. The great advantage to this is that if an edit changes the data, the template will dynamically update to reflect the change. This keeps the data in sync in both how it is stored and displayed across files and sites.

Examples of templates already modified to work with Lua and structured data, courtesy of User:Jarekt:

  • Module:Artwork: if {{Artwork}} is missing Wikidata field, but structured data has digital representation of (P6243) property, than Wikidata field is set to P6243.
  • Module:Title: if {{Title}} with Wikidata field can fetch titles from Wikidata. None (or very few) files have {{Title}} with Wikidata field, but if structured data has digital representation of (P6243) property, than Wikidata field is set to P6243.

User:Mike Peel has been working to build a template to pull and display structured data on the main file page as a set. {{Structured Data}} calls other templates, description information, date, author, source, location, licensing, and other information like categories, together into one place.

Lua’s ability to pull data and present it elsewhere on Commons, whether in modules or templates, will greatly expand the reach of structured data. Using structured data makes all of these Lua modules and Lua-powered templates multilingual as well. Support for all languages is inherently provided, helping to further remove the barrier of English from Commons contributions.