improved duplication script

This commit is contained in:
Yann Esposito (Yogsototh) 2019-11-28 19:00:22 +01:00
parent e3e3c3d909
commit 1499ad8877
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646

View file

@ -8,21 +8,25 @@ debug () {
print -- $* >/dev/null
}
type -a filelist
setopt extendedglob
if (($#>0)); then
filelist=( $* )
else
filelist=( $webdir/**/*.html(.) )
fi
trans(){
local suff=$1;
local fic=$2;
cat $fic | perl -p -e 's#href="?/css/mk.css"?#href=/css/'$suff'.css#;s#(/?(index|archive|slides|about-me)).html#$1-'$suff'.html#g;s#(posts/[a-zA-Z0-9_-]*).html#$1-'$suff'.html#g;s#-'$suff'.html>mk#.html>mk#g' > ${fic:r}-${suff}.html
}
for fic in $filelist; do
if echo $fic|egrep -- '-(mk|min|sci|modern).html$'>/dev/null; then
continue
fi
print -n -- "$fic "
cat $fic | perl -p -e 's#href="?/css/mk.css"?#href=/css/sci.css#' > ${fic:r}-sci.html
cat $fic | perl -p -e 's#href="?/css/mk.css"?#href=/css/min.css#' > ${fic:r}-min.html
cat $fic | perl -p -e 's#href="?/css/mk.css"?#href=/css/modern.css#' > ${fic:r}-modern.html
for suff in sci min modern; do
trans $suff $fic
done
print "[OK]"
done