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

Un livre de Wikilivres.
Contenu supprimé Contenu ajouté
WL:RD : Initialisation de la page
 
m →‎script tests_addappendix.bash : WL:RD : * diverses retouches
Ligne 92 : Ligne 92 :
#P Programmers notes
#P Programmers notes
#P -------------------------------
#P -------------------------------
VERSION=220116


echo "test first param empty"
echo -e "\033[1;033mtest addappendix.sh with first param empty\033[0m"
./addappendix.sh
./addappendix.sh
sleep 3
sleep 3
echo "----"
echo "----"


echo "test first param = '?'"
echo -e "\033[1;033mtest addappendix.sh with first param = '?'\033[0m"
./addappendix.sh ?
./addappendix.sh ?
sleep 3
sleep 3
echo "----"
echo "----"


echo "test first param = '-v'"
echo -e "\033[1;033mtest addappendix.sh with first param = '-v'\033[0m"
./addappendix.sh -v
./addappendix.sh -v
sleep 3
sleep 3
echo "----"
echo "----"


echo "test with param = https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel"
echo -e "\033[1;033mtest addappendix.sh with param = https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel\033[0m"
./addappendix.sh https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel
./addappendix.sh https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

</syntaxhighlight>
=== Résultat des tests ===
<syntaxhighligh>
cardabela@jpl-W230SS:~/addappendix-211219/tests/addapendix$ ./tests_addapendix.bash
test addappendix.sh with first param empty
No parameter. addappendix [ <full url of book> | ? | -v ]
----
test addappendix.sh with first param = '?'
Syntax: addappendix [ <full url of book> | -v ]
Example 1 : addappendix https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix
Example 2 : addappendix https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

----
test addappendix.sh with first param = '-v'
addapendix version : 220117
----
test addappendix.sh with param = https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel
https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel
is a wiki-books
File https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel is found

Book name : Faire_sa_fleur_de_sel
Compilations name: Wikilivres:Compilations
Suffix = compiled

Faire_sa_fleur_de_sel.compiled :
[[Faire fleurir le sel/Couverture]]
[[Faire fleurir le sel/Introduction]]
[[Faire fleurir le sel/Préparation]]
[[Faire fleurir le sel/Filtrer et aseptiser]]
[[Faire fleurir le sel/Récolter]]

Dowload https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

</syntaxhighligh>


{{AutoCat}}
{{AutoCat}}

Version du 17 janvier 2022 à 19:45

Attention : modification en cours !link={{{link}}}

Un contributeur est en train de retravailler en profondeur cette page. Vous êtes prié(e) d'éviter de le modifier pour limiter les risques de conflit de versions jusqu'à disparition de cet avertissement. Merci.

  • Cette page concerne le logiciel addappendix mis en paquet

script addapendix.sh

#!/bin/bash
#H Header doc
#H -------------------------------
#H File : tests/addappendix/addapendix.sh
#H Syntax : addapendix [ ?  | -v ]
#H Created : 220113 by GC
#H Updated : 220113 by ... for
#O Organizational chart
#O -------------------------------
#P Programmers notes
#P -------------------------------

VERSION=220113
TEXTDOMAIN=addappendix
TEXTDOMAINDIR="/usr/share/locale"
export TEXTDOMAINDIR

#P . gettext for translation
. gettext.sh

#O Script begin here
#O If parameters is empty
    if test -z $1
#O Then print the short syntax ant exit -1
    then 
      echo $"No parameter. addappendix [ <full url of book> | ? | -v ]"
      exit -1
    fi
#O If firt parameter is '?'
	if [ "$1" = "?" ]
#O Then print syntax whih examples and exit 0
    then 
      echo $"Syntax: addappendix [ <full url of book> | -v ]"
	  echo $"Example 1 : addappendix https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix"
	  echo $"Example 2 : addappendix https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel"	  
      exit 0
	fi
#O IF first parameter is "-v"
    if [ "$1" = "-v" ]
#O Then print addapendix version
	then
	  echo $"addapendix version : $VERSION"
	  exit 0
	fi
	
#O *** First parameter analysis ***
#O Test if the first parameter points to wikibooks.org/wiki
    if echo $1 | grep wikibooks.org/wiki 
	then 
	  echo "OK for wikibooks.org/wiki"
    else
	  echo "$1 is not a book on wikibooks"
      exit -1
    fi
#O Check if $1 file exist
    if wget --spider $1 2>/dev/null; then
      echo "File $1 exists"
    else
      echo "File $1 does not exist"
      exit -1
    fi

#O Find the bookname
    echo $1 | awk -F"/" ' { print $NF }' > bookname.txt
	read BOOKNAME<bookname.txt
	echo "Book name : $BOOKNAME"
#O Create Bookname diredtory
    install -d ~/Add_appendix/books/$BOOKNAME
#O Télécharger la page compilée
    cd ~/Add_appendix/books/$BOOKNAME
    wget -r -linif -k -p -E -i $1

    exit 0
#O Script end

script tests_addappendix.bash

<syntaxhighlight lang="bash">

  1. !/bin/bash
  2. H Header doc
  3. H -------------------------------
  4. H File : tests/addappendix/tests_addapendix.bash
  5. H Syntax : ./tests_addapendix.bash
  6. H Created : 220113 by GC
  7. H Updated : 220113 by ... for
  8. O Organizational chart
  9. O -------------------------------
  10. P Programmers notes
  11. P -------------------------------

VERSION=220116

echo -e "\033[1;033mtest addappendix.sh with first param empty\033[0m" ./addappendix.sh sleep 3 echo "----"

echo -e "\033[1;033mtest addappendix.sh with first param = '?'\033[0m" ./addappendix.sh ? sleep 3 echo "----"

echo -e "\033[1;033mtest addappendix.sh with first param = '-v'\033[0m" ./addappendix.sh -v sleep 3 echo "----"

echo -e "\033[1;033mtest addappendix.sh with param = https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel\033[0m" ./addappendix.sh https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

Résultat des tests

<syntaxhighligh> cardabela@jpl-W230SS:~/addappendix-211219/tests/addapendix$ ./tests_addapendix.bash test addappendix.sh with first param empty No parameter. addappendix [ <full url of book> | ? | -v ]


test addappendix.sh with first param = '?' Syntax: addappendix [ <full url of book> | -v ]

 Example 1 : addappendix https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix
 Example 2 : addappendix https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

test addappendix.sh with first param = '-v' addapendix version : 220117


test addappendix.sh with param = https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

 is a wiki-books

File https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel is found

Book name : Faire_sa_fleur_de_sel Compilations name: Wikilivres:Compilations Suffix = compiled

Faire_sa_fleur_de_sel.compiled : Faire fleurir le sel/Couverture Faire fleurir le sel/Introduction Faire fleurir le sel/Préparation Faire fleurir le sel/Filtrer et aseptiser Faire fleurir le sel/Récolter

Dowload https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

</syntaxhighligh>