optim WIP
This commit is contained in:
parent
7bab6d0b3e
commit
5a534922eb
4 changed files with 55 additions and 6 deletions
48
optim-classes.sh
Executable file
48
optim-classes.sh
Executable file
|
@ -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
|
|
@ -23,6 +23,8 @@ for fic in $filelist; do
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
print -n -- "$fic "
|
print -n -- "$fic "
|
||||||
cp $fic $tmp; minify --mime text/html $tmp > $fic
|
cp $fic $tmp
|
||||||
|
perl -pi -e 's#<div id="outline-container-[^>]*>#<div>#g;s# id="org[a-f0-9]{7}"##g' $tmp
|
||||||
|
minify --mime text/html $tmp > $fic
|
||||||
print "[OK]"
|
print "[OK]"
|
||||||
done
|
done
|
||||||
|
|
|
@ -24,10 +24,9 @@
|
||||||
|
|
||||||
(defvar org-blog-head
|
(defvar org-blog-head
|
||||||
(concat
|
(concat
|
||||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"" css-path "\"/>"
|
"<link rel=\"stylesheet\" href=\"" css-path "\"/>"
|
||||||
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
|
"<link rel=\"alternate\" type=\"application/rss+xml\" href=\"/rss.xml\" />"
|
||||||
"<link rel=\"alternative\" type=\"application/rss+xml\" title=\"" rss-title "\" href=\"/rss.xml\" />"
|
"<link rel=\"icon\" href=\"/favicon.ico\">"))
|
||||||
"<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\">"))
|
|
||||||
|
|
||||||
(defun menu (lst)
|
(defun menu (lst)
|
||||||
"Blog menu"
|
"Blog menu"
|
||||||
|
@ -101,7 +100,7 @@
|
||||||
(format "<div class=\"date\">Created: %s (%s)</div>" date (y-date date)))
|
(format "<div class=\"date\">Created: %s (%s)</div>" date (y-date date)))
|
||||||
(when-let ((keywords (plist-get info :keywords)))
|
(when-let ((keywords (plist-get info :keywords)))
|
||||||
(format "<div class=\"keywords\">Keywords: <code>%s</code></div>" keywords))
|
(format "<div class=\"keywords\">Keywords: <code>%s</code></div>" keywords))
|
||||||
"<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 rel=\"alternate\" type=\"application/rss+xml\" 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>"
|
"<div class=\"web-file-size\">Size: XXK (HTML: XXK, CSS: XXK, IMG: XXK)</div>"
|
||||||
|
|
BIN
project.el.sig
BIN
project.el.sig
Binary file not shown.
Loading…
Reference in a new issue