MediawikiGitRemote
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:
<syntaxhighlight lang="bash"> cpan MediaWiki::API cpan DateTime::Format::ISO8601 cpan LWP::Protocol::https </syntaxhighlight>
Clone our git fork containing minor changes to git-remote-mediawiki:
<syntaxhighlight lang="bash">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</syntaxhighlight>
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:
<syntaxhighlight lang="bash">export PERL5LIB="$PERL5LIB:<PATH>/git/contrib/mw-to-git";</syntaxhighlight>
Git-Mediawiki is now ready for prime time, clone this wiki:
<syntaxhighlight lang="bash">git clone mediawiki::http://wiki.base48.cz wiki</syntaxhighlight>
Test preview functionality:
<syntaxhighlight lang="bash"> cd wiki git mw preview Sandbox.mw</syntaxhighlight>
Proceed with setting your login and password:
<syntaxhighlight lang="bash"> chmod 600 .git/config git config remote.origin.mwLogin Username git config remote.origin.mwPassword <myrandompassword> </syntaxhighlight>
Try editing Sandbox.mw, then commit and push your changes:
<syntaxhighlight lang="bash"> 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
</syntaxhighlight>
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!