From 1499ad8877f76b8004dca3e6277a708de38d672c Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Thu, 28 Nov 2019 19:00:22 +0100 Subject: [PATCH] improved duplication script --- dup-for-themes.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dup-for-themes.sh b/dup-for-themes.sh index a68247e..9873172 100755 --- a/dup-for-themes.sh +++ b/dup-for-themes.sh @@ -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