Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item664: Adding Kenneth's twiki2foswiki to the developer tool box on SVN
This both works in an SVN checkout and in a non SVN copy. Remember it does not do code comments and the text in the .txt files so plan another 5 minutes manual work before you start. Do not upload name space converted extensions to foswiki.org unless you have tested that they work. In fact do not even check them in on svn before you know have tested them. We want our Foswiki extensions repository to be of a higher quality than we had on TWiki. git-svn-id: http://svn.foswiki.org/trunk@1767 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
- Loading branch information
KennethLavrsen
authored and
KennethLavrsen
committed
Jan 5, 2009
1 parent
0f4d3a2
commit 698ef94
Showing
2 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |