\n' \
"$e_url" "$e_name" "$e_size" "$e_date"
fi
;;
esac
done
fi
cat << 'EOF'
EOF
cat files/footer
} > public/download.html
}
generate_download_page
# build docs index
cat docs/readme.md > docs/index.md
for f in docs/*.md; do
case $f in */readme.md|*/index.md) continue;; esac
title=$(head -n1 "$f" | sed "s/^#* *//")
file=${f##*/}
echo "- [$title](./${file%.md}.html)" >> docs/index.md
done
# convert markdown to html
find . -type f -name "*.md" ! -path './public/*' | sed 's|^\./||' | while IFS= read -r i; do
dir=${i%/*}
file=${i##*/}
title=${dir##*/}
[ "$dir" = "$file" ] && {
title=home; dir=
}
mkdir -p "public/$dir"
printf 'generating html for %s...\n' "$i"
{
sed "s/@TITLE@/$title/g" files/header
case $i in docs/readme.md|docs/index.md) ;; *) case $i in docs/*) printf '<- back to docs\n\n';; esac; esac
cmark "$i"
case $i in docs/readme.md|docs/index.md) ;; *) case $i in docs/*) printf '\n<- back to docs\n';; esac; esac
cat files/footer
} > "public/${i%.md}.html"
done
# move readme.html to index.html
find public -type f -name "readme.html" | while IFS= read -r i; do
mv -n "$i" "${i%/*}/index.html"
done
rm -f docs/index.md
if [ -d files ]; then
cp -ra files public/
fi
echo alicelinux.org > public/.domains
echo alicelinux.emmett1.my >> public/.domains
exit 0