her.esy.fun/engine/dup-for-themes.sh

35 lines
805 B
Bash
Raw Normal View History

2020-05-25 20:28:06 +00:00
#!/usr/bin/env zsh
2019-11-22 03:23:04 +00:00
2020-02-10 08:42:17 +00:00
cd "$(git rev-parse --show-toplevel)" || exit 1
2020-02-09 11:57:46 +00:00
2019-11-22 03:23:04 +00:00
webdir="_site"
debug () {
2020-02-10 08:42:17 +00:00
print -- "$@" >/dev/null
2019-11-22 03:23:04 +00:00
}
if (($#>0)); then
filelist=( $* )
else
filelist=( $webdir/**/*.html(.) )
fi
2019-11-28 18:00:22 +00:00
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
}
2019-12-22 23:01:06 +00:00
print -- "Duplicate HTML by themes"
2019-11-22 03:23:04 +00:00
for fic in $filelist; do
2020-02-10 08:42:17 +00:00
if echo $fic|grep -E -- '-(mk|min|sci|modern).html$'>/dev/null; then
2019-11-22 03:23:04 +00:00
continue
fi
print -n -- "$fic "
2019-11-28 18:00:22 +00:00
for suff in sci min modern; do
trans $suff $fic
done
2019-11-22 03:23:04 +00:00
print "[OK]"
done
2019-12-22 23:01:06 +00:00
print "Duplicate HTML by theme [done]"