Différences entre les versions de « Auto-éditer un wikilivre/Annexer (Version internationalisée)/src/add sclt.sh »

→‎en_sclt.inc : Ajout du contenu à la section
(→‎fr_sclt.inc : Mise à jour)
(→‎en_sclt.inc : Ajout du contenu à la section)
== en_sclt.inc ==
<syntaxhighlight lang="bash">
#! /bin/bash
#H File : en_sclt.inc to add at add_sclt.sh
#H Version 21-06-10
cd $Projectdir
#T echo "Projectdir : $Projectdir" exit 0
#O but final: créer la page "Annexe" avec les pages Projet.sclt et Projet.scli.
#O ---
#O Créer la page PageSclt=$Projectdir/$1.sclt et afficher son contenu.
echo "$Projectdir/$1.sclt creation"
echo "----------"
echo "= Appendix =" > "$Projectdir/$1.sclt"
echo "" >> $Projectdir/$1.sclt
 
#O Add <references />
echo "== References ==" >> "$PageSclt"
echo "<references />" >> "$PageSclt"
echo " " >> "$PageSclt"
echo "{{Newpage}}" >> "$PageSclt"
 
#? (option) add the la list create with "Contents" page for printable book version or compiled page (collection) ?
#O add the link to printable book and to articles.
echo "== Contents ==" >> $PageSclt
echo "<div style="font-zize:85%";>" >> $PageSclt
cat $Projectdir/$1".list" | tr ' ' '_' | tr '\n' '%' | sed "s/%/\n\n/g" >> $PageSclt
echo "</div>" >> $PageSclt
 
#0 Add the link to the source of this edition.
echo "=== Source for this edition ===" >> $PageSclt
echo "<div style="font-zize:85%";>" >> $PageSclt
echo -n "https://" >> $PageSclt
cat $Projectdir/$1.mainPage | sed "s/\\\ /_/g" >> $PageSclt
#P other version : cat $Projectdir/$1".list" | tr ' ' '_' | tr '\n' '%' | sed "s/%/%\n/g" | grep $1% | tr -d % >> $PageSclt
echo "</div>" >> $PageSclt
echo " " >> $PageSclt
echo "{{Newpage}}" >> $PageSclt
 
#O Create section 'Article', 'Source', 'License', 'Contributors(?)'
echo "== Articles Sources, and contributors ==" >> $PageSclt
#O add the text : style PediaPress or personalized.
#O The ''sources'' listed for each article provide more detailled licencing
#O information including the copyright status, the copyleft owner and the license conditions.
echo "<span style="font-zize:85%";>The ''sources'' listed for each article provide more detailled licencing information including the copyright status, the copyleft owner and the license conditions..</span>" >> $PageSclt
#O or, validate one or the other of these texts :
# echo "<span style="font-zize:85%";>The texts are available with their respective licenses, however other terms may apply.<br />See the terms of use for more details : <br />https://wikimediafoundation.org/wiki/Conditions_d'utilisation.</span>" >> $PageSclt
echo " " >> $PageSclt
echo "<div style="font-zize:72%";>" >> $PageSclt
 
 
 
 
 
 
#T exit 0
#T echo -n "Current directory : "
#T pwd
echo "----------"
#O Create or recreate the list-file $Projectdir/$1.pj
cat $Projectdir/$1.list | awk -F"/" '{ print $NF }' > $Projectdir/$1.pj
Pjlist=$Projectdir/$1.pj
echo "Pjlist : "$PjList
#T exit 0
 
#O While exist line in file $List ,
while read line
do
#O Print the line read,
echo ""
echo " line read = "$line
echo ""
#O Extract and copy all strings from the fichier html file
#O $line.html in the file $line.str and add to screen
#T pwd
mkd -pws '**' "$line/$line.html" $Projectdir/$line/$line.tmp | tr ',' '\n' > $Projectdir/$line.str
#T break
#O Create the documentation file of pages :
echo "*** References : articles, src, lic, contrib. "
#O Print article,
if [ $line != $1 ]
then
echo "'''"$line"'''" >> $PageSclt
fi
echo "'''"$line"'''" > $Projectdir/$line/$line.article
cat $Projectdir/$line/$line.article
#O Print source,
echo -n ", ''source : ''https://"$Site"/w/index.php?oldid=" > $Projectdir/$line/$line.RevisionId
cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e wgRevisionId | tr -d ':' | sed "s/\"/%/g" | cut -d'%' -f3 >> $Projectdir/$line/$line.RevisionId
if [ "$line" != "$1" ]
then
cat $Projectdir/$line/$line.RevisionId >> $PageSclt
fi
cat $Projectdir/$line/$line.RevisionId
 
#P license du bas de page :
#P <li id="footer-info-copyright">Les textes sont disponibles sous <a href="https://creativecommons.org/licenses/by-sa/3.0/">license Creative Commons attribution partage à l’identique</a> ; d’autres termes peuvent s’appliquer.<br/>
#P Voyez les <a href="https://wikimediafoundation.org/wiki/Conditions_d'utilisation">termes d’utilisation</a> pour plus de détails.<br/></li>
#P
#P Print license :
#P <link rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"/>
 
 
#T echo ", ''Copyright :''" >> ArticleUn.tmp
#T cat ArticleUn.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | cut -d'%' -f2 |sed "s/\/\//https:\/\//g" >> ArticleUn.tmp
#O Print license :
echo -n ", ''license : ''" > $Projectdir/$line/$line.license
#T cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | cut -d'%' -f4 >> $Projectdir/$line/$line.license
cat $Projectdir/$line.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | tr '"' '%' | cut -d'%' -f4 >> $Projectdir/$line/$line.license
#T cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | cut -d'%' -f2 | sed "s/\/\//https:\/\//g" >> $Projectdir/$line/$line.license
if [ $line != $1 ]
then
cat $Projectdir/$line/$line.license >> $PageSclt
fi
cat $Projectdir/$line/$line.license
#
#P spécial pour bas de page fr ##
cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e footer-info-copyright | sed "s/\"\//%\//g" | tr '"' '%' | cut -d'%' -f4 > $Projectdir/$line/$line.license
 
#O Author(s).
echo -n ", ''author(s) : ''" > $Projectdir/$line/$line.author
cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e wgRelevantUserName | sed "s/\"/%/g" | cut -d'%' -f4 > tmp
if test -s tmp;
then cat tmp >> $Projectdir/$line/$line.author; rm tmp;
else
echo "Author not found ! " >> $Projectdir/$line/$line.author
if wget --spider https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$line 2>/dev/null
then
echo " see : https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$line" >> $Projectdir/$line/$line.author
elif wget --spider https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$Bookname/$line 2>/dev/null
then
echo " see : https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$Bookname/$line" >> $Projectdir/$line/$line.author
else echo " see ''contributors'' in book ''$Bookname'' history page of ''$line''" >> $Projectdir/$line/$line.author
fi
fi
#https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/Guide_to_Unix/Introduction
if [ $line != $1 ]
then
cat $Projectdir/$line/$line.author >> $PageSclt
cat $Projectdir/$line/$line.author
fi
echo "" >> $PageSclt
#O fin du tant que.
done < $Pjlist
echo "</div>" >> $PageSclt
echo "{{Newpage}}" >> $PageSclt
if [ "$2" = "--t" ]; then more $PageSclt; fi
 
exit 0
# En of en_sclt.inc
</syntaxhighlight>
 
== tests_add_sclt.bash==
<syntaxhighlight lang="bash">