Template talk:Imported module list

From finiki, the Canadian financial wiki

Querying page information

It can be done via the MediaWiki API, such as Module:About info --Peculiar Investor 19:16, 2 January 2023 (EST)

How to generate list - process change

At the moment I am using an off-line method to query a database backup and extract the Last imported/updated and Wikipedia version Edit history links. Investigation into utilizing MediaWiki's API:Info capabilities continues. There is also MediaWiki's XTools that might be helpful towards automation.--Peculiar Investor 11:03, 5 January 2023 (EST)

Revised approach in python (discussion)

The sections below describe an automated approach implemented in python. --LadyGeek 13:30, 20 February 2023 (UTC)

The API does not return the correct number of modules. See: Bogleheads talk:Imported Wikipedia modules. finiki is reporting 223 modules, but searching as All pages (Module namespace) finds 319 modules. --LadyGeek 15:18, 20 February 2023 (UTC)
I have rolled back the page update until the problem is identified and resolved. --Peculiar Investor 15:33, 20 February 2023 (UTC)
I have identified and resolved the problem. See: Bogleheads talk:Imported Wikipedia modules. Both the script and All pages (Module namespace) find 319 modules. Should the current table be overwritten? There is an extra column pointing to the Wikipedia module history. The working script is supplied below. --LadyGeek 16:03, 22 February 2023 (UTC) (Link modified --LadyGeek 21:56, 22 February 2023 (UTC))

Approach

  • Generate an API query string.
  • Extract the page title and timestamp (latest revision date)
  • Build the wikitext table
    • mw-datatable class
    • Page title formatted as internal link [[Page title]]
    • timestamp formatted appropriately

API query

The query is defined through the wiki's built-in API sandbox. Special pages --> Version --> /w/api.php --> Special:ApiSandbox

An initial prototype was developed at MediaWiki.org. API sandbox - MediaWiki uses a full text search. However, using the same query here produced no results. This is likely due to MediaWiki.org using a later version customized for Wikipedia.

The "allpages" list can not be customized to add a revision property. Instead, I ended up with an "allrevisions" list query.

The working API sandbox query: API sandbox - finiki

Click "Make request", then go to the Results section on the left-side menu.

  • Show request data as: JSON
  • "Request JSON:" are the parameters for the python request.

Documentation: API:Allrevisions - MediaWiki - scroll down to the Sample code for the python implementation. There's also a ton of help via google.

Source

The python source code has been updated and moved to the template documentation page. --LadyGeek 21:56, 22 February 2023 (UTC)

SyntaxHighlight output limitation

The tags <syntaxhighlight>...</syntaxhighlight> to produce line numbers and source language formatting require python3 on the server. It is not currently available due to server hosting limitation . --Peculiar Investor 14:10, 20 February 2023 (UTC)