Code Monkey home page Code Monkey logo

local-mediawiki-sync's Introduction

Local MediaWiki Editing

The purpose of this project is to support local editing of a MediaWiki installation.

This works by downloading a copy of all the pages in a MediaWiki installation to local files. Then, using a plaintext editor such as NotationalVelocity, the files can be edited on a local machine. The sync script will upload any local changes to the wiki when it is run.

This is designed to be used with Notational Velocity and Dropbox.

Notational Velocity

Notational Velocity is a simple editor designed to quickly edit large volumes of simple documents. It can optionally store its documents in plain text files in a folder of your choosing.

Dropbox

Dropbox is an excellent file sync tool that lets you share a folder between multiple computers or people. It is free for accounts that can store up to 2GB and they have paid plans for more storage. You can read more here: http://aaron.pk/dropbox

We take advantage of Dropbox's excellent synchronization capability to handle the cases where you may be editing the local files with no Internet connection. Dropbox will upload the files once you have an Internet connection again.

Overview

The ideal setup is this:

  • You use Notational Velocity to edit the files on your local computer
  • NV saves its files to a folder that is managed by Dropbox
  • Dropbox will upload changes, which will be received by a Linux client on a server somewhere
  • The Linux server will run this script, making changes to the wiki content
  • If the wiki is updated, the Linux client will download changes into its Dropbox folder, which will be synced back to your local machine via Dropbox

Setup

There are two ways of running this script, with or without Dropbox. If you do not use Dropbox, you may have to add a bit of error checking code to handle the cases when you try to sync but are offline.

If you don't wish to use Dropbox, you can simply run this script on the local machine that you want to edit the files on. If you do want to use Dropbox, you will need to install this script on a computer that has a permanent Internet connection for optimal performance.

My preferred setup is running this script on a Linux server using the Linux Dropbox client.

Sync Setup

Copy config.template.php to a file named config.php. Fill in your wiki URL, username and password you'd like to use for the edits that will be made from local files. Set your Dropbox path to the base URL where you'd like the files to be saved.

When you run import.php, the script will crawl all wikis defined in the config file and get the list of all pages in the wiki. They will be downloaded into the dropbox folder you previously defined. The naming convention for files is:

wiki.example.com -- Page Title.txt

Any special characters will be URL-encoded so they don't conflict with the filesystem's conventions, with the exception of slashes which are converted to a double-hyphen (--).

Next, set up the sync.php script to run as a cron job every 1-5 minutes. You can do this by adding something like this to your crontab file:

          • /usr/bin/php /path/to/sync.php >> /var/log/mediawiki-sync.log 2>&1

The script will begin looking for changes to the remote wiki and will update the local files accordingly. When the local files are modified, the script will attempt to update the remote MediaWiki pages with the contents of the local file.

Notes

It is not possible to rename pages in MediaWiki from the text files. The sync script only looks for changes to the file contents, not files that have been moved.

Avoid naming pages with characters that aren't allowed in filenames. Sticking to the alphabet and spaces and hyphens is safe.

This script errs on the side of caution, and will try to avoid overwriting your local files with remote changes if it's unsure of who has the latest version. MediaWiki has good tools for examining diffs and reverting changes, so it's usually safe to make changes there rather than potentially losing changes you made to your local copy.

local-mediawiki-sync's People

Contributors

aaronpk avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.