« Auto-éditer un wikilivre/Annexer (Version internationalisée)/src/list.sh » : différence entre les versions

Un livre de Wikilivres.
Contenu supprimé Contenu ajouté
Reconstruction du script
Corrections importantes
Ligne 12 : Ligne 12 :
#H modified : 2021-03-21 by GC for for layout
#H modified : 2021-03-21 by GC for for layout
#H modified : 2021-05-21 by GC Reconstructed version
#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
#H
#D list.sh documentation
#D list.sh documentation
Ligne 19 : Ligne 21 :
#D Suffix available for bookname.suffix : compiled, summary, contents
#D Suffix available for bookname.suffix : compiled, summary, contents
#D
#D
VERSION=210521
VERSION=210523
#O . gettext.sh for translation
#O . gettext.sh for translation
. gettext.sh
. gettext.sh
Ligne 26 : Ligne 28 :
else echo "$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
else echo "$Bindir/header.inc not found. Execute sbin/cp-src2bin.sh"; exit -1
fi
fi
###P Initialize the project list in project directory
#w Initialize the project list in project directory
###P the book must be included at the root of wikibooks
#w If the book is included at the root of wikibooks
## echo "https://$Site/wiki/$1" > $Project/$1.list
#w echo "https://$Site/wiki/$1" > $Project/$1.list
#w Else take the url into account
#O Code extraction as appropriate case
#O Code extraction as appropriate case
#O Case compiled pages for PediaPress
#O Case compiled pages for PediaPress. Lines syntax :[[Book article]]
SitePrefix=https:\/\/$Site\/wiki\/
SitePrefix=https:\/\/$Site\/wiki\/
if test -e $Projectdir/$1.compiled
if test -e "$Projectdir/$1.compiled"
then
then
{
{
echo "$(gettext ' Found Compiled page : ')$Project/$1.compiled"; echo
echo "$(gettext ' Found Compiled page : ')$Project/$1.compiled"; echo
echo " create $Projectdir/$1.list with :"; echo " $Projectdir/$1.compiled"; echo
echo " create $Projectdir/$1.list with :"; echo " $Projectdir/$1.compiled"; echo
cat $Projectdir/$1.compiled | sed "s/:\[\[/https:\/\/$Site\/wiki\//g" | tr '|' '\n' | sed "s/\]\]//g" | grep "wiki" | tr ' ' '_' > $Projectdir/$1.list
cat "$Projectdir/$1.compiled" | sed -f ~/Add_appendix/datas/content_cleaner.dat > $Projectdir/$1.compiled.cleaned
cat $Projectdir/$1.compiled | grep $1 | sed "s/:\[\[//g" | tr '|' '\n' | grep $1 | sed "s/$1\]\]/\r/g" | sed "s/\]\]//g" | cut -sd '/' -f2-5 > $Projectdir/$1.prj
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
#O Case contents suffix
elif test -e $Projectdir/$1.contents
elif test -e "$Projectdir/$1.contents"
then
then
{
{
Ligne 48 : Ligne 52 :
#O The book must be included at the root of wikibooks
#O The book must be included at the root of wikibooks
echo "$Bookfullurl" > $Project/$1.list
echo "$Bookfullurl" > $Project/$1.list
echo " Do not use {{BASEPAGENAME}} in Contents page"
cat $Projectdir/$1.contents | sed "s/\[\[/https:\/\/$Site\/wiki\//g" | tr '|' '\n' | sed "s/\]\]//g" | grep "wiki" | tr ' ' '_' > $Projectdir/$1.list
cat $Projectdir/$1.contents | grep $1 | sed "s/\[\[//g" | tr '|' '\n' | grep $1 | sed "s/$1\]\]/\r/g" | sed "s/\]\]//g" | cut -sd '/' -f2-5 > $Projectdir/$1.prj
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
#O Case Summary suffix
elif test -e $Projectdir/$1.summary
elif test -e "$Workdir/books/$1/$1.summary"
then
then
{
{
echo "$(gettext ' Found Summary page : ')"$Projectdir/$1.summary; echo
#w Check upstream $Projectdir is not validaded for 'summary'
Projets=$Workdir/books
echo " create $Projectdir/$1.list with :"; echo " $Projectdir/$1.summary"; echo
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
#O The book must be included at the root of wikibooks
echo "$Bookfullurl" > $Projectdir/$1.list
echo "$Bookfullurl" > $Projets/$1/$1.list
echo " Do not use {{BASEPAGENAME}} in Summary page"
#T cat $Projectdir/$1.summary | sed "s/\[\[/\nhttps:\/\/$Site\/wiki\//g" | grep -e "https:" | grep -v "Catégorie:" | grep -v "#" | sed "s/{{BASEPAGENAME}}/$1/g" | tr '|' '\n' | sed "s/\]\]//g" | grep "wiki" | tr ' ' '_' > $Projectdir/$1.list
cat "$Projets/$1/$1.summary" | sed -f ~/Add_appendix/datas/content_cleaner.dat > "$Projets/$1/$1".summary.cleaned
cat $Projectdir/$1.summary | sed "s/# //g" | sed "s/* //g" | tr ' ' '_' | sed "s/\[\[/https:\/\/$Site\/wiki\//g" | tr ' ' '_'| sed "s/\]\]//g" | grep "wiki" |cut -d '|' -f1 >> $Projectdir/$1.list
cat $Projectdir/$1.summary | sed "s/# //g" | sed "s/* //g" | tr ' ' '_' | sed "s/\[\[$1\///g" | sed "s/\]\]//g" |cut -d '|' -f1 > $Projectdir/$1.prj
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"
#else echo "bookname.suffix : $1.$Suffix not found"
fi
fi
#O Print file Project.list and file Project.prj
#O Print file Project.list and file Project.prj
echo
echo
echo "$(gettext ' File Project.list')"
echo "$(gettext ' File Project.list')"
cat $Projectdir/$1.list
cat $Workdir/books/$1/$1.list
echo
echo
echo "$(gettext ' File Project.prj')"
echo "$(gettext ' File Project.prj')"
cat $Projectdir/$1.prj
cat $Workdir/books/$1/$1.prj
echo " "
echo " "
read -p "If all OK : return to continue, Ctrl-C to quit > "
read -p "If all OK : return to continue, Ctrl-C to quit > "

Version du 23 mai 2021 à 18:52

Remarquelink={{{link}}}

Les messages en anglais sont introduits pour l'internalisation avec gettext.
les commentaires #P pour les programmeurs sont en anglais, les autres commentaires ont été réduits au minimum.

#! /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