Commit ba87f0a2 authored by Clément OUDOT's avatar Clément OUDOT

New doc script

parent 3a74c3f8
......@@ -1062,7 +1062,6 @@ translation: omegat-configuration-file
translated-doc: omegat-configuration-file
omegat omegat.files/$(LANGCODE) --mode=console-translate --quiet 2>/dev/null
cd po-doc/$(LANGCODE)/pages/documentation && rm -rf current && ln -s $$(find * -maxdepth 0 -type d) current
# 2. Public targets
......@@ -1072,7 +1071,6 @@ translated-doc: omegat-configuration-file
%-doc: test_omegat_%_dir omegat-%-clean
mkdir -p po-doc/$*
$(MAKE) translated-doc LANGCODE=$* OMEGATCODE=`$(call language_code,$*)`
cd po-doc/$*/pages/documentation/ && rm -rf current && ln -s 2.0 current && cd -
omegat-clean:
rm -rf omegat.files/*/omegat.project omegat.files/*/omegat/project_save*.bak
......
......@@ -3,7 +3,8 @@
#====================================================================
# Offline doc script
#
# Use Dokuwiki offline plugin
# Use Dokuwiki exportsite plugin
# https://www.dokuwiki.org/plugin:siteexport
#
# This script is part of LemonLDAP::NG project
# Released under GPL license
......@@ -13,76 +14,50 @@ use strict;
use LWP::Simple;
use Tie::File;
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';
my $remove_versions = [qw/latest 1.0 1.1 1.2 1.3 1.4 1.9/];
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";
my $rc;
# Launch remote offline script
$rc = getprint($offline_script_url);
exit 1 if ( is_error($rc) );
# Get offline archive
$rc = getstore( $offline_zip_url, 'offline.zip' );
$rc = getstore( $offline_zip_url, 'siteexport.zip' );
exit 1 if ( is_error($rc) );
# Unzip archive
system("unzip -o offline.zip");
system("rm -f offline.zip");
# Move offline contents in current directory
system("cp -rf offline/* .");
system("rm -rf offline");
# Keep only the latest
system("rm -rf pages/wiki pages/playground");
foreach my $version (@$remove_versions) {
system("rm -rf pages/documentation/$version");
}
system('find . -name \*.html -exec sed -i "s#/latest/#/current/#g" {} \;');
# Rewrite documentation.html
tie my @documentation, 'Tie::File', 'pages/documentation.html'
or die("Unable to open pages/documentation.html");
splice @documentation, 61, 27;
# Remove old doc
system('rm -rf pages/documentation/current/*');
# Correct some bad media links
system('find . -name \*.html -exec sed -i "s#/_media#../media#g" {} \;');
# Unzip archive
system("unzip -o siteexport.zip -d pages/documentation/current/");
system("rm -f siteexport.zip");
# Remove unused pages
system("rm -rf pages/default_sidebar.html");
system("rm -rf pages/start.html");
# Remove some files
system('rm -rf pages/documentation/current/screenshots');
system('rm -rf pages/documentation/current/_export');
# Rewrite index.html
tie my @index, 'Tie::File', 'index.html' or die("Unable to open index.html");
# 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" {} \;');
my @links = (
"\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>",
);
# Remove background image
system('sed -i "s#/lib/tpl/bootstrap3/images/background.jpeg##g" pages/documentation/current/lib/exe/css*');
splice @index, 21, 2, @links;
# 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" {} \;');
# Remove external logos and replace them by a default image
system('rm -rf media/applications/ media/logos/');
system('find . -name \*.html -exec sed -i "s#/media/applications/[^\.]*\.\(png\|jpg\|gif\)#/media/icons/kmultiple.png#g" {} \;');
system('find . -name \*.html -exec sed -i "s#/media/logos/[^\.]*\.\(png\|jpg\|gif\)#/media/icons/kmultiple.png#g" {} \;');
# 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\"/>#" {} \;');
# Remove Facebook iframe (See http://jira.ow2.org/browse/LEMONLDAP-674)
system('sed -i "/<iframe/d" pages/contact.html');
# Put content in a container
system('find . -name \*.html -exec sed -i "s#<div class=\"dokuwiki export\">#<div class=\"dokuwiki export container\">#" {} \;');
# Remove background image
system('sed -i "s#/lib/tpl/bootstrap3/images/background.jpg##g" css/*');
# Responsive images
system('find . -name \*.html -exec sed -i "s#<img class=\"mediacenter\">#<img class=\"mediacenter img-responsive\">#" {} \;');
# Download missing images
system('mkdir -p lib/bootstrap3/images && cd lib/bootstrap3/images && wget -l 1 -nd -r http://lemonldap-ng.org/lib/tpl/bootstrap3/images/ && rm -f index* && cd -');
# Tables
system('find . -name \*.html -exec sed -i "s#<table class=\"inline\">#<table class=\"inline table table-bordered table-striped\">#" {} \;');
# 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@);
system("find lib/bootstrap3/images -name '*.1' -delete");
exit 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment