diff --git a/core/tools/README b/core/tools/README index 149cf299de..cb4c5a1f43 100644 --- a/core/tools/README +++ b/core/tools/README @@ -15,6 +15,9 @@ The tools directory contains the following: * When run in an SVN checkout area, links all the twikiplugins into the core source tree, so they look as if they are installed. * plugins_conformance_analyser.pl * Generates the plugins standards conformance report Plugins.PluginsConformanceReport + * twiki2foswiki + * A script that will do 95-99% of the work of converting an extension from TWiki namespace to Foswiki. You will still need to manually update doc work and comments in the code as required. + ---++ a full TWikiFor builder and installer * builddistros.pl * distro diff --git a/core/tools/twiki2foswiki b/core/tools/twiki2foswiki new file mode 100755 index 0000000000..2f97351b09 --- /dev/null +++ b/core/tools/twiki2foswiki @@ -0,0 +1,150 @@ +#!/bin/bash +# Converts a TWiki Extension to a Foswiki Extension + +if [ $# -ne 1 ] +then + echo "Usage: `basename $0` Extension_name" + echo "You must run the script from a current working directory in which you have the extension to be converted in a subdirectory with the same name as the extension." + echo "If the extension is in an SVN checkout and the script finds a directory called .svn in the extension directory, the script with use svn mv commands when converting." + exit $E_BADARGS +fi + +curdir=`pwd` + +# If there is a .svn directory in the extension directory +# we assume we are within an SVN checkout and will put svn +# in front of the mv commands + +svncommand='' +if [ -d $curdir/$1/.svn ] +then + svncommand=svn +fi + +#first we change directory names +if [ -d $curdir/$1/data/TWiki ] +then + $svncommand mv $curdir/$1/data/TWiki $curdir/$1/data/System +fi + +if [ -d $curdir/$1/lib/TWiki ] +then + $svncommand mv $curdir/$1/lib/TWiki $curdir/$1/lib/Foswiki +fi + +if [ -d $curdir/$1/pub/TWiki ] +then + $svncommand mv $curdir/$1/pub/TWiki $curdir/$1/pub/System +fi + + +#name space change all .pm files in contrib and plugins +cd $curdir/$1/lib/Foswiki + +for file in $( find -type f -name '*.pm') +do + sed -i -e "s/TWiki::/Foswiki::/g" $file + sed -i -e "s/new TWiki\(\);/new Foswiki();/g" $file + sed -i -e "s/use TWiki;/use Foswiki;/g" $file + sed -i -e "s/twiki\([A-Z][A-Za-z]\+\)/foswiki\1/g" $file + sed -i -e "s/'twiki'/'foswiki'/g" $file + sed -i -e "s/TWikiCompatibility/FoswikiCompatibility/g" $file + sed -i -e "s/&Foswiki::Func::getTwikiWebname()/$Foswiki::cfg{SystemWebName}/g" $file + sed -i -e "s/Foswiki::Func::getTwikiWebname()/$Foswiki::cfg{SystemWebName}/g" $file + sed -i -e "s/^=begin twiki/=begin TML/g" $file +done + +# First then we update the build contrib files for a plugin +if [ -d Plugins ] +then + cd $curdir/$1/lib/Foswiki/Plugins/$1 + sed -i -e "s.^data/TWiki.data/System.g" MANIFEST + sed -i -e "s.^pub/TWiki.pub/System.g" MANIFEST + sed -i -e "s.^lib\/TWiki.lib/Foswiki.g" MANIFEST + sed -i -e "s/TWiki::/Foswiki::/g" build.pl + sed -i -e "s/TWiki::/Foswiki::/g" Config.spec + sed -i -e "s/new TWiki\(\);/new Foswiki();/g" build.pl + sed -i -e "s/TWiki::/Foswiki::/g" DEPENDENCIES +fi + +cd $curdir/$1/lib/Foswiki + +# Updating build contrib files if it is a contrib +if [ -d Contrib ] +then + cd $curdir/$1/lib/Foswiki/Contrib/$1 + sed -i -e "s.^data/TWiki.data/System.g" MANIFEST + sed -i -e "s.^pub/TWiki.pub/System.g" MANIFEST + sed -i -e "s.^lib\/TWiki.lib/Foswiki.g" MANIFEST + sed -i -e "s/TWiki::/Foswiki::/g" build.pl + sed -i -e "s/TWiki::/Foswiki::/g" Config.spec + sed -i -e "s/new TWiki\(\);/new Foswiki();/g" build.pl + sed -i -e "s/TWiki::/Foswiki::/g" DEPENDENCIES +fi + +# name space change pub files for css and js name space changes +cd $curdir/$1 +if [ -d pub/System/$1 ] +then + cd $curdir/$1/pub/System/$1 + for file in $( find -type f -name '*.css') + do + sed -i -e "s/twiki\([A-Z][A-Za-z]\+\)/foswiki\1/g" $file + done + + for file in $( find -type f -name '*.js') + do + sed -i -e "s/twiki\([A-Z][A-Za-z]\+\)/foswiki\1/g" $file + done + +fi + + +# name space change templates +cd $curdir/$1 +if [ -d templates ] +then + cd $curdir/$1/templates + for file in $( find -type f -name '*.tmpl') + do + sed -i -e "s/twiki\([A-Z][A-Za-z]\+\)/foswiki\1/g" $file + done +fi + + +# name space change tools files +cd $curdir/$1 +if [ -d tools ] +then + cd $curdir/$1/tools + for file in $( find -type f -name '*') + do + sed -i -e "s/TWiki::/Foswiki::/g" $file + sed -i -e "s/new TWiki\(\);/new Foswiki();/g" $file + sed -i -e "s/use TWiki;/use Foswiki;/g" $file + sed -i -e "s/twiki\([A-Z][A-Za-z]\+\)/foswiki\1/g" $file + done +fi + + +# name space the most common things in Data files. +# Note you still have to manually do some work +cd $curdir/$1 +if [ -d data ] +then + cd $curdir/$1/data/System + sed -i -e "s/%TWIKIWEB%\.TWikiPlugins/[[%SYSTEMWEB%.Plugins][Plugins]]/g" $1.txt + sed -i -e "s'| Plugin Home: | http://TWiki\.org/cgi-bin/view/Plugins/%TOPIC% |'| Plugin Home: | http://foswiki.org/Extensions/%TOPIC% |'g" $1.txt + sed -i -e "s'| Feedback: | http://TWiki\.org/cgi-bin/view/Plugins/%TOPIC%Dev |'| Feedback: | http://foswiki.org/Extensions/%TOPIC%Dev |'g" $1.txt + sed -i -e "/TWiki.org\/cgi-bin\/view\/Plugins\/%TOPIC%Appraisal/d" $1.txt + sed -i -e "/\[\[TWiki:Plugins\/Benchmark\]\[Benchmarks\]\]/d" $1.txt + sed -i -e "s/| TWiki Dependency: | \$TWiki::Plugins::VERSION/| Dependency: | \$Foswiki::Plugins::VERSION/g" $1.txt + sed -i -e "s'data/TWiki/'data/System/'g" $1.txt + sed -i -e "s'pub/TWiki/'pub/System/'g" $1.txt + sed -i -e "s'lib/TWiki/'lib/Foswiki/'g" $1.txt + sed -i -e "s/%TWIKIWEB%\.TWikiPreferences/%SYSTEMWEB%.SitePreferences/g" $1.txt + sed -i -e "s/%TWIKIWEB%\.TextFormattingRules/%SYSTEMWEB%.TextFormattingRules/g" $1.txt + sed -i -e "s/TWiki 4\.0 and up: //g" $1.txt + sed -i -e "s/author=\"[^\"]*\"/author=\"ProjectContributor\"/" $1.txt + sed -i -e "s/reprev=\"1..\"//" $1.txt +fi