tips:twiki_to_dokuwiki_conversion
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tips:twiki_to_dokuwiki_conversion [2009-08-27 18:45] – 88.153.25.67 | tips:twiki_to_dokuwiki_conversion [2010-03-20 21:23] (current) – 88.66.13.59 | ||
---|---|---|---|
Line 18: | Line 18: | ||
* Headings | * Headings | ||
* Unordered Lists | * Unordered Lists | ||
+ | * Ordered Lists | ||
* Bold, Italic, Bold-Italic Text | * Bold, Italic, Bold-Italic Text | ||
* <b>, <i>, <u> to Doku syntax | * <b>, <i>, <u> to Doku syntax | ||
Line 27: | Line 28: | ||
* I **highly** recommend running this script on a copy of your existing TWiki site...but that goes without saying. | * I **highly** recommend running this script on a copy of your existing TWiki site...but that goes without saying. | ||
- | * Assuming your copied TWiki data is in / | + | * Using these two scripts |
- | * < | + | * Use the first script to copy the data and it will call the second script to do the transformations |
* Save the code below into a file with a .sh extension e.g. twikiconverter.sh. The filename does not matter. | * Save the code below into a file with a .sh extension e.g. twikiconverter.sh. The filename does not matter. | ||
* Open a terminal window and browse to the directory into which you saved the twikiconverter.sh file. | * Open a terminal window and browse to the directory into which you saved the twikiconverter.sh file. | ||
* Change the permission of this file to allow execution | * Change the permission of this file to allow execution | ||
- | * < | + | * < |
- | * From the terminal, run the twikiconverter.sh script against a file or set of files | + | chmod u+x ./ |
- | * < | + | chmod u+x ./ |
- | * Thats it! All of your TWiki documents are now DokuWiki documents | + | * From the terminal, run the migratenamespace.sh script against a twiki namespace |
+ | * < | ||
+ | * Thats it! All of your TWiki documents are now DokuWiki documents | ||
===== Source Code ===== | ===== Source Code ===== | ||
+ | <code bash migratenamespace.sh> | ||
+ | #!/bin/bash | ||
+ | #Twiki to DokuWiki File Converter | ||
+ | #Developed by Thomas Vachon < | ||
+ | #Licensed under the GPL: (http:// | ||
+ | |||
+ | if [ -z " | ||
+ | echo " | ||
+ | exit | ||
+ | fi | ||
+ | |||
+ | #Copy the files to your present directory (run this in the data directory of the doku desination) | ||
+ | rsync -arv / | ||
+ | cd $1 | ||
+ | rm *,v *.lock | ||
+ | |||
+ | #Makes all the filenames lowercase (as it is a dokuwiki requirement) | ||
+ | for f in *; do | ||
+ | g=`expr " | ||
+ | mv " | ||
+ | done | ||
+ | |||
+ | cd ../ | ||
+ | |||
+ | #make the namespace directory lowercase | ||
+ | namespace=`echo $1 | tr ' | ||
+ | mv $1 $namespace | ||
+ | ./ | ||
+ | </ | ||
+ | |||
- | <code bash> | + | <code bash twikiconverter> |
#!/bin/bash | #!/bin/bash | ||
- | #Twiki to DokuWiki Converter | + | #Twiki to DokuWiki |
#Developed by Ben Chapman < | #Developed by Ben Chapman < | ||
+ | # | ||
#Licensed under the GPL: (http:// | #Licensed under the GPL: (http:// | ||
Line 53: | Line 86: | ||
INPUT=$* | INPUT=$* | ||
- | # Removing | + | #Remove the ---+++++ !! (headed links) |
- | perl -pi -e ' | + | perl -pi -e ' |
+ | |||
+ | # Substituting newlines for carriage returns | ||
+ | perl -pi -e 's/\r/\n\n/g' $* | ||
# Stripping Twiki %META information | # Stripping Twiki %META information | ||
Line 87: | Line 123: | ||
# Converting unordered lists | # Converting unordered lists | ||
- | # I'm using %^ as a placeholder so the | + | # I'm using %^ as a placeholder so the |
# bold conversion below does not mess with | # bold conversion below does not mess with | ||
# our lists. Don't worry it gets fixed below. | # our lists. Don't worry it gets fixed below. | ||
Line 98: | Line 134: | ||
perl -pi -e ' | perl -pi -e ' | ||
- | # Twiki' | + | # Commented out. See below |
- | # weak...not | + | # Convert Ordered Lists v1 |
+ | #perl -pi -e 's/ | ||
+ | #perl -pi -e ' | ||
+ | #perl -pi -e ' | ||
+ | #perl -pi -e ' | ||
+ | #perl -pi -e ' | ||
+ | #perl -pi -e ' | ||
+ | #perl -pi -e ' | ||
+ | |||
+ | # In Perl 5.1, the \1 in the capture group is supposed to reference a capturing group. I assume the original author intended that to be a single " | ||
+ | # Convert Ordered Lists v2 | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
# Converting bold-italic text | # Converting bold-italic text | ||
Line 120: | Line 173: | ||
perl -pi -e ' | perl -pi -e ' | ||
perl -pi -e ' | perl -pi -e ' | ||
- | |||
# Removing < | # Removing < | ||
perl -pi -e ' | perl -pi -e ' | ||
Line 140: | Line 192: | ||
perl -pi -e ' | perl -pi -e ' | ||
perl -pi -e ' | perl -pi -e ' | ||
+ | |||
+ | #Remove !! | ||
+ | perl -pi -e ' | ||
+ | |||
+ | #Remove %TOC% | ||
+ | perl -pi -e ' | ||
+ | |||
+ | #Fix named links | ||
+ | perl -pi -e ' | ||
+ | |||
+ | #Remove unneeded META info and HTML 4.0 Traditional br's | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | |||
+ | #Name pre-formatted text as code | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | |||
+ | #Fix Twiki' | ||
+ | #Yes, I know this is ugly, but it works, feel free to clean it up | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
+ | perl -pi -e ' | ||
exit 0 | exit 0 | ||
Line 154: | Line 234: | ||
--- [[bkchapman@gmail.com|Ben Chapman]] | --- [[bkchapman@gmail.com|Ben Chapman]] | ||
+ | |||
+ | * This code has been updated (Nov 17, 2009) to support (at least in part) Twiki syntax as of 1.4.0. Although we had some legacy markup. | ||
+ | * This will now import entire namespaces, instead of just converting existing files. | ||
+ | |||
+ | --- [[vachon-dokuwiki@gamelogic.com|Thomas Vachon]] | ||
+ | | ||
* If you are running this script on Windows, you may encounter the " | * If you are running this script on Windows, you may encounter the " |
tips/twiki_to_dokuwiki_conversion.1251391516.txt.gz · Last modified: 2009-08-27 18:45 by 88.153.25.67