Extension and standalone js lib to support storing and editing of structured data and meta data based on MultiContentRevisions, json, json-schema and json-ld.
MwJson is a MediaWiki extension that enables you to:
- Store and edit structured data in JSON format
- Validate data against JSON schemas
- Organize content in different slots (header, main, footer)
- Use AI to help complete data entries
- Connect to external data sources
- Work with JSON-LD for semantic data
-
Data Management
- JSON data storage and editing
- Schema-based validation
- Multi-slot content organization
- External data integration
-
Content Organization
- Slot-based content structure
- Header, main, and footer sections
- Flexible content organization
- Easy navigation between sections
-
Smart Features
- AI-powered data completion
- Schema validation
- External data fetching
- JSON-LD support
-
Basic Usage
- Create a new page
- Add content to different slots
- Define JSON schemas
- Use the editor interface
-
Accessing Content
- Use
Special:SlotResolverto view slots - Format:
Special:SlotResolver/<namespace>/<page>.slot_<slotname>.<extension>
- Use
-
Configuration Add to your LocalSettings.php:
$wgMwJsonAllowSubmitInvalide = 'always'; // Allow saving invalid data $wgMwJsonAiCompletionApiUrl = null; // Set AI completion API $wgMwJsonOrderSlotRenderResults = false; // Order of sections $wgMwJsonWrapSlotRenderResults = false; // Wrap sections in divs
The extension is built with a modular architecture:
-
Core Components
MwJson.php: Main extension classSpecialSlotResolver.php: Slot resolution handler- Integration with WSSlots for slot management
- Integration with SemanticMediaWiki for semantic features
-
JavaScript Modules
ext.mwjson: Core functionalityext.mwjson.util: Utility functionsext.mwjson.api: API interfaceext.mwjson.editor: Editor UIext.mwjson.parser: Content parsing
-
Slot Management
- Integration with WSSlots extension
- Custom slot organization
- Slot-based content rendering
- Slot validation system
-
Data Handling
- JSON Schema validation
- MultiContentRevision support
- JSON-LD integration
- External data fetching
-
API System
// Get page content mwjson.api.getPage('PageTitle').then(page => { // Handle page data }); // Edit slot content mwjson.api.editSlot('PageTitle', 'slotName', content, 'Edit summary'); // Get semantic properties mwjson.api.getSemanticProperties('PageTitle').then(properties => { // Handle properties });
-
Requirements
- MediaWiki >= 1.35
- WSSlots
- SemanticMediaWiki
- SemanticCompoundQueries
- CodeEditor
- CodeMirror
- VEForAll
-
Installation
cd extensions git clone https://github.com/OpenSemanticLab/mediawiki-extensions-MwJson.git MwJson cd MwJson
In the
LocalSettings.phpfile, add the config$wgMwJsonSlotRenderResultTransformation = [ "enabled" => true, ];By enabling the MwJson option, this ensures slot render results are displayed correctly
-
Building
- Install dependencies
- Run tests
- Build assets
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This extension is licensed under AGPL-3.0-or-later. See the LICENSE file for details.
For issues and feature requests, please use the GitHub issue tracker.
See also T324933
{
"wgMwJsonAllowSubmitInvalide": {
"value": "always",
"description": "Forbid ('never'), conditional if set in schema option ('option') or always ('always') allow the user to save data failing schema validation."
},
"wgMwJsonAiCompletionApiUrl": {
"value": null,
"description": "REST-API endpoint acception {\"promt\": \"...\", \"jsonschema\": \"\"} and returning a valide schema instance."
},
"wgMwJsonOrderSlotRenderResults": {
"value": false,
"description": "Brings the render results of the slots into order 'header', 'main', 'footer', <additional slots>."
},
"wgMwJsonWrapSlotRenderResults": {
"value": false,
"description": "Wraps the render results of the slots in a div element"
}
}