2007-05-11 09:52:19 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
#====================================================================
|
|
|
|
# Offline doc script
|
|
|
|
#
|
2016-10-15 19:56:45 +02:00
|
|
|
# Use Dokuwiki exportsite plugin
|
|
|
|
# https://www.dokuwiki.org/plugin:siteexport
|
2010-10-13 12:29:02 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
my $version = "2.0";
|
|
|
|
my $offline_zip_url = "http://lemonldap-ng.org/documentation/$version/start?depth=0&depthType=1.0&disableCache=1&do=siteexport&ens=documentation%3A$version%3Astart&exportLinkedPages=1&exportbody=1&renderer=&template=bootstrap3&disableplugin[]=acl&disableplugin[]=config&disableplugin[]=extension&disableplugin[]=oddeven&disableplugin[]=siteexport&disableplugin[]=usermanager";
|
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
|
|
|
# Get offline archive
|
2016-10-15 19:56:45 +02:00
|
|
|
$rc = getstore( $offline_zip_url, 'siteexport.zip' );
|
2010-11-01 09:13:00 +01:00
|
|
|
exit 1 if ( is_error($rc) );
|
2010-03-20 18:14:28 +01:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Remove old doc
|
|
|
|
system('rm -rf pages/documentation/current/*');
|
2012-02-25 20:21:51 +01:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Unzip archive
|
|
|
|
system("unzip -o siteexport.zip -d pages/documentation/current/");
|
|
|
|
system("rm -f siteexport.zip");
|
2010-03-20 18:14:28 +01:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Remove some files
|
|
|
|
system('rm -rf pages/documentation/current/screenshots');
|
|
|
|
system('rm -rf pages/documentation/current/_export');
|
2014-01-28 18:07:17 +01:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Remove external logos and replace them by a default image
|
|
|
|
system('rm -rf pages/documentation/current/applications/*png pages/documentation/current/applications/*gif pages/documentation/current/applications/*jpeg');
|
|
|
|
system('find . -name \*.html -exec sed -i "s#applications/[^\"]*\.\(png\|jpeg\|gif\)#icons/kmultiple.png#g" {} \;');
|
2007-05-11 09:52:19 +02:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Remove background image
|
|
|
|
system('sed -i "s#/lib/tpl/bootstrap3/images/background.jpeg##g" pages/documentation/current/lib/exe/css*');
|
2007-06-27 10:08:36 +02:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Remove alternate and canonical head links fo fix lintian privacy-breach-generic errors
|
|
|
|
system('find . -name \*.html -exec sed -i "/<link rel=\"alternate\"/d" {} \;');
|
|
|
|
system('find . -name \*.html -exec sed -i "/<link rel=\"canonical\"/d" {} \;');
|
|
|
|
system('find . -name \*.html -exec sed -i "/oss\.maxcdn\.com/d" {} \;');
|
2008-08-29 16:01:58 +02:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Add link to bootstrap
|
|
|
|
system('find . -name \*.html -exec sed -i "s#<link rel=\"stylesheet\" type=\"text/css\" href=\"lib/exe/css.php.t.bootstrap3.css\"/>#<link rel=\"stylesheet\" type=\"text/css\" href=\"lib/exe/css.php.t.bootstrap3.css\"/>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/bwr/bootstrap/dist/css/bootstrap.min.css\"/>#" {} \;');
|
2012-12-14 21:27:01 +01:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Put content in a container
|
|
|
|
system('find . -name \*.html -exec sed -i "s#<div class=\"dokuwiki export\">#<div class=\"dokuwiki export container\">#" {} \;');
|
2014-01-22 17:18:18 +01:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Responsive images
|
|
|
|
system('find . -name \*.html -exec sed -i "s#<img class=\"mediacenter\">#<img class=\"mediacenter img-responsive\">#" {} \;');
|
2015-07-24 11:53:07 +02:00
|
|
|
|
2016-10-15 19:56:45 +02:00
|
|
|
# Tables
|
|
|
|
system('find . -name \*.html -exec sed -i "s#<table class=\"inline\">#<table class=\"inline table table-bordered table-striped\">#" {} \;');
|
2015-12-27 14:20:43 +01:00
|
|
|
|
2015-12-28 13:59:21 +01:00
|
|
|
# Link duplicates files
|
|
|
|
system(q@find . -type f -printf "%s %p\n"|sort -n|perl -a -ne 'if($F[0]==$lf&&`md5sum $F[1]|cut -f1 -d" "` eq `md5sum $ln|cut -f1 -d" "`){print "ln -srf $ln $F[1]\n"}else{$lf=$F[0];$ln=$F[1]}'|sh@);
|
|
|
|
|
2010-10-13 12:29:02 +02:00
|
|
|
exit 0;
|