Commit 0b3a4174 authored by Richard Mansfield's avatar Richard Mansfield

Merge branch 'master' of gitorious.org:mahara/mahara-scripts

parents a40b2a02 4908e2bf
# mt2mw -- package for migrating a Mindtouch wiki to MediaWiki
# Copyright (C) 2010 Catalyst IT Ltd
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# system library
import ConfigParser as cp
......@@ -26,19 +9,24 @@ cfg = cp.SafeConfigParser()
cfg.read('config.ini')
# get the root element in the page structure
print "Attempting to get the mindtouch wiki layout"
mtwiki = MTWiki(cfg.get('config', 'mindtouch_url'))
homepage = mtwiki.get_sitemap()
if homepage:
print "Have mindtouch layout."
directdb = cfg.get('config', 'direct_db')
dbconfig = None
if directdb:
dbconfig = {
'host': cfg.get('config', 'mediawiki_db_host'),
'port': cfg.get('config', 'mediawiki_db_port'),
'database': cfg.get('config', 'mediawiki_db'),
'user': cfg.get('config', 'mediawiki_db_user'),
'password': cfg.get('config', 'mediawiki_db_password'),
}
print "Attempting to create mediawiki connection"
mwwiki = MWWiki(
cfg.get('config', 'mediawiki_url'),
cfg.get('config', 'mediawiki_user'),
......@@ -46,10 +34,15 @@ mwwiki = MWWiki(
dbconfig,
cfg.get('config', 'dataroot'),
)
if mwwiki:
print "MediaWiki Connection created"
print "Creating MediaWiki from mindtouch site..."
mwwiki.create_from_mindtouch(homepage)
print "MediaWiki updated"
# point MediaWiki:MainPage at the new homepage
print "Updating MediaWiki homepage"
mwwiki.update_mainpage(homepage)
mwwiki.done()
print "All done!"
......@@ -101,14 +101,5 @@ def html2wiki(html):
out, err = converter.communicate(input=html)
if err:
raise Exception(err)
# the HTML::WikiConverter module does something funny with urlencoded characters
# in the link portion of a wiki link. The title portion appears to be fine
# we need to replace sets of two consecutive url-encoded characters (4 bytes)
# with the outer two bytes, when those sets are found between
out = urllib2.quote(out)
links = re.findall('%5B%5B(.*?)%7C.*?%5B%5B', out)
for link in links:
fixedlink = re.sub('((%[0-9A-F]{2}){4})', reducechars, link)
out = out.replace(link, fixedlink)
return urllib2.unquote(out)
return out
......@@ -238,8 +238,8 @@ echo "lp-project-upload mahara ${RELEASE} mahara-${RELEASE}.tar.bz2" >> ${CURREN
echo "lp-project-upload mahara ${RELEASE} mahara-${RELEASE}.zip" >> ${CURRENTDIR}/${CLEANUPSCRIPT}
echo "echo" >> ${CURRENTDIR}/${CLEANUPSCRIPT}
echo "echo All done. Once you've checked that the files were uploaded successfully, run this:" >> ${CURRENTDIR}/${CLEANUPSCRIPT}
echo "echo rm -rf ${BUILDDIR}" >> ${CURRENTDIR}/${CLEANUPSCRIPT}
echo "echo \"All done. Once you've checked that the files were uploaded successfully, run this:\"" >> ${CURRENTDIR}/${CLEANUPSCRIPT}
echo "echo \" rm -rf ${BUILDDIR}\"" >> ${CURRENTDIR}/${CLEANUPSCRIPT}
chmod 700 ${CURRENTDIR}/${CLEANUPSCRIPT}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment