[debian-edu-commits] debian-edu/ 01/01: Replace with get_manual version from debian-edu-doc and adjust Makefile.
Petter Reinholdtsen
pere at moszumanska.debian.org
Sat Mar 21 16:41:02 UTC 2015
This is an automated email from the git hooks/post-receive script.
pere pushed a commit to branch master
in repository debian-edu-itil-doc-nb.
commit 5230cea003e93718a658cf343b94a5638dc05f72
Author: Petter Reinholdtsen <pere at hungry.com>
Date: Sat Mar 21 17:40:21 2015 +0100
Replace with get_manual version from debian-edu-doc and adjust
Makefile.
---
documentation/itil/Makefile | 6 +--
documentation/scripts/get_manual | 94 +++++++++++++++-------------------------
2 files changed, 38 insertions(+), 62 deletions(-)
diff --git a/documentation/itil/Makefile b/documentation/itil/Makefile
index b91a2c4..bd6b5b3 100644
--- a/documentation/itil/Makefile
+++ b/documentation/itil/Makefile
@@ -1,9 +1,9 @@
#
# configuration here:
#
-url=https://wiki.debian.org/DebianEdu/Documentation/nb/ITIL
-path1=Dokumentasjon/nb/ITIL
-path2='\/Dokumentasjon\/nb\/ITIL\/'
+url=https://wiki.debian.org/DebianEdu/Documentation/nb/ITIL/
+path1=DebianEdu/Documentation/nb/ITIL
+path2='\/DebianEdu\/Documentation\/nb\/ITIL\/'
ORIGLANG = nb
diff --git a/documentation/scripts/get_manual b/documentation/scripts/get_manual
index 5c83088..0e7f5a3 100755
--- a/documentation/scripts/get_manual
+++ b/documentation/scripts/get_manual
@@ -1,6 +1,4 @@
#!/bin/sh
-
-set -x
#
# download the AllInOne page of a manual on wiki.debian.org as docbook
# and transform it into proper XML
@@ -35,16 +33,15 @@ fi
TMPFILE=$(mktemp)
xmlfile=$name.xml
-site=http://wiki.debian.org/
-
# Make sure all section IDs are unique. If file--subsection is not
# unique, use file--section--subsection--subsubsection instead.
unique_section_ids() {
# Emulate anchor_name_from_text() function from moin
perl -MURI::Escape -pe "my \$file = escape(${ASCIINAME}); my @h = \$file;" \
-e 'my %ids; sub escape {
- my $s = shift;
+ my $s = shift;
$s=~s/ /_/g;
+ $s=~s/~/+/g;
$s=~s/"/.22/g;
$s=~s/\+/+-/g;
$s=~s/\//+AC8/g;
@@ -54,25 +51,21 @@ unique_section_ids() {
$s=~s/\.3A/:/g;
return $s;
}; sub anchor{
- my ($pre, $title) = @_;
- if ("</section>" eq $pre) {
- pop @h;
+ my ($pre, $title) = @_;
+ if ("</section>" eq $pre) {
+ pop @h;
return "$pre";
- } else {
- my ($s) = $title =~ m%<title>(.+)</title>%;
- $s = escape($s);
- push(@h, $s);
- my $id = "$file--$s";
- if (exists $ids{$id}) {
- $ids{$id}++;
- $id .= "-" . ($ids{$id} - 1);
-# $id = join("--", @h);
- }
- my $retval = "<section id=\"$id\">$title";
- $ids{$id}++;
-# print STDERR "S: $retval\n";
- return $retval;
- }
+ } else {
+ my ($s) = $title =~ m%<title>(.+)</title>%;
+ $s = escape($s);
+ push(@h, $s);
+ my $id = "$file--$s";
+ $id = join("--", @h) if (exists $ids{$id});
+ my $retval = "<section id=\"$id\">$title";
+ $ids{$id} = 1;
+# print STDERR "S: $retval\n";
+ return $retval;
+ }
}
s%(</?section>)(<title>[^<]*?</title>)?%&anchor($1, $2)%eg;'
}
@@ -80,13 +73,7 @@ unique_section_ids() {
# the last but one sed "preserves" the 2nd matched regex
# the last sed does the same as dos2unix
# head at the end chops of the last two lines with the Category:Permalink entry
-GET -H User-Agent: "${url}AllInOne?action=raw" |
- grep -v 'TableOfContents(' |
- grep -v CategoryPermalink |
- sed "s%<<Include(%%g" |
- sed "s%)>>%%g" |
- sed "s%$path1%%g" |
- sed 's/.$//' > id
+PERL_LWP_SSL_VERIFY_HOSTNAME=0 GET -H User-Agent: "${url}AllInOne?action=raw"|sed "s%<<Include(%%g" | sed "s%)>>%%g" | sed 's/<<TableOfContents(1//' | sed "s%$path1%%g" |sed 's/.$//'|head -n -2> id
for i in `cat id` ; do
NAME=`echo "${i}" |sed "s/\(.*\)\/\(.*\)/\2/" `
@@ -101,24 +88,24 @@ for i in `cat id` ; do
# - remove the revision history
# - remove the Category:Permalink line
# - add some linebreaks
- # - delete the first line containing the XML declaration
- GET "${url}${i}?action=show&mimetype=text/docbook" |
+ # - delete the first lines containing the XML declaration
+ PERL_LWP_SSL_VERIFY_HOSTNAME=0 GET "${url}${i}?action=show&mimetype=text/docbook" |
# replace tags:
sed "s%code>%computeroutput>%g" |
sed "s%/htdocs/rightsidebar/img/%./images/%g" |
- # remove final tag:
- sed "s%</article>%%" |
+ # remove initial and final tags:
+ perl -pe "s%</?article>%%g" |
# remove tags and enclosed content:
sed "s#<articleinfo>\(.*\)</articleinfo>##g" |
# Comment useless remarks from XML: they just show an ugly drawing in XML
perl -pe "s%<remark>.*?</remark>%<!-- $& -->%g" |
# Broken URL: workaround to #656945
- sed "s%<ulink url='$site${path1}${i}/%<ulink url='$site%g" |
+ sed "s%<ulink url=\"https://wiki.debian.org/${path1}${i}/%<ulink url=\"https://wiki.debian.org/%g" |
# Make wiki self links actually local
- sed "s%<link linkend='%<link linkend='${ASCIINAME}--%g" |
- perl -pe "s%<ulink url='$site${path1}/(HowTo/)?(\w+)#'>(.*?)</ulink>%<link linkend='\2'>\3</link>%g" |
- perl -pe "s%<ulink url='$site${path1}/(HowTo/)?(\w+)#(.*?)'>(.*?)</ulink>%<link linkend='\2--\3'>\4</link>%g" |
- sed "s%<para><ulink url='${site}CategoryPermalink#'>CategoryPermalink</ulink> </para>%%" |
+ sed "s%<link linkend=\"%<link linkend=\"${ASCIINAME}--%g" |
+ perl -pe "s%<ulink url=\"https://wiki.debian.org/${path1}/(HowTo/)?(\w+)#\">(.*?)</ulink>%<link linkend='\2'>\3</link>%g" |
+ perl -pe "s%<ulink url=\"https://wiki.debian.org/${path1}/(HowTo/)?(\w+)#(.*?)\">(.*?)</ulink>%<link linkend='\2--\3'>\4</link>%g" |
+ perl -000 -pe "s%<para><ulink url=\"https://wiki.debian.org/CategoryPermalink#\">CategoryPermalink</ulink>\s*</para>%%" |
unique_section_ids |
# introduce line breaks:
sed "s%<title>%\n<title>%g" |
@@ -130,14 +117,8 @@ for i in `cat id` ; do
sed "s%FIXME%\nFIXME%g" |
sed "s%<itemizedlist>%\n<itemizedlist>%" |
sed "s%<listitem>%\n<listitem>%" |
- # cut off first line:
- sed '1d' > $TARGET
- if grep -q '<para>' "$TARGET" ; then
- :
- else
- echo "error: failure fetching $i. docbook export problem?"
- exit 1
- fi
+ # cut off first lines:
+ sed '1,4d' > $TARGET
if [ "$(grep -v FIXMEs $TARGET |grep FIXME |grep -v 'status ignore')" != "" ] ; then
echo "----------------------------------" >> $TMPFILE
echo ${url}${i} >> $TMPFILE
@@ -171,29 +152,24 @@ echo "calling ../scripts/get_images $xmlfile $path1"
# this needs to run after ./get_images
#
# -0\777 read multiple lines
-perl -0\777 -pi -e "s/<ulink url='$path2(.*)\/(.*)'>(.*)\n<\/ulink>/<link linkend=\"\2\">\3<\/link>/g" $xmlfile
+perl -0\777 -pi -e "s/<ulink url=\"$path2(.*)\/(.*)\">(.*)\n<\/ulink>/<link linkend=\"\2\">\3<\/link>/g" $xmlfile
# make it a docbook article again
sed -i "1,/</ s#<#<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE article PUBLIC \"-//OASIS//DTD DocBook XML V4.4//EN\" \"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd\"><article lang=\"en\"><articleinfo><title>$DEBIAN_EDU_DOC_TITLE <?dbtimestamp?></title></articleinfo>\n<#" $xmlfile
sed -i "$ s#>#>\n</article>#" $xmlfile
-# remove the first empty line
-sed -i "1d" $xmlfile
+# remove the first empty lines
+sed -i "1,2d" $xmlfile
# clean it further
TMPFILE2=$(mktemp)
-if xmllint $xmlfile > $TMPFILE2 ; then
- mv $TMPFILE2 $xmlfile
-else
- rm $TMPFILE2
- echo "error: xmllint failed"
- exit 1
-fi
+xmllint $xmlfile > $TMPFILE2
+mv $TMPFILE2 $xmlfile
# motivate
-if [ "$(grep -v FIXMEs $xmlfile |grep FIXME|uniq)" != "" ] ; then
+if [ "$(grep -v FIXMEs $xmlfile |grep FIXME|grep -v 'status ignore'|uniq)" != "" ] ; then
echo "====================" >> $TMPFILE
- echo `grep -v FIXMEs $xmlfile |grep FIXME|uniq|wc -l` FIXMEs left to fix >> $TMPFILE
+ echo `grep -v FIXMEs $xmlfile |grep FIXME|grep -v 'status ignore'|uniq|wc -l` FIXMEs left to fix >> $TMPFILE
echo "====================" >> $TMPFILE
fi
mv $TMPFILE fixme-status.txt
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/upstream/debian-edu-itil-doc-nb.git
More information about the debian-edu-commits
mailing list