simplify awk commands, remove org generation
This commit is contained in:
parent
3225cb1eb2
commit
a6c95ed07d
1 changed files with 17 additions and 44 deletions
61
generate.sh
61
generate.sh
|
@ -30,7 +30,6 @@ target="www"
|
|||
defaultLang="fr"
|
||||
header="header.html"
|
||||
footer="footer.html"
|
||||
org=0
|
||||
testDocker=0
|
||||
|
||||
################################################################################
|
||||
|
@ -54,7 +53,6 @@ Les options suivantes seront codées dans un futur proche :
|
|||
fr par défaut
|
||||
-n génère la langue dans le nom du fichier et non dans le chemin
|
||||
(example.org/fr/index.html -> example.org/index.fr.html)
|
||||
-o génère les fichiers org
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -69,9 +67,6 @@ fi
|
|||
while [ -n "$1" ]
|
||||
do
|
||||
case $1 in
|
||||
"-o") # génération des fichiers org
|
||||
org=1
|
||||
;;
|
||||
"-c") # on nettoie les fichiers
|
||||
# TODO si on précise un dossier, nettoyer ce dossier
|
||||
echo "Nettoyage de $target"
|
||||
|
@ -97,7 +92,7 @@ do
|
|||
done
|
||||
|
||||
###############################################################################
|
||||
# Génère un fichier header propre à une langue
|
||||
# Génère un fichier header temporaire propre à une langue
|
||||
#
|
||||
# $1 : le chemin vers le fichier header.link
|
||||
###############################################################################
|
||||
|
@ -111,26 +106,16 @@ function generate_header {
|
|||
FS = ":"
|
||||
code = 0
|
||||
}
|
||||
{
|
||||
if ($0 ~ /^%links%$/) {
|
||||
code = 1
|
||||
next
|
||||
} else if ($0 ~ /^%endlinks%$/) {
|
||||
code = 0
|
||||
}
|
||||
|
||||
if (code && $1 !~ /^#/) {
|
||||
gsub(/ $/, "", $1); gsub(/^ /, "", $2)
|
||||
print " <a href=\""$1"\">"$2"</a>"
|
||||
}
|
||||
}' $1 >> $tmpHeader
|
||||
/^%endlinks%$/ { code = 0 }
|
||||
code == 1 && ! /^#/ {
|
||||
gsub(/ $/, "", $1); gsub(/^ /, "", $2)
|
||||
print " <a href=\""$1"\">"$2"</a>"
|
||||
}
|
||||
/^%links%$/ { code = 1 }
|
||||
' $1 >> $tmpHeader
|
||||
echo -e " </div>\n" >> $tmpHeader
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if [ $testDocker -eq 1 ]
|
||||
then
|
||||
docker build . --tag site && echo -e \
|
||||
|
@ -245,29 +230,17 @@ cp -t $target -r $annexes
|
|||
|
||||
echo "Generate default index page..."
|
||||
cp $target/$defaultLang/index.html $target
|
||||
for c in $(awk 'BEGIN {
|
||||
FS = "\n";
|
||||
code = 0
|
||||
}
|
||||
{
|
||||
if ($0 ~ /id="header-links"/) {
|
||||
code = 1
|
||||
next
|
||||
} else if ($0 ~ /\/div/) {
|
||||
code = 0
|
||||
} if (code) {
|
||||
print NR
|
||||
}
|
||||
}' $target/index.html)
|
||||
|
||||
# on récupère les numéros des lignes à modifier
|
||||
for c in $(awk 'BEGIN { code = 0 }
|
||||
/\/div/ { code = 0 }
|
||||
code == 1 { print NR }
|
||||
/id="header-links"/ { code = 1 }
|
||||
' $target/index.html)
|
||||
do
|
||||
sed -i -e "$c s/href=\"/href=\"$defaultLang\//" $target/index.html
|
||||
done
|
||||
|
||||
echo "Link Links (lul)"
|
||||
ln -s $pathLinks $target
|
||||
#echo "Link Links (lul)"
|
||||
#ln -s $pathLinks $target
|
||||
|
||||
if [ $org -eq 1 ]
|
||||
then
|
||||
echo "Generate org files..."
|
||||
#emacs -u $USER --script publish.el
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue