2 # convertlinks - a perl script to make hrefs to
3 # http://api.openoffice.org/common/ref relativ.
5 # Copyright (c) 2000 Sun Microsystems, Inc.
10 # for the convenience of &wanted calls, including -eval statements:
11 use vars qw
/*name *dir/;
12 *name
= *File
::Find
::name
;
13 *dir
= *File
::Find
::dir
;
24 find
(\
&wanted
, "$ARGV[0]");
30 next if( $i->{directory
} =~ /.*common((\/|\\)ref(.*))/ ||
31 $i->{directory
} =~ /.*cpp((\/|\\)ref(.*))/ ||
32 $i->{directory
} =~ /.*java((\/|\\)ref(.*))/ );
34 open ( FILEIN
, $i->{filename
} ) || die "could not open $i->{filename} for reading";
38 if( $i->{directory
} =~ /.*$pattern((\/|\\)(.*))/ )
41 $relPath =~ s
#\w+#\.\.#go;
42 if($pattern eq "examples")
44 $relPath = "\.\.\/$relPath";
48 $relToSource = "\.\.\/$relPath";
51 $relToSource = $relPath;
55 if($pattern eq "examples")
61 $relToSource = "\.\.";
64 $relToSource = $relPath;
70 open( FILEOUT
, ">$i->{filename}.tmp" ) || die "could not open $i->{filename} for writing";
73 # change the refenreces to the index in dependency of UDK or ODK
74 if("$ARGV[1]" eq "udk_" | "$ARGV[1]" eq "odk_")
76 s
#((\")(index.html\"))#$2$ARGV[1]$3#go;
77 s
#((\/|\")(faq.html\"))#$2$ARGV[1]$3#go;
78 s
#((\/|\")(bylaws.html\"))#$2$ARGV[1]$3#go;
81 s
#((http:\/\/api\.openoffice\.org\/)(common\/ref[^\"]+))#$relPath\/$3#go;
82 s
#((http:\/\/api\.openoffice\.org\/unbranded-source\/)(.*)(examples\/examples.html))#$relToSource\/$4#go;
84 if($pattern eq "examples")
86 # change the links for the C++/Java examples in the ODK
87 s
#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(java\/*))#$3#go;
88 s
#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(cpp\/*))#$3#go;
89 s
#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(basic\/*))#$3#go;
90 s
#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(OLE\/*))#$3#go;
92 # change link api specific stuff
93 s
#((http:\/\/api\.openoffice\.org\/)(design_guide.html))#$relPath\/www\/$3#go;
94 s
#(http:\/\/api\.openoffice\.org\/index.html)#$relPath\/www\/odk_index.html#go;
96 # change the links for the C++ examples in the UDK
97 s
#((http:\/\/udk\.openoffice\.org\/source\/browse\/udk\/product\/examples\/)(cpp\/*))#$3#go;
99 # change the links to udk.openoffice.org to relativ links
100 s
#(http:\/\/udk\.openoffice\.org\/index.html)#$relPath\/www\/udk_index.html#go;
101 s
#((http:\/\/udk\.openoffice\.org)(\/*))#$relPath\/www$3#go;
103 # change the link to tutorial
104 s
#((http:\/\/api\.openoffice\.org\/)(basic\/man\/tutorial\/tutorial.pdf))#$relPath\/www\/$3#go;
109 chmod 0666, $i->{filename
};
110 rename "$i->{filename}.tmp", $i->{filename
} || die "could not rename $i->{filename}.tmp to $i->{filename}";
121 push @files, {%file} if /^.*\.html\z/s;