compress files to save on traffic

master
muflax 2012-02-04 21:17:48 +01:00
parent a0ca26bd2e
commit 21fdb6181f
4 changed files with 35 additions and 2 deletions

13
compress-html.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/zsh
# Copyright muflax <mail@muflax.com>, 2012
# License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html>
setopt RE_MATCH_PCRE
echo "compressing 'out'..."
for f in out/**/*(.); do
if [[ $f =~ "\.(html|css|xml|js)$" ]]; then
gzip --best -f -v -c "$f" > "$f.gz"
fi
done

View File

@ -1,6 +1,14 @@
# manual 404 page
ErrorDocument 404 /404/index.html
# don't alienate people who use the old feed
# rewrite stuff
RewriteEngine on
# don't alienate people who use the old feed
RewriteRule ^feed/? /rss.xml
# serve gzipped files if available
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME} !\.gz$
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [L]

12
tasks/compress.rake Normal file
View File

@ -0,0 +1,12 @@
# compress all text files in out/ to save on traffic
namespace :compress do
desc "compress html (and related) files"
task :html do
system "./compress-html.sh"
end
end
desc "compress everything"
task :compress => ['compress:html']

View File

@ -17,4 +17,4 @@ namespace :publish do
end
desc "publish complete site"
task :publish => ['publish:push', 'publish:deploy']
task :publish => ['publish:push', 'compress', 'publish:deploy']