Skip to content
Snippets Groups Projects
Commit d5d76667 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Install PHP helpers for Doxygen zip files in CI job

parent bbde0786
Branches rtd-clean
No related tags found
No related merge requests found
Pipeline #2731831 passed
......@@ -286,6 +286,7 @@ doxygen:
- cmake --build build --target doc
- rm -rf public
- mkdir -p public/doxygen
- cp -r GaudiRelease/web_helpers/. public/doxygen/.
- mv build/doxygen/html ${CI_COMMIT_REF_SLUG}
- zip -r -q public/doxygen/${CI_COMMIT_REF_SLUG}.zip ${CI_COMMIT_REF_SLUG}
......
Options +Indexes
DirectoryIndex index.php index.html index.htm index.php
RewriteEngine On
# this is a clever trick for avoiding RewriteBase
# see http://stackoverflow.com/a/21063276
RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]
# add /index.html to the top entry
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule ^([^/]+)/?$ %{ENV:BASE}$1/index.html [L,R]
# extract the requested file from zip, unless it exists
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule ^([^/]+)/(.+) %{ENV:BASE}/extract.php?zip=%{DOCUMENT_ROOT}%{ENV:BASE}$1.zip&path=$1/$2 [L]
<?php
$zip_name = $_GET['zip'];
$path = $_GET['path'];
if ( ! $zip_name || ! file_exists($zip_name) ) {
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404);
echo "404 - Not Found";
return;
}
switch(pathinfo($path, PATHINFO_EXTENSION)) {
case 'css': $ct = 'text/css'; break;
case 'png': $ct = 'image/png'; break;
case 'gif': $ct = 'image/gif'; break;
case 'jpg': $ct = 'image/jpeg'; break;
case 'js': $ct = 'text/javascript'; break;
case 'svg': $ct = 'image/svg+xml'; break;
case 'json': $ct = 'application/json'; break;
default: $ct = 'text/html';
}
# PHP < 5.4.5 (or < 5.3.15) has problems with zip files with more than 65535
# entries (issue in the version of libzip used, see
# https://libzip.org/news/release-0.10.html)
if (PHP_VERSION_ID >= 50405) {
$zip = new ZipArchive();
if ($zip->open($zip_name)) {
$index = $zip->locateName($path);
if ( $index === FALSE ) {
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404);
echo "404 - Not Found";
} else {
header('Content-Type: ' . $ct);
echo $zip->getFromIndex($index);
}
$zip->close();
}
} else {
exec('/usr/bin/unzip -qq -l "' . $zip_name . '" "' . $path. '"',
$output, $return_var);
if ( $return_var != 0 ) {
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404);
echo "404 - Not Found";
} else {
header('Content-Type: ' . $ct);
passthru('/usr/bin/unzip -p "' . $zip_name . '" "' . $path. '"');
}
}
?>
<!DOCTYPE html>
<html>
<head><title>Available Gaudi Doxygen documentations</title></head>
<body>
<h1>Gaudi Doxygen documentation available for the following versions:</h1>
<ul>
<?php
$versions = array();
$has_master = false;
$dh = opendir(".");
while (($file = readdir($dh)) !== false) {
if (preg_match("/(v[0-9]+r.*)\.zip/", $file, $matches))
$versions[] = $matches[1];
elseif ($file == "master.zip") {
$has_master = true;
}
}
closedir($dh);
natsort($versions);
if ($has_master) $versions[] = "master";
$versions = array_reverse($versions);
foreach ($versions as $value) {
echo '<li><a href="' . $value . '/index.html">' . $value . '</a> (<a href="' . $value . '.zip">zip</a>)</li>';
}
?>
</ul>
<body>
</html>
<?php
// return the list of available .zip files (without extension)
header('Content-Type: text/plain');
$versions = array();
$has_master = false;
$dh = opendir(".");
while (($file = readdir($dh)) !== false) {
if (preg_match("/(v[0-9]+r.*)\.zip/", $file, $matches))
$versions[] = $matches[1];
elseif ($file == "master.zip") {
$has_master = true;
}
}
closedir($dh);
natsort($versions);
if ($has_master) $versions[] = "master";
$versions = array_reverse($versions);
foreach ($versions as $value) {
echo $value . "\n";
}
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment