Page MenuHomePhabricator

Make a Scribunto extension that lets Lua talk to the Toolhub API
Open, LowPublic


It would be really awesome if there was a lua module that can be used to build infoboxes and lists based on data stored in Toolhub. Making the API calls from lua will require a helper in Scribunto that implements a PHP backend for actually calling the foreign API.

See also:

Event Timeline

bd808 created this task.
Legoktm renamed this task from Make a Scribunto extenstion that lets lua talk to the Toolhub API to Make a Scribunto extension that lets Lua talk to the Toolhub API.Oct 8 2021, 10:43 PM
Legoktm subscribed.
bd808 changed the task status from Open to In Progress.Jul 11 2022, 4:23 PM
bd808 claimed this task.
bd808 moved this task from Backlog to In Progress on the Toolhub board.

I will be working on a proof-of-concept version of this during the week of 2022-07-11 as my chosen project for the "Inspiration Week" event being conducted by the Product and Technology departments at the Wikimedia Foundation.

I didn't want to wait for a gerrit repo to get started on this, so is the initial home for the extension. At the end of day one I have:

I spent today playing around with templates and lua and now have a template that invokes a lua module method which in turn fetches data from the Toolhub API and then uses that data to populate a second template that I imported from wikitech ( The end result? The wikitext {{AutoTool|wikimedia-toolhub}} renders a page that looks like:

Screen Shot 2022-07-12 at 6.06.11 PM.png (299×931 px, 67 KB)

Tomorrow I plan to work on adding support for fetching lists and searching for collections of tools. I'm also considering adding a special page for interactive searching of toolhub from the wiki.

Change 813707 had a related patch set uploaded (by BryanDavis; author: Bryan Davis):

[integration/config@master] zuul: Add mediawiki/extensions/Toolhub

Change 813707 merged by jenkins-bot:

[integration/config@master] zuul: Add mediawiki/extensions/Toolhub

Day 3 progress:

  • Refactored implementation to separate lua interface and api client for easier testing and reuse of api client
  • Moved git hosting to gerrit
  • Setup CI with an assist from @Reedy
  • Added ApiClient->getListById( $id )
  • Fell into a deep dark hole while trying to get unit tests working for ApiClient with HttpRequestFactory mocking
    • Mocked methods do what is expected when called directly, but seem to not be called at all indirectly?

Day 4:

  • Figured out the PHP mocking mystery. createPartialMock() was the thing I needed to allow mocking some methods while otherwise letting the real object do things.
  • @Reedy gave patches to add phan configuration and to declare the dependency on Scribunto
  • Added declare( strict_types = 1 ); and missing type hints
    • Discovered that mixed only works as a type hint in PHP >=8.0 later (test coverage could use work)
  • Added GET /api/search/tools client and lua binding

Things that are interesting me for day 5 of this "inspiration" sprint:

  • a demo server to show others what this can do
  • a special page to do searches of Toolhub
  • researching what if anything wikidata does to trigger reparses of pages using data via lua
  • refactoring ApiClient for better error reporting when things go boom
bd808 added a subscriber: LucasWerkmeister.

Day 5:

After inspiration week ended:

bd808 changed the task status from In Progress to Open.Aug 15 2022, 8:36 PM