Skip to content

cscott/node-mediawiki-express

Repository files navigation

node-mediawiki-express

NPM

Build Status dependency status dev dependency status

The node mediawiki-express package uses the php-embed package to embed MediaWiki with a node express server.

This is a proof-of-concept for a "single integrated install" of MediaWiki, which will eventually bundle Parsoid and other PHP and JavaScript services into a single server.

We hope to eventually allow easy addition of extensions and skins via npm. See https://phabricator.wikimedia.org/T114457 for more discussion.

USAGE

To start a HTTP server on port 1234:

mediawiki -p 1234

Your wiki will then be found at http://localhost:123/wiki/

API

To customize or extend your MediaWiki server, you can use the JavaScript API.

mwExpress.runServer(options)

Starts an express web server on a specified port, with /w and /wiki routed to a MediaWiki installation. The MediaWiki can be customized via the options parameter.

  • options: an object containing various parameters for the server. All are optional.
    • serverName: the server name to pass to PHP, which will be used as part of MediaWiki's generated URLs. Defaults to localhost.
    • serverPort: the port on which to start the server. Defaults to 8080.
    • localSettingsHook: a JavaScript function which will be invoked at the end of MediaWiki's LocalSettings.php file, and passed PHP's $GLOBALS array as its first parameter. This allows you to customize the settings for the wiki.
    • expressHook: a JavaScript function which will be invoked after the MediaWiki-related routes have been set up on the express app object. It is passed the app object as its first parameter. This allows you to add additional routes to the server before starting it. The / route will be added after expressHook returns (as a redirect to the main page of the wiki), so you can override the / route in this hook if you wish.

INSTALLING

You can use npm to download and install:

  • The latest mediawiki-express package: npm install mediawiki-express

  • GitHub's master branch: npm install https://github.com/cscott/node-mediawiki-express/tarball/master

As a postinstall script, npm will configure mediawiki and create an SQLite database for it to use. It will create an admin account and store its credentials in admin.json for you.

TESTING

Currently npm test only runs a linter. Hopefully in the future we can hook up phantomjs to run the mediawiki test suite.

CONTRIBUTORS

RELATED PROJECTS

  • php-embed: Provides the bidirectional Node<->PHP embedding.
  • php-express: A similar embedding of PHP into a Node.js server, but forks the PHP CLI binary in a separate process instead of embedding PHP.
  • php-cgi: Another implementation forking the php binary and forging a CGI request.

LICENSE

Copyright (c) 2015 C. Scott Ananian.

mediawiki-express is licensed using the same license as mediawiki itself.

About

An installation of mediawiki invoked from node.js/express.

Resources

Stars

Watchers

Forks

Packages

No packages published