Category Reporter: Difference between revisions

From Freephile Wiki
Created page with "= Enhanced Category Report = First, we need to load external data... in this case we're retrieving from the MediaWiki API: {{#get_web_data: url=https://wiki.freephile.org/wiki/api.php?action=query&list=categorymembers&cmtitle=Category:Documentation&cmtype=page&cmlimit=5000&format=json format=json data=categoryMembers }} Now we can use our Category Reporter module in Lua processing that data: {{#invoke:CategoryReporter|categoryWithExternalData|Documentation}} ==..."
 
No edit summary
Line 1: Line 1:
= Enhanced Category Report =
This page is a demo of using a Lua Module to process data from the mw.Api


First, we need to load external data... in this case we're retrieving from the MediaWiki API:
While we can invoke the api [[Categories/javascript|via JavaScript]], we wanted to try out a little bit of Lua, which in the end would also allow for integration with the ExternalData extension to be able to process and format data from other wikis outside this farm.
{{#get_web_data:
  url=https://wiki.freephile.org/wiki/api.php?action=query&list=categorymembers&cmtitle=Category:Documentation&cmtype=page&cmlimit=5000&format=json
  format=json
  data=categoryMembers
}}


Now we can use our Category Reporter module in Lua processing that data:
Example local Api query that could be easily manipulated in JavaScript.
{{#invoke:CategoryReporter|categoryWithExternalData|Documentation}}
https://wiki.freephile.org/wiki/api.php?action=query&list=categorymembers&cmtitle=Category:Documentation&cmtype=page&cmlimit=5000&format=json
 
== Pages in Category: Documentation ==
{| class="wikitable sortable"
! Page Title !! Last Modified !! Page ID
{{#for_external_table:categoryMembers.query.categorymembers|
|-
| [[{{{title}}}]] || {{#external_value:timestamp}} || {{{pageid}}}
}}
|}

Revision as of 11:19, 6 June 2025

This page is a demo of using a Lua Module to process data from the mw.Api

While we can invoke the api via JavaScript, we wanted to try out a little bit of Lua, which in the end would also allow for integration with the ExternalData extension to be able to process and format data from other wikis outside this farm.

Example local Api query that could be easily manipulated in JavaScript. https://wiki.freephile.org/wiki/api.php?action=query&list=categorymembers&cmtitle=Category:Documentation&cmtype=page&cmlimit=5000&format=json