GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - Eccenux/wiki-lua-mw-mock: Minimal impl of 'mw' object (MW toolkit) for Lua modules of Wikipedia. Use only for debugging and testing.

BranchesTags
Open more actions menu

Latest commit

 

History

34 Commits
34 Commits

Folders and files

NameName
Last commit message
Last commit date
.vscode
.vscode
 
 
external
external
 
 
README.md
README.md
 
 
_test.lua
_test.lua
 
 
html.lua
html.lua
 
 
langMock.lua
langMock.lua
 
 
mw.lua
mw.lua
 
 
site.gen.lua
site.gen.lua
 
 
site.lua
site.lua
 
 
text.lua
text.lua
 
 
title.lua
title.lua
 
 
ustring.lua
ustring.lua
 
 

Repository files navigation

  • πŸš€ Quick start
  • ✨ Features
  • πŸ–₯️ Setup Instructions
    • Install Lua
    • Install Visual Studio Code and Lua Debug
  • 🐞 Debugging in VS Code
  • πŸ“ Project Structure Example
  • πŸ§ͺ Simple Example
  • πŸ› οΈ Plans / Ideas

mw-mock

Minimal implementation of the mw object for testing and debugging Wikipedia Lua modules outside of MediaWiki.

⚠️ This is a lightweight mock. It is not complete or production-safe β€” intended for development and debugging only.

πŸš€ Quick start

First add a module to your repo:

# add to your repo
git submodule add https://github.com/Eccenux/wiki-lua-mw-mock.git mw
# commit the change
git commit -am "Add 'mw' submodule"

There are many other ways. Like e.g.: download zip of this repo an unzip to "mw" subdirectory, download once and create a symlink (Unix) or junction (Windows).

Quick example:

-- include this library
local mw = require("mw/mw")

-- replace require to support namespace removal
local originalRequire = require
function require(moduleName)
	moduleName = moduleName:gsub("Modu[^:]+:", "")
	return originalRequire(moduleName)
end

-- Load a copy of a module
-- Note that this loads "Piechart.lua" file (a local file).
local p = require('Module:Piechart')
local json_data = '[{"label": "k: $v", "value": 33.1}, {"label": "m: $v", "value": -1}]'
local html = p.renderPie(json_data)
mw.logObject(html)

✨ Features

  • Implements a minimal mw table with placeholders for:
    • mw.log, mw.logObject
    • mw.text
    • mw.ustring (proxy to string)
  • Useful for writing and testing Lua modules locally before deploying to Wikipedia or Wikidata.
  • Pure Lua β€” no dependencies.

πŸ–₯️ Setup Instructions

1. Install Lua

After this lua and luac should be available in your terminal.

1a) Lua on Windows

Install Lua on Windows using Scoop.

If you don’t have Scoop yet:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

Then install Lua:

scoop install lua

1b) Lua on MacOS

Install Homebrew.

Then install Lua:

brew update
brew install lua

2. Install Visual Studio Code and Lua Debug

Install Visual Studio Code.

Install the Lua Debug extension by actboy168:

Extension ID: actboy168.lua-debug

🐞 Debugging in VS Code

  1. Create a .vscode/launch.json:

    {
    	"version": "0.2.0",
    	"configurations": [
    		{
    			"type": "lua",
    			"request": "launch",
    			"name": "Launch Lua script",
    			"program": "${workspaceFolder}/_test.lua"
    		}
    	]
    }
  2. Create a test file, e.g. _test.lua:

    mw = require("mw") -- your mock
    
    mw.log("Hello from mock mw!")
    mw.logObject({ foo = "bar", nested = { a = 1 } })
  3. Set breakpoints, hit F5 to debug.

πŸ“ Project Structure Example

lua-wiki/
β”‚
β”œβ”€β”€ mw/
β”‚   β”œβ”€β”€ mw.lua             -- mw entry point
β”‚   β”œβ”€β”€ text.lua           -- mw.text mock
β”‚   β”œβ”€β”€ ustring.lua        -- mw.ustring proxy
|   ...
β”œβ”€β”€ _test.lua              -- your dev entry point

πŸ§ͺ Simple Example

-- _test.lua
require("mw")

local data = {
	title = "Example",
	ns = 0,
	isTalk = false,
}

mw.logObject(data)

πŸ› οΈ Plans / Ideas

  • Add more realistic implementations (e.g. Unicode support in mw.ustring).
  • Other mocks/implementations?
  • Optional strict mode to catch unexpected fields.

About

Minimal impl of 'mw' object (MW toolkit) for Lua modules of Wikipedia. Use only for debugging and testing.

Topics

luamediawikitest-automationwikipedia

Resources

Readme
Activity

Stars

2 stars

Watchers

1 watching

Forks

0 forks
Report repository

Contributors

Languages

You are visitor 01402503 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.