2000-12-13 08:53:51 -06:00
|
|
|
#
|
|
|
|
# convertlinks - a perl script to make hrefs to
|
|
|
|
# http://api.openoffice.org/common/ref relativ.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2000 Sun Microsystems, Inc.
|
|
|
|
#
|
|
|
|
|
|
|
|
use File::Find;
|
|
|
|
|
|
|
|
# for the convenience of &wanted calls, including -eval statements:
|
|
|
|
use vars qw/*name *dir/;
|
|
|
|
*name = *File::Find::name;
|
|
|
|
*dir = *File::Find::dir;
|
|
|
|
@files = ();
|
|
|
|
|
2001-09-06 09:11:45 -05:00
|
|
|
if($#ARGV == 1)
|
|
|
|
{
|
|
|
|
$pattern = "www";
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
$pattern = $ARGV[2];
|
|
|
|
}
|
|
|
|
|
2000-12-13 08:53:51 -06:00
|
|
|
find(\&wanted, "$ARGV[0]");
|
|
|
|
|
|
|
|
$return = 1;
|
2001-11-02 02:40:15 -06:00
|
|
|
|
2000-12-13 08:53:51 -06:00
|
|
|
foreach $i (@files)
|
|
|
|
{
|
2001-11-02 02:40:15 -06:00
|
|
|
next if( $i->{directory} =~ /.*common((\/|\\)ref(.*))/ ||
|
|
|
|
$i->{directory} =~ /.*cpp((\/|\\)ref(.*))/ ||
|
|
|
|
$i->{directory} =~ /.*java((\/|\\)ref(.*))/ );
|
|
|
|
|
2000-12-13 08:53:51 -06:00
|
|
|
open ( FILEIN, $i->{filename} ) || die "could not open $i->{filename} for reading";
|
|
|
|
|
|
|
|
$relPath = ".";
|
2001-09-06 09:11:45 -05:00
|
|
|
if( $i->{directory} =~ /.*$pattern((\/|\\)(.*))/ )
|
2000-12-13 08:53:51 -06:00
|
|
|
{
|
|
|
|
$relPath = $3;
|
2001-09-06 09:11:45 -05:00
|
|
|
$relPath =~ s#\w+#\.\.#go;
|
|
|
|
if($pattern eq "examples")
|
|
|
|
{
|
|
|
|
$relPath = "\.\.\/$relPath";
|
|
|
|
}
|
2001-11-23 08:34:53 -06:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
if($pattern eq "examples")
|
|
|
|
{
|
|
|
|
$relPath = "\.\.";
|
|
|
|
}
|
2000-12-13 08:53:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
@lines = <FILEIN>;
|
|
|
|
close( FILEIN );
|
|
|
|
open( FILEOUT, ">$i->{filename}.tmp" ) || die "could not open $i->{filename} for writing";
|
|
|
|
foreach $_ (@lines)
|
|
|
|
{
|
2001-11-23 08:34:53 -06:00
|
|
|
# change the refenreces to the index in dependency of UDK or ODK
|
2001-02-20 07:41:41 -06:00
|
|
|
if("$ARGV[1]" eq "udk_" | "$ARGV[1]" eq "odk_")
|
|
|
|
{
|
|
|
|
s#((\")(index.html\"))#$2$ARGV[1]$3#go;
|
|
|
|
s#((\/|\")(faq.html\"))#$2$ARGV[1]$3#go;
|
|
|
|
s#((\/|\")(bylaws.html\"))#$2$ARGV[1]$3#go;
|
|
|
|
}
|
|
|
|
|
2000-12-13 08:53:51 -06:00
|
|
|
s#((http:\/\/api\.openoffice\.org\/)(common\/ref[^\"]+))#$relPath\/$3#go;
|
2001-09-06 09:11:45 -05:00
|
|
|
if($pattern eq "examples")
|
|
|
|
{
|
2001-11-23 08:34:53 -06:00
|
|
|
# change the links for the C++/Java examples in the ODK
|
|
|
|
s#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(java\/*))#$3#go;
|
|
|
|
s#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(cpp\/*))#$3#go;
|
2001-11-30 07:47:34 -06:00
|
|
|
s#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(basic\/*))#$3#go;
|
|
|
|
s#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(OLE\/*))#$3#go;
|
2001-11-23 08:34:53 -06:00
|
|
|
|
|
|
|
# change link api specific stuff
|
|
|
|
s#((http:\/\/api\.openoffice\.org\/)(design_guide.html))#$relPath\/www\/$3#go;
|
|
|
|
s#(http:\/\/api\.openoffice\.org\/index.html)#$relPath\/www\/odk_index.html#go;
|
|
|
|
|
|
|
|
# change the links for the C++ examples in the UDK
|
|
|
|
s#((http:\/\/udk\.openoffice\.org\/source\/browse\/udk\/product\/examples\/)(cpp\/*))#$3#go;
|
|
|
|
|
|
|
|
# change the links to udk.openoffice.org to relativ links
|
|
|
|
s#(http:\/\/udk\.openoffice\.org\/index.html)#$relPath\/www\/udk_index.html#go;
|
|
|
|
s#((http:\/\/udk\.openoffice\.org)(\/*))#$relPath\/www$3#go;
|
|
|
|
|
|
|
|
# change the link to tutorial
|
2001-09-06 09:11:45 -05:00
|
|
|
s#((http:\/\/api\.openoffice\.org\/)(basic\/man\/tutorial\/tutorial.pdf))#$relPath\/www\/$3#go;
|
|
|
|
}
|
2000-12-13 08:53:51 -06:00
|
|
|
print FILEOUT $_;
|
|
|
|
}
|
|
|
|
close FILEOUT;
|
2001-11-01 08:11:49 -06:00
|
|
|
chmod 0666, $i->{filename};
|
2000-12-13 08:53:51 -06:00
|
|
|
rename "$i->{filename}.tmp", $i->{filename} || die "could not rename $i->{filename}.tmp to $i->{filename}";
|
|
|
|
$return = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit $return;
|
|
|
|
|
|
|
|
sub wanted {
|
|
|
|
%file = (
|
2001-11-23 08:34:53 -06:00
|
|
|
directory => $dir,
|
|
|
|
filename => $name
|
|
|
|
);
|
2000-12-13 08:53:51 -06:00
|
|
|
push @files, {%file} if /^.*\.html\z/s;
|
2001-09-06 09:11:45 -05:00
|
|
|
}
|