MoinMoin

MoinMoin is an advanced, easy to use and extensible WikiEngine with a large community of users. Said in a few words, it is about collaboration on easily editable web pages.

http://moinmo.in/

File list:

MoinMoin backup wiki pages

Run the following commands

   1 yum install mutt #install as superuser, required to attach files with the mail
   2 su moin
   3 cd /home/moin/moin-1.9.7
   4 vim backupWiki.sh

   1 #!/bin/sh
   2 BACKUPFOLDER=/home/moin/moin-1.9.7/backups
   3 DATAFOLDER=/home/moin/moin-1.9.7/wiki/data/pages
   4 CURRDATE=`date -u "+%Y-%m-%dT%H:%m:%S.%Z"`
   5 SUBJECT="MoinMoin Backup"
   6 BODY="Backup from Wiki MoinMoin"
   7 MAILDESTINATION=xpto@example.org
   8 FILE=$BACKUPFOLDER/backup$CURRDATE.tar.gz
   9 
  10 #create backup folder 
  11 mkdir -p $BACKUPFOLDER
  12 #compress the file with the current data
  13 tar cvzf $FILE $DATAFOLDER
  14 #sends the mail with attached file
  15 echo $BODY | mutt -a "$FILE" -s "$SUBJECT" -- $MAILDESTINATION

Set a cron job as user moin, to send the backup daily:

   1 crontab -e 
   2 @daily /home/moin/moin-1.9.7/backupWiki.sh

MoinMoin Default theme

MoinMoin has several default themes which are:

To change the default theme edit the file /home/moin/moin-1.9.7/wikiconfig.py and change the variable theme_default.

   1 #theme_default=u'classic'
   2 #theme_default=u'modern'
   3 #theme_default=u'modernized'
   4 theme_default=u'modernized_cms'
   5 #theme_default=u'rightsidebar'

MoinMoin Init Script

Init script to start MoinMoin on RHEL 6.4 and CentOS 6.4.

File is located in /etc/init.d/moinmoin.

To register the service the command chkconfig --add moinmoin must be runned.

Run chkconfig moinmoin on.

To start run service moinmoin start.

To stop run service moinmoin stop.

To get status run service moinmoin status.

To restart service moinmoin restart.

File content:

   1 #!/bin/sh
   2 # chkconfig: 345 99 99
   3 # description: Starts and stops the MoinMoin wiki process
   4 USER=moin
   5 PROG="wikiserver"
   6 PROGPATH=/home/moin/moin-1.9.7/wikiserver.py
   7 PIDFILE="/tmp/moin.pid"
   8 PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin"
   9 LOG=/home/moin/moin-1.9.7/log.txt
  10 
  11 start(){
  12   echo "Start called"
  13   su $USER -c $PROGPATH >> $LOG 2>&1  &
  14   /bin/sleep 2
  15   PID=`ps uax| grep python | grep $PROG | grep $USER | awk '{print $2}'`
  16   echo "Program PID: $PID"
  17   echo "$PID" > $PIDFILE
  18 }
  19 status(){
  20   PID=`cat $PIDFILE`
  21   echo "Running with PID: $PID"
  22 }
  23 stop(){
  24   echo "Stop called"
  25   PID=`cat $PIDFILE`
  26   echo "PID to kill $PID"
  27   kill -9 $PID
  28   rm $PIDFILE
  29 }
  30 
  31 # switch
  32 case "$1" in
  33 start)
  34 start
  35 ;;
  36 status)
  37 status
  38 ;;
  39 stop)
  40 stop
  41 ;;
  42 restart)
  43 stop
  44 start
  45 ;;
  46 *)
  47 echo "moinmoin start|status|stop|restart"
  48 exit 1
  49 ;;
  50 esac

MoinMoin to listen on all interfaces and use port 80

Edit the file /home/moin/moin-1.9.7/wikiserverconfig.py .

Change the hostname to '' and port to 80.

   1 hostname = ''
   2 port = 80

After the file is changed restart MoinMoin with service moinmoin restart.

MoinMoin Navigation Bar

To change the available Moin Moin navigation bar open the file /home/moin/moin-1.9.7/wikiconfig.py .

Add or replace the variable navi_bar with an array of the Wiki pages that should appear, inside the Python class LocalConfig.

   1   navi_bar =[u'Wiki',u'SiteMap']

After the file is changed restart MoinMoin with service moinmoin restart.

MoinMoin Sitemap Update

Shell script to update an Ad-Hoc Sitemap periodically.

MoinMoin "filesystem power" !!!!

Run the following commands:

   1 su moin
   2 cd /home/moin/moin-1.9.7
   3 vim sitemap.sh

Fill sitemap.sh file with the following:

   1 #!/bin/sh
   2 WIKIPAGESLOCATION=/home/moin/moin-1.9.11/wiki/data/pages
   3 SITEMAP=$WIKIPAGESLOCATION/Sitemap/revisions/00000001
   4 #create directories for Sitemap wiki page
   5 mkdir -p $WIKIPAGESLOCATION/Sitemap
   6 mkdir -p $WIKIPAGESLOCATION/Sitemap/revisions
   7 # sets the current page revision
   8 echo "00000001" > $WIKIPAGESLOCATION/Sitemap/current
   9 # find files with name current. current exists in "live" wiki pages
  10 find $WIKIPAGESLOCATION -name "current" > $SITEMAP
  11 #replace /current by empty string
  12 sed -i 's/\/current/]]/' $SITEMAP
  13 # replace ./wiki/data/pages by empty string
  14 sed -i 's/\/home\/moin\/moin-1.9.11\/wiki\/data\/pages\// * [[/' $SITEMAP
  15 # replace wiki/underlay/pages by empty string
  16 sed -i 's/\/home\/moin\/moin-1.9.11\/wiki\/underlay\/pages\// * [[/' $SITEMAP
  17 # replace 0x2f by /
  18 sed -i 's/(2f)/\//g' $SITEMAP
  19 # replace 0x2e by .
  20 sed -i 's/(2e)/./g' $SITEMAP
  21 sed -i 's/(20)/\ /g' $SITEMAP
  22 #sorts the pages by name
  23 sort $SITEMAP -o $SITEMAP
  24 #CURRDATE=`date`
  25 #echo $CURRDATE
  26 #add text at top, Sitemap with heading 1
  27 sed -i '1s/^/= Sitemap =\n/' $SITEMAP

Set a cron job with:

   1 crontab -e
   2 * * * * * /home/moin/moin-1.9.11/sitemap.sh

Set the script as executable and setup the ownership

   1 chmod 755 sitemap.sh 
   2 chown moin sitemap.sh 
   3 chgrp moin sitemap.sh

The sitemap will be updated every minute.

Markup

= Level 1 =
== Level 2 ==
=== Level 3 ===
==== Level 4 ====
===== Level 5 =====
====== Level 6 ======
'''Bold Text'''
''Italic''

{{{#!highlight python
Code
}}}

[[ItemName]]    
[[ItemName|Named Item]]
[[https://moinmo.in/]]
[[https://moinmo.in/|MoinMoin Wiki]]
{{https://static.moinmo.in/logos/moinmoin.png}}
# comment
* item 1
* item 2 (preceding white space)
 * item 2.1
  * item 2.1.1
||Head A ||Head B ||Head C ||
=============================
||a      ||b      ||c      ||
||x      ||y      ||z      ||

Cleanup pages without current or revisions

   1 #!/usr/bin/python
   2 """
   3 python cleanup_bad_moinmoin_pages.py  > res.sh
   4 """
   5 import os
   6 for root, dirs, files in os.walk("./wiki/data/pages", topdown=False):
   7    for name in files:
   8       if name.endswith("edit-log"):
   9           name = name.replace("edit-log","current") 
  10           fullname = os.path.join(root, name)
  11           try:
  12               os.stat( fullname )
  13           except Exception as ex:
  14               print "rm -rf \"%s\""%(  fullname.replace("/current","")  )

Install memodump theme - twitter bootstrap

   1 git clone https://github.com/dossist/moinmoin-memodump.git
   2 sudo bash
   3 cd moinmoin-memodump/
   4 cp memodump.py /home/moin/moin-1.9.7/wiki/data/plugin/theme/
   5 cd /home/moin/moin-1.9.7/MoinMoin/web/static/htdocs
   6 cp /home/userx/moinmoin-memodump/memodump -R .
   7 chgrp www-data * -R
   8 chown moin * -R
   9 cd /home/moin/moin-1.9.7/wiki/data/plugin/theme/
  10 chgrp www-data * -R
  11 chown moin * -R
  12 # Edit wikiconfig.py to change theme_default.
  13 #    theme_default = 'memodump'
  14 cd /home/moin/moin-1.9.7
  15 vi wikiconfig.py
  16 chgrp www-data wikiconfig.py
  17 chown moin wikiconfig.py
  18 service apache2 restart

Log page edits

Change action MoinMoin/action/edit.py with syslog to log the user that is editing a page.

   1 import syslog
   2 def execute(...)
   3     syslog.syslog(syslog.LOG_INFO, "MoinMoin edit request: %s "%( str(request.user)   )  )

Quick setup

   1 cd ~/tmp 
   2 wget https://github.com/moinwiki/moin-1.9/releases/download/1.9.11/moin-1.9.11.tar.gz
   3 tar xvzf moin-1.9.11.tar.gz
   4 cd moin-1.9.11/
   5 vi wikiconfig.py 
   6 # superuser=[u"userx"]
   7 # page_front_page = u'FrontPage'
   8 # acl_rights_default = u"userx:read,write,delete,revert,admin All:read"
   9 python2.7 wikiserver.py
  10 # http://localhost:8080/
  11 #?action=newaccount 
  12 #user: userx
  13 #pwd: ???????? (use secure pass)
  14 #email: userx@gmail.com 
  15 http://localhost:8080/FrontPage

Python/MoinMoin (last edited 2024-01-28 23:59:23 by vitor)