MediawikiGitRemote

From base48
Jump to: navigation, search

How to edit wiki with $EDITOR & git

Pre-requisites

  • git >= 1.9
  • Perl libs:
    • MediaWiki::API
    • DateTime::Format::ISO8601
    • LWP::Protocol::https

Obtaining Perl libs using cpan:

cpan MediaWiki::API
cpan DateTime::Format::ISO8601
cpan LWP::Protocol::https

Clone our git fork containing minor changes to git-remote-mediawiki:

git clone https://github.com/hackerspace/git.git
cd git/contrib/mw-to-git
FROM_PWD="$( pwd )" # you'll need this in next steps
echo "Cloned to: $FROM_PWD"

su # become root
cd $( git --exec-path )
ln -s "$FROM_PWD/git-remote-mediawiki.perl" git-remote-mediawiki
ln -s "$FROM_PWD/git-mw git-mw"
exit # end root session

Adjust PERL5LIB to point to correct path - replace <PATH> placeholder with $FROM_PWD path from previous session and put following line to you ~./bashrc file:

export PERL5LIB="$PERL5LIB:<PATH>/git/contrib/mw-to-git";

Git-Mediawiki is now ready for prime time, clone this wiki:

git clone mediawiki::http://wiki.base48.cz wiki

Test preview functionality:

cd wiki
git mw preview Sandbox.mw

Proceed with setting your login and password:

chmod 600 .git/config
git config remote.origin.mwLogin Username
git config remote.origin.mwPassword <myrandompassword>

Try editing Sandbox.mw, then commit and push your changes:

git diff # review changes
git add Sandbox.mw # or use 'git commit -a' when only changing one file
git commit -m "Testing Git-Mediawiki"
git push origin master # push changes back to wiki
git pull --rebase # it's advised to run pull --rebase after push...
# ...and also before starting any work to pick up new changes

If commit message contains word minor your edit is marked as minor and bot won't spam your changes (useful for editing shopping lists).

Profit!