bibi/make.sh

54 行
978 B
Bash
実行ファイル

#!/bin/sh
# usage:
# - production:
# ./make.sh
# - for local reading:
# ./make.sh -local
arg1=$1
# 静的ファイル
static="
src/*.css
src/*.js
src/favicon.ico
src/robots.txt
src/images
src/styles
"
make_html() {
name=`basename $1`
out=www/$name
cat include/header.html $path >> $out
# ライセンス表示
if [ $name = publicdomain.html ]; then
show_license >> $out
# 目次以外にはフッターあり
elif [ $name != index.html ]; then
cat include/footer.html >> $out
fi
# localでない場合: "./index.html" -> "./"
if [ "$arg1" != '-local' ]; then
sed -i -e's/href=".\/index.html"/href=".\/"/g' $out
fi
echo "$path -> $out"
}
show_license() {
echo '<blockquote cite="https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt"><pre>'
sed -e's/"/\&quot;/g' -e"s/'/\&#39;/g" LICENSE.txt
echo '</pre></blockquote>'
echo '<p>以上</p>'
}
mkdir -p www
rm -rf www/*
cp -rpv $static www
for path in src/*.html; do
make_html $path
done