diff --git a/optim-classes.sh b/optim-classes.sh new file mode 100755 index 0000000..b648402 --- /dev/null +++ b/optim-classes.sh @@ -0,0 +1,48 @@ +#!/bin/zsh + +classes=( $(cat _site/**/*.html | perl -p -e 's/class="?([a-zA-Z0-9-_]*)/\nCLASS: $1\n/g'|grep CLASS|sort -u|cut -d\ -f 2,2) ) + +chr() { + [ "$1" -lt 26 ] || return 1 + printf "\\$(printf '%03o' $(( 97 + $1 )))" +} + +ord() { + LC_CTYPE=C printf '%d' "'$1" +} + +shortName() { + if [ "$1" -gt 25 ]; then + print -- $(shortName $(( ( $1 / 26 ) - 1 )))$(shortName $(( $1 % 26 ))) + else + chr $1 + fi +} + +i=0; +typeset -A assoc +for c in $classes; do + sn=$(shortName $i) + print "$c $sn" + assoc[$c]=$sn + ((i++)) +done + +hmltreplace='' +cssreplace='' +for long in $classes; do + htmlreplace="${htmlreplace}s/\(class=\"\?\)${long}/\$\{1\}${assoc[${long}]}/g;" + cssreplace="${cssreplace}s/\(\\.\)${long}/\$\{1\}${assoc[${long}]}/g;" +done + +print -- $htmlreplace +print -- $cssreplace + +for fic in _site/**/*.html; do + print -- $fic + perl -pi -e $htmlreplace $fic; +done +for fic in _site/**/*.css; do + echo $fic + perl -pi -e $cssreplace $fic; +done diff --git a/optim-html.sh b/optim-html.sh index b689a78..4e2b85f 100755 --- a/optim-html.sh +++ b/optim-html.sh @@ -23,6 +23,8 @@ for fic in $filelist; do continue fi print -n -- "$fic " - cp $fic $tmp; minify --mime text/html $tmp > $fic + cp $fic $tmp + perl -pi -e 's#
$fic print "[OK]" done diff --git a/project.el b/project.el index 797dc65..d2eb329 100644 --- a/project.el +++ b/project.el @@ -24,10 +24,9 @@ (defvar org-blog-head (concat - "" - "" - "" - "")) + "" + "" + "")) (defun menu (lst) "Blog menu" @@ -101,7 +100,7 @@ (format "
Created: %s (%s)
" date (y-date date))) (when-let ((keywords (plist-get info :keywords))) (format "
Keywords: %s
" keywords)) - "
RSS: Valid RSS
" + "
RSS: Valid RSS
" (format "
Generated: %s
" (format-time-string "%Y-%m-%d %H:%M:%S")) "
Size: XXK (HTML: XXK, CSS: XXK, IMG: XXK)
" diff --git a/project.el.sig b/project.el.sig index 0abcca4..1873af1 100644 Binary files a/project.el.sig and b/project.el.sig differ