2007-05-11 09:52:19 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
#====================================================================
|
|
|
|
# Offline doc script
|
|
|
|
#
|
|
|
|
# Use Dokuwiki offline plugin
|
|
|
|
#
|
|
|
|
# This script is part of LemonLDAP::NG project
|
2012-11-30 13:15:05 +01:00
|
|
|
# Released under GPL license
|
2010-10-13 12:29:02 +02:00
|
|
|
#====================================================================
|
2010-03-20 18:14:28 +01:00
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
use strict;
|
|
|
|
use LWP::Simple;
|
|
|
|
use Tie::File;
|
2010-03-20 18:14:28 +01:00
|
|
|
|
2010-11-01 09:13:00 +01:00
|
|
|
my $offline_script_url =
|
|
|
|
'http://lemonldap-ng.org/lib/plugins/offline/create.php';
|
|
|
|
my $offline_zip_url = 'http://lemonldap-ng.org/lib/plugins/offline/offline.zip';
|
2014-01-22 17:18:18 +01:00
|
|
|
my $remove_versions = [qw/latest 1.0 1.1 1.2 1.3/];
|
2010-10-13 12:29:02 +02:00
|
|
|
my $rc;
|
2008-02-25 12:32:36 +01:00
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
# Launch remote offline script
|
2010-11-01 09:13:00 +01:00
|
|
|
$rc = getprint($offline_script_url);
|
|
|
|
exit 1 if ( is_error($rc) );
|
2010-03-20 18:14:28 +01:00
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
# Get offline archive
|
2010-11-01 09:13:00 +01:00
|
|
|
$rc = getstore( $offline_zip_url, 'offline.zip' );
|
|
|
|
exit 1 if ( is_error($rc) );
|
2010-03-20 18:14:28 +01:00
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
# Unzip archive
|
|
|
|
system("unzip -o offline.zip");
|
|
|
|
system("rm -f offline.zip");
|
2010-03-20 18:14:28 +01:00
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
# Move offline contents in current directory
|
|
|
|
system("cp -rf offline/* .");
|
|
|
|
system("rm -rf offline");
|
2010-03-20 18:14:28 +01:00
|
|
|
|
2012-02-25 20:21:51 +01:00
|
|
|
# Keep only the latest
|
2012-02-26 15:54:43 +01:00
|
|
|
system("rm -rf pages/wiki pages/playground");
|
2014-01-22 17:18:18 +01:00
|
|
|
foreach my $version (@$remove_versions) {
|
2012-02-25 23:45:20 +01:00
|
|
|
system("rm -rf pages/documentation/$version");
|
|
|
|
}
|
2012-02-26 15:54:43 +01:00
|
|
|
system('find . -name \*.html -exec sed -i "s#/latest/#/current/#g" {} \;');
|
|
|
|
|
|
|
|
# Rewrite documentation.html
|
2014-01-22 17:18:18 +01:00
|
|
|
tie my @documentation, 'Tie::File', 'pages/documentation.html'
|
|
|
|
or die("Unable to open pages/documentation.html");
|
2012-02-26 15:54:43 +01:00
|
|
|
|
|
|
|
splice @documentation, 61, 20;
|
2012-02-25 20:21:51 +01:00
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
# Correct some bad media links
|
|
|
|
system('find . -name \*.html -exec sed -i "s#/_media#../media#g" {} \;');
|
2010-03-20 18:14:28 +01:00
|
|
|
|
2014-01-28 18:07:17 +01:00
|
|
|
# Remove unused pages
|
|
|
|
system("rm -rf pages/default_sidebar.html");
|
|
|
|
system("rm -rf pages/start.html");
|
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
# Rewrite index.html
|
2010-11-01 09:13:00 +01:00
|
|
|
tie my @index, 'Tie::File', 'index.html' or die("Unable to open index.html");
|
2007-05-11 09:52:19 +02:00
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
my @links = (
|
2010-11-01 09:13:00 +01:00
|
|
|
"\t\t<p><a href=\"pages/documentation.html\" class=\"wikilink1\">Documentation</a></p>",
|
|
|
|
"\t\t<p><a href=\"pages/contact.html\" class=\"wikilink1\">Contact</a></p>",
|
|
|
|
"\t\t<p><a href=\"index/alphabetical.html\" class=\"wikilink1\">All pages</a></p>",
|
2010-10-13 12:29:02 +02:00
|
|
|
);
|
2007-06-27 10:08:36 +02:00
|
|
|
|
2014-01-28 18:07:17 +01:00
|
|
|
splice @index, 21, 2, @links;
|
2008-08-29 16:01:58 +02:00
|
|
|
|
2012-12-14 21:27:01 +01:00
|
|
|
# Remove external logos
|
2013-01-16 17:07:31 +01:00
|
|
|
system('rm -rf media/applications/ media/logos/');
|
2012-12-14 21:27:01 +01:00
|
|
|
|
2014-01-22 17:18:18 +01:00
|
|
|
# Remove Facebook iframe (See http://jira.ow2.org/browse/LEMONLDAP-674)
|
|
|
|
system('sed -i "/<iframe/d" pages/contact.html');
|
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
exit 0;
|