add gzip size

This commit is contained in:
Yann Esposito (Yogsototh) 2020-05-03 21:50:56 +02:00
parent bae4ce7967
commit 175612b82f
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
3 changed files with 16 additions and 2 deletions

View file

@ -31,6 +31,9 @@ for fic in $filelist; do
htmlsize=$(sizeof $fic) htmlsize=$(sizeof $fic)
debug HTML: $htmlsize debug HTML: $htmlsize
gzhtmlsize=$( gzip -c $fic|wc -c )
debug GZHTML: $gzhtmlsize
xfic=$tmpdir/$fic xfic=$tmpdir/$fic
mkdir -p $(dirname $xfic) mkdir -p $(dirname $xfic)
@ -49,21 +52,29 @@ for fic in $filelist; do
css=( $( < $xfic hxselect -i -c -s '\n' 'link[rel=stylesheet]::attr(href)')) css=( $( < $xfic hxselect -i -c -s '\n' 'link[rel=stylesheet]::attr(href)'))
csssize=0 csssize=0
gzcsssize=0
for i in $css; do for i in $css; do
isize=$( sizeof $webdir/$i ) isize=$( sizeof $webdir/$i )
gzisize=$( gzip -c $webdir/$i | wc -c )
debug $i '=>' $isize debug $i '=>' $isize
(( csssize += isize )) (( csssize += isize ))
(( gzcsssize += gzisize ))
done done
debug CSS: $csssize debug CSS: $csssize
debug GZCSS: $gzcsssize
total=$(( htmlsize + imgsize + csssize )) total=$(( htmlsize + imgsize + csssize ))
gztotal=$(( gzhtmlsize + imgsize + gzcsssize ))
# the space is important before the toh total # the space is important before the toh total
sizeinfos=$(print -- " $(toh $total) (html $(toh $htmlsize), css $(toh $csssize)") sizeinfos=$(print -- " $(toh $total) (html $(toh $htmlsize), css $(toh $csssize)")
gzsizeinfos=$(print -- " $(toh $gztotal) (html $(toh $gzhtmlsize), css $(toh $gzcsssize)")
if ((imgsize>0)); then if ((imgsize>0)); then
sizeinfos="$sizeinfos, img $(toh $imgsize))" sizeinfos="$sizeinfos, img $(toh $imgsize))"
gzsizeinfos="$gzsizeinfos, img $(toh $imgsize))"
else else
sizeinfos="$sizeinfos)" sizeinfos="$sizeinfos)"
gzsizeinfos="$gzsizeinfos)"
fi fi
print -- $sizeinfos print -- $sizeinfos
perl -pi -e 's#(<div class="?web-file-size"?>)[^<]*(</div>)#$1'"$sizeinfos"'$2#' $fic perl -pi -e 's#(<div class="?web-file-size"?>)[^<]*(</div>)#$1'"$sizeinfos"'$2#;s#(<div class="?gzweb-file-size"?>)[^<]*(</div>)#$1'"$gzsizeinfos"'$2#' $fic
done done
rm -rf $tmpdir rm -rf $tmpdir

View file

@ -171,7 +171,9 @@
(format "<div class=\"date\">%s</div>" (format "<div class=\"date\">%s</div>"
(format-time-string "%Y-%m-%d %H:%M:%S"))) (format-time-string "%Y-%m-%d %H:%M:%S")))
(size (size
"<div class=\"web-file-size\">XXK (HTML: XXK, CSS: XXK, IMG: XXK)</div>") "<div class=\"web-file-size\">XXK (html XXK, css XXK, img XXK)</div>")
(gzsize
"<div class=\"gzweb-file-size\">XXK (html XXK, css XXK, img XXK)</div>")
(generated-with (generated-with
(format (concat "<div class=\"creator\">" (format (concat "<div class=\"creator\">"
"<a href=\"https://www.gnu.org/software/emacs/\" target=\"_blank\" rel=\"noopener noreferrer\">Emacs %s</a>, " "<a href=\"https://www.gnu.org/software/emacs/\" target=\"_blank\" rel=\"noopener noreferrer\">Emacs %s</a>, "
@ -195,6 +197,7 @@
("tags" . ,keywords) ("tags" . ,keywords)
("rss" . ,rss) ("rss" . ,rss)
("size" . ,size) ("size" . ,size)
("gz" . ,gzsize)
("gen-date" . ,generated-date) ("gen-date" . ,generated-date)
("get-with" . ,generated-with) ("get-with" . ,generated-with)
("src" . ,website-code) ("src" . ,website-code)

Binary file not shown.