add file size
This commit is contained in:
parent
32ab26c448
commit
90c072ab8c
4 changed files with 57 additions and 0 deletions
|
@ -5,6 +5,8 @@ echo $rootdir
|
||||||
|
|
||||||
echo "Full Build"
|
echo "Full Build"
|
||||||
./fullbuild.sh
|
./fullbuild.sh
|
||||||
|
echo "Update file size"
|
||||||
|
./update-file-size.sh
|
||||||
echo "Building RSS"
|
echo "Building RSS"
|
||||||
./mkrss.sh
|
./mkrss.sh
|
||||||
echo "RSS Built"
|
echo "RSS Built"
|
||||||
|
|
|
@ -105,6 +105,7 @@
|
||||||
"<div class=\"rss\"><a href=\"/rss.xml\">RSS</a>: <a href=\"https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fher.esy.fun%2Frss.xml\">Valid RSS</a></div>"
|
"<div class=\"rss\"><a href=\"/rss.xml\">RSS</a>: <a href=\"https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fher.esy.fun%2Frss.xml\">Valid RSS</a></div>"
|
||||||
(format "<div class=\"date\">Generated: %s</div>"
|
(format "<div class=\"date\">Generated: %s</div>"
|
||||||
(format-time-string "%Y-%m-%d %H:%M:%S"))
|
(format-time-string "%Y-%m-%d %H:%M:%S"))
|
||||||
|
"<div class=\"web-file-size\">Size: XXK (HTML: XXK, CSS: XXK, IMG: XXK)</div>"
|
||||||
(format (concat "<div class=\"creator\"> Generated with "
|
(format (concat "<div class=\"creator\"> Generated with "
|
||||||
"<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>, "
|
||||||
"<a href=\"http://spacemacs.org\" target=\"_blank\" rel=\"noopener noreferrer\">Spacemacs %s</a>, "
|
"<a href=\"http://spacemacs.org\" target=\"_blank\" rel=\"noopener noreferrer\">Spacemacs %s</a>, "
|
||||||
|
|
BIN
project.el.sig
BIN
project.el.sig
Binary file not shown.
54
update-file-size.sh
Executable file
54
update-file-size.sh
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i zsh
|
||||||
|
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
|
||||||
|
|
||||||
|
webdir="_site"
|
||||||
|
|
||||||
|
sizeof() {
|
||||||
|
stat --format="%s" "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
debug () {
|
||||||
|
# print -- $*
|
||||||
|
}
|
||||||
|
|
||||||
|
toh () {
|
||||||
|
numfmt --to=iec $*
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
for fic in $webdir/**/*.html(.); do
|
||||||
|
print -n -- "$fic "
|
||||||
|
|
||||||
|
htmlsize=$(sizeof $fic)
|
||||||
|
debug HTML: $htmlsize
|
||||||
|
|
||||||
|
xfic=$tmpdir/$fic
|
||||||
|
mkdir -p $(dirname $xfic)
|
||||||
|
hxclean $fic > $xfic
|
||||||
|
|
||||||
|
images=( $( < $xfic hxselect -i -c -s '\n' 'img::attr(src)' | sed 's/^\.\.\///' ) )
|
||||||
|
imgsize=0
|
||||||
|
nbimg=0
|
||||||
|
for i in $images; do
|
||||||
|
((nbimg++))
|
||||||
|
isize=$( sizeof ${fic:h}/$i )
|
||||||
|
debug $i '=>' $isize
|
||||||
|
(( imgsize += isize ))
|
||||||
|
done
|
||||||
|
debug IMG: $imgsize
|
||||||
|
|
||||||
|
css=( $( < $xfic hxselect -i -c -s '\n' 'link[rel=stylesheet]::attr(href)'))
|
||||||
|
csssize=0
|
||||||
|
for i in $css; do
|
||||||
|
isize=$( sizeof $webdir/$i )
|
||||||
|
debug $i '=>' $isize
|
||||||
|
(( csssize += isize ))
|
||||||
|
done
|
||||||
|
debug CSS: $csssize
|
||||||
|
total=$(( htmlsize + imgsize + csssize ))
|
||||||
|
sizeinfos=$(print -- "Size: $(toh $total) (HTML: $(toh $htmlsize), CSS: $(toh $csssize), IMG: $(toh $imgsize))")
|
||||||
|
print -- $sizeinfos
|
||||||
|
perl -pi -e 's#(<div class="web-file-size">)[^<]*(</div>)#$1'"$sizeinfos"'$2#' $fic
|
||||||
|
done
|
||||||
|
rm -rf $tmpdir
|
Loading…
Reference in a new issue