tips:moinmoin2doku
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tips:moinmoin2doku [2011-03-20 13:39] – [Python] link to whole project so people won't ask stupid questions like where to find doku.py 82.131.59.160 | tips:moinmoin2doku [2023-09-01 18:31] (current) – [Discussion] glen | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Migration from MoinMoin to DokuWiki ====== | ====== Migration from MoinMoin to DokuWiki ====== | ||
+ | Code written in Python/PHP that can do full conversion: all pages and their history, including edit log. Also copies attachments. | ||
- | Below you will find scripts in PHP and Python to facilitate the conversion process. Before running them you must eliminate the leftmost ">" | + | Checkout files from [[https:// |
+ | * '' | ||
- | > FIXME Are there any parameters that need to be passed to the PHP script and how is that to be done? According to the code there should be three parameters. | + | Consult README for details. |
- | Another document on switching appears at http:// | + | **NB:** The project is no longer maintained (as I got my wiki converted), but it may work for you (at least better starting point than I had), feel free to send Pull-Requests. --- [[user> |
+ | ===== Other and older versions ===== | ||
- | ===== PHP ===== | + | You can dig the older versions or older variants |
- | + | ||
- | I have written a small PHP script to convert wiki pages from MoinMoin | + | |
- | + | ||
- | <code php moin2doku.php> | + | |
- | # | + | |
- | <?php | + | |
- | + | ||
- | //check comman line parameters | + | |
- | if ($argc != 3 || in_array($argv[1], | + | |
- | echo " | + | |
- | echo " | + | |
- | echo " | + | |
- | echo " | + | |
- | } | + | |
- | else { | + | |
- | //get input and output directories | + | |
- | $inDir = realpath($argv[1]) or die(" | + | |
- | $outDir = realpath($argv[2]) or die(" | + | |
- | //just print information | + | |
- | echo " | + | |
- | echo " | + | |
- | + | ||
- | //get all files from directory | + | |
- | if (is_dir($inDir)) { | + | |
- | $files = filesFromDir($inDir); | + | |
- | } | + | |
- | + | ||
- | //migrate each file | + | |
- | foreach ($files As $file) { | + | |
- | //convert filename | + | |
- | $ofile = convFileNames($file); | + | |
- | //just print information | + | |
- | echo " | + | |
- | + | ||
- | //read input file | + | |
- | $text = readFl($inDir."/" | + | |
- | + | ||
- | //convert content | + | |
- | $text = moin2doku($text); | + | |
- | + | ||
- | //encode in utf8 | + | |
- | $text = utf8_encode($text); | + | |
- | + | ||
- | //write output file | + | |
- | writeFl($outDir."/" | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | + | ||
- | function moin2doku($text) { | + | |
- | /* like convFileNames and more | + | |
- | * ToDo: [[Datestamp]] delete? | + | |
- | * bold and italic, what goes wrong? | + | |
- | * | + | |
- | * | + | |
- | * | + | |
- | * Moin handles code sections without closing }}} right, DokuWiki does not | + | |
- | */ | + | |
- | + | ||
- | //line by line | + | |
- | $lines | + | |
- | foreach($lines As $line) { | + | |
- | //start converting | + | |
- | $find = Array( | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/# | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/\|{2}/', | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | ); | + | |
- | $replace = Array( | + | |
- | '', | + | |
- | '', | + | |
- | ' | + | |
- | '', | + | |
- | ' | + | |
- | ' | + | |
- | '<>> | + | |
- | '<>>/ | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | '// | + | |
- | ' | + | |
- | ' | + | |
- | ); | + | |
- | $line = preg_replace($find, | + | |
- | + | ||
- | $ret = $ret.$line." | + | |
- | } | + | |
- | return $ret; | + | |
- | } | + | |
- | + | ||
- | + | ||
- | function convFileNames($name) { | + | |
- | /* ö,ä,ü, ,. and more | + | |
- | */ | + | |
- | $find = Array('/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | '/ | + | |
- | ); | + | |
- | $replace = Array(' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ); | + | |
- | $name = preg_replace($find, | + | |
- | $name = strtolower($name); | + | |
- | return $name." | + | |
- | } | + | |
- | + | ||
- | + | ||
- | function filesFromDir($dir) { | + | |
- | $files = Array(); | + | |
- | $handle=opendir($dir); | + | |
- | while ($file = readdir ($handle)) { | + | |
- | if ($file != " | + | |
- | | + | |
- | } | + | |
- | } | + | |
- | closedir($handle); | + | |
- | return $files; | + | |
- | } | + | |
- | + | ||
- | function readFl($file) { | + | |
- | $fr = fopen($file," | + | |
- | if ($fr) { | + | |
- | while(!feof($fr)) { | + | |
- | $text = $text.fgets($fr); | + | |
- | } | + | |
- | fclose($fr); | + | |
- | } | + | |
- | return $text; | + | |
- | } | + | |
- | + | ||
- | function writeFl($file, | + | |
- | $fw = fopen($file, | + | |
- | if ($fw) { | + | |
- | fwrite($fw, $text); | + | |
- | } | + | |
- | fclose($fw); | + | |
- | } | + | |
- | + | ||
- | ?> | + | |
- | </ | + | |
- | + | ||
- | ===== Python ===== | + | |
- | + | ||
- | Based on the above PHP version, a Python script that automates the file renaming, copying and conversion business. | + | |
- | Can do attachments moving, convert attachment code, creates namespaces based on structure in MoinMoin-Wiki. | + | |
- | also converts some Codes of German ' | + | |
- | + | ||
- | Checkout files from [[https:// | + | |
- | * '' | + | |
- | + | ||
- | ===== Perl ===== | + | |
- | + | ||
- | I've written more powerful conversion script, now it converts correctly (as I think ;-) ) all syntax from [[http:// | + | |
===== Discussion ===== | ===== Discussion ===== | ||
- | |||
> Why did you switch from MoinMoin to DokuWiki? | > Why did you switch from MoinMoin to DokuWiki? | ||
>> Because MoinMoin is **not as stable** as it looks like? You know the [[http:// | >> Because MoinMoin is **not as stable** as it looks like? You know the [[http:// | ||
- | >>> | + | |
+ | > Has anyone used this successfully to convert from MoinMoin 1.9.*? | ||
+ | >> I needed to migrate, because I am upgrading my servers | ||
+ | >> I tried to modify moin2doku to use it with MoinMoin 1.9, but I was not able, because there have been to many changes in MoinMoin. But I found a workaround. I have installed a migration-KVM with: | ||
+ | >> | ||
+ | >>I have manually added the following software | ||
+ | >> | ||
+ | >> | ||
+ | >> | ||
+ | >>I was able to copy my Debian-buster MoinMoin 1.9 data to this migration-KVM and convert it with moin2doku and after that copy it to my Debian-bookworm dokuwiki 0.0.20220731.a-2. But I had to make some >> | ||
+ | >> | ||
+ | >> | ||
+ | >> Thank You very much for moin2doku |
tips/moinmoin2doku.1300624747.txt.gz · Last modified: 2011-03-20 13:39 by 82.131.59.160