2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # convertlinks - a perl script to make hrefs to
21 # http://api.openoffice.org/common/ref relativ.
26 # for the convenience of &wanted calls, including -eval statements:
27 use vars qw
/*name *dir/;
28 *name
= *File
::Find
::name
;
29 *dir
= *File
::Find
::dir
;
40 find
(\
&wanted
, "$ARGV[0]");
46 next if( $i->{directory
} =~ /.*common((\/|\\)ref(.*))/ ||
47 $i->{directory
} =~ /.*cpp((\/|\\)ref(.*))/ ||
48 $i->{directory
} =~ /.*java((\/|\\)ref(.*))/ );
50 open ( FILEIN
, $i->{filename
} ) || die "could not open $i->{filename} for reading";
54 if( $i->{directory
} =~ /.*$pattern((\/|\\)(.*))/ )
57 $relPath =~ s
#\w+#\.\.#go;
58 if($pattern eq "examples")
60 $relPath = "\.\.\/$relPath";
64 $relToSource = "\.\.\/$relPath";
67 $relToSource = $relPath;
71 if($pattern eq "examples")
77 $relToSource = "\.\.";
80 $relToSource = $relPath;
86 open( FILEOUT
, ">$i->{filename}.tmp" ) || die "could not open $i->{filename} for writing";
89 # change the refenreces to the index in dependency of UDK or ODK
90 if("$ARGV[1]" eq "udk_" | "$ARGV[1]" eq "odk_")
92 s
#((\")(index.html\"))#$2$ARGV[1]$3#go;
93 s
#((\/|\")(faq.html\"))#$2$ARGV[1]$3#go;
94 s
#((\/|\")(bylaws.html\"))#$2$ARGV[1]$3#go;
97 s
#((http:\/\/api\.openoffice\.org\/)(common\/ref[^\"]+))#$relPath\/$3#go;
98 s
#((http:\/\/api\.openoffice\.org\/unbranded-source\/)(.*)(examples\/examples.html))#$relToSource\/$4#go;
100 if($pattern eq "examples")
102 # change the links for the C++/Java examples in the ODK
103 s
#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(java\/*))#$3#go;
104 s
#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(cpp\/*))#$3#go;
105 s
#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(basic\/*))#$3#go;
106 s
#((http:\/\/api\.openoffice\.org\/source\/browse\/api\/odk\/examples\/)(OLE\/*))#$3#go;
108 # change link api specific stuff
109 s
#((http:\/\/api\.openoffice\.org\/)(design_guide.html))#$relPath\/www\/$3#go;
110 s
#(http:\/\/api\.openoffice\.org\/index.html)#$relPath\/www\/odk_index.html#go;
112 # change the links for the C++ examples in the UDK
113 s
#((http:\/\/udk\.openoffice\.org\/source\/browse\/udk\/product\/examples\/)(cpp\/*))#$3#go;
115 # change the links to udk.openoffice.org to relativ links
116 s
#(http:\/\/udk\.openoffice\.org\/index.html)#$relPath\/www\/udk_index.html#go;
117 s
#((http:\/\/udk\.openoffice\.org)(\/*))#$relPath\/www$3#go;
119 # change the link to tutorial
120 s
#((http:\/\/api\.openoffice\.org\/)(basic\/man\/tutorial\/tutorial.pdf))#$relPath\/www\/$3#go;
125 chmod 0666, $i->{filename
};
126 rename "$i->{filename}.tmp", $i->{filename
} || die "could not rename $i->{filename}.tmp to $i->{filename}";
137 push @files, {%file} if /^.*\.html\z/s;