Auto-éditer un wikilivre/Annexer (Version internationalisée)/Version imprimable
Wikibooks user Auto-éditer_un_wikilivre Add_appendix - (VI) |
Auto-éditer un wikilivre
Add_appendix Version internationalisée
Éditeur : wikibooks users
Table des matières par chapitres
modifier1 Table des matières par chapitres 5
- Programmes d'installation et de dépendances 5
2 install_annex.sh 6 2.1 Description - Recommandations 8 2.2 install_annex.sh 8 2.3 test_install_annex.bash 19 2.4 Copy2Tmp.bash 26 3 users_install_annex.sh 22 3.1 users_install_annex.sh 22 3.2 test_users_install_annex.sh 28 3.3 users_uninstall_annex.sh 29 3.4 test_users_uninstall_annex.sh 31 3.5 uploadfromTmp.sh 31
- Fonctions de la librairie
4 annex.lib 33 4.1 Fonction findbook 33 4.2 Fonction ecfpb.sh 34 4.3 Fonction ecfpc.sh 36 killOPT et killALLDOC 38
- Liste des fichiers de programmes
5 addappendix + annexer 40 5.1 addappendix.sh 5.2 annexer.sh 44 6 pre-annex.sh 46 6.1 pre-annex.sh 46 6.1.1 unrecognized_links.dat 50 6.2 test_pre-annex.bash 50 6.2.1 sitelist.sh 52 6.2.2 sitelist.txt 53 7 header.inc.sh 54 7.1 src/header.inc.sh 55 7.2 tests/header.inc/tests_header.inc.bash 59 7.3 List to tests header.inc 60 7.3.1 text list for tests 61 8 annex.sh 63 8.1 Annex.sh 64 8.2 Global test 70 9 list.sh 72 9.1 list.sh 73 9.2 tests_list.bash 74 9.3 content_cleaner.dat 76 10 download.sh 77 10.1 download.sh 79 10.2 tests_download.sh 79 11 add_sclt.sh 82 11.1 add_sclt.sh 83 11.2 fr_sclt.inc 84 11.3 en_sclt.inc 88 11.4 tests_add_sclt.bash 91 11.5 See results 92 11.5.1 LivreTest 92 11.5.2 TestBook 12 scli.inc.sh 93 12.1 scli.inc.sh 94 12.2 Tests_scli.inc.bash 95 12.3 Exemple de présentation 12.3.1 Pour les livres en français 96 12.4 Sources des images licences et contributeurs 96 12.4.1 For books in English 96 12.5 Images sources licenses and contributors 96 13 add_sclic.sh 97 13.1 add-sclic.sh 98 13.2 en_sclic.inc 98 13.3 fr_sclic.inc 100 13.4 tests_add_sclic.bash 101 14 add_sclipco.sh 103 14.1 Add_sclipco.sh 104 14.2 en_slipco.inc.sh 104 14.3 fr_slipco.inc.sh 104 14.4 tests_add_sclipco.bash 15 add_sclipwb.sh 110 15.1 add_sclipwb.sh 111 15.2 en_sclipwb.inc 111 15.3 fr_sclipwb.sh 113 15.4 tests_add_sclipwb.bash 115
- Progammes de maintenance 117
16 copy sources to sbin/src 118 16.1 Compil2bin.sh 118 16.2 old version cp-src2bin.sh 120 16.3 test_compil2bin.bash 121 16.4 Manuel 122 17 copy all tested commands to src and bin directories 123
Add appendix
Programmes d'installation et de dépendances
Éditeur : Goelette Cardabela
install_annex.sh
modifierCes programmes sont à exécuter deux fois afin de générer les fichiers de traduction !
install_annex.sh Installe la structure des répertoires du programme add_appendix pour les programmeurs et la maintenance.
La commande est exécutée une première fois lors de l'installation et une deuxième fois pour générer les fichiers de traduction après l'exécution de cp-src2bin.sh
Cette commande peut être ré-exécutée à volonté.
vβ 210519
Description - Recommandations
modifier- install_annex.sh is tested with test_install_annex.bash and Copy2Tmp.bash
- This script install Add_appendix or Annexer for single user or Add_appendix for all users
- Syntax to install and tests: The scripts to tests are all in user working tests directory
$HOME/Tmp/test_install_annex.bash
- Syntax to install directly:
$HOME/Tmp/install_annex.sh Add_appendix $HOME/Tmp/install_annex.sh Annexer $HOME/Tmp/install_annex.sh /usr/local
install_annex.sh
modifier#! /bin/bash
#H File install_annex.sh in ~/tmp or re-install_annex.sh in /usr/local/sbin directory
#H Codage UTF-8 sans BOM
#H Syntax : ~/Add_appendix/sbin/install_annex.sh [Install directory | ? ]
#H The installation directory can be /usr/local or /usr or ~/Annexer or ~/Add_appendixby default
#P Creation date : 2020/06/10 by GC
#P Modification date : 2020/06/12 by GC
#P Modification date : 2021/05/19 by GC
#P Last test date : 2021/05/19 by GC
#P This program installs the directory structure for the annex program of wikibooks.
#P
#P . gettext for translation
#P . gettext.sh
#O Include function users_install_annex.sh
function users_install_annex ()
{
#T Tests
echo "First param : $1"
#O Create variables : Workdir, Bindir
if [ $1 = "Add_appendix" ]; then Workdir=~/Add_appendix; echo "Workdir = "$Workdir; fi
if [ $1 = "Annexer" ]; then Workdir=~/Annexer; echo "Workdir = "$Workdir; fi
if [ -d $Workdir ]; then echo " $Workdir is present."; else echo " $Workdir is not present, i create it."; mkdir $Workdir; fi
Bindir="$Installdir/bin"; echo "Bindir : "$Bindir
if test -d $Bindir
then echo " is ok."
else echo " not present, create it"; mkdir $Bindir
fi
#T Breakpoint exit 0
#O Create or recreate directory hierarchy
cd $Workdir
echo -n "The current directory to create $Workdir sub directories = "; pwd
mkdir bin books datas lib man lib/src resources sbin share src temp tests vars
cd $Workdir/tests
echo "$Workdir/tests is the current directory to create sub tests directories."; pwd
mkdir 00-install_annex 0-pre-annex.sh 1-annex.lib 2-annex.sh 3-header.inc.sh 4-list.sh 5-download.sh 6-add_sclt.sh
mkdir 7-scli.inc.sh 8-add_sclic.sh 9-add_sclipco.sh 10-add_sclipwb.sh 11-annexer.sh 12-add_appendix.sh
cd $Workdir/share
echo "$Workdir/share is the current directory to create sub share directories."; pwd
mkdir man doc doc/html
mkdir -p man man/{man1,fr,fr/man1,fr.UTF8,fr.UTF8/man1,es,es/man1}
mkdir -p locale locale/{en,en/LC_MESSAGES,fr,fr/LC_MESSAGES,es,es/LC_MESSAGES}
#T Breakpoint exit 0
#O If findbook.sh, ecfpb.sh, ecfpc.sh, exist in the lib/src directory, build the annex.lib file
if test -e $Workdir/lib/src/findbook.sh && test -e $Workdir/lib/src/ecfpb.sh && test -e $Wordir/lib/src/ecfpc
then
cat $Workdir/lib/src/findbook.sh | grep -v "#O\|#P\|#T" > $Workdir/lib/annex.lib
cat $Workdir/lib/src/ecfpb.sh | grep -v "#O\|#P\|#T" >> $Workdir/lib/annex.lib
cat $Workdir/lib/src/ecfpc.sh | grep -v "#O\|#P\|#T" >> $Workdir/lib/annex.lib
else echo "annex.lib is not builded or not updated in $Workdir/lib/annex.lib"
fi
#O If file annex.lib not exist in $Libdir and if file annex.lib.sh exist in $Libdir/src,
if test -z $Workdir/lib/annex.lib && test -e $Workdir/src/annex.lib.sh
then cat $Workdir/src/annex.lib.sh | grep -v "#O\|#P\|#T" > $Workdir/lib/annex.lib
fi
rm $Workdir/vars/installdir.var
echo "Installdir=$Installdir" > $Workdir/vars/installdir.var
echo "Workdir=$Workdir" >> $Workdir/vars/installdir.var
echo; echo "Content of file $Workdir/vars/installdir.var"
cat $Workdir/vars/installdir.var
if [ "$1" = "Annexer" ]
then
echo; echo "First param = $1"
echo; echo "Se connecter à l'url :"
echo "https://fr.wikibooks.org/wiki/Autoéditer_un_wikilivre/Annexer_(Version_internationalisée)#src.orig_en_français"
echo "Copier les pages de codes, les coller dans un éditeur de texte et les enregistrer dans les répertoires spécialisés"
echo "Les fichiers : "
echo " sources, dans le répertoire $1/src"
echo " de données dans $1/datas"
echo " de librairies, dans $1/lib"
echo " d'exécutables de maintenance, dans $1/sbin (chmod 755 * dans sbin)"
echo " de documentation dans $1/share/doc"
echo " de manuels dans $1/share/man"
echo "Utiliser cette version imprimable : "
echo " https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/Version_imprimable"
echo " pour copier les codes bash"
echo; echo "Finalement ré-exécuter cette commande ~/Annexer/sbin/users_install_annex.sh"
fi
if [ "$1" = "Add_appendix" ]
then
echo; echo "First param = $1"
echo; echo "Login to url :"
echo "https://fr.wikibooks.org/wiki/Autoéditer_un_wikilivre/Annexer_(Version_internationalisée)#Codes_sources_(internationalized_source_code)"
echo "Copy code pages in memory, paste them in a text editor and save in the specialized directory"
echo "The files :"
echo " sources in the directory Add_appendix/src"
echo " datas in Add_appendix/datas"
echo " library in Add_appendix/lib"
echo " executable for maintenance, in Add_appendix/sbin (chmod 755 * in sbin)"
echo " documentation in Add_appendix/share/doc"
echo " manuals in Add_appendix/share/man"
echo "Use this printable version : "
echo " https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/Version_imprimable"
echo " to copy the bash code"
echo; echo "Finaly reexecute this command ~/Add_appendix/sbin/users_install_annex.sh"
fi
echo
#O Initialize $Conversions variable
Datasdir=$Workdir/datas; echo "Datadir = $Datasdir"
Conversions=$Datasdir/conversions.dat; echo "Conversion file = $Conversions"
#O Create or recreate the conversions.dat file in datas directory
if test -e $Conversions
then echo "The $Conversions file is present and will not be updated"
else
{
echo "s/%24/\$/g;s/%21/\!/g;s/%25/%/g;s/%2B/+/g;s/%3C/\\\<\;/g;s/%3E/\>\;/g;" > $Conversions
echo "s/%5C/\\\/g;s/%B0/°/g" >> $Conversions
echo "s/%E0/à/g;s/%E2/â/g" >> $Conversions
echo "s/%E8/è/g;s/%E9/é/g;s/%EA/ê/g;s/%EB/ë/g" >> $Conversions
echo "s/%EE/î/g;s/%EF/ï/g" >> $Conversions
echo "s/%F4/ô/g" >> $Conversions
echo "s/%F9/ù/g;s/%FB/û/g" >> $Conversions
echo "s/%25/%/g;" >> $Conversions
echo "s/%28/(/g;s/%29/)/g;" >> $Conversions
echo "s/%2B/+/g;" >> $Conversions
echo "s/%3A/:/g;" >> $Conversions
echo "s/%3D/=/g;" >> $Conversions
echo "s/%5B/[/g;" >> $Conversions
echo "s/%5D/]/g" >> $Conversions
echo "s/%3B/;/g;s/%2F/\//g;s/%27/'/g" >> $Conversions
echo 's/%22/"/g' >> $Conversions
echo "s/%C3%A7/ç/g;s/%E7/ç/g" >> $Conversions
echo "s/%C3%A0/à/g;s/%C3%A2/â/g" >> $Conversions
echo "s/%C3%A9/é/g;s/%C3%A8/è/g;s/%C3%AA/ê/g" >> $Conversions
echo "s/%C3%AE/î/g;s/%C3%AF/ï/g" >> $Conversions
echo "s/%C3%B4/ô/g" >> $Conversions
echo "s/%C3%B9/ù/g;s/%C3%BB/û/g" >> $Conversions
echo "s/%C2%B7/-/g;s/%C2%AB/«/g;s/%C2%BB/»/g" >> $Conversions
}
fi
echo "----"
#O Initialize $Content_cleaner variable
Content_cleaner=$Datasdir/content_cleaner.dat
echo "Content_cleaner = $Content_cleaner"
#O If not exist create the content_cleaner.dat in datas directory
if test -e $Content_cleaner
then echo "The $Content_cleaner file is present and will not be updated"
else
{
echo "s/: \[/\[/g;s/:\[/\[/g" > $Content_cleaner
echo "s/# \[/[/g;s/#\[/\[/g" >> $Content_cleaner
echo "s/* \[/[/g;s/*\[/\[/g" >> $Content_cleaner
echo "s/; /;/g" >> $Content_cleaner
}
fi
echo "----"
#O Initialize $Unrecognized_links variable
Unrecognized_links=$Datasdir/unrecognized_links.dat
echo "Unrecognized_links = $Unrecognized_links"
#O If not exist, create the file Unrecognized_links.dat
#O If not exist create the content_cleaner.dat in datas directory
if test -e $Unrecognized_links
then echo "The $Unrecognized_links file is present and will not be updated"
else
{
echo "fr.wikibooks.org: unrecognized_link.dat ignore les liens non contenus dans les pages Résumé ou Sommaire"
echo "title" > $Unrecognized_links
echo "Spécial" >> $Unrecognized_links
echo "Accueil" >> $Unrecognized_links
echo "Vitrine" >> $Unrecognized_links
echo "Tous_les_livres" >> $Unrecognized_links
echo "Rechercher_un_livre" >> $Unrecognized_links
echo "Wikijunior" >> $Unrecognized_links
echo "Portail_communautaire" >> $Unrecognized_links
echo "Le_Bistro" >> $Unrecognized_links
echo "Special:" >> $Unrecognized_links
echo "Aide:Accueil" >> $Unrecognized_links
echo "propos_de" >> $Unrecognized_links
echo "https://fr.wikibooks.org/wiki/Wikilivres" >> $Unrecognized_links
echo "Wikilivres:" >> $Unrecognized_links
echo "Catégorie:" >> $Unrecognized_links
echo "en.wikibooks.org: unrecognized_link.dat ignore the uncontained Links in the Summary or Contents pages"
echo "Main_Page" >> $Unrecognized_links
echo "Help:Contents" >> $Unrecognized_links
echo "Card_Catalog_Office" >> $Unrecognized_links
echo "Cookbook:Table_of_Contents" >> $Unrecognized_links
echo "Featured_books" >> $Unrecognized_links
echo "Using_Wikibooks" >> $Unrecognized_links
echo "Reading_room" >> $Unrecognized_links
echo "Community_Portal" >> $Unrecognized_links
echo "Reading_room/Bulletin_Board" >> $Unrecognized_links
echo "Maintenance" >> $Unrecognized_links
echo "Policies_and_guidelines" >> $Unrecognized_links
echo "Contact_us" >> $Unrecognized_links
echo "Welcome" >> $Unrecognized_links
echo "General_disclaimer" >> $Unrecognized_links
echo "Category:" >> $Unrecognized_links
}
fi
echo "----"
#O Write README in bin directory
#T echo "param 1 = $1"
if [ "$1" = "Add_appendix" ]
then
echo "*** Write bin/README file "
echo "README to use bin directory" > $Workdir/bin/README
echo "This directory is reserved for commands without a '.sh' file suffix." >> $Workdir/bin/README
echo "Commands without '.sh' are stripped of comments. They come from the" >> $Workdir/bin/README
echo " 'src' directory or from the 'tests' subdirectories." >> $Workdir/bin/README
echo "Executables commands with '.sh', '.x' or .exe suffix are commands for" >> $Workdir/bin/README
echo " maintainers in 'sbin' directory" >> $Workdir/bin/README
echo "*** Write README in Add_appendix"
echo "README file in Add_apperdix" > $Workdir/README
echo "Type ~/Add_appendix/bin/annex to launch the application" >> $Workdir/README
fi
if [ "$1" = "Annexer" ]
then
echo "*** écriture du fichier bin/LISEZ-MOI"
echo "LISEZ-MOI pour l'utilisation du répertoire 'bin'" > $Workdir/bin/LISEZ-MOI
echo "Ce répertoire est réservé aux commandes shell sans l'extension '.sh'." >> $Workdir/bin/LISEZ-MOI
echo "Les commandes sans '.sh' proviennent du répertoire 'src' ou des sous-répertoires" >> $Workdir/bin/LISEZ-MOI
echo " des 'tests', dépouillées des commentaires." >> $Workdir/bin/README
echo "Les exécutables avec l'extension 'sh', '.x' ou .exe sont des commandes" >> $Workdir/bin/LISEZ-MOI
echo " pour les mainteneurs dans le répertoire'sbin'" >> $Workdir/bin/LISEZ-MOI
echo "*** écriture du fichier LISEZ-MOI dans Annexer"
echo "Fichier LISEZ-MOI dans Annexer" > $Workdir/LISEZ-MOI
echo "Taper ~/Annexer/bin/annex pour lancer l'application" >> $Workdir/LISEZ-MOI
fi
#O When you run this script again, the message translation .pot files will be updated.
if test -e $Installdir/bin/header.inc; then
xgettext -L shell -o $Installdir/share/locale/header.inc.pot --from-code=UTF-8 $Installdir/bin/header.inc; fi
if test -e $Installdir/bin/annex; then
xgettext -L shell -o $Installdir/share/locale/annex.pot --from-code=UTF-8 $Installdir/bin/annex; fi
echo "-----"
echo -e "\033[1;33mYou find Pot-files in $Workdir/share/locale for translations with 'Poedit':\033[0m"
ls -R $Workdir/share/locale
echo -e "\033[1;33mWhen you run this script again, the message translation .pot files will be updated.\033[0m"
#O Copy this program to $Workdir/sbin
cp -Pu $0 $Workdir/sbin/users_install_annex.sh
#O Create the documentation of this program
if test -e $Workdir/sbin/users_install_annex.sh; then cat $Workdir/sbin/users_install_annex.sh | grep -e "#D" | grep -v "if test" | sed 's/#D//g' > $Workdir/share/doc/users_install_annex.sh.doc; fi
#O Clean tmpfiles
if test -d ~/tmp; then rm -r ~/tmp; fi
#O End of function users_install_annex
}
#######################################################
#O clean screen
clear;
#O Version
VERSION=210919
if [ "$1" = "--v" ]; then echo "Version of install_annex.sh $VERSION"; exit 0; fi
#O If the first parameter '$1' is empty or '?' print syntax.
if [ "$1" = "?" ]; then echo "Syntax for install_annex.sh: $0 [ <Install-directory> | ? | --v ]"; exit 0; fi
if [ -z $1 ];
then
echo "Syntax ~/Tmp/install_annex.sh [ --v | ? | Add_appendix | Annexer | /usr/local ]"; exit 0
fi
#P Do not use sudo
if [ $USER = "root" ]; then echo "USER = $USER"; echo "Do not use 'sudo' please."; exit -1; fi
#O Go to home directory and print the current directory.
cd ~
echo""; echo -n "current directory = "; pwd; echo ""
#O If the first parameter is not empty
if [ $1 ];
then
if [ $1 = "/usr/local" ]; then Installdir=$1; echo "Installdir = /usr/local"
elif [ $1 = "Annexer" ]; then Installdir=~/Annexer; echo "Installdir = $Installdir"
elif [ $1 = "Add_appendix" ]; then Installdir=~/Add_appendix; echo "Installdir = $Installdir"
fi
fi
if [ $1 = "Annexer" ] || [ $1 = "Add_appendix" ]; then users_install-annex $1; exit 0; fi
if [ $1 = "/usr/local" ]
then
if test -d /usr/local/src/Add_appendix
then echo "/usr/local/src/Add_appendix is present"
else echo "/usr/local/src/Add_appendix is not found, create it."; sudo mkdir /usr/local/src/Add_appendix
fi
#O Create variables
Workdir=~/Add_appendix
Booksdir=$Workdir/books
Testsdir=$Workdir/tests
Varsdir=$Workdir/vars
Installdir=/usr/local
Bindir=$Installdir/bin
Includedir=$Installdir/include
Libdir=$Installdir/lib
Mandir=$Installdir/man
Sbindir=$Installdir/sbin
Sharedir=$Installdir/share
Srcdir=$Installdir/src/Add_appendix
#P Extra directories added
Datasdir=$Installdir/datas
Resourcesdir=$Workdir/resources
#O Print variables
echo "Workdir=$Workdir"
echo "Booksdir=$Booksdir"
echo "Testsdir=$Testsdir"
echo "Varsdir=$Varsdir"
echo "Installdir=$Installdir"
echo "Bindir=$Bindir"
echo "Includedir=$Includedir"
echo "Libdir=$Libdir"
echo "Mandir=$Mandir"
echo "Sbindir=$Sbindir"
echo "Sharedir=$Sharedir"
echo "Srcdir=$Srcdir"
echo "Extra directory Datadir=$Datasdir"
echo "Extra directory Resourcesdir=$Resourcesdir"
#O Directives
echo "Copy or update all sources .sh files in $Srcdir with root privilege."
fi
#T Test break exit 0
########################################"
#O Create or recreate directories
mkdir -p $Varsdir $Booksdir $Resourcesdir $Resourcesdir/{lang,lang/po,lang/po/fr,lang/po/es,lang/man,man,man/en,man/es,man/fr}
sudo mkdir -p $Datasdir
#O If findbook.sh, ecfpb.sh, ecfpc.sh, exist in the lib/src directory, build the annex.lib file
mkdir $Workdir/lib
if test -e $Srcdir/findbook.sh
then sudo cat $Srcdir/findbook.sh | grep -v "#O\|#P\|#T" > $Workdir/lib/annex.lib
sudo cp $Workdir/lib/annex.lib $Libdir/annex.lib
else echo "findbook in annex.lib is not builded or not updated in $Libdir/annex.lib"
fi
rm -rf $Workdir/lib
# if test -e $Srcdir/ecfpb.sh; then cat $Srcdir/ecfpb.sh | grep -v "#O\|#P\|#T" >> $Libdir/annex.lib; fi
# if test -e $Srcdir/ecfpc.sh; then cat $Srcdir/ecfpc.sh | grep -v "#O\|#P\|#T" >> $Libdir/annex.lib; fi
#O If they exist: install_datasfiles.sh in the lib/src directory,
#O then build this file and move to $Datasdir
if test -e $Srcdir/install_datasfiles.sh
then
mkdir $Workdir/datas
cp $Srcdir/install_datasfiles.sh $Workdir/datas/.; chmod 755 $Workdir/datas/install_datasfiles.sh
$Workdir/datas/install_datasfiles.sh
sudo cp -Rf $Workdir/datas/*.dat /usr/local/datas/.
else echo "install_datasfiles.sh not found in $Srcdir (datas files not updated in $Datasdir)"
fi
rm -r $Workdir/datas
#O Verify the content of datas dir
if test -e $Datasdir/content_cleaner.dat; then echo "$Datasdir/content_cleaner.dat is found"; else echo "$Datasdir/content_cleaner.dat not found"; fi
if test -e $Datasdir/conversions.dat; then echo "$Datasdir/conversions.dat is found"; esle echo "$Datasdir/conversions.dat is not found"; fi
if test -e $Datasdir/unrecognized_links; then echo "$Datasdir/unrecognized_links is found"; else echo "$Datasdir/unrecognized_links is not found"; fi
#O Install cp-src2bin.shx, install_annex.shx, users_install_annex.shx, makeman_annex.shx, docu2html.shx
mkdir $Workdir/sbin
if test -e $Srcdir/cp-src2bin.sh; then cp $Srcdir/cp-src2bin.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/cp-src2bin.sh -o $Workdir/sbin/cp-src2bin.x; else echo "$Srcdir/cp-src2bin.sh not found"; fi
if test -e $Workdir/sbin/cp-src2bin.x; then sudo cp $Workdir/sbin/cp-src2bin.x /usr/local/sbin/; fi
if test -e $Srcdir/install_annex.sh; then cp $Srcdir/install_annex.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/install_annex.sh -o $Workdir/sbin/install_annex.x; else echo "$Srcdir/install_annex.sh not found"; fi
if test -e $Workdir/sbin/install_annex.x; then sudo cp $Workdir/sbin/install_annex.x /usr/local/sbin/; fi
if test -e $Srcdir/users_install_annex.sh; then cp $Srcdir/users_install_annex.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/users_install_annex.sh -o $Workdir/sbin/users_install_annex.x; else echo "$Srcdir/users_install_annex.sh not found"; fi
if test -e $Workdir/sbin/users_install_annex.x; then sudo cp $Workdir/sbin/users_install_annex.x /usr/local/sbin/; fi
if test -e $Srcdir/makeman_annex.sh; then cp $Srcdir/makeman_annex.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/users_install_annex.sh -o $Workdir/sbin/users_install_annex.x; else echo "$Srcdir/makeman_annex.sh not found"; fi
if test -e $Workdir/sbin/users_install_annex.x; then sudo cp $Workdir/sbin/users_install_annex.x /usr/local/sbin/; fi
if test -e $Srcdir/docu2html.sh; then cp $Srcdir/docu2html.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/docu2html.sh -o $Workdir/sbin/docu2html.x; else echo "$Srcdir/docu2html.sh not foud"; fi
if test -e $Workdir/sbin/docu2html.x; then sudo cp $Workdir/sbin/docu2html.x /usr/local/sbin/; fi
if test -e $Srcdir/install_datasfiles.sh; then cp $Srcdir/install_datasfiles.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/install_datasfiles.sh -o $Workdir/sbin/install_datasfiles.x; else echo "$Srcdir/install_datasfiles.sh not foud"; fi
if test -e $Workdir/sbin/install_datasfiles.x; then sudo cp $Workdir/sbin/install_datasfiles.x /usr/local/sbin/; fi
# rm -rf $Workdir/sbin
exit 0
#O Create function cpcleaned2bin
function cpcleaned2bin
{
#O Cleaner
mkdir -p $Workdir/tmp
sudo cat $Srcdir/$1.sh | grep -v "#O\|#P\|#T" | sed "s/eval_gettext /echo \$/g" | sed "s/; echo//g" \
| sed "s/\"\$(gettext '/\$\"/g" | sed "s/' )//g" | sed "s/')//g" > $Workdir/tmp/$1
sudo cp $Workdir/tmp/$1 $Bindir/$1
if echo $Bindir/$1 | grep ".inc"; then sudo chmod 644 $Bindir/$1; else sudo chmod 755 $Bindir/$1; fi
#O Create new .pot file
xgettext -L shell -o $Resourcesdir/lang/po/$1.pot --from-code=UTF-8 $Bindir/$1
#O Create or update fr .po files
if test -z $Resourcesdir/lang/po/fr/$1.po
then cp $Resourcesdir/lang/po/$1.pot $Resourcesdir/lang/po/fr/$1.po
else msgmerge --update $Resourcesdir/lang/po/fr/$1.po $Resourcesdir/lang/po/$1.pot
fi
#O Create or update fr .mo files in resources directory
msgfmt $Resourcesdir/lang/po/fr/$1.po -o $Resourcesdir/lang/po/fr/$1.mo
echo -e "\033[1;33m### Only if you are edit and update $1.po with Poedit: ###\033[0m"
echo "copy $Resourcesdir/lang/po/fr/$1.mo to /usr/share/locale/fr/LC_MESSAGES/$1.mo"
#O Create or update es .po files
if test -z $Resourcesdir/lang/po/es/$1.po
then cp $Resourcesdir/lang/po/$1.pot $Resourcesdir/lang/po/es/$1.po
else msgmerge --update $Resourcesdir/lang/po/es/$1.po $Resourcesdir/lang/po/$1.pot
fi
#O Create or update fr .mo files in resources directory
msgfmt $Resourcesdir/lang/po/es/$1.po -o $Resourcesdir/lang/po/es/$1.mo
echo -e "\033[1;33m### Only if you are edit and update $1.po with Poedit: ###\033[0m"
echo "copy $Resourcesdir/lang/po/es/$1.mo to /usr/share/locale/es/LC_MESSAGES/$1.mo"
}
#O Clean program sources files and add .pot files
# add_sclic
if [ -e $Srcdir/add_sclic.sh ]; then cpcleaned2bin add_sclic; else echo "$Srcdir/add_sclic.sh not found"; fi
# add_sclipco
if [ -e $Srcdir/add_sclipco.sh ]; then cpcleaned2bin add_sclipco; else echo "$Srcdir/add_sclipco.sh not found"; fi
# add_sclipwb
if [ -e $Srcdir/add_sclipwb.sh ]; then cpcleaned2bin add_sclipwb; else echo "$Srcdir/add_sclipwb.sh not found"; fi
# add_sclt
if [ -e $Srcdir/add_sclt.sh ]; then cpcleaned2bin add_sclt; else echo "$Srcdir/add_sclt.sh not found"; fi
# annex
if [ -e $Srcdir/annex.sh ]; then cpcleaned2bin annex; else echo "$Srcdir/annex.sh not found"; fi
# download
if [ -e $Srcdir/download.sh ]; then cpcleaned2bin download; else echo "$Srcdir/download.sh not found"; fi
# en_sclic.inc
if [ -e $Srcdir/en_sclic.inc.sh ]; then cpcleaned2bin en_sclic.inc; else echo "$Srcdir/en_sclic.inc.sh not found"; fi
# en_sclipco.inc
if [ -e $Srcdir/en_sclipco.inc.sh ]; then cpcleaned2bin en_sclipco.inc; else echo "$Srcdir/en_sclipco.inc.sh not found"; fi
# en_sclipwb.inc
if [ -e $Srcdir/en_sclipwb.inc.sh ]; then cpcleaned2bin en_sclipwb.inc; else echo "$Srcdir/en_sclipwb.inc.sh not found"; fi
# en_sclt.inc
if [ -e $Srcdir/en_sclt.inc.sh ]; then cpcleaned2bin en_sclt.inc; else echo "$Srcdir/en_sclt.inc.sh not found"; fi
# fr_sclic.inc
if [ -e $Srcdir/fr_sclic.inc.sh ]; then cpcleaned2bin fr_sclic.inc; else echo "$Srcdir/fr_sclic.inc.sh not found"; fi
# fr_sclipco.inc
if [ -e $Srcdir/fr_sclipco.inc.sh ]; then cpcleaned2bin fr_sclipco.inc; else echo "$Srcdir/fr_sclipco.inc.sh not found"; fi
# fr_sclipwb.inc
if [ -e $Srcdir/fr_sclipwb.inc.sh ]; then cpcleaned2bin fr_sclipwb.inc; else echo "$Srcdir/fr_sclipwb.inc.sh not found"; fi
# fr_sclt.inc
if [ -e $Srcdir/fr_sclt.inc.sh ]; then cpcleaned2bin fr_sclt.inc; else echo "$Srcdir/fr_sclt.inc.sh not found"; fi
# header.inc
if [ -e $Srcdir/header.inc.sh ]; then cpcleaned2bin header.inc; else echo "$Srcdir/header.inc.sh not found"; fi
# list
if [ -e $Srcdir/list.sh ]; then cpcleaned2bin list; else echo "$Srcdir/list.sh not found"; fi
# pre-annex
if [ -e $Srcdir/pre-annex.sh ]; then cpcleaned2bin pre-annex; else echo "$Srcdir/pre-annex.sh not found"; fi
# scli.inc
if [ -e $Srcdir/scli.inc.sh ]; then cpcleaned2bin scli.inc; else echo "$Srcdir/scli.inc.sh not found"; fi
#O List the Installdir/src directory and recreate the tmp/shell_files.prj
#P if test -e ~/tmp; then rm -r ~/tmp; fi
#P mkdir ~/tmp
#P ls $Srcdir/*.sh > ~/tmp/shell_files.prj
#T Breakpoint exit 0
#O While line read in shell_files.prj
#P while read line
#P do
#O Read $line, delete comments, write the result in Testdir directory for the Units Tests.
#P echo $line | awk -F "/" '{print $NF}' > ~/tmp/tmpfile.txt
#P read file < ~/tmp/tmpfile.txt
#T echo " file = "$file
#P mkdir $Testdir/$file
#P cp $Srcdir/$file $Testdir/$file/$file; chmod 755 $Testdir/$file/$file
#P done < ./tmp/shell_files.prj
#O Clean tmpfile
#P rm ~/tmp/tmpfile.txt
#P rm -r ~/tmp
#O Message of the tasks to be accomplished.
echo "-----"
echo "Tasks to be accomplished :"
echo "Modify these files as functions"
echo "Integrate functions in the librairie $Libdir/annex.lib"
echo "Copy include files in $Includedir"
# echo "Copy $Srcdir/install_annex.sh in $Sbindir"
echo "See also users_install_annex.sh, best command for user"
#O Put install dirs to /vars/installdir.var
rm $Workdir/vars/installdir.var
echo "Installdir=$Installdir" > $Varsdir/installdir.var
echo "Workdir=$Workdir" >> $Varsdir/installdir.var
echo "Booksdir=$Booksdir" >> $Varsdir/installdir.var
echo "Testsdir=$Testsdir" >> $Varsdir/installdir.var
echo "Varsdir=$Varsdir" >> $Varsdir/installdir.var
echo "Bindir=$Bindir" >> $Varsdir/installdir.var
echo "Includedir=$Includedir" >> $Varsdir/installdir.var
echo "Libdir=$Libdir" >> $Varsdir/installdir.var
echo "Mandir=$Mandir" >> $Varsdir/installdir.var
echo "Sbindir=$Sbindir" >> $Varsdir/installdir.var
echo "Sharedir=$Sharedir" >> $Varsdir/installdir.var
echo "Srcdir=$Srcdir" >> $Varsdir/installdir.var
echo "Extra directory Datadir=$Datasdir" >> $Varsdir/installdir.var
echo "Extra directory Resourcesdir=$Resourcesdir" >> $Varsdir/installdir.var
echo; echo "Content of file $Varsdir/installdir.var"
cat $Varsdir/installdir.var
#O Clean tmpfiles
if test -d ~/tmp; then rm -r ~/tmp; fi
if test -d $Workdir/tmp; then rm -r $Workdir/tmp; fi
#O End 'install_annex.sh'
test_install_annex.bash
modifier#!/bin/bash
#P File : test_install_annex.bash
#H Usage : ~/Tmp/test_install_annex.bash [ --v | ? | Annexer | Add_appendix ]
#H
#P Creation date : 2021/07/27 by GC
#P Update and tests : 2021/07/27 by GC
#P
#D This Documentation is included in source file
#H Header of file included in source file
#O Organigram of program included in source file
#P Comments for programmers included in source file
#S Structure comments of program included in source file
#w Warnings comments in program included in source file
#O clean screen
clear
# Copy files to Tmp directory
./Copy2Tmp.bash
#O Version
unset $VERSION
VERSION=210917
if [ "$1" = "--v" ]; then echo "Version of test_install_annex.bash "$VERSION; exit 0; fi
#O If the first parameter '$1' is '?' print syntax.
if [ "$1" = "?" ]
then
echo "$HOME/Tmp/test_install_annex.bash [ --v | ? | Annexer | Add_appendix | /urs/local ]"; exit 0
fi
#O If the first parameter '$1' is empty print syntax.
#T echo "param 0 = $0; param 1 = $1" exit 0
if [ "$0" != "$HOME/Tmp/test_install_annex.bash" ] || [ -z $1 ]
then
echo "Copy test_install_annex.bash in ~/Tmp directory"
echo "Syntax $HOME/Tmp/test_install_annex.bash [ --v | ? | Add_appendix | Annexer | /usr/local ]"
fi
#T Test break exit 0
#O Test whishout firstparam
echo "Test whishout firstparam"
$HOME/Tmp/install_annex.sh
sleep 3
#O Test --v
echo "Test VERSION with '--v'"
$HOME/Tmp/install_annex.sh --v
sleep 3
#O Test ?
echo "Test syntax with '?'"
$HOME/Tmp/install_annex.sh ?
sleep 4
#O Choose Annexer or Add_appendix
echo -n "Choose Annexer inkey '1' or Add_appendix inkey '2' or /usr/local inkey '3': "
read Inkey
if [ "$Inkey" == "1" ]
then
#O Test Annexer
$HOME/Tmp/install_annex.sh Annexer
echo "Contenu du répertoire Annexer :"
ls -al ~/Annexer
echo "Contenu des sous-répertoires"
ls -al ~/Annexer/datas ~/Annexer/lib ~/Annexer/lib/src ~/Annexer/sbin ~/Annexer/share/doc ~/Annexer/vars
exit 0
elif [ "$Inkey" == "2" ]
then
#O Test Add_appendix
$HOME/Tmp/install_annex.sh Add_appendix
echo "Add_appendix directory :"
ls -al ~/Add_appendix
echo "Contents of sub-directories :"
ls -al ~/Add_appendix/datas ~/Add_appendix/lib ~/Add_appendix/lib/src ~/Add_appendix/sbin ~/Add_appendix/share/doc ~/Add_appendix/vars
exit 0
elif [ "$Inkey" == "3" ]
then
#O Test /usr/local
$HOME/Tmp/install_annex.sh /usr/local
ls -al ~/Add_appendix ~/Add_appendix/vars ~/Add_appendix/resources
echo; echo "Contents of /usr/local sub-directories :"
ls -al /usr/local/src/Add_appendix /usr/local/datas /usr/local/lib /usr/local/sbin
exit 0
#O Else print syntax
else $HOME/Tmp/install_annex.bash ?
fi
#O End test_install_annex.bash
Copy2Tmp.bash
modifier#!/bin/bash
#H File Copy2Tmp.bash in $Workdir/tests/00-install_annex directory
VERSION=210818
cp -u test_users_install_annex.bash ~/Tmp/.; chmod 766 ~/Tmp/test_users_install_annex.bash
cp -u users_install_annex.sh ~/Tmp/.; chmod 766 ~/Tmp/users_install_annex.sh
cp -u users_install_annex.sh.x ~/Tmp/.
#
cp -u test_install_annex.bash ~/Tmp/.; chmod 766 ~/Tmp/test_install_annex.bash
cp -u install_annex.sh ~/Tmp/.; chmod 766 ~/Tmp/install_annex.sh
#P End of file Copy2Tmp.bash
users_install_annex.sh
modifierusers_install_annex.sh Installe la structure des répertoires du programme annex pour produire les pages Annexe des wikilivres.
Cette commande peut être ré-exécutée à volonté.
vβ 210722
modifier le fichier de commandes
users_install_annex.sh
modifier- Install this executable shell code in sbin ( /usr/local/sbin | ~/Add_appendix/sbin | ~/Annexer/sbin )
- Installer ce code shell exécutable dans sbin
- espagnol ; Instale este código de shell ejecutable en sbin
#! /bin/bash
#H File : users_install_annex.sh in ~/Tmp or re-install_annex.sh in /usr/local/sbin directory
#H Origine : https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/users_install_annex.sh
#H Codage UTF-8 without BOM
#H
#D users_install_annex.sh documentation
#D ------------------------------------
#D This program install or re-install the directory structure for the annex
#D program of wikibooks.
#D Syntax for all annex programs : ~/Tmp/users_install_annex.sh [ OPTIONS ]
#D Do not use ./users_install_annex.sh
#D The installation Directories can be ~/Annexer or ~/Add_appendix
#D OPTIONS :
#D * Annexer, Add_appendix
#D * --v to print version
#D * ? to print syntax and usage
#D
#D To uninstall see users_uninstall_annex.sh
#D
#P Creation date : 2021/04/16 by GC
#P Modification date : 2021/04/18 by Clara
#P Modification date : 2021/04/25 by GC
#P Last test date : 2021/04/19 by Clara
#P Update and tests : 2021/07/16 by Clara.
#P Update and tests : 2021/07/21 by JPL for new french program "Annexer"
#P update annex.lib and copy this program to sbin
#P
#D This Documentation is included in source file
#H Header of file included in source file
#O Organigram of program included in source file
#P Comments for programmers included in source file
#S Structure comments of program included in source file
#w Warnings comments in program included in source file
#O clean screen
clear
#O Version
unset $VERSION
VERSION=211101
if [ "$1" = "--v" ]; then echo "Version of users_install_annex.sh "$VERSION; exit 0; fi
#O If the first parameter '$1' is '?' print doc or syntax.
if [ "$1" = "?" ]
then
if test -z $Workdir/doc/users_install_annex.sh.doc
then cat $Workdir/doc/users_install_annex.sh.doc
else echo "Syntax : $0 [ --v | ? | Add_appendix | Annexer ]"
fi
exit 0
fi
#O If the first parameter '$1' is empty print syntax.
if [ -z $1 ]
then
echo "Copy users_install_annex.sh in ~/Tmp directory"
echo "Syntax ~/Tmp/users_install_annex.sh [ --v | ? | Add_appendix | Annexer ]"; exit 0
fi
#P Do not use sudo
if [ $USER = "root" ]; then echo "USER = $USER"; echo "Do not use 'sudo' please."; exit -1; fi
#O Go to home directory and print the current directory.
cd ~
echo; echo -n "current directory = "; pwd; echo
#O If the first parameter is not empty
if [ $1 ];
then
if [ "$1" = "Annexer" ]; then Installdir=~/Annexer; echo "Installdir = "$Installdir
elif [ "$1" = "Add_appendix" ]; then Installdir=~/Add_appendix; echo "Installdir = "$Installdir
else echo "Syntax error ! "
echo "Copy users_install_annex.sh in ~/Tmp directory"
echo "Syntax ~/Tmp/users_install_annex.sh [ --v | ? | Add_appendix | Annexer ]"
exit -1
fi
fi
#O Test if Install directory exist
if [ -d $Installdir ];
then echo " is ok, $Installdir is present."
else echo " $Installdir not exist, i create it"; mkdir $Installdir;
fi
#O Create variables : Workdir, Bindir
if [ $1 = "Add_appendix" ] && [ $1 != "Annexer" ]; then Workdir=~/Add_appendix; echo "Workdir = "$Workdir; fi
if [ $1 = "Annexer" ] && [ $1 != "Add_appendix" ]; then Workdir=~/Annexer; echo "Workdir = "$Workdir; fi
if [ -d $Workdir ]; then echo " $Workdir is present."; else echo " $Workdir is not present, i create it."; mkdir $Workdir; fi
Bindir="$Installdir/bin"; echo "Bindir : "$Bindir
if test -d $Bindir
then echo " is ok."
else echo " not present, create it"; mkdir $Bindir
fi
#T Breakpoint exit 0
#O Create or recreate directory hierarchy
cd $Workdir
echo -n "The current directory to create $Workdir sub directories = "; pwd
mkdir bin books datas lib lib/src sbin sbin/src share src temp tests vars
ln -s share/man man
cd $Workdir/tests
echo "$Workdir/tests is the current directory to create sub tests directories."; pwd
mkdir 00-install_annex 01-sbsrc 02-manuels 0-pre-annex.sh 1-annex.lib 2-annex.sh 3-header.inc.sh 4-list.sh 5-download.sh 6-add_sclt.sh
mkdir 7-scli.inc.sh 8-add_sclic.sh 9-add_sclipco.sh 10-add_sclipwb.sh 11-annexer.sh 12-add_appendix.sh
cd $Workdir/tests
mkdir -p 1-annex.lib 1-annex.lib/{11-findbook.sh,12-efcpb.sh,efcpc.sh,cpcleaned2bin.sh,killalldoc.sh}
mkdir -p 01-sbsrc 01-sbsrc/{011-compil2bin.sh,012-findversions.sh,013-install_datasfiles.sh,014-makeman_annex.sh}
cd $Workdir/share
echo "$Workdir/share is the current directory to create sub share directories."; pwd
mkdir man doc doc/html
mkdir -p man man/{man1,fr,fr/man1,fr.UTF8,fr.UTF8/man1,es,es/man1}
mkdir -p locale locale/{en,en/LC_MESSAGES,fr,fr/LC_MESSAGES,es,es/LC_MESSAGES}
mkdir -p addappendix addappendix/resources
cd addappendix/resources
mkdir -p lang lang/{po,po/en,po/es,po/fr}
mkdir -p man man/{man1,es,es/man1,fr,fr/man1,fr.UTF-8,fr.UTF-8/man1}
#T Breakpoint exit 0
rm $Workdir/vars/installdir.var
echo "Installdir=$Installdir" > $Workdir/vars/installdir.var
echo "Workdir=$Workdir" >> $Workdir/vars/installdir.var
echo; echo "Content of file $Workdir/vars/installdir.var"
cat $Workdir/vars/installdir.var
if [ "$1" = "Annexer" ]
then
echo; echo "First param = $1"
echo; echo "Se connecter à l'url :"
echo "https://fr.wikibooks.org/wiki/Autoéditer_un_wikilivre/Annexer_(Version_internationalisée)#src.orig_en_français"
echo "Copier les pages de codes, les coller dans un éditeur de texte et les enregistrer dans les répertoires spécialisés"
echo "Les fichiers : "
echo " sources, dans le répertoire $1/src"
echo " de données dans $1/datas"
echo " de librairies, dans $1/lib"
echo " d'exécutables de maintenance, dans $1/sbin (chmod 755 * dans sbin)"
echo " de documentation dans $1/share/doc"
echo " de manuels dans $1/share/man"
echo "Utiliser cette version imprimable : "
echo " https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/Version_imprimable"
echo " pour copier les codes bash"
echo; echo "Finalement ré-exécuter cette commande ~/Annexer/sbin/users_install_annex.sh"
fi
if [ "$1" = "Add_appendix" ]
then
echo; echo "First param = $1"
echo; echo "Login to url :"
echo "https://fr.wikibooks.org/wiki/Autoéditer_un_wikilivre/Annexer_(Version_internationalisée)#Codes_sources_(internationalized_source_code)"
echo "Copy code pages in memory, paste them in a text editor and save in the specialized directory"
echo "The files :"
echo " sources in the directory Add_appendix/src"
echo " datas in Add_appendix/datas"
echo " library in Add_appendix/lib"
echo " executable for maintenance, in Add_appendix/sbin (chmod 755 * in sbin)"
echo " documentation in Add_appendix/share/doc"
echo " manuals in Add_appendix/share/man"
echo "Use this printable version : "
echo " https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/Version_imprimable"
echo " to copy the bash code"
echo; echo "Finaly reexecute this command ~/Add_appendix/sbin/users_install_annex.sh"
fi
echo
#O Initialize $Conversions variable
Datasdir=$Workdir/datas; echo "Datadir = $Datasdir"
Conversions=$Datasdir/conversions.dat; echo "Conversion file = $Conversions"
#O Create or recreate the conversions.dat file in datas directory
if test -e $Conversions
then echo "The $Conversions file is present and will not be updated"
else
{
echo "s/%24/\$/g;s/%21/\!/g;s/%25/%/g;s/%2B/+/g;s/%3C/\\\<\;/g;s/%3E/\>\;/g;" > $Conversions
echo "s/%5C/\\\/g;s/%B0/°/g" >> $Conversions
echo "s/%E0/à/g;s/%E2/â/g" >> $Conversions
echo "s/%E8/è/g;s/%E9/é/g;s/%EA/ê/g;s/%EB/ë/g" >> $Conversions
echo "s/%EE/î/g;s/%EF/ï/g" >> $Conversions
echo "s/%F4/ô/g" >> $Conversions
echo "s/%F9/ù/g;s/%FB/û/g" >> $Conversions
echo "s/%25/%/g;" >> $Conversions
echo "s/%28/(/g;s/%29/)/g;" >> $Conversions
echo "s/%2B/+/g;" >> $Conversions
echo "s/%3A/:/g;" >> $Conversions
echo "s/%3D/=/g;" >> $Conversions
echo "s/%5B/[/g;" >> $Conversions
echo "s/%5D/]/g" >> $Conversions
echo "s/%3B/;/g;s/%2F/\//g;s/%27/'/g" >> $Conversions
echo 's/%22/"/g' >> $Conversions
echo "s/%C3%A7/ç/g;s/%E7/ç/g" >> $Conversions
echo "s/%C3%A0/à/g;s/%C3%A2/â/g" >> $Conversions
echo "s/%C3%A9/é/g;s/%C3%A8/è/g;s/%C3%AA/ê/g" >> $Conversions
echo "s/%C3%AE/î/g;s/%C3%AF/ï/g" >> $Conversions
echo "s/%C3%B4/ô/g" >> $Conversions
echo "s/%C3%B9/ù/g;s/%C3%BB/û/g" >> $Conversions
echo "s/%C2%B7/-/g;s/%C2%AB/«/g;s/%C2%BB/»/g" >> $Conversions
}
fi
echo "----"
#O Initialize $Content_cleaner variable
Content_cleaner=$Datasdir/content_cleaner.dat
echo "Content_cleaner = $Content_cleaner"
#O If not exist create the content_cleaner.dat in datas directory
if test -e $Content_cleaner
then echo "The $Content_cleaner file is present and will not be updated"
else
{
echo "s/: \[/\[/g;s/:\[/\[/g" > $Content_cleaner
echo "s/# \[/[/g;s/#\[/\[/g" >> $Content_cleaner
echo "s/* \[/[/g;s/*\[/\[/g" >> $Content_cleaner
echo "s/; /;/g" >> $Content_cleaner
}
fi
echo "----"
#O Initialize $Unrecognized_links variable
Unrecognized_links=$Datasdir/unrecognized_links.dat
echo "Unrecognized_links = $Unrecognized_links"
#O If not exist, create the file Unrecognized_links.dat
#O If not exist create the content_cleaner.dat in datas directory
if test -e $Unrecognized_links
then echo "The $Unrecognized_links file is present and will not be updated"
else
{
echo "fr.wikibooks.org: unrecognized_link.dat ignore les liens non contenus dans les pages Résumé ou Sommaire"
echo "title" > $Unrecognized_links
echo "Spécial" >> $Unrecognized_links
echo "Accueil" >> $Unrecognized_links
echo "Vitrine" >> $Unrecognized_links
echo "Tous_les_livres" >> $Unrecognized_links
echo "Rechercher_un_livre" >> $Unrecognized_links
echo "Wikijunior" >> $Unrecognized_links
echo "Portail_communautaire" >> $Unrecognized_links
echo "Le_Bistro" >> $Unrecognized_links
echo "Special:" >> $Unrecognized_links
echo "Aide:Accueil" >> $Unrecognized_links
echo "propos_de" >> $Unrecognized_links
echo "https://fr.wikibooks.org/wiki/Wikilivres" >> $Unrecognized_links
echo "Wikilivres:" >> $Unrecognized_links
echo "Catégorie:" >> $Unrecognized_links
echo "en.wikibooks.org: unrecognized_link.dat ignore the uncontained Links in the Summary or Contents pages"
echo "Main_Page" >> $Unrecognized_links
echo "Help:Contents" >> $Unrecognized_links
echo "Card_Catalog_Office" >> $Unrecognized_links
echo "Cookbook:Table_of_Contents" >> $Unrecognized_links
echo "Featured_books" >> $Unrecognized_links
echo "Using_Wikibooks" >> $Unrecognized_links
echo "Reading_room" >> $Unrecognized_links
echo "Community_Portal" >> $Unrecognized_links
echo "Reading_room/Bulletin_Board" >> $Unrecognized_links
echo "Maintenance" >> $Unrecognized_links
echo "Policies_and_guidelines" >> $Unrecognized_links
echo "Contact_us" >> $Unrecognized_links
echo "Welcome" >> $Unrecognized_links
echo "General_disclaimer" >> $Unrecognized_links
echo "Category:" >> $Unrecognized_links
}
fi
echo "----"
#O Write README in bin directory
#T echo "param 1 = $1"
if [ "$1" = "Add_appendix" ]
then
echo "*** Write bin/README file "
echo "README to use bin directory" > $Workdir/bin/README
echo "This directory is reserved for commands without a '.sh' file suffix." >> $Workdir/bin/README
echo "Commands without '.sh' are stripped of comments. They come from the" >> $Workdir/bin/README
echo " 'src' directory or from the 'tests' subdirectories." >> $Workdir/bin/README
echo "Executables commands with or without '.sh', '.x' or '.exe' suffix are" >> $Workdir/bin/README
echo " commands for maintainers in 'sbin' directory" >> $Workdir/bin/README
echo "*** Write README in Add_appendix"
echo "README file in ~/Add_apperdix" > $Workdir/README
echo "Type ~/Add_appendix/bin/annex <bookname> to update the book" >> $Workdir/README
echo "Type ~/Add_appendix/bin/addappendix <full-url-bookname> to launch app" >> $Workdir/README
fi
if [ "$1" = "Annexer" ]
then
echo "*** écriture du fichier bin/LISEZ-MOI"
echo "LISEZ-MOI pour l'utilisation du répertoire 'bin'" > $Workdir/bin/LISEZ-MOI
echo "Ce répertoire est réservé aux commandes shell sans l'extension '.sh'." >> $Workdir/bin/LISEZ-MOI
echo "Les commandes sans extension '.sh' proviennent du répertoire 'src'" >> $Workdir/bin/LISEZ-MOI
echo " ou des sous-répertoires des 'tests', dépouillées des commentaires." >> $Workdir/bin/LISEZ-MOI
echo "Les exécutables avec ou sans l'extension 'sh', '.x' ou '.exe' sont des" >> $Workdir/bin/LISEZ-MOI
echo " commandes pour les mainteneurs dans le répertoire 'sbin'" >> $Workdir/bin/LISEZ-MOI
echo "*** écriture du fichier LISEZ-MOI dans Annexer"
echo "Fichier LISEZ-MOI dans ~/Annexer" > $Workdir/LISEZ-MOI
echo "Taper ~/Annexer/bin/annex <nom-du-livre> pour mettre le livre à jour" >> $Workdir/LISEZ-MOI
echo "Taper ~/Annexer/bin/annexer <url-complète-du livre> pour lancer l'app" >> $Workdir/LISEZ-MOI
fi
#O When you run this script again, the message translation .pot files will be updated.
if test -e $Installdir/bin/header.inc; then
xgettext -L shell -o $Installdir/share/addapendix/resources/lang/po/header.inc.pot --from-code=UTF-8 $Installdir/bin/header.inc; fi
if test -e $Installdir/bin/annex; then
xgettext -L shell -o $Installdir/share/addapendix/resources/lang/po/annex.pot --from-code=UTF-8 $Installdir/bin/annex; fi
if test -e $Installdir/bin/annexer; then
xgettext -L shell -o $Installdir/share/addapendix/resources/lang/po/annexer.pot --from-code=UTF-8 $Installdir/bin/annexer; fi
if test -e $Installdir/bin/addappendix; then
xgettext -L shell -o $Installdir/share/addapendix/resources/lang/po/addappendix.pot --from-code=UTF-8 $Installdir/bin/addappendix; fi
echo "-----"
echo -e "\033[1;33mYou find Pot-files in $Workdir/share/locale for translations with 'Poedit':\033[0m"
ls -R $Workdir/share/locale
echo -e "\033[1;33mWhen you run this script again, the message translation .pot files will be updated.\033[0m"
#O Copy install program(s) to $Workdir/sbin/src
cp -u ~/Tmp/users_install_annex.sh $Workdir/sbin/src/.
cp -u ~/Tmp/users_uninstall_annex.sh $Workdir/sbin/src/.
#O Create manual of this script to $Workdir/share/man
if test -e $Workdir/sbin/src/users_install_annex.sh; then cat $Workdir/sbin/src/users_install_annex.sh | grep -e "M" | sed 's/#M //g' > $Workdir/share/addappendix/resources/man/users_install_annex_en.1; fi
#O Create the documentation of this program
if test -e $Workdir/sbin/users_install_annex.sh; then cat $Workdir/sbin/users_install_annex.sh | grep -e "#D" | grep -v "if test" | sed 's/#D//g' > $Workdir/share/doc/users_install_annex.sh.doc; fi
#O Clean tmpfiles and exit 0
if test -d ~/tmp; then rm -r ~/tmp; fi
exit 0
#O End of users_install_annex.sh
test_users_install_annex.sh
modifier- Install this executable shell code in ~/Tmp directory
#!/bin/bash
#H File : test_users_intall.sh
#H Usage : ~/Tmp/test_users_install_annex.sh [ --v | ? | Annexer | Add_appendix ]
#H
#P Creation date : 2021/07/27 by GC
#P Update and tests : 2021/07/27 by GC
#P
#D This Documentation is included in source file
#H Header of file
#O Organigram of program
#P Comments for programmers
#S Structure comments of program
#w Warnings comments in program
#O clean screen
clear
#O Version
unset $VERSION
VERSION=210728
if [ "$1" = "--v" ]; then echo "Version of test_users_install_annex.sh "$VERSION; exit 0; fi
#O If the first parameter '$1' is '?' print syntax.
if [ "$1" = "?" ]
then
echo "~/Tmp/test_users_install_annex.sh [ --v | ? | Annexer | Add_appendix ]"; exit 0
fi
#O If the first parameter '$1' is empty print syntax.
#T echo "param 0 = $0; param 1 = $1" exit 0
if [ "$0" != "~/Tmp/test_users_install_annex.sh" ] || [ -z $1 ]
then
echo "Copy test_users_install_annex.sh in ~/Tmp directory"
echo "Syntax ~/Tmp/test_users_install_annex.sh [ --v | ? | Add_appendix | Annexer ]"
fi
#T Test break exit 0
#O Test whishout firstparam
~/Tmp/users_install_annex.sh
sleep 10
#O Test --v
~/Tmp/users_install_annex.sh --v
sleep 10
#O Test ?
~/Tmp/users_install_annex.sh ?
sleep 10
#O Test Annexer
~/Tmp/users_install_annex.sh Annexer
echo "Contenu du répertoire Annexer :"
ls -al ~/Annexer
echo "Contenu des sous-répertoires"
ls -al ~/Annexer/lib ~/Annexer/lib/src ~/Annexer/sbin ~/Annexer/share/doc ~/Annexer/vars
exit 0
#O Test Add_appendix
~/Tmp/users_install_annex.sh Add_appendix
echo "Add_appendix directory :"
ls -al ~/Add_appendix
echo "Contents of sub-directories :"
ls -al ~/Add_appendix/lib ~/Add_appendix/lib/src ~/Add_appendix/sbin ~/Add_appendix/share/doc ~/Add_appendix/vars
exit 0
#O End of test_users_install_annex.sh
users_uninstall_annex.sh
modifier- Install this executable shell code in sbin ( /usr/local/sbin | ~/Add_appendix/sbin | ~/Annexer/sbin )
- Installer ce code shell exécutable dans sbin
- espagnol ; Instale este código de shell ejecutable en sbin
#!/bin/bash
#H File : users_uninstall_annex.sh
#H Origine : https://fr.wikibooks.org/wiki/Auto-%C3%A9diter_un_wikilivre/Annexer_(Version_internationalis%C3%A9e)/users_install_annex.sh#users_install_annex.sh
#H Codage UTF-8 without BOM
#H
#D users_uninstall_annex.sh documentation
#D --------------------------------------
#D This program uninstalls the directory structure of the annex
#D program of wikibooks.
#D this program use $Workdir/vars/installdir.var
#D Syntax : ~/Tmp/users_uninstall_annex.sh [OPTIONS]
#D OPTIONS : --v, ?, Annexer, Add_appendix
#D
#D To re-install see users_uninstall_annex.sh
#D
#P Creation date : 2021/07/22 by GC
#P Update and tests : 2021/07/22 by GC
#P
#D This Documentation is included in source file
#H Header of file
#O Organigram of program
#P Comments for programmers
#S Structure comments of program
#w Warnings comments in program
#O clean screen
clear
#O Version
unset $VERSION
VERSION=210726
if [ "$1" = "--v" ]; then echo "Version of users_uninstall_annex.sh "$VERSION; exit 0; fi
#O If the first parameter '$1' is '?' print doc or syntax.
if [ "$1" = "?" ]
then
if test -z $Workdir/doc/users_uninstall_annex.sh.doc
then cat $Workdir/doc/users_install_annex.sh.doc
else echo "Syntax : ~/Tmp/users_uninstall_annex.sh [ --v | ? | Add_appendix | Annexer ]"
fi
exit 0
fi
#O If the first parameter '$1' is empty print syntax.
if [ "$0" != "~/Tmp/users_uninstall_annex.sh" ] || [ -z $1 ]
then
echo "Copy users_uninstall_annex.sh in ~/Tmp directory"
echo "Syntax ~/Tmp/users_uninstall_annex.sh [ --v | ? | Add_appendix | Annexer ]"; exit 0
fi
#O Include installdir.var
if [ "$1" == "Annexer" ]; then source ~/Annexer/vars/installdir.var
elif [ "$1" == "Add_appendix" ]; then source ~/Add_apendix/vars/installdir.var
else echo "installdir.var is not found. see syntax of users_uninstall_annex.sh program."; exit -1
fi
#O Uninstall user $Installdir directory
if test -d $Installdir; then rm -R $Installdir; else echo "$Installdir not found"; fi
#O End of users_uninstall_annex.sh
test_users_uninstall_annex.sh
modifier- Install this executable shell code in tests directory or in ~/Tmp
uploadfromTmp.sh
modifier- Install this executable script in tests directory 00-install_annex/.
#!/bin/bash
#H File uploadfromTmp.sh
#H This script import modifieds files from ~/Tmp
cp -u ~/Tmp/*install_annex.sh .
cp -u ~/Tmp/*unintall_annex.sh .
ls -al .
# end of file importfromTmp.sh
Add appendix
annex.lib, (findbook), (ecfpb), (ecfpc)
Éditeur : Goelette Cardabela
annex.lib
modifierLa fontion findbook est validée, les fonctions ecfp* sont à réviser. 17 mai 2021 à 11:38 (CEST) vβ 210514
- Si vous désirez éprouver ces codes, vous pouvez les installer dans les répertoires ~/Add_appendix/tests/1-annex.lib/<sous-répertoires : 11-findbook.sh/, 12-ecfpb.sh/, 13-ecfpc.sh/
- Cette librairie est à mettre à jour dans les répertoires :
~/Annexer/lib/
et/ou
~/Add_appendix/lib/
et/ou
/usr/local/lib/
Tester le code source de la fonction findbook avec test_findbook.bash
Tester le code source de la fonction ecfpb avec ecfpb.sh (extract contents from printable book)
Tester le code source de la fonction ecfpc avec ecfpc.sh (extract contents from compiled book)
Tester le code source de la fonction cpcleaned2bin avec test_cpcleaned2bin
Tester le code source des fonctions de killalldoc avec test_killalldoc.bash
#!bin/bash
#H File : findbook.sh, source for test the findbook function to insert in
#H annex.lib file. Copy this content in file $Workdir/lib/src/findbook.sh
#H Last Update on fr:Wikibooks : 2021-04-26 by GC
#H Tested : by GC 2021-04-26
#H Updated : 2021-04-28 by user GC For layout
#H Revision: by JPL 2021-10-06 mise en commentaire de .gettext lestraductions ne sont pas encore prévues pour ce fichier.
#H
#w Attention, the character ';' at the end of the line is equal to '\' before NL
#w if the following line is a comment, it will concatenate it at the end of
#w the previous line and the command with grep -v deletes the whole line
VERSION=211019
#. gettext.sh
function findbook ()
{
if [ "$1" = "--v" ]; then echo "findbook version : $VERSION";return 0;fi
if [ -z $1 ]; then
echo " -- Suffix availables in function findbook() version $VERSION : "
echo " <book-name>/Contenus or Contenu or Contents, "
echo " <book-name>/Sommaire or Summary, "
echo " Compilations/<book-name> or Collections/<book-name>. "
fi
echo $1 | awk -F "/" '{for (i=1;i<=NF;i++) print $i}' > bookname.txt
cat bookname.txt | grep wikibooks > sitename.txt
read Site < sitename.txt
wc -l bookname.txt | cut -d" " -f1 > N.txt; read N < N.txt
let n=N
let local m=N-1
echo $1 | cut -d '/' -f5-$m > mwbookurl.txt
read "MWbookurl" < mwbookurl.txt
#let n-=1
echo $1 | cut -d '/' -f$n > lastfield.txt
read Lastfield < lastfield.txt
unset Suffix
if [ "$Lastfield" = "Contenus" ] || [ "$Lastfield" = "Contenu" ] || [ "$Lastfield" = "Contents" ] || [ "$Lastfield" = "Content" ]
then Suffix=contents
fi
if [ "$Lastfield" = "Sommaire" ] || [ "$Lastfield" = "Sommaire_du_livre" ] || [ "$Lastfield" = "Summary" ];
then Suffix=summary
else Bookname=$Lastfield
fi
if [ "$Suffix" = "contents" ] || [ "$Suffix" = "summary" ]
then
let local m=N-1
echo $1 | cut -d '/' -f1-$m > bookurl.txt
read Bookfullurl < bookurl.txt
fi
let n-=1; echo $1 | cut -d '/' -f$n > penultimatefield.txt
read Penultimatefield < penultimatefield.txt
if [ "$Penultimatefield" = "Compilations" ] \
|| [ "$Penultimatefield" = "Collections" ] \
|| [ "$Penultimatefield" = "Wikilivres:Compilations" ] \
|| [ "$Penultimatefield" = "Wikibooks:Collections" ]
then
Suffix=compiled
else Bookname=$Penultimatefield
fi
rm bookname.txt sitename.txt lastfield.txt penultimatefield.txt N.txt
}
#!/bin/bash
#H File : ecfpb.sh, source for test the function ecfpb to insert in
#H annex.lib file. Copy this content in file $Workdir/lib/src/ecfpb.sh
#H Last Update on fr:Wikibooks : 2021-04-28 by GC
#H Tested : by GC 2021-04-28
#H Updated : 2021-04-26 by user GC For layout
#H
#w Attention, the character ';' at the end of the line is equal to '\' before NL
#w if the following line is a comment, it will concatenate it at the end of
#w the previous line and the command with grep -v deletes the whole line
VERSION=210429
function ecfpb ()
{
source $HOME/Add_appendix/datas/installdir.var
if [ "$1" = "--v" ]; then echo "ecfpb version : $VERSION";return 0;fi
if [ "$2" = "--t" ]; then
source ~/Add_appendix/tests/1-annex.lib/11-findbook.sh/findbook.sh
echo "Finbook in tests version"
else source $Installdir/lib/annex.lib
fi
findbook $1
Projectdir=$Workdir/$Bookname
if [ -n $Site ] && [ "$Suffix" = "contents" ] || [ "$Suffix" = "Summary" ]
then
echo "url is a printable version."
#wget https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/Contenu
wget -Nq $1
#cat Contenu | grep /wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/ | grep -v -i Contenu > $Lastfield.txt
cat $Lastfield | grep /$MWbookurl/ | grep -v -i $Lastfield > beforelastfield.txt
cat beforelastfield.txt | awk -F "/" '{for (i=1;i<=NF;i++) print $i}' > fieldlist.txt
cat fieldlist.txt | sed -e "s/\"/\n/g" | sed -e "s/ /\n/g" > fieldlist2.txt
wc -l fieldlist.txt | cut -d" " -f1 > N.txt; read N < N.txt
let n=N; i=0 ; j=0; article=1; flag0=0; #flag1=1
#rm article.*.txt
while read line
do
let i+=1;
if [ "$line" = "wiki" ]; then echo -n "[[$MWbookurl/" > article.$article.txt; let flag0=1; fi
if [ $flag0 = "1" ] && [ "$line" = "$Bookname" ]; then let j=i+1; fi
if [ $flag0 = "1" ] && [ "$i" = "$j" ]; then echo "$line]]" >> article.$article.txt; let article+=1; let flag0=0; fi
done < fieldlist2.txt
fi
let i=1; #rm $Bookname.$Suffix
echo "[[$MWbookurl]]" > $Bookname.$Suffix
while (( i < 10 ))
do
#echo "article.$i.txt ="; cat article.$i.txt
if [ -r article.$i.txt ]; then cat article.$i.txt >> $Bookname.$Suffix; let i+=1 ; else break; fi
done
if test -n $Projectdir && ! test -d $Projectdir; then mkdir "$Projectdir"; fi
if test -d $Projectdir
then
echo "Project directory = $Projectdir"
if [ -r "$Projectdir/$Bookname.$Suffix" ]
then
echo
echo "Bookname.Suffix Contents :"; cat $Bookname.$Suffix; echo
#echo "Bookname.Suffix = $Bookname.$Suffix"
echo -n -e "$(gettext ' \033[31mUpdate Bookname.Suffix ? y/n :\033[0m ')"; read -s -n1 -p "inkey" Inkey; echo;
if [ "$Inkey" = "y" ]
then chmod 755 "$Projectdir/$Bookname.$Suffix"; cp "$Bookname.$Suffix" $Projectdir/.; chmod 555 "$Projectdir/$Bookname.$Suffix";
else echo "$(gettext ' file is not updated ! ... Go forward ... ')"
fi
else cp "$Bookname.$Suffix" $Projectdir/.
fi
fi
}
# End function ecfpb ()
#!/bin/bash
#H File : ecfpc.sh, source for test the function ecfpc to insert in
#H annex.lib file. Copy this content in file $Workdir/lib/src/ecfpc.sh
#H Last Update on fr:Wikibooks : 2021-04-28 by GC
#H Tested : by GC 2021-04-28
#H Updated : 2021-04-26 by user GC For layout
#H
#w Attention, the character ';' at the end of the line is equal to '\' before NL
#w if the following line is a comment, it will concatenate it at the end of
#w the previous line and the command with grep -v deletes the whole line
VERSION=210429
function ecfpc ()
{
source $HOME/Add_appendix/datas/installdir.var
if [ "$1" = "--v" ]; then echo "* ecfpc version : $VERSION";return 0;fi
if [ "$2" = "--t" ]; then
source ~/Add_appendix/tests/1-annex.lib/11-findbook.sh/findbook.sh
echo "* Finbook in tests version"
else source $Installdir/lib/annex.lib
fi
findbook $1
#if [ "$2" = "--t" ]; then
echo "* Site name :"$Site
echo "* Bookname : "$Bookname
echo "* Suffix : "$Suffix
echo "* Bookname.Suffix = "$Bookname.$Suffix
echo "*----"; echo
#fi
echo "* Bookname : "$Bookname
Projectdir=~/Add_appendix/$Bookname
echo "* Project directory = $Projectdir"
if test -d $Projectdir; then echo "* Project directory exist"; else mkdir $Projectdir; echo "* $Projectdir is created"; fi
if [ -n $Site ] && [ "$Suffix" = "compiled" ] || [ "$Suffix" = "Collection" ]
then
echo "* url is a compiled version (Collection)."
#wget https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel
#wget -Nq $1
rm lastfield.txt
cat $Bookname | grep /$Bookname/ > lastfield.txt
cat lastfield.txt | awk -F " " '{for (i=1;i<=NF;i++) print $i}' | grep "href=" > fieldlist.txt
cat fieldlist.txt | sed -e "s/href=\"\/wiki\//[[/g" | sed -e "s/\"/]]/g" > fieldlist2.txt
cat fieldlist2.txt | sed -f ~/Add_appendix/datas/conversions.dat > $Bookname.$Suffix
fi
if test -d $Projectdir
then
if [ -r "$Projectdir/$Bookname.$Suffix" ] && [ -s "$Bookname.$Suffix" ]
then
echo -n -e "$(gettext ' \033[31mUpdate $Bookname.$Suffix ? y/n :\033[0m ')"; read -s -n1 -p "inkey : " Inkey;echo " ";
if [ "$Inkey" = "y" ];
then chmod 755 "$Projectdir/$Bookname.$Suffix"; cp "$Bookname.$Suffix" $Projectdir/.; chmod 555 "$Projectdir/$Bookname.$Suffix";
else echo "*$(gettext ' file is not updated ! ... Continue ... ')"
fi
elif [ -s "$Bookname.$Suffix" ]; then cp $Bookname.$Suffix $Projectdir/.
fi
fi
}
#!/bin/bash
#H File cpcleaned2bin.sh cpcleand2bin in annex.lib
#H Bindir Resourcesdir Srcdir Verbose variables are defined in the calling program
VERSION=211020
function cpcleaned2bin ()
{
if [ "$1" = "--v" ]; then echo "cpcleaned2bin version : $VERSION";return 0;fi
mkdir -p ./tmp
if test -e $Srcdir/$1; then echo; else echo "$Srcdir/$1 not found by function cpcleaned2bin."; return -1;fi
awk '{
if ($1=="#D" || $1=="#M" || $1=="#O" || $1=="#P" || $1=="#T") {;} # do not replace with an empty line
else {print $0}
}' $Srcdir/$1 > ./tmp/$1.cleaned-1
cat ./tmp/$1.cleaned-1 | sed "s/eval_gettext /echo \$/g" | sed "s/; echo//g" > ./tmp/$1.cleaned-2
cat ./tmp/$1.cleaned-2 | sed "s/\"\$(gettext '/\$\"/g" | sed "s/' )//g" | sed "s/')//g" > ./tmp/$1.cleaned-3
echo $1 | sed "s/.sh//g" | sed "s/.bash//g" > ./tmp/first.txt
read First < ./tmp/first.txt
cat ./tmp/$1.cleaned-3 > $Bindir/$First
if echo $Bindir/$First | grep ".inc"; then chmod 644 $Bindir/$First; else chmod 755 $Bindir/$First; fi
if cat $Bindir/$First | grep -e '$\"'
then
xgettext -L shell -o $Resourcesdir/lang/po/$First.pot --from-code=UTF-8 $Bindir/$First
if test -z $Resourcesdir/lang/po/fr/$First.po
then
cp $Resourcesdir/lang/po/$First.pot $Resourcesdir/lang/po/fr/$First.po
else
msgmerge --update $Resourcesdir/lang/po/fr/$First.po $Resourcesdir/lang/po/$First.pot
fi
msgfmt $Resourcesdir/lang/po/fr/$First.po -o $Resourcesdir/lang/po/fr/$First.mo
echo -e "\033[1;33m### Only if you are edit and update $First.po with Poedit: ###\033[0m"
echo "copy $Resourcesdir/lang/po/fr/$First.mo to /usr/share/locale/fr/LC_MESSAGES/$First.mo"
if test -z $Resourcesdir/lang/po/es/$First.po
then
cp $Resourcesdir/lang/po/$First.pot $Resourcesdir/lang/po/es/$First.po
else
msgmerge --update $Resourcesdir/lang/po/es/$First.po $Resourcesdir/lang/po/$First.pot
fi
msgfmt $Resourcesdir/lang/po/es/$First.po -o $Resourcesdir/lang/po/es/$First.mo
echo -e "\033[1;33m### Only if you are edit and update $First.po with Poedit: ###\033[0m"
echo "copy $Resourcesdir/lang/po/es/$First.mo to /usr/share/locale/es/LC_MESSAGES/$First.mo"
fi
rm -r ./tmp
if [ "$Verbose" = "true" ];then echo "$Bindir/$First is updated:"; ls -l $Bindir/$First; fi
}
#!/bin/bash
#H File killalldoc.sh
VERSION=211019
if [ "$1" = "--v" ];then echo "killalldoc.sh version: $VERSION"; exit 0;fi
function killOPT ()
{
if test -z $1; then return -1; fi
awk '{
if ($1=="#O" || $1=="#P" || $1=="#T") {print " "} # replace with blank line
else {print $0}
}' $1
}
function killDMOPT ()
{
if test -z $1; then return -1; fi
awk '{
if ($1=="#D" || $1=="#M" || $1=="#O" || $1=="#P" || $1=="#T") {print " "} # replace with blank line
else {print $0}
}' $1
}
function killALLDOC ()
{
if test -z $1; then return -1; fi
awk '{
if ($1=="#D" || $1=="#M" || $1=="#O" || $1=="#P" || $1=="#T") {;} # do not replace with an empty line
else {print $0}
}' $1
}
Fonction findbook
modifierβ-210514 - Tester le code source de la fonction findbook avec le programme test_findbook.bash (extrait les lien (urls) du Sommaire, du Contenu ou de la Compilation pour préparer la création de l'annexe des livres)
Fonction ecfpb.sh
modifierβ-210409 - Tester le code source de la fonction ecfpb avec test_ecfpb.bash] (extrait le contenu des livres imprimables)
Fonction ecfpc.sh
modifier β-210415 - Tester le code source de la fonction ecfpc function with test_ecfpc.bash (extrait le contenu des livres compilés)
Add appendix
pre-annex.sh
Éditeur : Goelette Cardabela
addappendix + annexer
modifierL'internationalisation des messages est faite pour les deux scripts vβ 210516
add_appendix.sh
modifieraddappendix.sh doit être converti en add_appendix.sh
- français: add_appendix est le programme qui lance tout le programme de création de l'annexe des livres de wikibooks
- Il fait appel au programme pre-annex pour créer les répertoire et condition d'exécution du script annex
- anglais: add_appendix is the program that launches the entire program for creating the appendix of wikibooks books
- espagnol: add_appendix es el programa que lanza todo el programa para crear el apéndice de libros de wikilibros
#!/bin/bash
#H Header Documentation of the add_appendix.sh file
#H File add_appendix.sh
#H Syntax: add_appendix.sh <full url of wiki-book> [ ? ] [ -v ] [ -pb | -pc ]
#H the syntax is necessary for the call of the command 'annex [ <book-name> || ? ] [ -v ] [ -pb || -pc ]'
#H ? to print syntax
#H -v verbose mode
#H -pb for illustration uploaded from wikibooks
#H -pc for illustration uploaded from commons
#H
#D Documentation of add_appendix.sh file
#D This script is the master program for creating the wiki-book appendix.
#D The firs parameter must be the full url to wikibooks book.
#D Syntax: add_appendix.sh <full url of wiki-book> [Options]
#D OPtions:
#D ? to print syntax
#D -v verbose mode
#D -pb for illustration uploaded from wikibooks
#D -pc for illustration uploaded from commons
#D Subroutine scripts for 'add_appendix.sh' and 'add_appendix.sh' in order of execution:
#D Each of these scripts can be tested separately.
#D pre-annex: create the directory structure of the book
#D annex: is the master program which creates the appendix of the wiki-book
#D header.inc: this file is included in all subroutine
#D list: list files to download in project
#D download: download listed files
#D add_sclt en_sclt.inc fr_sclt.inc: create chapter source, contributor, licence of articles
#D add_sclic scli.inc en_sclic.inc: create standard illustration chapter src, contrib,lic
#D add_sclipco en_sclipco.inc fr_sclipco.inc: create standard illustration chapter with src on commons
#D add_sclipwb en_sclipwb.inc fr_sclipwb.inc: create standard illustration chapter with src on wikibooks
#D
VERSION=220216
TEXTDOMAIN=add_appendix
TEXTDOMAINDIR="~/Add_appendix/share/locale"
export TEXTDOMAINDIR
#P . gettext for translation
. gettext.sh
#O If not parameter
if test -z $1
then
echo $"No parameter. < add_appendix | annexer > [ <full url of wiki-book> | ? ]"
exit -1
fi
if [ "$1" = "?" ]
then
echo $"Syntax: < add_appendix | annexer > [ <full url of wiki-book> | ? ] [ -v ] [ -pb | -pc ]"
exit 0
fi
#O If the command parameter is 'add_appendix' then working directory is 'Add_appendix'
echo $0 | grep add_appendix > command.txt
if test -s command.txt
then
Workdir=~/Add_appendix
rm command.txt > /dev/null
echo $0 | grep annexer > command.txt
#O Elif the command parameter is 'annexer' then working directory is 'Annexer'
elif test -s command.txt
then
Workdir=~/Annexer
rm command.txt > /dev/null
#O Else print Working directory is not found. Exit from script.
else
echo $"Working directory is not found. Exit from script."
exit -1
#O End if
fi
#O The books directory is '$Workdir/books' create it if not exist
if test -d $Workdir/books
then
echo $"Working directory found: $Workdir"
echo $"script version: $VERSION"
else
echo $"$Workdir/books is not found"
echo $"$Workdir/books creation"
install -d $Workdir/books
fi
#O If the file installdir.var not exist, create it.
if test -e $Workdir/vars/installdir.var
then
echo $"OK installdir.var exist"
else
install -d $Workdir/books $Workdir/vars
fi
#O Initialize installdir.var
echo "Workdir=$Workdir" > $Workdir/vars/installdir.var
if test -d $Workdir/bin
then
echo "$Workdir/bin exist then Installdir=$Workdir"
Installdir=$Workdir
echo "Installdir=$Workdir" >> $Workdir/vars/installdir.var
Bindir=$Workdir/bin
echo "Bindir=$Bindir" >> $Workdir/vars/installdir.var
Booksdir=$Workdir/books
echo "Booksdir=$Workdir/books" >> $Workdir/vars/installdir.var
Datasdir=$Workdir/datas
echo "Datasdir=$Workdir/datas" >> $Workdir/vars/installdir.var
Libdir=$Workdir/lib
echo "Libdir=$Workdir/lib" >> $Workdir/vars/installdir.var
Sharedir=$Workdir/share
echo "Sharedir=$Workdir/share" >> $Workdir/vars/installdir.var
Srcdir=$Workdir/src
echo "Srcdir=$Workdir/src" >> $Workdir/vars/installdir.var
Testdir=$Workdir/tests
echo "Testsdir=$Workdir/tests" >> $Workdir/vars/installdir.var
Varsdir=$Workdir/vars
echo "Varsdir=$Workdir/vars" >> $Workdir/vars/installdir.var
else
echo "$Workdir/bin does not exist then Installdir=/usr/local"
Installdir=/usr/local
echo "Installdir=/usr/local" >> $Workdir/vars/installdir.var
Bindir=/usr/local/bin
echo "Bindir=$Bindir" >> $Workdir/vars/installdir.var
Booksdir=$Workdir/books
echo "Booksdir=$Workdir/books" >> $Workdir/vars/installdir.var
Datasdir=/usr/local/datas
echo "Datasdir=/usr/local/datas" >> $Workdir/vars/installdir.var
Libdir=/usr/local/lib
echo "Libdir=/usr/local/lib" >> $Workdir/vars/installdir.var
Sharedir=/usr/local/share
echo "$Sharedir=/usr/local/share" >> $Workdir/vars/installdir.var
Srcdir=/usr/local/src/Add_appendix
echo "Srcdir=/usr/local/src/Add_appendix" >> $Workdir/vars/installdir.var
Varsdir=$Workdir/vars
echo "Varsdir=$Workdir/vars" >> $Workdir/vars/installdir.var
fi
#T test break cat $Workdir/vars/installdir.var; exit 0
#O Update variables from installdir.var if necessary
# source $HOME/Add_appendix/vars/installdir.var
#O Test if first parameter is https and wikibooks site
rm -f *.txt > /dev/null
echo $1 | grep -e "wikibooks.org" > wikibooks-site.txt
echo -n "wikibooks-site.txt: "
cat wikibooks-site.txt
echo
if test -s wikibooks-site.txt
then
echo $"OK to continue with book site validation"
rm -f wikibooks-site.txt
else
echo $"First parameter entry is not a wikibooks site"
exit -1
fi
#T test break exit 0
#O Test if the url content a book file
rm -f valid-book-site.txt > /dev/null
echo $1 | grep "Collection\|Compilation\|Content\|Contenu\|Sommaire\|Summary" > valid-book-site.txt
if test -s valid-book-site.txt
then
echo $"OK to continue with pre-annex"
rm -f valid-book-site.txt
else
echo $"First parameter entry is not a valid book site"
exit -1
fi
#O Valider les variables de mode bavard et Bindir Report-silent
if [ "$2" = "-v" ] || [ "$3" = "-v" ]
then Verbose="true"
else
Verbose=$"false"
echo $"Verbose mode = $Verbose"
fi
#P If not exist $Workdir/temp/Report-silent-mode create it
if test -d $Workdir/temp/Report-silent-mode
then echo "$Workdir/temp/Report-silent-mode exist" > /dev/null
else install -d $Workdir/temp/Report-silent-mode; fi
#P Running pre-annex
echo
echo
echo $"*** Continue with pre-annex ***"
if [ $Verbose = "true" ]
then
echo $"Verbose mode = true ? :$Verbose"
$Bindir/pre-annex $1 $2 $3
else
echo $"Verbose mode = false ? $Verbose"
$Bindir/pre-annex $1 > $Workdir/temp/Report-silent-mode/pre-annex-cmd.txt
fi
#P Test if $TEXTDOMAIN=add_appendix and restore if not
if [ $TEXTDOMAIN != "add_appendix" ]
then TEXTDOMAIN=add_appendix
fi
#P Return value from pre-annex
Return=$?
if [ $Return -gt '0' ]
then
echo "$(gettext ' Error in shell module pre-annex in silent mode. See $Workdir/temp/Report-silent-mode/pre-annex-cmd.txt ')"
exit 1
fi
#P Running annex
echo; echo; echo "*** Continue with annex and sub-annex scripts ***"
#T echo "$Varsdir +++ $Libdir"
source $Libdir/annex.lib
findbook $1
echo "Bookname : $Bookname"
#T exit 0
if [ "$Verbose" = "true" ]
then
$Bindir/annex $Bookname $2 $3
else
$Bindir/annex $Bookname $2 $3 > $Workdir/temp/Report-silent-mode/annex-cmd.txt
fi
if [ $TEXTDOMAIN != "add_appendix" ]
then TEXTDOMAIN=add_appendix
fi
#P Return value from annex
Return=$?
if [ $Return -gt '0' ]
then
echo "$(gettext ' Error in shell module annex in silent mode. See $Workdir/temp/Report-silent-mode/annex-cmd.txt ')"
exit 1
fi
exit 0
#O End of add_appendix.sh
annexer.sh
modifier- annexer est le programme qui lance tout le programme de création de l'annexe des livres de wikibooks
- annexer permet de créer la documentation en français, vérifie la validité de la ligne de commandes et fait appel à add_appendix.
- les traductions de add_appendix en français font de annexer un programme en langue française
#!/bin/bash
#H Documentation de l'enête du fichier annexer.sh
#H File annexer.sh
#H syntaxe annexer <adresse url complète du livre> [ ? ] [ -v ] [ -pb | -pc ]
#H la syntaxe est nessessitée pour l'appel de:
#H < add_appendix | annexer > [ <full url of wiki-book> | ? ] [ -v ] [ -pb | -pc ]
#H annex [ <book-name> || ? ] [ -v ] [ -pb || -pc ]
#H OPtions:
#H ? pour demander la syntaxe
#H -v est le mode bavard
#H -pb pour illustration téléchargées sur wikilivres
#H -pc pour illustration téléchargées sur commons
#H
#D Documentation du fichier annexer.sh
#D Ce scipt est le programme maître pour créer l'annexe des wiki-livres.
#D Le premier paramètre doit être l'adresse, (l'url) complète du livre.
#D Syntaxe: annexer <adresse url complète du livre> [Options]
#D OPtions:
#D ? pour demander la syntaxe
#D -v est le mode bavard de l'exécution des scripts enfants
#D -pb pour illustration téléchargées sur wikilivres
#D -pc pour illustration téléchargées sur commons
#D Scripts sous-programmes pour 'annexer' et 'add_appendix' dans l'ordre d'exécution:
#D Chacun de ces scripts est éprouvable séparément
#D pre-annex: crée la structure des répertoires du livre
#D annex: est le programme maître qui crée l'annexe du wiki-livre
#D header.inc:
#D list
#D download
#D add_sclt en_sclt.inc fr_sclt.inc
#D add_sclic scli.inc en_sclic.inc
#D add_sclipco en_sclipco.inc fr_sclipco.inc
#D add_sclipwb en_sclipwb.inc fr_sclipwb.inc
#D
VERSION=220304
TEXTDOMAIN=annexer
TEXTDOMAINDIR="/usr/share/locale"
export TEXTDOMAINDIR
#O Utiliser le script de add_appendix commun aux deux versions avec la même traduction
#D L'installation commune dans /usr/local ne crée pas de répertoire bin dans le répertoire de travail
#D Ceci est mis à profit pour trouver les répertoire de travail et les binaires appropriés.
#D Lorsque l'installation est commune le répertoire de travail est toujours $HOME/Add_appendix
if test -e $HOME/Annexer/bin/add_appendix; then $HOME/Annexer/bin/add_appendix $1 $2 $3
elif test -e /usr/local/bin/add_appendix; then /usr/local/bin/add_appendix $1 $2 $3
else echo $"the script add_appendix is not found: in Annexer/bin nor in /usr/local/bin, exit"; exit -1
fi
#O End of annexer.sh
pre-annex.sh
modifierL'internationalisation des messages est faite vβ 210516
pre-annex.sh
modifier- Documentation
#D pre-annex program documentation #D This program use findbook to analyse the link to the book #D If the result is correct, create the project directory, pre-create the #D file project.suffix and create a local html book in project directory #D if the suffix is 'content' or 'summary', else for 'collection' link create #D a local collection file #D If everything is correct, edit the local book contents file or the local #D collection file to check and possibly update the file manually. Then copy #D the content to the project.suffix file if necessary #D #F Documentation du programme pre-annex #F Ce programme pré-annexe la construction de l'annexe du livre #F Si ce programme s'est bien exécuté, le répertoire de projet aura été créé #F - le fichier projet.suffixe et un fichier html local auront été créés dans #F - le répertoire du projet #F Il est proposé d'éditer la page 'Contenu' ou 'Sommaire' ou de 'Compilation' #F afin d'être éventuellement recopiée manuellement dans le fichier #F projet.suffixe #F
- Program pre-annex code
#!/bin/bash
#H pre-annex header documentation
#H ------------------------------
#H Workdir is ~/Add_appendix or ~/Annexer
#H Source file : Workdir/src/pre-annex.sh
#H Executable file : Workdir/bin/pre-annex
#H Syntax : pre-annex [ Full-url-of-book || --v ]
#H Example : ./pre-annex.sh https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel
#P https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel
#P https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel
#H Created : 12/05/2021 by GC
#H Last Update on fr:Wikibooks :
#H Tested : by GC 12/05/2021
#H Updated : by user GC For layout
#H
#D pre-annex program documentation
#D -------------------------------
#D This program use findbook to analyse the link to the book
#D If the result is correct, create the project directory, pre-create the
#D file project.suffix and create a local html book in project directory.
#D If everything is correct, edit a collection file or a book contents file
#D to manually copy the content to the project/project.suffix file
#D
#w pre-annex wanings documentation
#w -------------------------------
#w Install Add_appendix or Annexer with the program executable users_install_annex.sh
#W https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/users_install_annex.sh
#w Attention, the character ';' at the end of the line is equal to '\' before NL
#w if the following line is a comment, it will concatenate it at the end of
#w the previous line and the command with grep -v deletes the whole line
#w
#O pre-annex organizational chart documentation
#O --------------------------------------------
#O pre-annex programmers documentation
#O ------------------------------------
VERSION=211005
#O If first parameter is "--v", print pre-annex version
if [ "$1" = "--v" ]; then echo " pre-annex version $VERSION"; exit 0; fi
#O If first parameter is empty, print the syntax
if test -z $1
then
echo "Syntax : pre-annex [ --v | Full-url-of-book ] [ --t ] (with bin directory in environment variables)"
echo " Example in tests directory tests/pre-annex.sh/ :"
echo " ./pre-annex.sh https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel --t"
exit -1
fi
#O Else, the first parameter is not empty
#P Include install variables
pwd > pwd.txt
if cat pwd.txt | grep Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
source $Workdir/vars/installdir.var
if [ "$1" = "--t" ] || [ "$2" = "--t" ] ; then echo; echo "Global install variables :"; cat $Workdir/vars/installdir.var; fi
#T Test break exit 0
#O Find function findbook
Libdir=$Workdir/lib
Booksdir=$Workdir/books
if test -e $Libdir/annex.lib; then source $Libdir/annex.lib; elif test -e $Libdir/src/findbook.sh; \
then source $Libdir/src/findbook.sh; else echo "Function findbook not found"; exit -1; fi
#O Find book parameter
findbook $1
#O If option --t, print the book parameter
if [ "$2" = "--t" ]
then
echo
echo -n "--t : "; findbook --v
echo "--t : Global variables after findbook execution : "
echo "--t : Site name :"$Site
echo "--t : Bookname : "$Bookname
echo "--t : Suffix : "$Suffix
echo "--t : Bookname.Suffix = "$Bookname.$Suffix
if [ "$Suffix" = "compiled" ]
then
if test -n $MWcompilurl; then
echo "Compil mw url : "--t : $MWcompilurl
echo -n "--t : Compil mw syntax = [[ "$MWcompilurl; echo " ]] on $Site"
echo "--t : Compil full url : "$Compilfullurl
fi
else
if test -n $MWbookurl; then
echo "--t : mw book url = "$MWbookurl
echo -n "--t : mw book syntax = [[ "$MWbookurl/$Bookname; echo " ]] on $Site"
echo "--t : Book full url = "$Bookfullurl
fi
fi
echo " ----"
fi
#O If all parameter are found carry continue otherwise print the error
if ! test $Site || ! test $Bookname || ! test $Suffix
then
if ! test $Site; then echo "Site not found";fi
if ! test $Bookname; then echo "Bookname not found";fi
if ! test $Suffix; then echo "Suffix not found";fi
fi
#O Create the project directory
Projectdir=$Booksdir/$Bookname
if ! test -d "$Projectdir"; then mkdir $Projectdir; fi
#O Create the file bookname.suffix
if test -e $Projectdir/$Bookname.$Suffix
then
echo "$Bookname.$Suffix : "
cat $Projectdir/$Bookname.$Suffix
echo -e "\033[47m\033[1;30m Want you update $Projectdir/$Bookname.$Suffix ? \033[0m"
read -s -n1 -p "inkey y/n : " Inkey; echo $Inkey
if [ "$Inkey" = "y" ]
then
echo; chmod 755 $Projectdir/$Bookname.$Suffix
if [ "$Suffix" = "compiled" ]
then
if test -n $MWcompilurl; then echo "[[$MWcompilurl]]" > $Projectdir/$Bookname.$Suffix; fi
else
if test -n $MWbookurl; then echo "[[$MWbookurl]]" > $Projectdir/$Bookname.$Suffix; fi
fi
fi
else
if [ "$Suffix" = "compiled" ]
then
if test -n $MWcompilurl; then echo "[[$MWcompilurl]]" > $Projectdir/$Bookname.$Suffix; fi
else
if test -n $MWbookurl; then echo "[[$MWbookurl]]" > $Projectdir/$Bookname.$Suffix; fi
fi
fi
#O Download the book in html form
#O Télécharger le site récursivement avec une profondeur infinie ( -linf ), \
#O convertit les liens pour une consultation en local ( -k ), \
#O rapatrie tous les fichiers nécessaires à l'affichage convenable d'une page HTML ( -p ) \
#O et renomme toutes les pages HTML avec l'extension .html ( -E )
if ! test -d "$Workdir/temp"; then mkdir $Workdir/temp; fi
cd $Projectdir
if test -n "$Bookfullurl"; then echo "Dowload $Bookfullurl"; wget -r -linf -k -p -E "$Bookfullurl" -o $Workdir/temp/wget-log-télécharger.txt
elif test -n "$Compilfullurl"; then echo "Dowload $Compilfullurl"; wget -r -linf -k -p -E "$Compilfullurl" -o $Workdir/temp/wget-log-télécharger.txt
else echo " book full url not found to download"
fi
#O If everything is correct, edit a collection file or a book contents file
#O to manually copy the content to the project/project.suffix file
if test $Site || test $Bookname || test $Suffix
then
echo -e "\033[31mAttention : See and possibly complete the $Bookname.$Suffix "; echo -e "Edit and copy the wiki-code in $Workdir/$Bookname/$Bookname.$Suffix :\033[0m"
echo -e "\033[47m\033[1;30m Go forward to edit the book and copy wiki-code to $Bookname.$Suffix ? \033[0m"
read -s -n1 -p "inkey y/n" Inkey; echo "$Inkey"
if [ "$Inkey" = 'y' ]
then
gedit $Workdir/$Book/$Bookname/$Bookname.$Suffix&
xdg-open $1
fi
else
echo -e "\033[31m Non-compliant result \033[0m"
fi
#T xdg-open file:///home/jpl/Annexer/Faire_fleurir_le_sel/fr.wikibooks.org/wiki/Faire_fleurir_le_sel.html
#T xdg-open https://fr.wikibooks.org/w/index.php?title=Auto-%C3%A9diter_un_wikilivre/Auto-r%C3%A9f%C3%A9rencer/LivreTest/LivreTest.compil%C3%A9&action=edit
echo -n "$Projectdir/" > localbook.txt
echo "$Bookfullurl" | cut -d '/' -f3- >> localbook.txt
#T cat localbook.txt
read Localbook < localbook.txt
Htmlbook=$Localbook.html
echo "Htmlbook = $Htmlbook"
#T Test break exit 0
if test -e $Htmlbook
then
echo -e "\033[47m\033[1;30m Do you want to see the local html book ? \033[0m"
read -s -n1 -p "inkey y/n :" Inkey; echo "$Inkey"; echo
if [ "$Inkey" = 'y' ]; then xdg-open file://$Htmlbook ; fi
else echo "$Htmlbook not found"
fi
Varsdir=$Workdir/vars
#O Copy the variables from the book to 'vars/$Bookname.var'
if test -n "$Site"; then echo "Site=$Site" > $Varsdir/$Bookname.var; fi
if test -n "$Bookname"; then echo "Bookname=$Bookname" >> $Varsdir/$Bookname.var; fi
if test -n "$Suffix"; then echo "Suffix=$Suffix" >> $Varsdir/$Bookname.var; fi
if test -n "$Projectdir"; then echo "Projectdir=$Projectdir" >> $Varsdir/$Bookname.var; fi
if test -n "$Bookfullurl"; then echo "Bookfullurl=$Bookfullurl" >> $Varsdir/$Bookname.var; fi
if test -n "$Compilfullurl"; then echo "Compilfullurl=$Compilfullurl" >> $Varsdir/$Bookname.var; fi
if test -n "$Htmlbook"; then echo "Htmlbook=$Htmlbook" >> $Varsdir/$Bookname.var; fi
exit 0
#O End pre-annex.sh
unrecognized_links.dat
modifierData file in $Datasdir to remove unwanted links
title Spécial Accueil Vitrine Tous_les_livres Rechercher_un_livre Wikijunior Portail_communautaire Le_Bistro/2021 Special: Aide:Accueil propos_de https://fr.wikibooks.org/wiki/Wikilivres Wikilivres: Catégorie: Category Main_Page Help:Contents Card_Catalog_Office Cookbook:Table_of_Contents Featured_books Using_Wikibooks Reading_room Community_Portal Reading_room/Bulletin_Board Maintenance Policies_and_guidelines Contact_us Welcome General_disclaimer
test_pre-annex.bash
modifierInstall this code in ~/Add_appendix/tests/prannex.sh to test preannex.sh
#!/bin/bash
#H File : test_pre-annex.bash executable for testing the program pre-annex
#H Syntax : ./test_pre-annex.bash <full-url-book-name> (on the terminal for testing)
#H Example : ./test_pre-annex.bash https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/Contenus --t
#H : ./test_pre-annex.bash [ --v | <full-url-book-name> ] --t
VERSION=210619
#O Clean screen
clear
#P Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind drectory not found"; exit -1;fi
rm pwd.txt#O Download global variables
source $Workdir/datas/installdir.var
#O Print prog, version and Why
if [ "$1" = "--v" ];
then
echo "Command 'test_pre-annex.bash' is $VERSION for testing pre-annex function";
echo " Options : [ --v | <full-url-book-name> ] --t"
exit 0;
fi
#O Control if the test pre-annex.sh file is clean
echo -e "\033[1;33m Control pre-annex.sh in the local test directory \033[0m" > text-control.txt
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
echo -e "\033[1;33m ---- \033[0m"
grep -n -e "#T\|#O\|#P" pre-annex.sh >> text-control.txt
more text-control.txt
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
#T echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
echo " Beginning tests without parameter"
./pre-annex.sh
echo "----"; echo
sleep 2
echo " Test whith parameter --v"
./pre-annex.sh --v
echo "----"; echo
sleep 2
#T Test, all with option --t
echo " All tests whith parameter --t"
#P List fullurl books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./pre-annex.sh https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/Contenu --t
elif [ "$Inkey" = "2" ]; then ./pre-annex.sh https://fr.wikibooks.org/wiki/Hélices_de_navires_à_déplacement/Sommaire --t
elif [ "$Inkey" = "3" ]; then ./pre-annex.sh https://en.wikibooks.org/wiki/User:Goelette_Cardabela/Sandbox/TestBook/Content --t
elif [ "$Inkey" = "4" ]; then ./pre-annex.sh https://fr.wikibooks.org/wiki/Mkd_\(Extracteur_de_documents\)/Sommaire --t
elif [ "$Inkey" = "5" ]; then ./pre-annex.sh https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./pre-annex.sh https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./pre-annex.sh https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./pre-annex.sh https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/Tests_de_la_capacité_des_batteries_d%27accumulateurs
elif [ "$Inkey" = "9" ]; then ./pre-annex.sh https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/LivreTest --t
else echo "$inkey full url of site not found"; exit 0
fi
done
sitelist.sh
modifierInstall this code in /Add_appendix/tests, to product sitelist.txt
#!/bin/bash
#H File sitelist to test with 'test_preannex.bash in preannex.sh tests directory
#H Application for source ~/Add_appendix/datas/sitelist in 'test_preannex.bash'
#H or ./sitelist in datas directory in executable mode
#H Created 14/05/2021 by GC
#H Updated 19/06/2021 by GC
#P Make sitelist.txt : ./sitelist > sitelist.txt in datas directory
#
echo "sitelist to test annex programs, version 210516"
echo -e "\033[47m \033[1;32m Books with Contents or Summary \033[0m"
echo " 1 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/Contenu --t"
echo " 2 - https://fr.wikibooks.org/wiki/Hélices_de_navires_à_déplacement/Sommaire --t"
echo " 3 - https://en.wikibooks.org/wiki/User:Goelette_Cardabela/Sandbox/TestBook/Content --t"
echo " 4 - https://fr.wikibooks.org/wiki/Mkd_\(Extracteur_de_documents\)/Sommaire --t"
# echo -e "\033[47m \033[1;32m Books with Contents or Summary \033[0m"
echo -e "\033[47m \033[1;32m Collections \033[0m"
echo " 5 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel --t"
echo -e "\033[1;31m Same book second title \033[0m"
echo " 6 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel --t"
echo " 7 - https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix --t"
echo " 8 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/Tests_de_la_capacit%C3%A9_des_batteries_d%27accumulateurs"
echo " 9 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/LivreTest --t"
# echo -e "\033[47m \033[1;32m Books with Contents or Summary \033[0m"
echo -e "\033[47m \033[1;32m Atypical variants \033[0m"
echo -e "\033[1;31m Copy the line (Ctrl-Shift-C) and execute in terminal (Ctrl-Shift-V) \033[0m"
echo " xdg-open https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé"
echo " xdg-open https://fr.wikibooks.org/w/index.php?title=Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé&action=edit"
sitelist.txt
modifier- sitelist.txt to test program annex sub-programs
sitelist to test annex programs, version 210516 �[47m �[1;32m Books with Contents or Summary �[0m 1 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/Contenu --t 2 - https://fr.wikibooks.org/wiki/Hélices_de_navires_à_déplacement/Sommaire --t 3 - https://en.wikibooks.org/wiki/User:Goelette_Cardabela/Sandbox/TestBook/Content --t 4 - https://fr.wikibooks.org/wiki/Mkd_\(Extracteur_de_documents\)/Sommaire --t �[47m �[1;32m Collections �[0m 5 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel --t �[1;31m Same book second title �[0m 6 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel --t 7 - https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix --t 8 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/Tests_de_la_capacit%C3%A9_des_batteries_d%27accumulateurs 9 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/LivreTest --t �[47m �[1;32m Atypical variants �[0m �[1;31m Copy the line (Ctrl-Shift-C) and execute in terminal (Ctrl-Shift-V) �[0m xdg-open https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé xdg-open https://fr.wikibooks.org/w/index.php?title=Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé&action=edit
Add appendix
header.inc.sh
Éditeur : Goelette Cardabela
header.inc.sh
modifierL'internationalisation des messages est faite vβ 210519
src/header.inc.sh
modifier#!/bin/bash
#H File : bin/header.inc or src/header.inc.sh
#H Version : 2020-05-24
#H Syntax : header.inc [ <book-name> | ? ] [ -v ] [ -pb | -pc ]
#H Example : ./header.inc LivreTest (on the terminal for unit tests)
#H Creation: 2020-03-24
#H see https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Auto-référencer#Entête_des_modules
#H Updated : 2020-05-15 by GC
#H Updated : 2020-05-24 By GC to translate
#H Updated : 2020-06-15 by GC to update for translations and tests
#H Update on fr:Wikibooks : 2020-06-17
#H Last update : 2021-05-19
#H
#w NEW 17/05/2021: The books are now in the Book directory
#
#F Documentation en français
#F Le langage shell bash a été choisi plutôt d'autres shells pour son
#F universalité, c'est le langage de base pour apprendre. On trouve
#F la documentation dans toutes les langues et c'est aussi le plus
#F rapide à l'exécution, ce n'est pas un langage interprété, c'est du
#F code quasi binaire en dehors du temps consacré au contrôle de la
#F syntaxe à chaque exécution.
#F Le fichier de commandes header.sh doit être inclus dans tous les
#F modules de test du programme principal. Il initialise le
#F répertoire des commandes, le répertoire de travail du projet;
#F le répertoire du projet est le nom du livre, de
#F l'article ou de la page. Si ces répertoires n'existent pas ils
#F seront créés.
#F
#F Ce projet éducatif et de tests est destiné à être utilisé en liens
#F avec wikilivres en langue anglaise et caractères UTF8.
#F Les langues supportées pour les messages sont obtenues par édition
#F des fichiers .pot avec poedit pour produire les fichiers .po
#F d’interprétation dans des langues différentes. Les fichiers .pot
#F et .po sont enregistrés dans le répertoire ‘resource’ avant d’être
#F copiés dans le système unix ou linux.
#F Les manuels sont écrits en anglais et français et peuvent être
#F traduits dans d'autres langues.
#F
#w Les variables Site et SitePrefix se rapportent à "fr.wikibooks.org"
#w des anciennes versions sont supprimés depuis les versions 210501
#w
#F Le programme est prévu pour fonctionner à l'initiative du
#F contributeur qui doit copier la page "Contenus" ou la page de
#F compilation dans le répertoire des livres :
#F "~/Add_appendix/books/<nom du livre>"
#F Depuis les versions de mai 2021 ce travail peut être facilité avec
#F le programme pre-annex.sh
#F Les modules de programmes sont indépendants pour les tests,
#F cependant ils doivent être exécutés dans l'ordre
#F ./header.sh <livre>, ./lister <livre>, ./télécharger <livre>
#F ./ajouter_sclt <livre>, ./ajouter_sclic, ./ajouter_sclip <livre>
#F La liste des pages à analyser est indispensable dans tous les
#F modules en tests. Ils auront été copiés par vous-même ou par
#F le programme pre-annex et seront listés par le module lister.
#F L'absence de la liste des pages à analyser est signalée à chaque
#F lancement des modules du programme principal "Annexer" par
#F l'exécution de header.inc inclus dans chaque module en test.
#F
#E English documentation
#E
#O . gettext for message internationalization
. gettext.sh
VERSION=210519
ADD_APPENDIX=$HOME/Add_appendix
export PATH=$PATH:$HOME/Add_appendix/bin
TEXTDOMAIN=header.inc
TEXTDOMAINDIR="/usr/share/locale"
#O Clean messages on terminal
clear
#O Create the function tests_header_syntax
function tests_header_syntax
{
echo
echo "$(gettext ' Syntax of the header.inc command in test mode if the book is already created \$0 <bookname> --t ')"
echo "$(gettext ' Example : \$O TestBook --t ')"
echo "$(gettext ' Second syntax command in test mode if the book is not created : \$0 --t ')"
echo "$(gettext ' Example : \$0 --v or \$0 ? --t ')"
echo
exit 0
}
#O If first parmeter is empty, print the error and suggest the help syntax
if test -z $1; then echo "$(gettext ' Error: input parameter is empty, see the command : header.inc ? ')"; exit -1; fi
#O If help is requested
if [ "$1" = '?' ]; then
if [ "$2" = "--t" ]; then tests_header_syntax; else echo "Syntax : header.inc bookame"; exit 0; fi
fi
#O Display header.inc version on demand with option -v for first parameter
if [ "$1" = "--v" ]; then echo " header.inc version $VERSION"; exit 0; echo; fi
#O If the test mode is validated, initialize the Testmode variable to true
if [ "$2" = "--t" ]; then echo -n "Tests mode $2; "; Testsmode="true"; echo "Testmode = $Testsmode"; fi
#O Directories initialization, install, working, binaries, tests directories
#O If the file 'installdir.var exist in vars dir, include installdir.var
if [ -e ~/Add_appendix/vars/installdir.var ]
then
source ~/Add_appendix/vars/installdir.var
#O Else, print the problem and offer to reinstall Add_appendix directories
else
echo -n "Current directory in $0 "; pwd
echo "~/Add_appendix/vars/installdir.var not found in $0 command"
echo -e "\033[47m\033[1;30m Re-install Add_Appendix ? \033[0m"
read -s -n1 -p "inkey y/n: " Inkey; echo "$Inkey"
if [ "$Inkey" = 'y' ]; then
~/Add_appendix/sbin/users_install_annex.sh Add_appendix
#xdg-open https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_\(Version_internationalisée\)/users_install_annex.sh
exit 0
else exit -1
fi
fi
#O Initialize all global directories
#P In Install directories :
Bindir=$Installdir/bin
Libdir=$Installdir/lib
Mandir=$Installdir/man
Sharedir=$Installdir/share
Sbindir=$Installdir/sbin
#P In working directory :
Booksdir=$Workdir/books
Datasdir=$Workdir/datas
Resources=$Workdir/resources
Testsdir=$Workdir/tests
Varsdir=$Workdir/vars
#O If testmode is true (--t), print global directories variables
if [ "$Testsmode" = "true" ]; then
echo "* Install directory = $Installdir"
echo -e "\033[47m\033[1;30m In install directories \033[0m"
echo " Executables directory = $Bindir"
echo "- Library directory = $Libdir"
echo "- Manuals directory = $Mandir"
echo "- Share directory = $Sharedir"
echo "- Admin directory = $Sbindir"
echo
echo "* Working directory = $Workdir"
echo -e "\033[47m\033[1;30m In Working directory \033[0m"
echo "- Books directory = $Booksdir"
echo "- Datas directoy = $Datasdir"
echo "- Resources directory = $Resources"
echo "- Tests directory = $Testsdir"
echo "- Variables directory = $Varsdir"
fi
#O Check for the presence of the annex.lib file
if test -e $Libdir/annex.lib
then if [ "$Testsdmode" = "true" ]; then echo; echo " $Libdir/annex.lib is found"; fi
else
echo "To continue, copy annex.lib to $Libdir"
exit -1
fi
#O Initialize $Conversions variable
Conversions="$Datasdir/conversions.dat"
#O If the command is local for tests, clean the old file and create a new conversions file
if [ "$Testsdmode" = "true" ]
then
echo; echo "$(gettext ' When the command tests is $Testsdir, then conversion file is recreated to ')"$Conversions
rm $Conversions
fi
#O Create or recreate the conversions.dat file in datas directory
if test -e "$Conversions"
then echo "$(gettext ' The conversion file is present ')"
else
{
echo "s/%24/\$/g;s/%21/\!/g;s/%25/%/g;s/%2B/+/g;s/%3C/\\\<\;/g;s/%3E/\>\;/g;" >> $Conversions
echo "s/%5C/\\\/g;s/%B0/°/g" >> $Conversions
echo "s/%E0/à/g;s/%E2/â/g" >> $Conversions
echo "s/%E8/è/g;s/%E9/é/g;s/%EA/ê/g;s/%EB/ë/g" >> $Conversions
echo "s/%EE/î/g;s/%EF/ï/g" >> $Conversions
echo "s/%F4/ô/g" >> $Conversions
echo "s/%F9/ù/g;s/%FB/û/g" >> $Conversions
echo "s/%25/%/g;" >> $Conversions
echo "s/%28/(/g;s/%29/)/g;" >> $Conversions
echo "s/%2B/+/g;" >> $Conversions
echo "s/%3A/:/g;" >> $Conversions
echo "s/%3D/=/g;" >> $Conversions
echo "s/%5B/[/g;" >> $Conversions
echo "s/%5D/]/g" >> $Conversions
echo "s/%3B/;/g;s/%2F/\//g;s/%27/''/g" >> $Conversions
echo 's/%22/"/g' >> $Conversions
echo "s/%C3%A7/ç/g;s/%E7/ç/g" >> $Conversions
echo "s/%C3%A0/à/g;s/%C3%A2/â/g" >> $Conversions
echo "s/%C3%A9/é/g;s/%C3%A8/è/g;s/%C3%AA/ê/g" >> $Conversions
echo "s/%C3%AE/î/g;s/%C3%AF/ï/g" >> $Conversions
echo "s/%C3%B4/ô/g" >> $Conversions
echo "s/%C3%B9/ù/g;s/%C3%BB/û/g" >> $Conversions
echo "s/%C2%B7/-/g;s/%C2%AB/«/g;s/%C2%BB/»/g" >> $Conversions
}
echo "$(gettext ' The file conversions.dat is created or updated in file : ')" $Conversions
fi
#O If the first parameter is a project in the books directory
if test -d $Booksdir/$1; then
#O Initialize Books variables
if test -e "$Varsdir/$1.var"; then source $Varsdir/$1.var;
else
echo -e "$(gettext ' \033[31m'$1' variables not found in '$Varsdir'.\033[0m ')";
echo -n "Site=" > $Varsdir/$1.var; ls $Booksdir/$1 | grep wikibooks >> $Varsdir/$1.var
echo "Bookname=$1" >> $Varsdir/$1.var
#O Get suffix in Project directory and intialize Suffix
echo "$(gettext ' Get the suffix in project directory and put it in vars/$1.var : ')"
if test -e "$Booksdir/$1/$1.contents"; then cat $Booksdir/$1/$1.contents; echo "Suffix=contents" >> $Varsdir/$1.var
elif test -e "$Booksdir/$1/$1.summary"; then cat $Booksdir/$1/$1.summary; echo "Suffix=summary" >> $Varsdir/$1.var
elif test -e "$Booksdir/$1/$1.compiled"; then cat $Booksdir/$1/$1.compiled; echo "Suffix=compiled" >> $Varsdir/$1.var
else echo "$(gettext ' List of links to articles to be analyzed : not found ')"
fi
fi
fi
#O Print articles to be analyzed and if list-file exist
echo
echo -n "$(gettext ' Test if the file $Project/$1.list, exists : ')"; echo "$Booksdir/$1/$1.list"
if test -e "$Booksdir/$1/$1.list"
then
echo "$(gettext ' Yes, the file exists. ')"
else
echo -e "$(gettext ' \033[31mNo, '$Booksdir/$1/$1.list' is not yet created.\033[0m ')"
fi
#O Test if the .prj file exist and print the result
echo -n "$(gettext ' Test if the file $Project/$1.prj, exists: ')"; echo "$Booksdir/$1/$1.prj"
if test -e "$Booksdir/$1/$1.prj"
then echo "$(gettext ' Yes, the file exists. ')"
else echo -e "$(gettext ' \033[31mNo, '$Booksdir/$1/$1.prj' is not yet created.\033[0m ')"
fi
#O If the first parameter is not empty, print the file list in the project diretory
if test -n $1
then echo; echo -e -n "$(gettext ' \033[33mContents in the project directory : ')"; echo -e "$Booksdir/$1 \033[0m"
ls -al $Booksdir/$1
fi
#O Cat Book variables
echo; echo -n -e "$(gettext ' \033[33mVariables in the project directory : ')"; echo -e "$Booksdir/$1 \033[0m"
source $Varsdir/$1.var
cat $Varsdir/$1.var
#O List the content of local book
echo; echo -n -e "$(gettext ' \033[33mLink to the local html book : ')"; echo -e "$Booksdir/$1 \033[0m"
ls -1R $Booksdir/$1/$Site | tail -n 2 | sed "s/:/\//g" | tr -d "\n"; echo; echo
# End header.inc.sh
tests/header.inc/tests_header.inc.bash
modifier- Exemple de fichier de commande d'un test dans le répertoire ~/Add_appendix/tests/header.inc/.
#! /bin/bash
#P file : tests_header.inc.bash
#P Syntax ./tests_header.inc.bash
VERSION=210522
#O Clean screen
clear
#O Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
#O Download global variables
source $Workdir/vars/installdir.var
#O Print test_header.inc.bash version
echo " test_header.inc.bash version = $VERSION"
sleep 2
#T echo "----"
#O Print command header.inc.sh version
#T echo "Command header.inc.sh --v to veriy header.inc version"
./header.inc.sh --v
echo;echo " wait for 2 sec"
sleep 2; echo "----"
#O Control if the test header.inc.sh file is clean
echo -e "\033[1;33m Control header.inc.sh in the local test directory \033[0m" > text-control.txt
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
echo -e "\033[1;33m ---- \033[0m"
grep -n -e "#T\|#O\|#P" header.inc.sh >> text-control.txt
more text-control.txt
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
#T echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
#O test header.inc.sh in test-mode
echo "Command ./header.inc.sh - --t to verify environnement variables"
echo " in test mode with first param empty"
./header.inc.sh - --t
echo;echo " wait for 2 sec"
sleep 5; echo "----"
#O Test with first param empty
echo "Command ./header.inc.sh without parameter"
./header.inc.sh
echo;echo " wait for 2 sec"
sleep 2; echo "----"
#O Test, all with option --t
echo " All tests whith parameter --t"
#O List local books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./header.inc.sh LivreTest --t
elif [ "$Inkey" = "2" ]; then ./header.inc.sh Hélices_de_navires_à_déplacement --t
elif [ "$Inkey" = "3" ]; then ./header.inc.sh TestBook --t
elif [ "$Inkey" = "4" ]; then ./header.inc.sh Mkd_\(Extracteur_de_documents\) --t
elif [ "$Inkey" = "5" ]; then ./header.inc.sh Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./header.inc.sh Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./header.inc.sh Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./header.inc.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs
elif [ "$Inkey" = "9" ]; then ./header.inc.sh LivreTest --t
else echo "$inkey local url of site not found"; exit 0
fi
done
#O End tests_header.inc.bash
List to tests header.inc
modifiersitelist.sh
#!/bin/bash
#H File sitelist to test with 'test_preannex.bash in preannex.sh tests directory
#H Application for source ~/Add_appendix/datas/sitelist in 'test_preannex.bash'
#H or ./sitelist in datas directory in executable mode
#H Create 14/05/2021 by GC
#H Updated 16/05/2021 by GC
#P Make sitelist.txt : ./sitelist > sitelist.txt in datas directory
#
echo "sitelist to test annex programs"
echo -e "\033[47m \033[1;32m Books with Contents or Summary \033[0m"
echo " 1 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/Contenu --t"
echo " 2 - https://fr.wikibooks.org/wiki/Hélices_de_navires_à_déplacement/Sommaire --t"
echo " 3 - https://en.wikibooks.org/wiki/User:Goelette_Cardabela/sandbox/TestBook/Content --t"
echo " 4 - https://fr.wikibooks.org/wiki/Mkd_\(Extracteur_de_documents\)/Sommaire --t"
# echo -e "\033[47m \033[1;32m Books with Contents or Summary \033[0m"
echo -e "\033[47m \033[1;32m Collections \033[0m"
echo " 5 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel --t"
echo -e "\033[1;31m Same book second title \033[0m"
echo " 6 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel --t"
echo " 7 - https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix --t"
echo " 8 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/Tests_de_la_capacit%C3%A9_des_batteries_d%27accumulateurs"
echo " 9 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/LivreTest --t"
# echo -e "\033[47m \033[1;32m Books with Contents or Summary \033[0m"
echo -e "\033[47m \033[1;32m Atypical variants \033[0m"
echo -e "\033[1;31m Copy the line (Ctrl-Shift-C) and execute in terminal (Ctrl-Shift-V) \033[0m"
echo " xdg-open https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé"
echo " xdg-open https://fr.wikibooks.org/w/index.php?title=Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé&action=edit"
text list for tests
modifierSitelist.txt
sitelist to test annex programs �[47m �[1;32m Books with Contents or Summary �[0m 1 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Sandbox/LivreTest/Contenu --t 2 - https://fr.wikibooks.org/wiki/Hélices_de_navires_à_déplacement/Sommaire --t 3 - https://en.wikibooks.org/wiki/User:Goelette_Cardabela/sandbox/TestBook/Content --t 4 - https://fr.wikibooks.org/wiki/Mkd_\(Extracteur_de_documents\)/Sommaire --t �[47m �[1;32m Collections �[0m 5 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_fleurir_le_sel --t �[1;31m Same book second title �[0m 6 - https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel --t 7 - https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix --t 8 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/Tests_de_la_capacit%C3%A9_des_batteries_d%27accumulateurs 9 - https://fr.wikibooks.org/wiki/Utilisateur:Goelette_Cardabela/Compilations/LivreTest --t �[47m �[1;32m Atypical variants �[0m �[1;31m Copy the line (Ctrl-Shift-C) and execute in terminal (Ctrl-Shift-V) �[0m xdg-open https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé xdg-open https://fr.wikibooks.org/w/index.php?title=Auto-éditer_un_wikilivre/Auto-référencer/LivreTest/LivreTest.compilé&action=edit
Add appendix
annex.sh
Éditeur : Goelette Cardabela
annex.sh
modifierL'internationalisation des messages est faite vβ 210616 français: Avant d'utiliser cette commande en mode exécutable,
- la structure des répertoires du programme doit être correctement installée ou mise à jour avec la commande: ~/Tmp/users_install_annex.sh,
- les livres doivent avoir été initialisés avec la commande: bin/pre-annex du répertoire de travail de l'application Annexer ou Add_appendix.
anglais: To use this annex command,
- you must have initialized the program directories with: ~/Tmp/users_install_annex.sh or reset with sbin/users_install_annex.sh,
- the books must have been initialized with the command: bin/pre-annex from the working directory of the Add_appendix application
Annex.sh
modifier#!/bin/bash
#H ****
#H Header documentation of annex.sh
#H --------------------------------
#H File : annex and-or annex.sh
#H Version : 2020-05-24
#H Syntax : annex [ <book-name> || ? ] [ -v ] [ -pb || -pc ]
#H Example : ./annex TestBook (on the terminal for unit tests)
#H Creation: 2020-03-24 by GC
#H see https://fr.wikibooks.org/w/index.php?title=Auto-éditer_un_wikilivre/Auto-référencer#Entête_des_modules
#H Updated : 2020-05-15 by GC
#H Updated : 2020-05-24 by GC to translate
#H Updated : 2021-04-02 by User GC
#H Last update : 2021-04-22 for tests in tests dir 2-annex.sh
#H Update on fr:Wikibooks : 2021-03-26 incomplet
#H ****
#P ****
#P Programmers documentation of file annex.sh
#P ------------------------------------------
#P header.inc is included in each module for its individual test and
#P permanently in this command file 'annex'.
#P
#P export permanently ~/Add_appendix/bin in ~/.bashrc file : www is not recommended
#P echo "export PATH=$PATH:/home/user/mes_prog" >> /home/user/.bashrc
#P
#P export ~/Add_appendix/bin for this session onl
#P
#T ****
#T Tests documentation of annex.sh
#T -------------------------------
#T export PATH=$PATH:~/Add_appendix/bin
#T env | grep Add_appendix
#T
#D ****
#D Documentation for file annex
#D ----------------------------
#D addappendix with pre-annex are the main programs to create directories
#D needed to run the annex script.
#D annex is the main program to find the books contents of wikibooks and
#D of Commons to create appendix of book
#D ****
#P . gettext for translation
. gettext.sh
VERSION=211004
if [ "$1" = "--v" ]; then echo "Annex version $VERSION"; exit 0; echo; fi
TEXTDOMAIN=annex
TEXTDOMAINDIR="/usr/share/locale"
#P If first param is empty print the syntax and exit
if [ -z $1 ]
then
echo "$(gettext ' No Parameter ')"
echo "$(gettext ' Syntax : annex [ <book/contents url> | <Collections/book url> | ? ] [ -v ] [ -pb | -pc ] ')";
exit 0;
fi
#P If help whis the '?' character
if [ "$1" = "?" ]
then
{
clear
echo "$(gettext ' Syntax : ')"
echo "$(gettext ' annex [ <book/contents url> | <collections/book url> | ? ] [ -v ] [ -pb | -pc ] ')"
echo "$(gettext ' Options : ')"
echo "$(gettext ' annex ?, to display the command syntax. ')"
echo "$(gettext ' -pb for personal version with illustrations on Wikibooks. ')"
echo "$(gettext ' -pc for personal version with illustrations on Commons. ')"
echo "$(gettext ' -v verbose mode. ')"
exit 0
}
fi
if [ -e $Workdir/vars/installdir.var ];
then
source $Workdir/vars/installdir.var
echo "$Workdir/vars/installdir.var is found in annex command"; echo
Bindir=$Installdir/bin
Testsdir=$Workdir/tests
else
echo -n "current directory in $0 "
pwd
echo "$Workdir/vars/installdir.var not found in $0 command"
exit -1
fi
#T
echo "Install directory = $Installdir"
#T
echo "Working directory = $Workdir"
#T
echo "Bin directory = $Bindir"
#T
echo "Tests directory = $Testsdir"
#T Test break exit 0
#P Include header.inc in binary environnment ~/Add_appendix/bin
if test -e "$Bindir/header.inc"
then
echo "header.inc found in $Bindir"
source $Bindir/header.inc
else echo "copy header.inc to $Bindir to continue"; exit -1
fi
#T Spotting
echo "*** 'annex' command ***"
#T Test env | grep Add_appendix
#T echo "Installdir : "$Installdir
#P Initializing modes
Verbose="false"
Personal="false"
Personalwb="false"
Personalco="false"
#T Breakpoint exit 0
if (("$#" > "1"))
then
if [ "$2" = "-v" ]
then
Verbose="true";
fi
if [ "$2" = "-pb" ]
then
Personalwb="true"; Personal="true";
fi
if [ "$2" = "-pc" ]
then
Personalco="true"; Personal="true";
fi
fi
if (("$#" == "3"))
then
if [ "$3" = "-v" ]
then
Verbose="true";
fi
if [ "$3" = "-pb" ]
then
if test "$Personalco" = "false"
then
Personalwb="true"; Personal="true"
else
echo "$(gettext ' -annex- Error at command line, parameter three :$3 incompatible with parameter two :$2 ')"
exit 1
fi;
fi
if [ "$3" = "-pc" ]
then if test "$Personalwb" = "false"; then Personalco="true"; Personal="true";
else echo "$(gettext ' Error at command line, parameter three :$3 incompatible with parameter two :$2 ')"; exit 1; fi;
fi
fi
if (("$#" > "3"))
then
echo "$(gettext ' -annex- Error : too many parameters ! ')"
echo "$(gettext ' ./annex ? to display the syntax. ')"
exit 1
fi
#P Print variables from the command line
echo "$(gettext ' The variable Verbose is initialised at : ')"$Verbose
echo "$(gettext ' The variable Personalwb is initialised at : ')"$Personalwb
echo "$(gettext ' The variable Personalco is initialised at : ')"$Personalco
echo "$(gettext ' The variable Personal is initialised at : ')"$Personal
echo ""
#T Test break echo " Project directory = $Projectdirdir"exit 0
#P Print files in project directorie, and delete the files according to the answer
echo "$(gettext ' -Command annex- Files in project directory : ')"
ls $Projectdir
echo "$(gettext ' Delete in the project directory : *.html *.str *.img *.lnk tmp temp *.tmp *.temp *.list ? ')"
echo -e "$(gettext ' \033[31m 'y' to approve the deletion. \033[0m ')"
echo "$(gettext ' Return to continue, Ctrl-C to exit. ')"
read -n1 -p -s Inkey
echo "$(gettext ' Inkey = ')"$Inkey
if [ "$Inkey" = "y" ]
then
{
cd $Projectdir
echo -e "$(gettext ' \033[31mDeleting files.\033[0m ')"
rm -R *.html *.str *.img *.lnk tmp temp *.tmp *.temp *.list
}
else echo "$(gettext ' No file deletion ! ... Continue ... ')"
fi
echo "WAIT ..."
if test -d $Workdir/temp/Report-verbose-mode; then rm $Workdir/temp/Report-verbose-mode/*.txt; echo -n "" ; else mkdir $Workdir/temp//Report-verbose-mode; fi;
if test -d $Workdir/temp/Report-silent-mode; then rm $Workdir/temp/Report-silent-mode/*.txt; echo -n "" ; else mkdir $Workdir/temp/Report-silent-mode; fi;
#T Print Install directory echo "Installdir : in annex command : $Installdir"
#P Running list
if [ $Verbose = "true" ]
then $Bindir/list $1
else $Bindir/list $1 > $Workdir/temp/Report-silent-mode/list-cmd.txt
fi
#P Return value from list
Return=$?
if [ $Return -gt '0' ]
then
echo "$(gettext ' Error in shell module list in silent mode. See $Workdir/temp/Report-silent-mode/list-cmd.txt ')"
exit 1
fi
#T Breakpoint exit 0
#P Running downloads
if [ $Verbose = "true" ]
then $Bindir/download $1
else $Bindir/download $1 > $Workdir/temp/Report-silent-mode/download-cmd.txt
fi
#P Return value from downloads
Return=$?
if [ $Return -gt '0' ]
then
echo "$(gettext ' Error in shell module download in silent mode. See $Workdir/temp/Report-silent-mode/download-cmd.txt ')"
exit 1
fi
#P Running add_sclt
if [ $Verbose = "true" ]
then
$Bindir/add_sclt $1
else
$Bindir/add_sclt $1 > $Workdir/temp/Report-silent-mode/add_sclt-cmd.txt
fi
#P Return value from add_sclt
Return=$?
if [ $Return -gt '0' ]
then
echo "$(gettext ' Error in shell module add-sclt in silent mode. See $Workdir/temp/Report-silent-mode/add_sclt-cmd.txt ')"
exit 1
fi
#T test break exit 0
#P Running add_sclic
if [ $Personal = "false" ]
then
if [ $Verbose = "true" ]
then
$Bindir/add_sclic $1
else
$Bindir/add_sclic $1 > $Workdir/temp/Report-silent-mode/add_sclic-cmd.txt
fi
cat $Projectdir/$1.sclic > $Projectdir/$1.scli
fi
#P Return value from add_sclic
Return=$?
if [ $Return -gt '0' ] && [ $Personal = "false" ];
then
echo "$(gettext ' Error in shell module add_sclic in silent mode. See $Workdir/temp/Report-silent-mode/add_sclic-cmd.txt ')"
exit 1
fi
#P If option -pc is validated, running sclipco.sh
if [ "$Personalco" = "true" ]
then
if [ "$Verbose" = "true" ]; then $Bindir/add_sclipco $1; else $Bindir/add_sclipco $1 > $Workdir/temp/Report-silent-mode/add_sclipco-cmd.txt; fi;
echo "$(gettext ' sclipco has been executed ')";
fi
#P Return value from slipco
Return=$?
if [ $Return -gt '0' ] && [ $Personalpc = "true" ];
then
echo "$(gettext ' Error in shell module slipco. See $Workdir/temp/Report-silent-mode/sclipco-cmd.txt ')"
exit 1
fi
#P If option -pb is validated, running sclipw
if [ "$Personalwb" = "true" ]
then
if [ "$Verbose" = "true" ]; then $Bindir/add_sclipwb $1; else $Bindir/add_sclipwb $1 > $Workdir/temp/Report-silent-mode/add_scliwb-cmd.txt; fi;
echo "$(gettext ' sclipwb has been executed ')";
fi
if [ $Return -gt '0' ] && [ $Personalwb = "true" ];
then
echo "$(gettext ' Error in shell module slipwb. See $Workdir/temp/Report-silent-mode/scliwb-cmd.txt ')"
exit 1
fi
#P Flush article, source license ant text to project.appendix
cd $Projectdir
cat $1.sclt > $1.appendix
#P sclip.inc
if [ $Personalwb = "true" ]
then cat $Projectdir/$1.sclipwb >> $Projectdir/$1.appendix; echo "$(gettext ' $1.sclipwb is added to $1.appendix ')";
elif [ $Personalco = "true" ]
then cat $Projectdir/$1.sclipco >> $Projectdir/$1.appendix; echo "$(gettext ' $1.sclipco is added to $1.appendix ')";
else
cat $Projectdir/$1.sclic >> $Projectdir/$1.appendix; echo "$(gettext ' $1.sclic is added to $1.appendix ')";
fi
echo "$(gettext '== License == ')" >> $Projectdir/$1.appendix
cat $Projectdir/$1/$1.license >> $Projectdir/$1.appendix
echo "" >> $Projectdir/$1.appendix
#P echo "{{Nouvelle page imprimée}}" >> $Projectdir/$1.appendix
#P echo "$(gettext '{{Page-break/end}} ')"" on en:wikibooks >> $Projectdir/$1.appendix
echo "<br style=\"page-break-after: always\">" >> $Projectdir/$1.appendix
echo ""
echo ""
echo ""
echo -n "$(gettext ' Copy the contents of the file ')"$Projectdir/$1.appendix
echo "$(gettext ' to the Appendix page of the book ')"$1.
exit 0
#P ****
#T ****
# End annex command
Global test
modifier#! /bin/bash
#P file : tests_annex.sh
#P Syntax ./tests_annex.sh
clear
VERSION=210822
echo "test_annex.bash VERSION = $VERSION"
Workdir=~/Add_appendix
./annex.sh --v
echo;echo " wait for 2 sec"
sleep 2
#T test with $1 empty
./annex.sh
echo;echo " wait for 2 sec"
sleep 2
clear
./annex.sh ?
echo;echo " wait for 5 sec"
sleep 3
clear
#./annex.sh LivreTest
#echo;echo " wait for 3 sec"
#sleep 3
#O annex local books for tests
Inkey=1
cat $Workdir/tests/sitelist.txt; echo
for i in 'seq 1 9'
do
#cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./annex.sh LivreTest; ./annex.sh LivreTest -v -pc; ./annex.sh LivreTest -v -pb
elif [ "$Inkey" = "2" ]; then ./annex.sh Hélices_de_navires_à_déplacement; ./annex.sh Hélices_de_navires_à_déplacement -v -pc; ./annex.sh Hélices_de_navires_à_déplacement -v -pb
elif [ "$Inkey" = "3" ]; then ./annex.sh TestBook; ./annex.sh TestBook -v -pc; ./annex.sh TestBook-v -pb
elif [ "$Inkey" = "4" ]; then ./annex.sh Mkd_\(Extracteur_de_documents\); ./annex.sh Mkd_\(Extracteur_de_documents\) -v -pc; ./annex.sh Mkd_\(Extracteur_de_documents\) -v -pb
elif [ "$Inkey" = "5" ]; then ./annex.sh Faire_fleurir_le_sel; ./annex.sh Faire_fleurir_le_sel -v -pc; ./annex.sh Faire_fleurir_le_sel -v -pb
elif [ "$Inkey" = "6" ]; then ./annex.sh Faire_sa_fleur_de_sel; ./annex.sh Faire_sa_fleur_de_sel -v -pc; ./annex.sh Faire_sa_fleur_de_sel -v -pb
elif [ "$Inkey" = "7" ]; then ./annex.sh Guide_to_Unix; ./annex.sh Guide_to_Unix -v -pc; ./annex.sh Guide_to_Unix -v -pb
elif [ "$Inkey" = "8" ]; then ./annex.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs; ./annex.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs -v -pc; ./annex.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs -v -pb
elif [ "$Inkey" = "9" ]; then ./annex.sh LivreTest; ./annex.sh LivreTest -v -pc; ./annex.sh LivreTest -v -pb
else echo "$inkey local url of site not found"; exit 0
fi
done
#O End tests_annex.bash
Add appendix
list.sh
Éditeur : Goelette Cardabela
list.sh
modifierlist.sh
modifier#! /bin/bash
#H File list.sh
#H Syntax in console : "./bin/list.sh <bookname>"
#H Example : "./liste.sh LivreTest" à la console.
#H Creation date : 2020-03-26
#H Modified : 2020-04-26 by GC
#H Modified : 2020-05-30 by GC for automatic installation
#H Modified : 2020-06-30 by GC to include Summary pages at the list files
#H Modified : 2021-03-17 by GC for internationalization
#H modified : 2021-03-21 by GC for for layout
#H modified : 2021-05-21 by GC Reconstructed version
#H modified by Clara 23/05/2021 résolution provisoire du problème de la
#H variable $Projectdir pour les livres avec des Sommaires
#H
#D list.sh documentation
#D Creates the list of files included in the pages
#D header.inc is included and there is no need to recreate the environment
#D variables
#D Suffix available for bookname.suffix : compiled, summary, contents
#D
VERSION=210523
#O . gettext.sh for translation
. gettext.sh
#O Include the file header.inc
if test -e ~/Add_appendix/bin/header.inc; then source ~/Add_appendix/bin/header.inc
else echo "$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
fi
#w Initialize the project list in project directory
#w If the book is included at the root of wikibooks
#w echo "https://$Site/wiki/$1" > $Project/$1.list
#w Else take the url into account
#O Code extraction as appropriate case
#O Case compiled pages for PediaPress. Lines syntax :[[Book article]]
SitePrefix=https:\/\/$Site\/wiki\/
if test -e "$Projectdir/$1.compiled"
then
{
echo "$(gettext ' Found Compiled page : ')$Project/$1.compiled"; echo
echo " create $Projectdir/$1.list with :"; echo " $Projectdir/$1.compiled"; echo
cat "$Projectdir/$1.compiled" | sed -f ~/Add_appendix/datas/content_cleaner.dat > $Projectdir/$1.compiled.cleaned
cat "$Projectdir/$1.compiled.cleaned" | grep -v '=' | sed "s/\[\[/https:\/\/$Site\/wiki\//g" | sed "s/\]\]//g" | grep "wiki" | tr ' ' '_' | cut -d '|' -f1 > $Projectdir/$1.list
cat "$Projectdir/$1.compiled.cleaned" | grep -v '=' | sed "s/\[\[//g" | sed "s/\]\]//g" | cut -d '|' -f1 > $Projectdir/$1.prj
}
#O Case contents suffix
elif test -e "$Projectdir/$1.contents"
then
{
echo "$(gettext ' Found contents page : ')$Projectdir/$1.contents"; echo
echo " create $Projectdir/$1.list with :"; echo " $Projectdir/$1.contents"; echo
#O The book must be included at the root of wikibooks
echo "$Bookfullurl" > $Project/$1.list
echo " Do not use {{BASEPAGENAME}} in Contents page"
cat "$Projectdir/$1.contents" | sed -f ~/Add_appendix/datas/content_cleaner.dat > $Projectdir/$1.contents.cleaned
cat "$Projectdir/$1.contents.cleaned" | grep -v '=' | sed "s/\[\[/https:\/\/$Site\/wiki\//g" | sed "s/\]\]//g" | grep "wiki" | tr ' ' '_' | cut -d '|' -f1 > $Projectdir/$1.list
cat "$Projectdir/$1.contents.cleaned" | grep -v '=' | sed "s/\[\[//g" | sed "s/\]\]//g" | cut -d '|' -f1 > $Projectdir/$1.prj
}
#O Case Summary suffix
elif test -e "$Workdir/books/$1/$1.summary"
then
{
#w Check upstream $Projectdir is not validaded for 'summary'
Projets=$Workdir/books
echo "$(gettext ' Found Summary page : ')"$Projets/$1/$1.summary; echo
echo " create $Projets/$1/$1.list with :"; echo " $Projets/$1/$1.summary"; echo
#O The book must be included at the root of wikibooks
echo "$Bookfullurl" > $Projets/$1/$1.list
echo " Do not use {{BASEPAGENAME}} in Summary page"
cat "$Projets/$1/$1.summary" | sed -f ~/Add_appendix/datas/content_cleaner.dat > "$Projets/$1/$1".summary.cleaned
cat "$Projets/$1/$1.summary.cleaned" | grep -v '=' | sed "s/\[\[/https:\/\/$Site\/wiki\//g" | sed "s/\]\]//g" | grep "wiki" | tr ' ' '_' | cut -d '|' -f1 >> $Projets/$1/$1.list
cat "$Projets/$1/$1.summary.cleaned" | grep -v '=' | sed "s/\[\[//g" | sed "s/\]\]//g" | cut -d '|' -f1 > "$Projets/$1/$1".prj
}
#else echo "bookname.suffix : $1.$Suffix not found"
fi
#O Print file Project.list and file Project.prj
echo
echo "$(gettext ' File Project.list')"
cat $Workdir/books/$1/$1.list
echo
echo "$(gettext ' File Project.prj')"
cat $Workdir/books/$1/$1.prj
echo " "
read -p "If all OK : return to continue, Ctrl-C to quit > "
# End list.sh
tests_list.bash
modifier#! /bin/bash
#P file : tests_list.bash
#P Syntax ./tests_list.bash
VERSION=210522
#O Clean screen
clear
#O Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
#O Download global variables
source $Workdir/vars/installdir.var
#O Print test_header.inc.bash version
echo " test_list.bash version = $VERSION"
sleep 2
#T echo "----"
#O Control if the test list.sh file is clean
echo -e "\033[1;33m Control list.sh in the local test directory \033[0m" > text-control.txt
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
echo -e "\033[1;33m ---- \033[0m"
grep -n -e "#T\|#O\|#P" list.sh >> text-control.txt
more text-control.txt
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
#T echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
#O test list.sh in test-mode
echo "Command ./list.sh - --t to verify environnement variables"
echo " in test mode with first param empty"
./list.sh - --t
echo;echo " wait for 2 sec"
sleep 5; echo "----"
#O Test with first param empty
echo "Command ./list.sh without parameter"
./list.sh
echo;echo " wait for 2 sec"
sleep 2; echo "----"
#O Test, all with option --t
echo " All tests whith parameter --t"
#O List local books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./list.sh LivreTest --t
elif [ "$Inkey" = "2" ]; then ./list.sh Hélices_de_navires_à_déplacement --t
elif [ "$Inkey" = "3" ]; then ./list.sh TestBook --t
elif [ "$Inkey" = "4" ]; then ./list.sh Mkd_\(Extracteur_de_documents\) --t
elif [ "$Inkey" = "5" ]; then ./list.sh Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./list.sh Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./list.sh Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./list.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs
elif [ "$Inkey" = "9" ]; then ./list.sh LivreTest --t
else echo "$inkey local url of site not found"; exit 0
fi
done
#O End tests_header.inc.bash
content_cleaner.dat
modifierCe fichier supprime l'espace après ';' et ": ", ':', "* ", '*' "# ", '#' devant la parenthèse '['
S'utilise de la façon suivante :
echo "Chaîne de caractères" | sed -f $Datasdir/content_cleaner.dat
ou :
cat "$Bookname.$Suffix" | sed -f $Datasdir/content_cleaner.dat > "$Bookname.$Suffix.cleaned"
s/: \[/\[/g;s/:\[/\[/g s/# \[/[/g;s/#\[/\[/g s/* \[/[/g;s/*\[/\[/g s/; /;/g
Add appendix
download.sh
Éditeur : Goelette Cardabela
download.sh
modifierdownload.sh
modifier#! /bin/bash
#H File download.sh
#H Syntax in console : "./bin/dowload <bookname>"
#H Example : "./download.sh LivreTest" in test mode in a terminal
#H Creation date : 28/03/2020
#H Modified : 26 april 2020 par GC
#H Modified : 30 may 2020 par GC for automatic insrallation
#H Modified : 27 may 2021 for Add_Appendix
#H Documentation version de la documentation on WikiLivres le : 26 april 2020
#H
#D download.sh documentation
#D header.inc is included and there is no need to recreate the environment
#D variables
#D Download creates or recreates a local html book with html subdirectories of all articles
#D Create a concatenated sub-list locale.list of the book from book articles-list
#D To document the book with its subpages :
#D Create a directory containing the main html page of the book and local directories
#D containing an html version of the articles
#D
VERSION=210619
#O . gettext.sh for translation
. gettext.sh
#O Include the file header.inc
if test -e ~/Add_appendix/bin/header.inc; then source ~/Add_appendix/bin/header.inc
else echo "$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
fi
#O Download the complete book structure in working directory
Projectdir=$Workdir/books/$1
cd $Projectdir
mkdir temp
if [ "$2" = "--t" ]; then echo "current dir : "; pwd; fi
echo "download all directories of the book '$1'"
wget -r -linf -k -p -E -i $1.list -o $Projectdir/temp/wget-log-download.txt
echo "----------"
#O Move the html pages into working sub-directories to document the pages and sub pages
#O create a local list to the downloaded directories $ Projectdir/$1.locale.list
echo "create the complete concatenated hierarchy of the directories of the book '$1'"
cat $Projectdir/$1.list | sed "s/https:\/\///g" | sed "s/\ /\\\ /g" | tr '\n' ',' > $Projectdir/$1.locale.list
echo " Concatenated local list $Projectdir/$1.locale.list :"
echo ""
cat $Projectdir/$1.locale.list
echo "----------"
#O Copy the html files to respective directories
#O Create a file with the pagename $Projectdir/$1.mainPage
echo "créer la page du lien local vers la page principale, 'le livre'."
echo "create the page from the local link to the main page, 'the book'"
cat $Projectdir/$1.locale.list | sed "s/ /\\ /g" | cut -d ',' -f1 > $Projectdir/$1.mainPage
echo "----------"
#O Initialize the variable $mainPage
read mainPage < $Projectdir/$1.mainPage
echo "variable mainPage = $mainPage"
#T cat $Projet/$1.mainPage | awk -F"/" '{print NF}' > nbchamps
#T read NbChamps < nbchamps
#T echo "Variable NbChamps = $NbChamps"
echo "----------"
#O Create a file of the working directories to be created.
ls "$mainPage" | sed "s/.html//g" > $Projectdir/$1.dirs
echo "sub-working-diectories : "
cat $Projectdir/$1.dirs
echo "----------"
#O Copy the html pages and subpages in the respective directories
while read line
do
echo "$line".html | sed "s/https:\/\///g" | tr '\n' ' ' > source
read Source < source
echo "Source = $Source"
echo "$line" | awk -F"/" '{ print $NF }'| tr '\n' '/' > destination
read dir < destination
mkdir $dir
echo "$line".html | awk -F"/" '{ print $NF }' >> destination
read Destination < destination
echo "Destination = $Destination"
echo "To copy : 'cp -f ./$Source $Destination'"
cp -f "./$Source" "$Destination"
done < $Projectdir/$1.list
rm source ; rm destination
#O Quitter le programme d'essai et passer à la création de la page "Annexe" des articles.
echo "----------"
# echo -en "\033[31mRetour-chariot une pour créer l'Annexe des articles, Ctrl-C pour quitter.\033[0m "
# read -p ">"
# "\033[31mRetour-chariot une pour créer l'Annexe, Ctrl-C pour quitter >"
# exit 0
# End download.sh
tests_download.sh
modifier#! /bin/bash
#P file : tests_download.bash
#P Syntax ./tests_download.bash
VERSION=210528
#O Clean screen
clear
#O Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
#O Download global variables
source $Workdir/vars/installdir.var
#O Print tests_download.bash version
echo " tests_download.bash version = $VERSION"
sleep 2
#T echo "----"
#O Control if the test download.sh file is clean
echo -e "\033[1;33m Control download.sh in the local test directory \033[0m" > text-control.txt
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
echo -e "\033[1;33m ---- \033[0m"
grep -n -e "#T\|#O\|#P" download.sh >> text-control.txt
more text-control.txt
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
#T echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
#O test download.sh in test-mode
echo "Command ./download.sh - --t to verify environnement variables"
echo " in test mode with first param empty"
./download.sh - --t
echo;echo " wait for 2 sec"
sleep 5; echo "----"
#O Test with first param empty
echo "Command ./download.sh without parameter"
./download.sh
echo;echo " wait for 2 sec"
sleep 2; echo "----"
#O Test, all with option --t
echo " All tests whith parameter --t"
#O download local books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./download.sh LivreTest --t
elif [ "$Inkey" = "2" ]; then ./download.sh Hélices_de_navires_à_déplacement --t
elif [ "$Inkey" = "3" ]; then ./download.sh TestBook --t
elif [ "$Inkey" = "4" ]; then ./download.sh Mkd_\(Extracteur_de_documents\) --t
elif [ "$Inkey" = "5" ]; then ./download.sh Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./download.sh Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./download.sh Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./download.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs
elif [ "$Inkey" = "9" ]; then ./download.sh LivreTest --t
else echo "$inkey local url of site not found"; exit 0
fi
done
#O End tests_download.bash
Add appendix
add_sclt.sh
Éditeur : Goelette Cardabela
add_sclt.sh
modifieradd_sclt.sh
modifiercette commande se décompose en un programme principal et des sous programmes en français et en anglais d'autres langues peuvent s'ajouter en fonction des livres de sites wikibooks autres que français et anglais
#! /bin/bash
#HF Fichier : add_sclt.sh
#HF Nom du fichier de commandes : add_sclt
#HF Syntaxe : "add_sclt <nom du livre> [ --t ]"
#HF Exemple : "./add_sclt LivreTest --t" à la console.
#HF Date de création : 12 avril 2020
#HF Modifié le : par GC le 1er mai 2020
#HF Modifié le : par GC pour l'installation automatique.
#HF Adapté le 28 mai 2021 pour la version Add_appendix
#HF Version de la documentation sur WikiLivres le : 30 avril 2020
#HF
#HF LES FICHIERS DE COMMANDES
#HF
#HF## header.sh ##############
#HF header.sh, a créé le répertoire des commandes si celui-ci ne préexistait pas
#HF il a vérifié la validité ou invalidé de ligne de commande, initialisé
#HF les variables $Projet, $Site, $SitePrefix, vérifié l'existence des
#HF fichiers de liste "$Projet/$1".list et "$Projet/$1".prj, puis affiché le
#HF contenu du répertoire de travail.
#HF
#HF## lister #################
#HF lister a créé le fichier de liste $Projet/$1.list par l'extraction du fichie
#HF fichier $Projet/$1.contenu, copie de la page "Contenus" de la version
#HF imprimable du livre, ou du fichier $Projet/$1.compilé issu d'une
#HF compilation destinée à la publication par PediaPress.
#HF il crée aussi le fichier $Projet/$1.prj qui conserve l'ordre d'affichage
#HF de la publication.
#HF
#HF## télécharger ############
#HF la commande aura téléchargé toutes les page du livre et aura copié les pages
#HF html dans des répertoires qui leurs sont dédiés pour y extraire toute la
#HF documentation nécessaire à la création de la page "Annexe" du livre.
#w à ce stade, pour les tests; on dispose des répertoires de travail :
#w LivreTest, ArticleUn, ArticleDeux, ArticleTrois
#HF qui contiennent chacun le fichier html de la page ou de l'article qui le
#HF concerne.
#HF L'ensemble de commandes aura créé les fichiers de listes :
#HF $Projet/$1.dirs, $Projet/$1.list, $Projet/$1.mainPage, $Projet/$1.prj
#HF
#DF La commande ./add_sclt <wikilivre> commence par créer la page
#DF $Projet/$1.sclt comme elle apparaîtra dans la première partie de la page
#DF "Annexe" du livre avec les titre en wikitexte et les sections :
#DF Références: toutes celles qui n'ont pas été affichées dans les pages.
#DF Contenus: liens établis vers la page du livre et les articles (sous-pages)
#DF Source de l'édition: lien vers la page qui a permis de créer l' "Annexe".
#DF Sources licences et contributeurs des articles: ne concerne que les
#DF articles, les sous-pages.
#DF
#DE the command ./add_sclt <Wiki-book>[--t], first create the page
#DE $ Project / $ 1.sclt as it will appear in the "Appendix" page with the
#DE titles and Wikitext sections:
#DE References : all references not referenced in articles
#DE Contents : links to book articles
#DE Sources of the edition : link to the page that allows you to create the
#DE annex page
#DE Licenses sources and article contributors : only articles and sub-pages
#DE
#www English sclt files will probably be with translation
VERSION=211006
TEXTDOMAIN=add_sclt
TEXTDOMAINDIR=/usr/share/local
export TEXDOMAINDIR
#O . gettext.sh for translation
. gettext.sh
if [ "$0" = "./add_sclt" ]; then echo "add_sclt : Version "$VERSION; fi
#O Include the file header.inc
if test -e ~/Add_appendix/bin/header.inc; then source ~/Add_appendix/bin/header.inc
else echo $"$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
fi
#O Create variable PageSclt
Projectdir=$Workdir/books/$1
PageSclt="$Projectdir/$1.sclt"
echo $PageSclt
if [ "$2" = "--t" ];
then
{
pwd > pwd.txt; read Localdir < pwd.txt; rm pwd.txt
if [ "$Site" = "fr.wikibooks.org" ]; then source $Localdir/fr_sclt.inc.sh
else source $Localdir/en_sclt.inc.sh
fi
}
else
if [ "$Site" = "fr.wikibooks.org" ]; then source $Bindir/fr_sclt.inc
else source $Bindir/en_sclt.inc
fi
fi
# End of add_sclt.sh
fr_sclt.inc
modifier#! /bin/bash
#H Fichier : fr_sclt.inc pour inclure dans add_sclt.sh
Version=210819
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 "créer la page $Projectdir/$1.sclt"
echo "----------"
echo "= Annexe =" > "$Projectdir/$1.sclt"
echo "" >> $Projectdir/$1.sclt
#O Ajouter la balise <references />
echo "== Références ==" >> "$PageSclt"
echo "<references />" >> "$PageSclt"
echo " " >> "$PageSclt"
echo "{{Nouvelle page imprimée}}" >> "$PageSclt"
#? (option) ajouter la liste créée avec la page "Contenus" de la version imprimable ou la page compilée ?
#O ajouter le lien vers : la page du livre imprimable, et vers les articles.
echo "== Contenus ==" >> $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 Ajouter lien vers la source de cette édition.
echo "=== Source de cette édition ===" >> $PageSclt
echo "<div style=\"font-zize:85%\";>" >> $PageSclt
echo -n "https://" >> $PageSclt
cat $Projectdir/$1.mainPage | sed "s/\\\ /_/g" >> $PageSclt
#P Autre version : cat $Projectdir/$1".list" | tr ' ' '_' | tr '\n' '%' | sed "s/%/%\n/g" | grep $1% | tr -d % >> $PageSclt
echo "</div>" >> $PageSclt
echo " " >> $PageSclt
echo "{{Nouvelle page imprimée}}" >> $PageSclt
#O Créer la section 'Article', 'Source', 'licence', 'Contributeur(?)'
echo "== Sources licences et contributeurs des articles ==" >> $PageSclt
#O ajouter le texte : style PediaPress ou personnalisé
#O Les ''sources'' listées pour chaque article fournissent des informations
#O de licence plus détaillées, y compris le statut des droits d'auteurs, les
#O détenteurs de ces droits et les conditions de licence.
echo "<span style=\"font-zize:85%\";>Les ''sources'' listées pour chaque article fournissent des informations de licence plus détaillées, y compris le statut des droits d'auteurs, les détenteurs de ces droits et les conditions de licence.</span>" >> $PageSclt
#O ou, valider l'un ou l'autre de ces textes :
#O Les textes sont disponibles avec leurs licences respectives, cependant
#O d’autres termes peuvent s’appliquer.<br />
#O Voyez les termes d’utilisation pour plus de détails :<br />
#O https://wikimediafoundation.org/wiki/Conditions_d'utilisation
# echo "<span style=\"font-zize:85%\";>Les textes sont disponibles avec leurs licences respectives, cependant d’autres termes peuvent s’appliquer.<br />Voyez les termes d’utilisation pour plus de détails :<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 "Répertoire courant : "
#T pwd
echo "----------"
#O Créer ou recréer le fichier de liste $Projectdir/$1.pj
cat $Projectdir/$1.list | awk -F"/" '{ print $NF }' > $Projectdir/$1.pj
Liste=$Projectdir/$1.pj
echo "Fichier de liste : "$Liste
#T exit 0
#O Tant qu'il y a des lignes dans le fichier de liste,
while read ligne
do
#O Afficher la ligne lue,
echo ""
echo " ligne lue = "$ligne
echo ""
#O Extraire et copier toutes les chaînes de caractères du fichier html
#O $ligne.html dans le fichier $ligne.str et les dupliquer à l'écran
#T pwd
mkd -pws '**' "$ligne/$ligne.html" $Projectdir/$ligne/$ligne.tmp | tr ',' '\n' > $Projectdir/$ligne/$ligne.str
#T break
#O Créer les fichiers de documentation des pages :
echo "*** Références : articles, src, lic, contrib. "
#O Article,
if [ $ligne != $1 ]
then
echo "'''"$ligne"'''" >> $PageSclt
fi
echo "'''"$ligne"'''" > $Projectdir/$ligne/$ligne.article
cat $Projectdir/$ligne/$ligne.article
#O Source,
echo -n ", ''source : ''https://"$Site"/w/index.php?oldid=" > $Projectdir/$ligne/$ligne.RevisionId
cat $Projectdir/$ligne/$ligne.str | grep -n -m 1 -i -e wgRevisionId | tr -d ':' | sed "s/\"/%/g" | cut -d'%' -f3 >> $Projectdir/$ligne/$ligne.RevisionId
if [ $ligne != $1 ]
then
cat $Projectdir/$ligne/$ligne.RevisionId >> $PageSclt
fi
cat $Projectdir/$ligne/$ligne.RevisionId
#P licence 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/">licence 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 license :
#P licence s'écrit license en anglais (langage de base en programmation).
#P <link rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"/>
#T echo ", ''Droits de copie :''" >> 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 Licence :
echo -n ", ''licence : ''" > $Projectdir/$ligne/$ligne.license
#T cat $Projectdir/$ligne/$ligne.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | cut -d'%' -f4 >> $Projectdir/$ligne/$ligne.license
cat $Projectdir/$ligne/$ligne.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | tr '"' '%' | cut -d'%' -f4 >> $Projectdir/$ligne/$ligne.license
#T cat $Projectdir/$ligne/$ligne.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | cut -d'%' -f2 | sed "s/\/\//https:\/\//g" >> $Projectdir/$ligne/$ligne.license
if [ $ligne != $1 ]
then
cat $Projectdir/$ligne/$ligne.license >> $PageSclt
fi
cat $Projectdir/$ligne/$ligne.license
#
#P spécial pour bas de page fr ##
cat $Projectdir/$ligne/$ligne.str | grep -n -m 1 -i -e footer-info-copyright | sed "s/\"\//%\//g" | tr '"' '%' | cut -d'%' -f4 > $Projectdir/$ligne/$ligne.licence
#O Auteur(s).
echo -n ", ''auteur(s) : ''" > $Projectdir/$ligne/$ligne.auteur
cat $Projectdir/$ligne/$ligne.str | grep -n -m 1 -i -e wgRelevantUserName | sed "s/\"/%/g" | cut -d'%' -f4 > tmp
if test -s tmp;
then cat tmp >> $Projectdir/$ligne/$ligne.auteur; rm tmp;
else
echo "Auteur non trouvé ! " >> $Projectdir/$ligne/$ligne.auteur
if wget --spider https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$ligne 2>/dev/null
then
echo ". éditer : https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$ligne" >> $Projectdir/$ligne/$ligne.auteur
elif wget --spider https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$Bookname/$ligne 2>/dev/null
then
echo ". éditer : https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$Bookname/$ligne" >> $Projectdir/$ligne/$ligne.auteur
else echo ". éditer ''contributeurs'' du livre ''$Bookname'' historique de la page ''$ligne''" >> $Projectdir/$ligne/$ligne.auteur
fi
fi
if [ $ligne != $1 ]
then
cat $Projectdir/$ligne/$ligne.auteur >> $PageSclt
cat $Projectdir/$ligne/$ligne.auteur
fi
echo "" >> $PageSclt
#O fin du tant que.
done < $Projectdir/$1.pj #< $Liste
echo "</div>" >> $PageSclt
echo "{{Nouvelle page imprimée}}" >> $PageSclt
if [ "$2" = "--t" ]; then more $PageSclt; fi
exit 0
# Fin de fr_sclt.inc
en_sclt.inc
modifierVersion pour l'internatioalistion avec gettext
#! /bin/bash
#H File : en_sclt.inc include in add at add_sclt.sh
#P . gettext for translation
. gettext.sh
Version=211006
TEXTDOMAIN=en_sclt.inc
TEXTDOMAINDIR=/usr/share/locale
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 "$(gettext '= Appendix = ')" > "$Projectdir/$1.sclt"
echo >> $Projectdir/$1.sclt
#O Add <references />
echo "$(gettext '== References == ')" >> "$PageSclt"
echo "$(gettext '<references /> ')" >> "$PageSclt"
echo >> "$PageSclt"
echo "$(gettext '{{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 "$(gettext '== 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 "$(gettext '=== 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 "$(gettext '{{Newpage}} ')" >> $PageSclt
#O Create section 'Article', 'Source', 'License', 'Contributors(?)'
echo "$(gettext '== 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 -n "<span style="font-zize:85%";>" >> $PageSclt
echo "$(gettext '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 $"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 "$(gettext ' 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/$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 "''$(gettext ', 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 "''$(gettext ', 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 "$(gettext ', ''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 "$(gettext '. 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 "$(gettext '. see :') https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$Bookname/$line" >> $Projectdir/$line/$line.author
else echo "$(gettext '. 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 "$(gettext ' {{Newpage}} ')" >> $PageSclt
<div style="page-break-before:always"></div>
if [ "$2" = "--t" ]; then more $PageSclt; fi
exit 0
# End of en_sclt.inc
tests_add_sclt.bash
modifier#! /bin/bash
#P file : tests_add_sclt.bash
#P Syntax ./tests_add_sclt.bash <short-bookname> [ --t ]
VERSION=210528
#O Clean screen
clear
#O Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
#O add_sclt global variables
source $Workdir/vars/installdir.var
#O Print tests_add_sclt.bash version
echo " tests_add_sclt.bash version = $VERSION"
sleep 2
#T echo "----"
#O Control if the test add_sclt.sh file is clean
echo -e "\033[1;33m Control add_sclt.sh in the local test directory \033[0m" > text-control.txt
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
echo -e "\033[1;33m ---- \033[0m"
echo -e "\033[1;33m### add_sclt.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" add_sclt.sh >> text-control.txt
echo -e "\033[1;33m###### en_sclt.inc ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" en_sclt.inc >> text-control.txt
echo -e "\033[1;33m###### fr_sclt.inc ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" fr_sclt.inc >> text-control.txt
more text-control.txt
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
#T echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
#O Test with first param empty
echo "Command ./add_sclt.sh without parameter"
./add_sclt.sh
echo;echo " wait for 2 sec"
sleep 2; echo "----"
#O Test, all with option --t
echo " All tests whith parameter --t"
#O add_sclt local books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./add_sclt.sh LivreTest --t
elif [ "$Inkey" = "2" ]; then ./add_sclt.sh Hélices_de_navires_à_déplacement --t
elif [ "$Inkey" = "3" ]; then ./add_sclt.sh TestBook --t
elif [ "$Inkey" = "4" ]; then ./add_sclt.sh Mkd_\(Extracteur_de_documents\) --t
elif [ "$Inkey" = "5" ]; then ./add_sclt.sh Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./add_sclt.sh Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./add_sclt.sh Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./add_sclt.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs --t
elif [ "$Inkey" = "9" ]; then ./add_sclt.sh LivreTest --t
else echo "$inkey local url of site not found"; exit 0
fi
done
#O End tests_add_sclt.bash
See results
modifierLivreTest
modifierTestBook
modifier
Add appendix
scli.inc.sh
Éditeur : Goelette Cardabela
scli.inc.sh
modifierscli.inc.sh
modifierCe fichier est l'entête des fichiers d'images scli, il est inclus dans toutes les commandes scli : add_sclic, add_sclipco, add_sclipwb
This file is included in all scli image commands, add_sclic, add_sclipco, add_sclipwb
#! /bin/bash
# Fichier : sclip.inc.sh
#H Nom du fichier de commandes : sclip.inc
#H Syntaxe : "sclip.inc <nom du livre>"
#H Exemple : "./sclip.inc LivreTest" à la console.
#H Date de création : 9 mai 2020
#P Modifié le : 21/06/2021 pour la version internationalisée Add_appendix
#P La version de la documentation sur WikiLivres le : 17 mai 2020 est obsolète
#P
TEXTDOMAIN=scli.inc
TEXTDOMAINDIR="/usr/share/locale"
VERSION=211008
#O . gettext.sh for translation
. gettext.sh
#O Si la commande est une commande de test afficher la version
if [ "$0" = "./sclip.inc.sh" ]; then echo "sclip.inc.sh : Version "$VERSION; fi
if [ "$2" = "--t" ]; then echo "sclip.inc : Version "$VERSION; fi
#O Include the file header.inc
if test -e ~/Add_appendix/bin/header.inc; then source ~/Add_appendix/bin/header.inc
else echo $"$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
fi
#0 Initialisation de la variable d'entête des fichiers scli.
Headscli=$Projectdir/$1.scli
echo > $Headscli
#O Si le livre est sur site wikibooks français
if [ "$Site" = "fr.wikibooks.org" ]
then
{
echo "$Headscli version en français"
echo "Entête des fichiers sclic, slipco, sclipwb : $Headscli"; echo
#O Créer la section 'Image', 'Source', 'licence', 'Contributeur(?)'
echo "== Sources des images licences et contributeurs ==" > $Headscli
#O Ajouter le texte : style PediaPress ou personnalisé.
#O style PediaPress :
echo "<span style=\"font-size:85%\">Les ''sources'' listées pour chaque illustration fournissent des informations de licence plus détaillées, y compris le statut des droits d'auteurs, les détenteurs de ces droits et les conditions de licence.</span>" >> $Headscli
#O Ou: (imprimer l'un ou l'autre de ces textes)
#O style personnalisé :
#O Les textes sont disponibles avec leurs licences respectives, cependant
#O d’autres termes peuvent s’appliquer.<br />
#O Voyez les termes d’utilisation pour plus de détails :<br />
#O https://wikimediafoundation.org/wiki/Conditions_d'utilisation
# echo "<span style=\"font-size:85%\">Les textes sont disponibles avec leurs licences respectives, cependant d’autres termes peuvent s’appliquer.<br />Voyez les termes d’utilisation pour plus de détails :<br />https://wikimediafoundation.org/wiki/Conditions_d\'utilisation.</span>" >> $Headscli
}
else
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
fi
echo " " >> $Headscli
echo "<div style=\"font-size:72%\">" >> $Headscli
echo >> $Headscli
#T
cat $Headscli
#T exit
# Fin de scli.inc.sh
Tests_scli.inc.bash
modifier [ --t ]
VERSION=210621
#O Clean screen
clear
#O Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
#O add global variables
source $Workdir/vars/installdir.var
#O Print tests_scli.inc.bash version
echo " tests_scli.inc.bash version = $VERSION"
sleep 2
#T echo "----"
#O Control if the test scli.inc.sh file is clean
echo -e "\033[1;33m Control scli.inc.sh in the local test directory \033[0m" > text-control.txt
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m### scli.inc.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" scli.inc.sh >> text-control.txt
echo >> text-control.txt
more text-control.txt
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
#T echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
#O Test with first param empty
echo "Command ./scli.inc.sh without parameter"
./scli.inc.sh
echo;echo " wait for 2 sec"
sleep 2; echo "----"
#O Test, all with option --t
echo " All tests whith parameter --t"
#O scli.inc local books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./scli.inc.sh LivreTest --t
elif [ "$Inkey" = "2" ]; then ./scli.inc.sh Hélices_de_navires_à_déplacement --t
elif [ "$Inkey" = "3" ]; then ./scli.inc.sh TestBook --t
elif [ "$Inkey" = "4" ]; then ./scli.inc.sh Mkd_\(Extracteur_de_documents\) --t
elif [ "$Inkey" = "5" ]; then ./scli.inc.sh Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./scli.inc.sh Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./scli.inc.sh Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./scli.inc.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs --t
elif [ "$Inkey" = "9" ]; then ./scli.inc.sh LivreTest --t
else echo "$inkey local url of site not found"; exit 0
fi
done
#O End tests_scli.inc.bash
Exemple de présentation
modifierPour les livres en français
modifierSources des images licences et contributeurs
modifierLes sources listées pour chaque illustration fournissent des informations de licence plus détaillées, y compris le statut des droits d'auteurs, les détenteurs de ces droits et les conditions de licence.
For books in English
modifierImages sources licenses and contributors
modifierThe sources listed for each illustration provide more detailed licensing information, including copyright status, the holders of these rights and the license conditions.
Add appendix
add_sclic.sh
Éditeur : Goelette Cardabela
add_sclic.sh
modifieradd-sclic.sh
modifierCette commande appelle en_scli.inc ou fr_scli.inc selon l'origine de wikibooks
#! /bin/bash
#HF Fichier : add-sclic.sh
#HF Nom du fichier de commandes : add-sclic
#HF Syntaxe : "add-sclic <nom du livre> [ --t ]"
#HF Exemple : "./add-sclic LivreTest --t" à la console.
#HF
#DF La commande ./add_sclic <wikilivre> commence par créer la page
#DF $Projet/$1.sclic comme elle apparaîtra dans la première partie de la page
#DF "Annexe" du livre avec les titre en wikitexte et les sections :
#DF Références: toutes celles qui n'ont pas été affichées dans les pages.
#DF Contenus: liens établis vers la page du livre et les articles (sous-pages)
#DF Source de l'édition: lien vers la page qui a permis de créer l' "Annexe".
#DF Sources licences et contributeurs des articles: ne concerne que les
#DF articles, les sous-pages.
#DF
#DE the command ./add_sclic <Wiki-book>[--t], first create the page
#DE $ Project / $ 1.sclic as it will appear in the "Appendix" page with the
#DE titles and Wikitext sections:
#DE References : all references not referenced in articles
#DE Contents : links to book articles
#DE Sources of the edition : link to the page that allows you to create the
#DE annex page
#DE Licenses sources and article contributors : only articles and sub-pages
#DE
TEXTDOMAIN=add_sclic
TEXTDOMAINDIR="/usr/share/locale"
VERSION=211008
#O . gettext.sh for translation
. gettext.sh
#O If first parameter is './add-sclic' print the add_sclic version
if [ "$0" = "./add-sclic" ]; then echo "add-sclic : Version "$VERSION; fi
#O Include the file header.inc
if test -e ~/Add_appendix/bin/header.inc; then source ~/Add_appendix/bin/header.inc
else echo $"$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
fi
#O Create variable PageSclic
Projectdir=$Workdir/books/$1
PageSclic="$Projectdir/$1.sclic"
echo $PageSclic
#O Inclure la commande scli.inc
source $Bindir/scli.inc
#O Page scli classique initialization with the title 'Images sources, etc.
cat $Projectdir/$1.scli > $PageSclic
#O Include the command corresponding to the origin of the book, depending on execution in test mode
if [ "$2" = "--t" ]
then
#T pwd > pwd.txt; read Localdir < pwd.txt; rm pwd.txt; else Localdir=$Bindir; fi
{
pwd > pwd.txt; read Localdir < pwd.txt; rm pwd.txt
if [ "$Site" = "fr.wikibooks.org" ]; then source $Localdir/fr_sclic.inc.sh
else source $Localdir/en_sclic.inc.sh
fi
}
else
if [ "$Site" = "fr.wikibooks.org" ]; then source $Bindir/fr_sclic.inc
else source $Bindir/en_sclic.inc
fi
fi
# end file add_sclic.sh
en_sclic.inc
modifier#! /bin/bash
#H File : en_scli.inc include in add at add_scli.sh
#P . gettext for translation
. gettext.sh
TEXTDOMAIN=en_sclic.inc
TEXTDOMAINDIR="/usr/share/locale"
VERSION=211008
cd $Projectdir
if [ "$2" = "--t" ]
then
echo "Projectdir = $Projectdir"
echo "en_sclic version = $VERSION"
fi
#O Select lines containing 'fichier:', 'file', image and create bookname.files
cat $Projectdir/$1/$1.str | grep -n -i -e fichier: -e file: -e image: > $Projectdir/$1/$1.files
#O Select lines containing 'fichier:', '.jpg', '.png', '.gif' and create bookname.pict
cat $Projectdir/$1/$1.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif > $Projectdir/$1/$1.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/$1/$1.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$1/$1.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/$1/$1.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/$1/$1.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/$1 -r -linf -k -p -E -i $Projectdir/$1/$1.links
#O Copy html liles from ./commons.wikimedia.org/wiki in the curreny directory
cd $1
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/$1/$1.links
then
{
echo $"$Projectdir/$1/$1.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/$1/$1.links
}
elif test -s $Projectdir/html.list; then cp $Projectdir/html.list $Projectdir/$1/html.list
else echo $"No images found in $Projectdir/$1"; 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
echo "</div>" >> $PageSclic
echo "$(gettext '{{Newpage}} ')" >> $PageSclic
exit 0
#end of file en_sclic.inc.sh
fr_sclic.inc
modifier#! /bin/bash
#H File : fr_sclic.inc include in add at add_sclic.sh
Version=210819
cd $Projectdir
if [ "$2" = "--t" ]
then
echo "Projectdir = $Projectdir"
echo "fr_sclic version = $Version"
fi
#O Sélectionner les lignes contenant 'fichier:', 'file', image et créer le fichier .files
cat $Projectdir/$1/$1.str | grep -n -i -e fichier: -e file: -e image: > $Projectdir/$1/$1.files
#O Sélectionner les lignes contenant 'fichier:', '.jpg', '.png', '.gif' et créer le fichier .pict
cat $Projectdir/$1/$1.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif > $Projectdir/$1/$1.picts
#O Sélectionner dans le fichier .files, les lignes contenant 'title', supprimer le tag <div> couper ">" et sélectionner le dernier champ pour créer le fichier des illustrations
cat $Projectdir/$1/$1.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$1/$1.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 troiè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/$1/$1.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/$1/$1.links
#O Télécharger les fichiers contenus dans la liste du fichier bookname.links
wget -P $Projectdir/$1 -r -linf -k -p -E -i $Projectdir/$1/$1.links
#O Copy html files from commons.wikimedia.org/wiki if this file exist, in current directory
cd $1
if test -e commons.wikimedia.org; then cp -R commons.wikimedia.org/wiki/*.html . ; fi
#O Copy html files from $Site if this file exist, in current directory
if test -e $Site; then cp -R $Site/wiki/*.html . ; fi
#O Initialiser le fichier html.list
echo -n "" > html.list
if test -s $Projectdir/$1/$1.links
then {
#O Tant qu'on lit des lignes dans le fichier .links, lire les images et les lister dans 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/$1/$1.links
}
elif test -s $Projectdir/html.list; then cp $Projectdir/html.list $Projectdir/$1/html.list
else echo "Aucune images trouvées dans $Projectdir/$1"; exit 0
fi
echo "*** Références : image, src, lic, contrib. "
#O tant que l'on lit des lignes dans le fichier html.list extraire les illustrations, sources, licences, auteurs(s)
while read line
do
echo ""
echo ""
echo "**** ligne lue = $line ****"
echo ""
mkd -pw '**' $line $line.tmp
cat $line.tmp | tr ',' '\n' > $line.str
echo -n "'''Illustration : '''" > $line.title
cat $line.str |grep wgTitle | cut -d '"' -f4 >> $line.title
cat $line.title >> $PageSclic
cat $line.title
echo -n ", ''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 ", ''licence : ''" > $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 ", ''auteur(s) : ''" > $line.auteur
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.auteur
else echo "-" >> $line.auteur
fi
cat $line.auteur >> $PageSclic
cat $line.auteur
echo >> $PageSclic
done < html.list
echo "</div>" >> $PageSclic
echo "{{Nouvelle page imprimée}}" >> $PageSclic
exit 0
# fin de fichier fr_sclic.sh
tests_add_sclic.bash
modifier#! /bin/bash
#P file : tests_add_sclic.bash
#P Syntax ./tests_add_sclic.bash <short-bookname> [ --t ]
VERSION=210618
#O Clean screen
clear
#O Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
#O add_sclic global variables
source $Workdir/vars/installdir.var
#O Print tests_add_sclic.bash version
echo " tests_add_sclic.bash version = $VERSION"
sleep 2
#T echo "----"
#O Control if the test add_sclic.sh file is clean
echo -e "\033[1;33m Control add_sclic.sh in the local test directory \033[0m" > text-control.txt
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m### add_sclic.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" add_sclic.sh >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m###### en_sclic.inc.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" en_sclic.inc.sh >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m###### fr_sclic.inc.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" fr_sclic.inc.sh >> text-control.txt
echo -e "\033[1;33m ---- \033[0m" >> text-control.txt
more text-control.txt
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
#T echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
#O Test with first param empty
echo "Command ./add_sclic.sh without parameter"
./add_sclic.sh
echo;echo " wait for 2 sec"
sleep 2; echo "----"
#O Test, all with option --t
echo " All tests whith parameter --t"
#O add_sclic local books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./add_sclic.sh LivreTest --t
elif [ "$Inkey" = "2" ]; then ./add_sclic.sh Hélices_de_navires_à_déplacement --t
elif [ "$Inkey" = "3" ]; then ./add_sclic.sh TestBook --t
elif [ "$Inkey" = "4" ]; then ./add_sclic.sh Mkd_\(Extracteur_de_documents\) --t
elif [ "$Inkey" = "5" ]; then ./add_sclic.sh Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./add_sclic.sh Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./add_sclic.sh Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./add_sclic.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs --t
elif [ "$Inkey" = "9" ]; then ./add_sclic.sh LivreTest --t
else echo "$inkey local url of site not found"; exit 0
fi
done
#O End tests_add_sclic.bash
Add appendix
add_sclipco.sh
Éditeur : Goelette Cardabela
add_sclipco.sh
modifierAdd_sclipco.sh
modifierThis is the master command for personified source, copyright, license for images on wikibooks (sclipco) and include en_sclipco.inc or fr_sclipco.inc
- en_sclipco.inc content gettext for translations.
#! /bin/bash
#HF Fichier : add_sclipco.sh
#HF Nom du fichier de commandes : add_sclipco
#HF Syntaxe : "add_sclippwb <nom du livre> [ --t ]"
#HF Exemple : "./add_sclipco LivreTest --t" à la console.
#HF La commande test est tests_add_sclipco.bash dans le répertoire des tests
#HF
#DF La commande ./add_sclipco <wikilivre> commence par créer la page
#DF
#DE the command ./add_sclipco <Wiki-book>[--t], first create the page
#DE
TEXTDOMAIN=add_slipco
TEXTDOMAINDIR="/usr/share/locale"
VERSION=211008
#O . gettext.sh for translation
. gettext.sh
#O If first parameter is './add-sclipco' print the add_sclipco version
if [ "$0" = "./add-sclipco" ]; then echo "add-sclipco : Version "$VERSION; fi
#O Include the file header.inc
if test -e ~/Add_appendix/bin/header.inc; then source ~/Add_appendix/bin/header.inc
else echo $"$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
fi
#O Create variable Pagesclipco
Projectdir=$Workdir/books/$1
Pagesclipco="$Projectdir/$1.sclipco"
echo $Pagesclipco
#O Include scli.inc
source $Bindir/scli.inc
#O Wikibooks sclipco personalized page initialization with the title 'Images sources, etc.
cat $Projectdir/$1.scli > $Pagesclipco
#O Include the command corresponding to the origin of the book, depending on execution in test mode
#O If tests mode
if [ "$2" = "--t" ]
then
#T pwd > pwd.txt; read Localdir < pwd.txt; rm pwd.txt; else Localdir=$Bindir; fi
{
pwd > pwd.txt; read Localdir < pwd.txt; rm pwd.txt
if [ "$Site" = "fr.wikibooks.org" ]; then source $Localdir/fr_sclipco.inc.sh
else source $Localdir/en_sclipco.inc.sh
fi
}
#O Else is not local test command with --t option
else
if [ "$Site" = "fr.wikibooks.org" ]; then source $Bindir/fr_sclipco.inc
else source $Bindir/en_sclipco.inc
fi
fi
# end file add_sclipco.sh
en_slipco.inc.sh
modifier#! /bin/bash
#H File : en_sclipco.inc include in add_sclipco.sh
TEXTDOMAIN=en_sclipco.inc
TEXTDOMAINDIR="/usr/share/locale"
Version=211008
cd $Projectdir
if [ "$2" = "--t" ]
then
echo "Projectdir = $Projectdir"
echo "en_sclipco version = $Version"
fi
#O Variable $PageScliPwb definition
Pagesclipco=$Projectdir/$1.sclipco
#O Create an identification loop of the directories corresponding to the articles
#O As long as we can read the lines of the file $Projectdir/$1.pj
while read pjline
do
#O If the line read is not $1 (name of the book)
#T echo "line read : " $line
if [ $pjline != $1 ]
#O Then:
then
#O Enter in the article directory,
cd $Projectdir/$pjline
#O Create image documentation files
#O Open the stream of $ Projectdir/$1/$1.str of the image and select
#O the character strings containing: File:, Image; and put in files
#O $Projectdir/$line/$line/.files, .pict, .illustration, .images, .links
cat $Projectdir/$pjline/$pjline.str | grep -n -i -e Fichier: -e file: -e image: | sed -f $RepCom/$Conversions > $Projectdir/$pjline/$pjline.files
cat $Projectdir/$pjline/$pjline.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif | sed -f $RepCom/$Conversions> $Projectdir/$pjline/$pjline.picts
cat $Projectdir/$pjline/$pjline.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$pjline/$pjline.illustrations
#T cat $Projectdir/$pjline/$pjline.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/$pjline/$pjline.links
cat $Projectdir/$pjline/$pjline.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https://$Site | sed "s/\"/!/g" | cut -d '!' -f2 > $Projectdir/$pjline/$pjline.images
#Tbreak
#O Transform the links of the image file on wikibooks into an image file on commons
cat $Projectdir/$pjline/$pjline.images | sed "s/$Site/commons.wikimedia.org/g"| sed "s/Fichier/File/g" > $Projectdir/$pjline/$pjline.commonsimages
#O Download the image files from the wikimedia server.
#P Note: the -N option allows you to avoid downloading an up-to-date file,
#P and without adding a numbering.
#T #T wget -N -P $Projectdir/$pjline -i $Projectdir/$pjline/$pjline.images
wget -P $Projectdir/$pjline -r -linf -k -p -E -i $Projectdir/$pjline/$pjline.commonsimages
#T echo "*** Commonsimages ***"; cat $Projectdir/$pjline/$pjline.commonsimages; exit 0
#O Copy the downloaded images to the directory of the current article..
cp $Projectdir/$pjline/commons.wikimedia.org/wiki/*.html $Projectdir/$pjline/.
#O Initialize the commonshtml.list file with empty text.
echo -n "" > commonshtml.doublons
#O List the image files in the order of printing or display,
#O using the list $Projectdir/$pjline/$pjline.commons.images
#O As long as we can read lines in $Projectdir/$pjline/$pictline.images
while read pictline
do
#O Cut the lignes at carriage return, sélect the last field and add '.html'
#echo $pictline | awk -F"/" '{for (i=1;i<=NF;i+=2) print $i "\n"}' #| cut -d '%' -f1 | cut -d '.' -f1 > tmp
echo $pictline | awk -F"/" '{ print $NF".html"}' >> commonshtml.doublons
#O Cut the duplicated lines and select even fields.
echo -n "" > commonshtml.list
awk 'BEGIN { FILENAME }
{memfile [NR] = $0 }
END { for ( i = 1 ; i <= NR ; i=i+2 ) {
print memfile[i] >> "commonshtml.list"
}
# print "Fin"
} ' commonshtml.doublons
#O End of while $Projectdir/$pjline/$pjline.commonsimages
done < $Projectdir/$pjline/$pjline.commonsimages
#T Afficher html.list
#T echo "*** commonshtml.list ***"; cat commonshtml.listexit 0
#O Copy article name in file $1.sclipco
echo "'''Article : $pjline'''<br \>" >> $Pagesclipco
echo "'''Article : $pjline'''"
#P## Annexe version 'wikimedia commons' ##############################
#O As long as there are (local) links in the commonshtml.list image file
while read htmlline
do
#O Afficher la ligne lue,
echo ""
echo ""
echo "$(gettext ' ---- line read = $htmlline --- ')"
echo ""
#O With mkd (sofware), select the character strings from the image file $htmlline
#O and copy them to $ htmlline.co.str after replacing the character ',' with
#O 'new-line'
mkd -pw '**' $htmlline $htmlline.tmp
cat $htmlline.tmp | tr ',' '\n' > $htmlline.co.str
#T echo "*** $htmlline.co.str : ***"; cat $htmlline.co.str; exit 0
#O images,
echo -n "'''$(gettext ' Illustration : ')'''" > $htmlline.co.title
cat $htmlline.co.str | grep wgTitle | cut -d '"' -f4 >> $htmlline.co.title
cat $htmlline.co.title >> $Pagesclipco
cat $htmlline.co.title
#T echo "*** $htmlline.co.title : ***"; cat $htmlline.co.title; exit 0
#O source,
echo -n ", ''$(gettext ' source : ')''https://commons.wikimedia.org/wiki/" > $htmlline.co.source
echo -n $htmlline | sed "s/.html//g" | sed "s/.str//g" >> $htmlline.co.source
if [ "$Site" = "fr.wikibooks.org" ]; then echo "?uselang=fr" >> $htmlline.co.source
elif [ "$Site" = "en.wikibooks.org" ]; then echo "?uselang=en" >> $htmlline.co.source
else echo
fi
cat $htmlline.co.source >> $Pagesclipco
cat $htmlline.co.source
#T echo "*** $htmlline.co.source : ***"; cat $htmlline.co.source; exit 0
#O license,
echo -n "$(gettext ' , ''license : ')'' " > $htmlline.co.license
cat $htmlline.co.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}' >> $htmlline.co.license
cat $htmlline.co.license >> $Pagesclipco
cat $htmlline.co.license
#T echo "*** $htmlline.co.license : ***"; cat $htmlline.co.license; exit 0
#O auteur(s).
echo -n '' > tmp
echo -n "$(gettext ' , ''author(s) : '' ')" > $htmlline.co.author
cat $htmlline.co.str | grep -i -n -m1 -A 1 -e Author -e Auteur | tr '/' '\n' | grep -i -e user -e utilisteur -e auteur -e author | cut -d '"' -f1 | grep -i -e user -e utilisteur -e auteur -e author > tmp
read Tmp < tmp
#T
echo "Tmp = $Tmp"
if [ "$Tmp" = "" ]
#T then echo "tmp empty"
then echo "-" > tmp
fi
#T echo $Tmp | cut -d '-' -f2 | sed "s/\.\ /%/g" | cut -d '%' -f1
cat tmp >> $htmlline.co.auteur
cat $htmlline.co.auteur >> $Pagesclipco
cat $htmlline.co.auteur
#T echo "*** $htmlline.co.auteur : ***"; cat $htmlline.co.auteur; exit 0
#O Finish the page $Pagesclipco
echo "" >> $Pagesclipco
#O End of as long as there are lines in commonshtml.list
done < commonshtml.list
#O End of 'if the line is not the name of book'.
fi
#O End of while line in $1.pj
done < $Projectdir/$1.pj
#O End of page $Pagesclipco
echo "</div>" >> $Pagesclipco
echo "$(gettext ' {{Newpage}} ')" >> $Pagesclipco
exit 0
# End of en_sclipco.inc.sh
fr_slipco.inc.sh
modifier#! /bin/bash
#H File : fr_sclipco.inc include in add_sclipco.sh
Version=210709
cd $Projectdir
if [ "$2" = "--t" ]
then
echo "Projectdir = $Projectdir"
echo "fr_sclipco version = $Version"
fi
#O Définition de la variable $Pagesclipco
Pagesclipco=$Projectdir/$1.sclipco
#O Créer une boucle d'identification des répertoires correspondants aux article
#O du livre.
#O Tant que l'on peut lire les lignes du fichier $Projectdir/$1.pj
while read pjline
do
#O Si la ligne lue n'est pas $1 (nom du livre)
#T echo "ligne lue : " $line
if [ $pjline != $1 ]
#O Alors:
then
#T echo "====="
#T echo ""
#T echo "ligne prise en compte : " $pjline
#O Entrer dans le répertore de l'article,
cd $Projectdir/$pjline
#T echo -n "répertoire courant : "
#T pwd
#T break
#O Créer les fichiers de documentation des images de la page.
#O Ouvrir le flux $Projectdir/$1/$1.str de limage et sélectionner les chaînes de
#O caractères contenant Fichier:, File:, Image:, les copier dans les nouveaux
#O fichiers $Projectdir/$line/$line/.files, .pict, .illustration, .images, .links
cat $Projectdir/$pjline/$pjline.str | grep -n -i -e Fichier: -e file: -e image: | sed -f $RepCom/$Conversions > $Projectdir/$pjline/$pjline.files
cat $Projectdir/$pjline/$pjline.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif | sed -f $RepCom/$Conversions> $Projectdir/$pjline/$pjline.picts
cat $Projectdir/$pjline/$pjline.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$pjline/$pjline.illustrations
#T cat $Projectdir/$pjline/$pjline.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/$pjline/$pjline.links
cat $Projectdir/$pjline/$pjline.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https://$Site | sed "s/\"/!/g" | cut -d '!' -f2 > $Projectdir/$pjline/$pjline.images
#Tbreak
#O Transformer les liens du fichier d'images sur wikibooks en fichier d'images sur commons
cat $Projectdir/$pjline/$pjline.images | sed "s/$Site/commons.wikimedia.org/g"| sed "s/Fichier/File/g" > $Projectdir/$pjline/$pjline.commonsimages
#O Télécharger les fichiers d'images depuis le serveur wikimedia.
#P Remarque : l'option -N permet d'éviter de téléchager un fichier à jour
#P et sans ajouter une numérotation.
#T #T wget -N -P $Projectdir/$pjline -i $Projectdir/$pjline/$pjline.images
wget -P $Projectdir/$pjline -r -linf -k -p -E -i $Projectdir/$pjline/$pjline.commonsimages
#T echo "*** Commonsimages ***"; cat $Projectdir/$pjline/$pjline.commonsimages; exit 0
#O Copier les images téléchargées dans le répertoire de l'article courant.
cp $Projectdir/$pjline/commons.wikimedia.org/wiki/*.html $Projectdir/$pjline/.
#O Initialiser le fichier de liste commonshtml.list avec un texte vide.
echo -n "" > commonshtml.doublons
#O Lister les fichiers d'images dans l'ordre d'impression ou de l'affichage,
#O à laide de la liste $Projectdir/$pjline/$pjline.images
#O Tant que l'on peut lire des lignes dans $Projectdir/$pjline/$pictline.images
while read pictline
do
#O Couper les lignes au retour chariot, sélectionner le dernier champ et ajouter '.html'
#echo $pictline | awk -F"/" '{for (i=1;i<=NF;i+=2) print $i "\n"}' #| cut -d '%' -f1 | cut -d '.' -f1 > tmp
echo $pictline | awk -F"/" '{ print $NF".html"}' >> commonshtml.doublons
#O Couper les doublons et sélectionner les champs pairs.
echo -n "" > commonshtml.list
awk 'BEGIN { FILENAME }
{memfile [NR] = $0 }
END { for ( i = 1 ; i <= NR ; i=i+2 ) {
print memfile[i] >> "commonshtml.list"
}
# print "Fin"
} ' commonshtml.doublons
#O Fin tant que l'on peut lire des lignes dans $Projectdir/$pictline/$pictline.images
done < $Projectdir/$pjline/$pjline.commonsimages
#T Afficher html.list
#T echo "*** commonshtml.list ***"; cat commonshtml.listexit 0
#O Copier le nom de l'article dans $1.sclip
echo "'''Article : $pjline'''<br \>" >> $Pagesclipco
echo "'''Article : $pjline'''"
#P## Annexe version 'wikimedia commons' ##############################
#O Tant qu'il y a des liens (locaux) dans le fichier d'images html.list
while read htmlline
do
#O Afficher la ligne lue,
echo ""
echo ""
echo "---- ligne lue = $htmlline ---"
echo ""
#O Avec mkd sélectionner les chaînes de caractères du fichier image $htmlline
#O et les copier dans $htmlline.str après remplacement du caractère ',' par
#O 'new-line'
mkd -pw '**' $htmlline $htmlline.tmp
cat $htmlline.tmp | tr ',' '\n' > $htmlline.co.str
#T echo "*** $htmlline.co.str : ***"; cat $htmlline.co.str; exit 0
#O images,
echo -n "'''Illustration : '''" > $htmlline.co.title
cat $htmlline.co.str | grep wgTitle | cut -d '"' -f4 >> $htmlline.co.title
cat $htmlline.co.title >> $Pagesclipco
cat $htmlline.co.title
#T echo "*** $htmlline.co.title : ***"; cat $htmlline.co.title; exit 0
#O source,
# https://commons.wikimedia.org/wiki/File:Gabriel_Garcia_Marquez_-_Fresque.jpg?uselang=en
echo -n ", ''source : ''https://commons.wikimedia.org/wiki/" > $htmlline.co.source
echo -n $htmlline | sed "s/.html//g" | sed "s/.str//g" >> $htmlline.co.source
if [ "$Site" = "fr.wikibooks.org" ]; then echo "?uselang=fr" >> $htmlline.co.source
elif [ "$Site" = "en.wikibooks.org" ]; then echo "?uselang=en" >> $htmlline.co.source
else echo
fi
cat $htmlline.co.source >> $Pagesclipco
cat $htmlline.co.source
#T echo "*** $htmlline.co.source : ***"; cat $htmlline.co.source; exit 0
#O license,
echo -n ", ''licence : ''" > $htmlline.co.license
cat $htmlline.co.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}' >> $htmlline.co.license
cat $htmlline.co.license >> $Pagesclipco
cat $htmlline.co.license
#T echo "*** $htmlline.co.license : ***"; cat $htmlline.co.license; exit 0
#O auteur(s).
echo -n '' > tmp
echo -n ", ''auteur(s) : ''" > $htmlline.co.auteur
cat $htmlline.co.str | grep -i -n -m1 -A 1 -e Author -e Auteur | tr '/' '\n' | grep -i -e user -e utilisteur -e auteur -e author | cut -d '"' -f1 | grep -i -e user -e utilisteur -e auteur -e author > tmp
read Tmp < tmp
#T
echo "Tmp = $Tmp"
if [ "$Tmp" = "" ]
#T then echo "tmp vide"
then echo "-" > tmp
fi
#T echo $Tmp | cut -d '-' -f2 | sed "s/\.\ /%/g" | cut -d '%' -f1
cat tmp >> $htmlline.co.auteur
cat $htmlline.co.auteur >> $Pagesclipco
cat $htmlline.co.auteur
#T echo "*** $htmlline.co.auteur : ***"; cat $htmlline.co.auteur; exit 0
#O Terminer la page $Pagesclipco
echo "" >> $Pagesclipco
#O Fin du tant qu'il y a des lignes
done < commonshtml.list
#O Fin du 'si la ligne n'est pas le nom du livre'.
fi
#O Fin du tq .pj
done < $Projectdir/$1.pj
#O Terminer la page $Pagesclipco
echo "</div>" >> $Pagesclipco
echo "{{Nouvelle page imprimée}}" >> $Pagesclipco
exit 0
# Fin de fr_sclipco.inc.sh
tests_add_sclipco.bash
modifier#! /bin/bash
#P file : tests_add_sclipco.bash
#P Syntax ./tests_add_sclipco.bash <short-bookname> [ --t ]
VERSION=210709
#O Clean screen
clear
#O Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
#O add_sclipco global variables
source $Workdir/vars/installdir.var
#O Print tests_add_sclipco.bash version
echo " tests_add_sclipco.bash version = $VERSION"
sleep 2
#T echo "----"
#O Control if the test add_sclipco.sh file is clean
echo -e "\033[1;33m Control add_sclipco.sh in the local test directory \033[0m" > text-control.txt
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m### add_sclipco.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" add_sclipco.sh >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m###### en_sclipco.inc.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" en_sclipco.inc.sh >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m###### fr_sclipco.inc.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" fr_sclipco.inc.sh >> text-control.txt
echo -e "\033[1;33m ---- \033[0m" >> text-control.txt
more text-control.txt
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
#T echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
#O Test with first param empty
echo "Command ./add_sclipco.sh without parameter"
./add_sclipco.sh
echo;echo " wait for 2 sec"
sleep 2; echo "----"
#O Test, all with option --t
echo " All tests whith parameter --t"
#O add_sclipco local books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./add_sclipco.sh LivreTest --t
elif [ "$Inkey" = "2" ]; then ./add_sclipco.sh Hélices_de_navires_à_déplacement --t
elif [ "$Inkey" = "3" ]; then ./add_sclipco.sh TestBook --t
elif [ "$Inkey" = "4" ]; then ./add_sclipco.sh Mkd_\(Extracteur_de_documents\) --t
elif [ "$Inkey" = "5" ]; then ./add_sclipco.sh Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./add_sclipco.sh Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./add_sclipco.sh Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./add_sclipco.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs --t
elif [ "$Inkey" = "9" ]; then ./add_sclipco.sh LivreTest --t
else echo "$inkey local url of site not found"; exit 0
fi
done
#O End tests_add_sclipco.bash
Add appendix
add_sclipwb.sh
Éditeur : Goelette Cardabela
add_sclipwb.sh
modifiervβ Les images sont téléchargées depuis le site wikibooks
Illustrations are downloaded from wikibooks
add_sclipwb.sh
modifierThis is the master command for personified source, copyright, license for images on wikibooks (sclipwb) and include en_sclipwb.inc or fr_sclipwb.inc
- en_sclipwb.inc content gettext for translations.
#! /bin/bash
#HF Fichier : add_sclipwb.sh
#HF Nom du fichier de commandes : add_sclipwb
#HF Syntaxe : "add_sclippwb <nom du livre> [ --t ]"
#HF Exemple : "./add_sclipwb LivreTest --t" à la console.
#HF La commande test est tests_add_sclipwb.bash dans le répertoire des tests
#HF
#DF La commande ./add_sclipwb <wikilivre> commence par créer la page
#DF
#DE the command ./add_sclipwb <Wiki-book>[--t], first create the page
#DE
TEXTDOMAIN=add_sclipwb
TEXTDOMAINDIR="/usr/share/locale"
VERSION=211008
#O . gettext.sh for translation
. gettext.sh
#O If first parameter is './add-sclipwb' print the add_sclipwb version
if [ "$0" = "./add-sclipwb" ]; then echo "add-sclipwb : Version "$VERSION; fi
#O Include the file header.inc
if test -e ~/Add_appendix/bin/header.inc; then source ~/Add_appendix/bin/header.inc
else echo $"$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
fi
#O Create variable PageSclipwb
Projectdir=$Workdir/books/$1
PageSclipwb="$Projectdir/$1.sclipwb"
echo $PageSclipwb
#O Inclure la commande scli.inc
source $Bindir/scli.inc
#O Wikibooks sclipwb personalized page initialization with the title 'Images sources, etc.
cat $Projectdir/$1.scli > $PageSclipwb
#O Include the command corresponding to the origin of the book, depending on execution in test mode
#O If tests mode
if [ "$2" = "--t" ]
then
#T pwd > pwd.txt; read Localdir < pwd.txt; rm pwd.txt; else Localdir=$Bindir; fi
{
pwd > pwd.txt; read Localdir < pwd.txt; rm pwd.txt
if [ "$Site" = "fr.wikibooks.org" ]; then source $Localdir/fr_sclipwb.inc.sh
else source $Localdir/en_sclipwb.inc.sh
fi
}
#O Else is not local test command with --t option
else
if [ "$Site" = "fr.wikibooks.org" ]; then source $Bindir/fr_sclipwb.inc
else source $Bindir/en_sclipwb.inc
fi
fi
# end file add_sclipwb.sh
en_sclipwb.inc
modifier#! /bin/bash
#H File : en_sclipwb.inc included in add_sclipwb.sh
#P . gettext for translation
. gettext.sh
TEXTDOMAIN=en_sclipwb.inc
TEXTDOMAINDIR="/usr/share/locale"
VERSION=211008
cd $Projectdir
if [ "$2" = "--t" ]
then
echo "Projectdir = $Projectdir"
echo "en_sclipwb version = $VERSION"
fi
#O Variable $PageScliPwb definition
PageScliPwb=$Projectdir/$1.sclipwb
#O Create an identification loop of the directories corresponding to the articles
#O As long as we can read the lines of the file $Projectdir/$1.pj
while read pjline
do
#O If the line read is not $1 (name of the book)
#T echo "line read : " $line
if [ $pjline != $1 ]
#O Then:
then
#O Enter in the article directory,
cd $Projectdir/$pjline
#O Create image documentation files
#O Open the stream of $ Projectdir/$1/$1.str of the image and select
#O the character strings containing: File:, Image; and put in files
#O $Projectdir/$line/$line/.files, .pict, .illustration, .images, .links
cat $Projectdir/$pjline/$pjline.str | grep -n -i -e Fichier: -e file: -e image: | sed -f $RepCom/$Conversions > $Projectdir/$pjline/$pjline.files
cat $Projectdir/$pjline/$pjline.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif | sed -f $RepCom/$Conversions> $Projectdir/$pjline/$pjline.picts
cat $Projectdir/$pjline/$pjline.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$pjline/$pjline.illustrations
#T cat $Projectdir/$pjline/$pjline.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/$pjline/$pjline.links
cat $Projectdir/$pjline/$pjline.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https://$Site | sed "s/\"/!/g" | cut -d '!' -f2 > $Projectdir/$pjline/$pjline.images
#Tbreak
#O Download the image files from the wikimedia server.
#P Note: the -N option allows you to avoid downloading an up-to-date file,
#P and without adding a numbering.
#T #T wget -N -P $Projectdir/$pjline -i $Projectdir/$pjline/$pjline.images
wget -P $Projectdir/$pjline -r -linf -k -p -E -i $Projectdir/$pjline/$pjline.images
#O Copy the downloaded images to the directory of the current article.
cp $Projectdir/$pjline/$Site/wiki/*.html $Projectdir/$pjline/.
#O Initialize the html.list file with empty text.
echo -n "" > html.doublons
#O List the image files in the order of printing or display,
#O using the list $Projectdir/$pjline/$pjline.images
#O As long as we can read lines in $Projectdir/$pjline/$pictline.images
while read pictline
do
#O Cut the lignes at carriage return, sélect the last field and add '.html'
#echo $pictline | awk -F"/" '{for (i=1;i<=NF;i+=2) print $i "\n"}' #| cut -d '%' -f1 | cut -d '.' -f1 > tmp
echo $pictline | awk -F"/" '{ print $NF".html"}' >> html.doublons
#O Cut the duplicated lines and select even fields.
echo -n "" > html.list
awk 'BEGIN { FILENAME }
{memfile [NR] = $0 }
END { for ( i = 1 ; i <= NR ; i=i+2 ) {
print memfile[i] >> "html.list"
}
# print "Fin"
} ' html.doublons
#O fin tant que l'on peut lire des lignes dans $Projectdir/$pictline/$pictline.images
done < $Projectdir/$pjline/$pjline.images
#O Copy article name in file $1.sclip
echo "'''$(gettext ' Article : ')'''$pjline'''<br \>" >> $PageScliPwb
echo "'''$(gettext ' Article : ')'''$pjline'''"
#P## Appendix version 'wikibooks' ##############################
#O As long as there are (local) links in the html.list image file
while read htmlline
do
#O Display the line read,
echo ""
echo ""
echo "$(gettext ' ---- line read = $htmlline --- ')"
echo ""
#O Select the character strings from the image file $htmlline and copy
#O them to $ htmlline.str after replacing the character ',' with 'new-line'
mkd -pw '**' $htmlline $htmlline.tmp
cat $htmlline.tmp | tr ',' '\n' > $htmlline.str
#O images,
echo -n "'''$(gettext ' Illustration : ')'''" > $htmlline.title
cat $htmlline.str | grep wgTitle | cut -d '"' -f4 >> $htmlline.title
cat $htmlline.title >> $PageScliPwb
cat $htmlline.title
#O source,
echo -n "''$(gettext ', source : ')''https://"$Site"/w/index.php?title=" > $htmlline.source
echo $htmlline.str | sed "s/.html//g" | sed "s/.str//g" >> $htmlline.source
cat $htmlline.source >> $PageScliPwb
cat $htmlline.source
#O license,
echo -n "$(gettext ' , ''license : ')'' " > $htmlline.license
cat $htmlline.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}' >> $htmlline.license
cat $htmlline.license >> $PageScliPwb
cat $htmlline.license
#O author(s).
echo -n '' > tmp
echo -n "$(gettext ' , ''author(s) : '' ')" > $htmlline.author
cat $htmlline.str | grep -i -n -m1 -A 1 -e Author -e Auteur | tr '/' '\n' | grep -i -e user -e utilisteur -e auteur -e author | cut -d '"' -f1 | grep -i -e user -e utilisteur -e auteur -e author > tmp
read Tmp < tmp
#T
echo "Tmp = $Tmp"
if [ "$Tmp" = "" ]
#T then echo "tmp vide"
then echo "-" > tmp
fi
#T echo $Tmp | cut -d '-' -f2 | sed "s/\.\ /%/g" | cut -d '%' -f1
cat tmp >> $htmlline.author
cat $htmlline.author >> $PageScliPwb
cat $htmlline.author
#O Finish the page $PageScliPwb
echo "" >> $PageScliPwb
#O End of as long as there are lines in html.list
done < html.list
#O End of 'if the line is not the name of book'.
fi
#O End of tq .pj
done < $Projectdir/$1.pj
#O Finish the page $PageScliPwb
echo "</div>" >> $PageScliPwb
echo "$(gettext ' {{Newpage}} ')" >> $PageScliPwb
exit 0
# End of en_sclipwb.inc.sh
fr_sclipwb.sh
modifier#! /bin/bash
#H File : fr_sclipwb.inc include in add_sclipwb.sh
Version=210707
cd $Projectdir
if [ "$2" = "--t" ]
then
echo "Projectdir = $Projectdir"
echo "fr_sclipwb version = $Version"
fi
#O Définition de la variable $PageScliPwb
PageScliPwb=$Projectdir/$1.sclipwb
#O Créer une boucle d'identification des répertoires correspondants aux article
#O du livre.
#O Tant que l'on peut lire les lignes du fichier $Projectdir/$1.pj
while read pjline
do
#O Si la ligne lue n'est pas $1 (nom du livre)
#T echo "ligne lue : " $line
if [ $pjline != $1 ]
#O Alors:
then
#T echo "====="
#T echo ""
#T echo "ligne prise en compte : " $pjline
#O Entrer dans le répertore de l'article,
cd $Projectdir/$pjline
#T echo -n "répertoire courant : "
#T pwd
#T break
#O Créer les fichiers de documentation des images de la page.
#O Ouvrir le flux $Projectdir/$1/$1.str de limage et sélectionner les chaînes de
#O caractères contenant Fichier:, File:, Image:, les copier dans les nouveaux
#O fichiers $Projectdir/$line/$line/.files, .pict, .illustration, .images, .links
cat $Projectdir/$pjline/$pjline.str | grep -n -i -e Fichier: -e file: -e image: | sed -f $RepCom/$Conversions > $Projectdir/$pjline/$pjline.files
cat $Projectdir/$pjline/$pjline.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif | sed -f $RepCom/$Conversions> $Projectdir/$pjline/$pjline.picts
cat $Projectdir/$pjline/$pjline.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$pjline/$pjline.illustrations
#T cat $Projectdir/$pjline/$pjline.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/$pjline/$pjline.links
cat $Projectdir/$pjline/$pjline.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https://fr.wikibooks.org | sed "s/\"/!/g" | cut -d '!' -f2 > $Projectdir/$pjline/$pjline.images
#Tbreak
#O Télécharger les fichiers d'images depuis le serveur wikimedia.
#P Remarque : l'option -N permet d'éviter de téléchager un fichier à jour
#P et sans ajouter une numérotation.
#T #T wget -N -P $Projectdir/$pjline -i $Projectdir/$pjline/$pjline.images
wget -P $Projectdir/$pjline -r -linf -k -p -E -i $Projectdir/$pjline/$pjline.images
#O Copier les images téléchargées dans le répertoire de l'article courant.
cp $Projectdir/$pjline/fr.wikibooks.org/wiki/*.html $Projectdir/$pjline/.
#O Initialiser le fichier de liste html.list avec un texte vide.
echo -n "" > html.doublons
#O Lister les fichiers d'images dans l'ordre d'impression ou de l'affichage,
#O à laide de la liste $Projectdir/$pjline/$pjline.images
#O Tant que l'on peut lire des lignes dans $Projectdir/$pjline/$pictline.images
while read pictline
do
#O Couper les lignes au retour chariot, sélectionner le dernier champ et ajouter '.html'
#echo $pictline | awk -F"/" '{for (i=1;i<=NF;i+=2) print $i "\n"}' #| cut -d '%' -f1 | cut -d '.' -f1 > tmp
echo $pictline | awk -F"/" '{ print $NF".html"}' >> html.doublons
#O Couper les doublons et sélectionner les champs pairs.
echo -n "" > html.list
awk 'BEGIN { FILENAME }
{memfile [NR] = $0 }
END { for ( i = 1 ; i <= NR ; i=i+2 ) {
print memfile[i] >> "html.list"
}
# print "Fin"
} ' html.doublons
#O Fin tant que l'on peut lire des lignes dans $Projectdir/$pictline/$pictline.images
done < $Projectdir/$pjline/$pjline.images
#T Afficher html.list
#T cat html.list
#O Copier le nom de l'article dans $1.sclip
echo "'''Article : $pjline'''<br \>" >> $PageScliPwb
echo "'''Article : $pjline'''"
#P## Annexe version 'wikibooks' ##############################
#O Tant qu'il y a des liens (locaux) dans le fichier d'images html.list
while read htmlline
do
#O Afficher la ligne lue,
echo ""
echo ""
echo "---- ligne lue = $htmlline ---"
echo ""
#O Sélectionner les chaînes de caractères du fichier image $htmlline et les
#O copier dans $htmlline.str après remplacement du caractère ',' par 'new-line'
mkd -pw '**' $htmlline $htmlline.tmp
cat $htmlline.tmp | tr ',' '\n' > $htmlline.str
#O images,
echo -n "'''Illustration : '''" > $htmlline.title
cat $htmlline.str |grep wgTitle | cut -d '"' -f4 >> $htmlline.title
cat $htmlline.title >> $PageScliPwb
cat $htmlline.title
#O source,
echo -n ", ''source : ''https://"$Site"/w/index.php?title=" > $htmlline.source
echo $htmlline.str | sed "s/.html//g" | sed "s/.str//g" >> $htmlline.source
cat $htmlline.source >> $PageScliPwb
cat $htmlline.source
#O license,
echo -n ", ''licence : ''" > $htmlline.license
cat $htmlline.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}' >> $htmlline.license
cat $htmlline.license >> $PageScliPwb
cat $htmlline.license
#O auteur(s).
echo -n '' > tmp
echo -n ", ''auteur(s) : ''" > $htmlline.auteur
cat $htmlline.str | grep -i -n -m1 -A 1 -e Author -e Auteur | tr '/' '\n' | grep -i -e user -e utilisteur -e auteur -e author | cut -d '"' -f1 | grep -i -e user -e utilisteur -e auteur -e author > tmp
read Tmp < tmp
#T
echo "Tmp = $Tmp"
if [ "$Tmp" = "" ]
#T then echo "tmp vide"
then echo "-" > tmp
fi
#T echo $Tmp | cut -d '-' -f2 | sed "s/\.\ /%/g" | cut -d '%' -f1
cat tmp >> $htmlline.auteur
cat $htmlline.auteur >> $PageScliPwb
cat $htmlline.auteur
#O Terminer la page $PageScliPwb
echo "" >> $PageScliPwb
#O Fin du tant qu'il y a des lignes
done < html.list
#O Fin du 'si la ligne n'est pas le nom du livre'.
fi
#O Fin du tq .pj
done < $Projectdir/$1.pj
#O Terminer la page $PageScliPwb
echo "</div>" >> $PageScliPwb
echo "{{Nouvelle page imprimée}}" >> $PageScliPwb
exit 0
# Fin de fr_sclipwb.inc.sh
tests_add_sclipwb.bash
modifier#! /bin/bash
#P file : tests_add_sclipwb.bash
#P Syntax ./tests_add_sclipwb.bash <short-bookname> [ --t ]
VERSION=210707
#O Clean screen
clear
#O Include install variables
pwd > pwd.txt
if cat pwd.txt | grep ~/Annexer; then Workdir=~/Annexer; elif cat pwd.txt | grep ~/Add_appendix; \
then Workdir=~/Add_appendix; else echo "Workind directory not found"; exit -1;fi
rm pwd.txt
#O add_sclipwb global variables
source $Workdir/vars/installdir.var
#O Print tests_add_sclipwb.bash version
echo " tests_add_sclipwb.bash version = $VERSION"
sleep 2
#T echo "----"
#O Control if the test add_sclipwb.sh file is clean
echo -e "\033[1;33m Control add_sclipwb.sh in the local test directory \033[0m" > text-control.txt
echo -e "\033[1;33m Please check that the comment line does not contain an command \033[0m" >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m### add_sclipwb.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" add_sclipwb.sh >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m###### en_sclipwb.inc.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" en_sclipwb.inc.sh >> text-control.txt
echo >> text-control.txt
echo -e "\033[1;33m###### fr_sclipwb.inc.sh ###\033[0m" >> text-control.txt
grep -n -e "#T\|#O\|#P" fr_sclipwb.inc.sh >> text-control.txt
echo -e "\033[1;33m ---- \033[0m" >> text-control.txt
more text-control.txt
echo; echo -e "\033[47m\033[1;30m Continue ? \033[0m"
read -s -e -n 1 -t 60 -p "y/n ? : " Inkey;echo
#T echo "Inkey = $Inkey"
if [ "$Inkey" != 'y' ]; then echo " Inkey is not yes, or time out after 60 sec, exit from $0"; exit 0;fi
#O Test with first param empty
echo "Command ./add_sclipwb.sh without parameter"
./add_sclipwb.sh
echo;echo " wait for 2 sec"
sleep 2; echo "----"
#O Test, all with option --t
echo " All tests whith parameter --t"
#O add_sclipwb local books for tests
Inkey=1
for i in 'seq 1 9'
do
cat $Workdir/tests/sitelist.txt; echo
echo -e "\033[47m\033[1;30m Choose the site number to test \033[0m"
read -s -n1 -p "inkey number 1 to 9 : " Inkey; echo;
if [ "$Inkey" = "1" ]; then ./add_sclipwb.sh LivreTest --t
elif [ "$Inkey" = "2" ]; then ./add_sclipwb.sh Hélices_de_navires_à_déplacement --t
elif [ "$Inkey" = "3" ]; then ./add_sclipwb.sh TestBook --t
elif [ "$Inkey" = "4" ]; then ./add_sclipwb.sh Mkd_\(Extracteur_de_documents\) --t
elif [ "$Inkey" = "5" ]; then ./add_sclipwb.sh Faire_fleurir_le_sel --t
elif [ "$Inkey" = "6" ]; then ./add_sclipwb.sh Faire_sa_fleur_de_sel --t
elif [ "$Inkey" = "7" ]; then ./add_sclipwb.sh Guide_to_Unix --t
elif [ "$Inkey" = "8" ]; then ./add_sclipwb.sh Tests_de_la_capacité_des_batteries_d%27accumulateurs --t
elif [ "$Inkey" = "9" ]; then ./add_sclipwb.sh LivreTest --t
else echo "$inkey local url of site not found"; exit 0
fi
done
#O End tests_add_sclipwb.bash
Add appendix
Programmes de maintenance
Éditeur : Goelette Cardabela
copy sources to sbin/src
modifiercp-src2bin.sh installe les fichiers exécutables du programme dans le répertoire bin à partir des fichiers sources.
vβ 210419
Compil2bin.sh
modifier- Attention this script is common for lib, sbin, and src for Add_appendix software
- this script is used in package addappendix-O~210927
#!/bin/bash
#H Header of compil2bin.sh
#H ------------------------
#H File : compil2bin.sh product compiled files in bindir and doumentation,
#H : pot files and more. See cpcleadned2bin.sh in lib directory
#H Syntax : compil2bin [--v|srcdir] [bindir|sbindir|libdir] [list-of-files.sh] [--t]
#H OPTIONS : --v, print version of compil2bin in test mode
#H : --t, clear screen and print parameters: version, srcdir, bindir, third parameter is present in test mode
#H : srcdir bindir, is source .sh shell directory, bindir is bin directory to receive compiled files
#H : list-of-files.sh, is the list of files in srcdir to convert for bin directory
#H
VERSION=211113
pwd > pwd.txt
read Currentdir<pwd.txt
cat pwd.txt | cut -d "/" -f4 > workname.txt
read Workname<workname.txt
#T echo -n "Working name directory= $Workname"
if [ $Workname = "Annexer" ] || [ $Workname = "Add_appendix" ]
then echo -n "" #T echo " is found";
else echo " Currentdir is not a working name directory"; exit -1
fi
rm workname.txt pwd.txt
Workdir=~/$Workname
Libdir=$Workdir/lib
source $Workdir/vars/installdir.var
#T echo "Install directory : $Installdir"
#T echo "Working dir : $Workdir"
#T echo "Sources = $1 ; Bin is : $2"; exit 0
#O Si le premier paramètre est vide afficher la syntaxe
if test -z "$1"
then
echo "Syntax : compil2bin [--v|srcdir] [bindir|sbindir|libdir] [list-of-shell-files] [--t]"
exit -1
fi
#O Afficher la version si le premier argument est --v
if [ "$1" = "--v" ]; then echo "compil2bin : VERSION $VERSION"; exit 0; fi
#O If file-list is empty create file_list from SRC
#if test -z $3; then ls -1 $1 > file-list; fi
#O Afficher les paramètres si
N=$#
if [ "$N" = "--t" ]
then
clear screen
echo "compil2bin version $VERSION"
echo "Directories: "
echo "SRC=$1, BIN=$2"
if test -e $3; then echo "file list is not empty, see forward."; fi
exit 0
fi
#O if [ "$1" = "compil2bin.sh" ]; then echo "cannot self extracting compil2bin.sh"; exit -1; fi
#O Affect Srcdir variable (#P if then else détaillé à cause des pertes d'information. éviter les ';')
if test -d $1
then
echo "Sources directory is found: $1"
Srcdir=$1
else
echo "Sources directory is not found"
exit -1
fi
#O Affect Bindir variable
if test -d $2
then
echo "Bin directory is found: $2"
Bindir=$2
else
echo "Bin directory is not found"
exit -1
fi
#O Affect Resourcesdir variable
if test -d "$Workdir/share/addappendix/resources"
then
Resourcesdir="$Workdir/share/addappendix/resources"
echo "Variable Resources is found $Resourcesdir"
fi
#O Indicate the number of pameters
echo "Number of parameter : $#"
#T exit 0
#P include $Libdir/annex.lib to access at cpcleaned2bin function
source $Libdir/annex.lib
#O If the commandline hat only two parameters then compile all lines
if [ "$N" = "2" ]
then
Pwd=$PWD; cd $1; ls -1 *.sh > $Pwd/list.txt; cd $Pwd
while read line
do
echo "Line of list.txt: $line"
cpcleaned2bin $line
done < $Pwd/list.txt
#O Else create loop to ...for i in `seq 1 $#`
else
for i in "$@"
do
if test $i != $1 && test $i != $2
then
echo "$i"
cpcleaned2bin $i
fi
done
fi
exit 0
#D
#D Documentation for compil2bin shell file
#D ----------------------------------------
#D Compil2bin is used in package to product addappendix-<version>.deb and
#D to copy sources files to bin directories.
#D
#D Makefile syntax: compil2bin SRC-OPTIONS BIN-OPTIONS <file-list>
#D SRC-OPTIONS: [ $(SRCS) | $(SBINS) | $(SLIBS) ]
#D BIN-OPTIONS: [ $(BIN) | $(SBIN) | $(LIB) ]
#D <file-list> are shell files list to compil from SRC directory
#D
#D Shell syntax: compil2bin [--v|srcdir] [bindir|sbindir|libdir] [list-of-shell-files] [--t]
#D
#D Examples: with file-list: users_install_annex.sh and install_annex.sh in SRC.
#D compil2bin srcdir bindir
#D or: compil2bin srcdir bindir $Parameters
#D $Parameters is variable content the list of files with .sh extensions
#D
#D The compilation consists of eliminating the tags of Documentation, Manual,
#D Organization-charts, Programmers-doc Tests-doc and producing .pot .po files
#D with cpcleaned2bin function, for the translations, can also update .mo files.
#D
#P Note: The manuals must be extracted with the command grep -v "#M ".
#P There must always be a space between #M and the text to extract.
#M .\ Manual man1 extraction: cat compil2bin.sh | grep "#M " | sed "s/#M //g" | grep -v "#P" > compil2bin_en.1
#M .\ This manual is included in compil2bin.sh source file
#M .\"Replace <program> with the program name, x with the Section Number
#M .TH compil2bin 1 "5 nov 2021" "compil2bin(1)" "Linux User's Manual"
#M .SH NAME
#M compi2bin \- compilation program consists of eliminating the tags of Documentation, Manual, Organization-charts, Programmers-doc Tests-doc and producing .pot .po files for the translations, can also update .mo files.
#M .SH SYNOPSIS
#M .B compil2bin
#M .RI $(SRC)\ [$(BIN)|$(SBIN)|$(LIB)]\ [files-list]\ in\ Makefile
#M .br
#M .B compil2bin
#M .RI [--v|srcdir]\ [bindir|sbindir|libdir]\ [files-list]\ [--t]
#M .br
#M in\ Add-appendix\ software
#M .br
#M .SH DESCRIPTION
#M This manual page explains the \fBcompil2bin\fP program. The \fBcompil2bin\fP program is included in Makefile to install sources files in binary directories such as bin lib sbin and product .pot .po .mo files to lang resources directories. If you are edit and saved po files you can copy .mo files to /usr/share/locale/lang/LC_MESSAGES/.
#M .SH OPTIONS
#M .IP \fB\-\ [--v]\fP
#M Print the compil2bin version
#M .IP \fB\-\ $(SRC)\ and\ srcdir\fP
#M This variable is used in makefile example: SRC=/usr/local/src or srcdir=$Workdir/src\ in \fBAdd_appendix\fP software
#M .IP \fB\-\ [$(BIN)|$(SBIN)|$(LIB)]\ and\ [bindir|sbindir|libdir]\fP
#M This variables are used in makefile example: SBIN=/usr/local/sbin or bindir=$Bindir sbindir=$Sbindir libdir=$Libdir in \fBAdd_appendix\fP software
#M .IP \fB\-\ [file-list]\fP
#M This arguments list are list of files to convert and install to $(BIN) or $(SBIN) or $(LIB)
#M .IP \fB\-\ [--t]\fP
#M Print the compil2bin variables in current command execution
#M .br
#M .SH EXAMPLES
#M .B compil2bin
#M .RI $Srcdir\ $Bindir
#M .br
#M .B compil2bin
#M .RI $Currentdir/src\ $Currentdir/bin\ $Parameters
#M .br
#M Variable \fB$Parameters\fP content the list of files to convert
#M .br
#M .SH NOTES
#M To complete your information:
#M https://fr.wikibooks.org/wiki/Annexes_de_wikibooks#Makefile_proposé_aux_essais
#M .SH "SEE ALSO"
#M addapendix packages
#M
#O End of compil2bin
old version cp-src2bin.sh
modifier- WARNING, this is an old version revised on Sep 18, 2021
- Install this executable shell code in sbin ( /usr/local/sbin | ~/Add_appendix/sbin | ~/Annexer/sbin )
- Installer ce code shell exécutable dans sbin
- espagnol ; Instale este código de shell ejecutable en sbin
#! /bin/bash
#P File : .../sbin/cp-src2bin.sh. This file must be copied in executable mode
#P Copy the source files to the executables directory.
#P The tests directory is used to individual test bash files from annex programm.
clear
VERSION=210419
if [ "$1" = "--v" ]; then echo "cp-src2bin.sh : VERSION $VERSION rrevised on Sep 18, 2021"; exit 0; fi
#P Find the current directory
pwd > pwd.txt
read Currentdir<pwd.txt
#P Find the working name directory
cat pwd.txt | cut -d "/" -f4 > workname.txt
read Workname<workname.txt
echo -n "Working name directory= $Workname"
if [ $Workname = "Annexer" ] || [ $Workname = "Add_appendix" ]
then echo " is found";
else echo " is not a working name directory"; exit -1
fi
#P Find full directories install, working etc.
source ~/$Workname/vars/installdir.var
echo "Install directory : $Installdir"
echo "Working dir : $Workdir"
#T Test break exit 0
#P Make list files.pj
echo "Make files list from src directory in files.pj"
ls -1 $Installdir/src/*.sh > files.pj
#P If files.pj is not empty copy all files *.sh to executable directory
if [ -s "files.pj" ]
then
echo "files in files.pj :"
cat files.pj
else
echo "files.pj is empty, exit from cp-src2bin.sh"
exit 1
fi
#P Copy copy without extension .sh, and make files executables
echo "#####################################################################"
echo "# Warning: this script move all src/*.sh to bin/* without comments. #"
echo "# Warning: is not available to product POT files for translations. #"
echo "#####################################################################"
while read line
do
#T echo "copy the ligne $line from files.pj '.sh' in the file exename without extension .sh"
echo $line | sed s/.sh//g | awk -F "/" '{print $NF}'> exename.txt
#P Affect the value in 'exename.txt' at the variable $Exename
read Exename < exename.txt
echo "copy $Installdir/src/$Exename.sh to $Installdir/bin/$Exename"
cat $Installdir/src/$Exename.sh | grep -v "#O\|#P\|#T" > $Installdir/bin/$Exename
echo "Add mode 755 'executable' at file $Installdir/bin/$Exename"
chmod 755 $Installdir/bin/$Exename
echo "----"
done < files.pj
#T Breakpoint exit 0
#P clean sbin directory
rm files.pj pwd.txt exename.txt
#P End cp-src2bin
test_compil2bin.bash
modifier- test program is in $Testdir/01-sbsrc/O11/compil2bin.sh/
- This test program also makes the manual copyable to /usr/share/man/man1/.
- syntax: sudo cp compil2bin_en.1.gz /usr/share/man/man1/compil2bin.1.gz
#!/bin/bash
#H File test_compil2bin.bash
#H
VERSION=211105
pwd > pwd.txt
read Currentdir<pwd.txt
cat pwd.txt | cut -d "/" -f4 > workname.txt
read Workname<workname.txt
#T echo -n "Working name directory= $Workname"
if [ $Workname = "Annexer" ] || [ $Workname = "Add_appendix" ]
then echo -n "" #T echo " is found";
else echo " Currentdir is not a working name directory"; exit -1
fi
rm workname.txt pwd.txt
Workdir=~/$Workname
Libdir=$Workdir/lib
source $Workdir/vars/installdir.var
Testsdir=$Workdir/tests
clear
if [ "$1" = "--v" ]; then echo "Version of test_compil2bin.bash $VERSION";exit 0;fi
echo -e "\033[1;33mcommande ./compil2bin.sh --v \033[0m"
./compil2bin.sh --v
sleep 3
echo "----"
echo -e "\033[1;33mcommande ./compil2bin.sh --v --t \033[0m"
./compil2bin.sh --v --t
sleep 3
echo "----"
echo -e "\033[1;33mcommande ./compil2bin.sh src bin --t \033[0m"
./compil2bin.sh src bin --t
sleep 3
echo "----"
echo -e "\033[1;33mcommande ./compil2bin.sh src bin compil2bin.sh --t; ls -1 bin after 3 sec \033[0m"
./compil2bin.sh src bin compil2bin.sh --t
sleep 3
echo -e "\033[1;33m ls -1 bin: \033[0m"; ls -1 bin
echo -e "\033[1;33m make local manual of compil2bin wtith compil2bin.sh \033[0m"
cat compil2bin.sh | grep "#M " | sed "s/#M //g" | grep -v "#P" > compil2bin_en.1
gzip compil2bin_en.1 compil2bin_en.1.gz
mv compil2bin_en.1.gz man/compil2bin_en.1.gz
man man/compil2bin_en.1.gz
sleep 3
echo "----"
echo -e "\033[1;33m./compil2bin.sh $Currentdir/src $Currentdir/bin \033[0m"
./compil2bin.sh $Currentdir/src $Currentdir/bin
sleep 3
ls -al bin
echo "----"
echo -e "\033[1;33m./compil2bin.sh $Currentdir/src $Currentdir/bin compil2bin.sh cp-src2bin.sh docu2html.sh findversions.sh install_annex.sh install_datasfiles.sh makeman_annex.sh users_install_annex.sh \033[0m"
./compil2bin.sh $Currentdir/src $Currentdir/bin compil2bin.sh cp-src2bin.sh docu2html.sh findversions.sh install_annex.sh install_datasfiles.sh makeman_annex.sh users_install_annex.sh
sleep 3
ls -al bin
echo "----"
clear
cd src;ls -m *.sh | sed "s/,//g"|tr "\n" " ">listm.txt
echo "List of files in srcdir:"; cat listm.txt; echo
cd $Currentdir
read Parameters < src/listm.txt
echo "Parameters: $Parameters"
echo -e "\033[1;33m./compil2bin.sh $Currentdir/src $Currentdir/bin $Parameters \033[0m"
./compil2bin.sh $Currentdir/src $Currentdir/bin $Parameters
ls -al bin
echo "----"
Manuel
modifiercompil2bin(1) Linux User's Manual compil2bin(1) NAME compi2bin - compilation program consists of eliminating the tags of Documentation, Manual, Organization-charts, Programmers-doc Tests-doc and producing .pot .po files for the translations, can also update .mo files. SYNOPSIS compil2bin $(SRC) [$(BIN)|$(SBIN)|$(LIB)] [files-list] in Makefile compil2bin [--v|srcdir] [bindir|sbindir|libdir] [files-list] [--t] in Add-appendix software DESCRIPTION This manual page explains the compil2bin program. The compil2bin pro‐ gram is included in Makefile to install sources files in binary direc‐ tories such as bin lib sbin and product .pot .po .mo files to lang resources directories. If you are edit and saved po files you can copy .mo files to /usr/share/locale/lang/LC_MESSAGES/. OPTIONS - [--v] Print the compil2bin version - $(SRC) and srcdir This variable is used in makefile example: SRC=/usr/local/src or srcdir=$Workdir/src in Add_appendix software - [$(BIN)|$(SBIN)|$(LIB)] and [bindir|sbindir|libdir] This variables are used in makefile example: SBIN=/usr/lo‐ cal/sbin or bindir=$Bindir sbindir=$Sbindir libdir=$Libdir in Add_appendix software - [file-list] This arguments list are list of files to convert and install to $(BIN) or $(SBIN) or $(LIB) - [--t] Print the compil2bin variables in current command execution EXAMPLES compil2bin $Srcdir $Bindir compil2bin $Currentdir/src $Currentdir/bin $Parameters Variable $Parameters content the list of files to convert NOTES To complete your information: https://fr.wikibooks.org/wiki/An‐ nexes_de_wikibooks#Makefile_proposé_aux_essais SEE ALSO addapendix packages compil2bin(1) 5 nov 2021 compil2bin(1)
copy all tested commands to src and bin directories
modifiercp_all_to_Add_appendix.bash copie toutes les commandes testées vers les répertoires src et bin de Add_appendix.
vβ 210616
Ce script commande la mise à jour, ou l'installation, de tous les fichiers éprouvés dans le répertoire des tests de l'application Add_appendix
#!/bin/bash
#H Directory : tests
#H File : cp_all_to_Add_appendix.bash
#H Syntax : in tests directory ./cp_all_to_Add_appendix.bash
#. gettext.sh
#
#D Documentation of file cp_all_to_Add_appendix.bash
#D $Workdir is ~/Add_appendix or ~/Annexer
#D This script install all tested sources files in $Workdir/bin for addappendix
#D software, copy the tested addappendix sources files to $Workdir/bin and
#D create translated messages .mo files if if necessary.
#D Also install alls tested sbin sources files to $Workdir/sbin
#D
VERSION=211205
clear
if pwd | grep Add_appendix >/dev/null
then
Workdir=~/Add_appendix
Srcs=~/Add_appendix/src/Add_appendix
echo "Working directory (Workdir) = $Workdir"
echo "Sources directory = $Srcs"
elif pwd | grep Annexer>/dev/null
then
Workdir=~/Annexer
Srcs=~/Annexer/src/Annexer
echo "Répertoire de travail (Workdir) = $Workdir"
echo "Réperdoire des sources = $Srcs"
else
echo "Workdir not found, exit"; exit 1
fi
#
if test -e $Workdir/vars/installdir.var
then source $Workdir/vars/installdir.var
fi
# Forcing $Testsdir and $Libdir
Testsdir=$Workdir/tests
echo "Testsdir = $Testsdir"
Libdir=$Workdir/lib
echo "Libdir = $Libdir"
# Update lib
$Testsdir/1-annex.lib/updt-annex-lib.sh
if test -e $Libdir/annex.lib
then
echo "$Libdir/annex.lib is found"
source $Libdir/annex.lib
else
$Libdir/annex.lib
exit -1
fi
#Test exit 0
echo "cp_all_to_Add_appendix.bash version : $VERSION"
# ******************* addappendix scripts.
# $Testsdir/00-install_annex
$Testsdir/00-install_annex/updt-install.bash
#Test exit 0
# $Testsdir/01-sbsrc
$Testsdir/01-sbsrc/updt-sbinsrcs.bash
# $Testsdir/02-manuels
$Testsdir/02-manuels/updt-manuals.bash
# $Testsdir/0-pre-annex.sh/
echo -e "\033[1;33m### Copy pre-annex.sh to src and bin directories ###\033[0m"
cp -u $Testsdir/0-pre-annex.sh/pre-annex.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/pre-annex.sh
# $Testsdir/1-annex.lib/
#echo -e "\033[1;33m### Copy libsrcs to $Libdir/src and install annex.lib ###\033[0m"
# $Testsdir/1-annex.lib/updt-annex-lib.sh # fait en tete de cette commande lignes 34-44
# $Testsdir/2-annex.sh/
echo -e "\033[1;33m### Copy annex to src and bin directories ###\033[0m"
cp -u $Testsdir/2-annex.sh/annex.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/annex.sh
# $Testsdir/3-header.inc.sh/
echo -e "\033[1;33m### Copy header.inc to src and bin directories ###\033[0m"
cp -u $Testsdir/3-header.inc.sh/header.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/header.inc.sh
# $Testsdir/4-list.sh/
echo -e "\033[1;33m### Copy list to src and bin directories ###\033[0m"
cp -u $Testsdir/4-list.sh/list.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/list.sh
# $Testsdir/5-download.sh/
echo -e "\033[1;33m### Copy download to src and bin directories ###\033[0m"
cp -u $Testsdir/5-download.sh/download.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/download.sh
# $Testsdir/6-add_sclt.sh/
# 6 add_sclt.sh
echo -e "\033[1;33m### Copy add_sclt to src and bin directories ###\033[0m"
cp -u $Testsdir/6-add_sclt.sh/add_sclt.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/add_sclt.sh
# 6 en_sclt.inc.sh
echo -e "\033[1;33m### Copy en_sclt.inc to src and bin directories ###\033[0m"
cp -u $Testsdir/6-add_sclt.sh/en_sclt.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/en_sclt.inc.sh
# 6 fr_sclt.inc.sh
echo -e "\033[1;33m### Copy fr_sclt to src and bin directories ###\033[0m"
cp -u $Testsdir/6-add_sclt.sh/fr_sclt.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/fr_sclt.inc.sh
# $Testsdir/7-scli.inc.sh/
echo -e "\033[1;33m### Copy scli.inc to src and bin directories ###\033[0m"
cp -u $Testsdir/7-scli.inc.sh/scli.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/scli.inc.sh
# $Testsdir/8-add_sclic.sh/
# 8 add_sclic.sh
echo -e "\033[1;33m### Copy add_sclic to src and bin directories ###\033[0m"
cp -u $Testsdir/8-add_sclic.sh/add_sclic.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/add_sclic.sh
# 8 en_sclic.inc
echo -e "\033[1;33m### Copy en_sclic.inc to src and bin directories ###\033[0m"
cp -u $Testsdir/8-add_sclic.sh/en_sclic.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/en_sclic.inc.sh
# 8 fr_sclic.inc
echo -e "\033[1;33m### Copy fr_sclic.inc to src and bin directories ###\033[0m"
cp -u $Testsdir/8-add_sclic.sh/fr_sclic.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/fr_sclic.inc.sh
# $Testsdir/9-add_sclipco.sh/
# 9 add_sclipco.sh
echo -e "\033[1;33m### Copy add_sclipco to src and bin directories ###\033[0m"
cp -u $Testsdir/9-add_sclipco.sh/add_sclipco.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/add_sclipco.sh
# 9 en_sclipco.inc.sh
echo -e "\033[1;33m### Copy en_sclipco.inc to src and bin directories ###\033[0m"
cp -u $Testsdir/9-add_sclipco.sh/en_sclipco.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/en_sclipco.inc.sh
# 9 fr_sclipco.inc.sh
echo -e "\033[1;33m### Copy fr_sclipco.inc to src and bin directories ###\033[0m"
cp -u $Testsdir/9-add_sclipco.sh/fr_sclipco.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/fr_sclipco.inc.sh
# $Testsdir/10-add_sclipwb.sh/
# 10 add_sclipwb.sh
echo -e "\033[1;33m### Copy add_sclipwb to src and bin directories ###\033[0m"
cp -u $Testsdir/10-add_sclipwb.sh/add_sclipwb.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/add_sclipwb.sh
# 10 en_sclipwb.inc.sh
echo -e "\033[1;33m### Copy en_sclipwb.inc to src and bin directories ###\033[0m"
cp -u $Testsdir/10-add_sclipwb.sh/en_sclipwb.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/en_sclipwb.inc.sh
# 10 fr_sclipwb.inc.sh
echo -e "\033[1;33m### Copy fr_sclipwb.inc to src and bin directories ###\033[0m"
cp -u $Testsdir/10-add_sclipwb.sh/fr_sclipwb.inc.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/fr_sclipwb.inc.sh
# $Testsdir/11-annexer.sh/
echo -e "\033[1;33m### Copy annexer to src and bin directories ###\033[0m"
cp -u $Testsdir/11-annexer.sh/annexer.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/annexer.sh
# Testsdir/12-addappendix.sh/
echo -e "\033[1;33m### Copy addappendix to src and bin directories ###\033[0m"
cp -u $Testsdir/12-addappendix.sh/addappendix.sh $Workdir/$Srcs/.
chmod 666 $Workdir/$Srcs/addappendix.sh
# Update bin directory
cd $Workdir
sbin/compil2bin $Srcs bin >/dev/null
# End for cp_all_to_Add_appendix.bash