« Auto-éditer un wikilivre/addappendix/reconstruction et tests du script addappendix » : différence entre les versions

Contenu supprimé Contenu ajouté
→‎Résultat des tests : WL:RD : ! mise en page mise à jour
→‎script addapendix.sh : Mise à jour
Ligne 28 :
#H Header doc
#H -------------------------------
#H File : ~/Add_appendix/tests/13-(pkg)-addappendix.sh/addapendix.sh
#H Syntax : addapendix [ ? | --v ]
#H Created : 220113 by GC
#H Updated : 220113220221 by ...GC for page ScliC
#O Organizational chart
#O -------------------------------
Ligne 37 :
#P -------------------------------
 
VERSION=2201262202221
TEXTDOMAIN=addappendix
TEXTDOMAINDIR="/usr/share/locale"
Ligne 134 :
Workdir=~/Add_appendix
mkdir -p $Workdir/temp
#O ============================================================================
##O Create the file bookname.suffix
#T ***********************
Ligne 171 ⟶ 172 :
cat $Projectdir/$Bookname.$Suffix
fi
#O ============================================================================
#O Download the book in html form
#O Télécharger le site récursivement avec une profondeur infinie ( -linf ), \
Ligne 251 ⟶ 252 :
done < $Projectdir/$Bookname.list
rm source ; rm destination
 
#O ============================================================================
#O Create variable PageSclt
PageSclt=$Projectdir/$Bookname.sclt
Ligne 391 ⟶ 393 :
#O end of while.
done < $Pjlist
#O Add end of div and pagre break
echo "</div>" >> $PageSclt
echo "<div style='page-break-before:always'></div>" >> $PageSclt
#P
#P Création de la page Bookname.scli (sources contributeurs licenses des images)
#P
 
#0 Initialisation de la variable d'entête des fichiers scli.
Headscli=$Projectdir/$Bookname.scli
echo > $Headscli
#O Afficher le nom du fichier Headscli à la console
#O Show Headscli filename to console
echo
echo $"$Headscli english version"; echo
echo $"== Images sources licenses and contributors ==" > $Headscli
echo $"<span style=\"font-size:85%\">The ''sources'' listed for each illustration provide more detailed licensing information, including copyright status, the holders of these rights and the license conditions.</span>" >> $Headscli
echo " " >> $Headscli
echo "<div style=\"font-size:72%\">" >> $Headscli
echo >> $Headscli
#T Show the content of file Headscli cat $Headscli; exit 0
 
#O ============================================================================
#O If the file $Projectdir/$Bookname/$Bookname.str exist, create the PageSclic in classic order
#O Si la page $Projectdir/$Bookname/$Bookname.str existe, créer la page $PageSclic contenant les images dans un ordre classique
if test -e $Projectdir/$Bookname/$Bookname.str
then
#O Select lines containing 'fichier:', 'file', image and create bookname.files
cat $Projectdir/$Bookname/$Bookname.str | grep -n -i -e fichier: -e file: -e image: > $Projectdir/$Bookname/$Bookname.files
#O Select lines containing 'fichier:', '.jpg', '.png', '.gif' and create bookname.pict
cat $Projectdir/$Bookname/$Bookname.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif > $Projectdir/$Bookname/$Bookname.picts
#O Sélect in bookname.files, the lines containing 'title', remove the tag <div> cut ">" and select the last champ to create bookname.illustrations
cat $Projectdir/$Bookname/$Bookname.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$Bookname/$Bookname.illustrations
#O Dans le fichier .files avec le séparateur "=" imprimer dans le champ 'i' le retour chariot, sélectionner le slignes conteneant 'https', remplacer le caractère '"' par '!'
#O et sélectionner le trosième champ, puis relélectionner la ligne contenant https, remplacer le caractère '>' par !, supprimer </a, puis supprimer le caractère '!'
#O et créer le fichier.links
cat $Projectdir/$Bookname/$Bookname.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https | sed "s/\"/!/g" | cut -d '!' -f3 \
| grep https | tr '>' ! | sed "s/<\/a//g" |sed "s/!//g" > $Projectdir/$Bookname/$Bookname.links
#OF Télécharger les fichiers contenus dans la liste du fichier bookname.links
#O Download the files contained in the list of the bookname.links file
wget -P $Projectdir/$Bookname -r -linf -k -p -E -i $Projectdir/$Bookname/$Bookname.links
#O Copy html liles from ./commons.wikimedia.org/wiki in the curreny directory
cd $Bookname
if test -e commons.wikimedia.org; then cp -R commons.wikimedia.org/wiki/*.html . ; fi
#O html.list initialization
echo -n "" > html.list
if test -s $Projectdir/$Bookname/$Bookname.links
then
{
echo $"$Projectdir/$Bookname/$Bookname.links is not empty"
#OF Tant qu'on lit des lignes dans le fichier .links, lire les images et les lister dans html.list
#O As long as there is a line in file html.links, read the line and copy it to html.list
while read line
do
echo $line | awk -F"/" '{print $NF}' | cut -d '%' -f1 | cut -d '.' -f1 > tmp
read Image < tmp
ls $Image*.html >> html.list
echo "Image : "$Image.html
done < $Projectdir/$Bookname/$Bookname.links
}
elif test -s $Projectdir/html.list; then cp $Projectdir/html.list $Projectdir/$Bookname/html.list
else echo $"No images found in $Projectdir/$Bookname"; exit 0
fi
echo " *** References : image, src, lic, contrib."
#O As long as there is a line in file html.list extract illustrations, sources, licenses, authors(s)
while read line
do
echo
echo
echo "$(gettext '**** line = ')$line ****"
echo
mkd -pw '**' $line $line.tmp
cat $line.tmp | tr ',' '\n' > $line.str
echo -n "'''$(gettext 'Illustration : ')'''" > $line.title
cat $line.str |grep wgTitle | cut -d '"' -f4 >> $line.title
cat $line.title >> $PageSclic
cat $line.title
 
echo -n ", ''$(gettext ' source : ')''https://"$Site"/w/index.php?title= " > $line.source
echo $line | sed "s/.html//g" >> $line.source
cat $line.source >> $PageSclic
cat $line.source
 
echo -n ", ''$(gettext ' license : ')''" > $line.license
cat $line.str | grep licensetpl_short | sed "s/<td>//g" | sed "s/<span class//g" | sed "s/<\/span>//g" | sed "s/style=\"display:none;\"//g" | tr '=' '\n' | grep licensetpl_short | awk -F">" '{print $NF}' >> $line.license
cat $line.license >> $PageSclic
cat $line.license
echo -n ", ''$(gettext ' author(s) : ')''" > $line.authors
rm tmp
cat $line.str | grep -i -n -m1 -A 1 -e Author | grep -i -e user -e utilisteur -e auteur | tr '/' '\n' | grep -i -e user -e utilisteur -e auteur | cut -d '"' -f1 > tmp
if test -s tmp
then cat tmp >> $line.authors
else echo "-" >> $line.authors
fi
cat $line.authors >> $PageSclic
cat $line.authors
echo >> $PageSclic
done < html.list
#P bas de la page avant la nouvelle page
echo "</div>" >> $PageSclic
#T echo "$(gettext '{{Newpage}} ')" >> $PageSclic
echo "<div style='page-break-before:always'></div>" >> $PageSclic
#O end of test -e $Projectdir/$Bookname/$Bookname.str
else
echo -e "\033[31m"
echo $"Can not create $Projectdir/$Bookname/$Bookname.sclic. URL page of book is not found"
echo -e "\033[0m"
#O end of create PageSclic
fi
#O ============================================================================
 
exit 0