more options and bug fixes

typo
Alessandro Mauri 4 years ago
parent d05f3d3dff
commit b428fe5616
  1. 49
      rivet.sh

@ -12,12 +12,13 @@ usage() {
printf "Usage: rivet [-o destdir] [-hovelf] srcdir domain\n" printf "Usage: rivet [-o destdir] [-hovelf] srcdir domain\n"
printf "\t-h: prints this message\n" printf "\t-h: prints this message\n"
printf "\t-o [destdir]: specifies the output direcotory to be [destdir]\n" printf "\t-o [destdir]: specifies the output direcotory to be [destdir]\n"
printf "\t-v: makes the script verbose\n" printf "\t-p: [string]: Rename the \"Pages\" section to [string]\n"
printf "\t-e: skips prepending _header.html to .html files\n" printf "\t-v: Makes the script verbose\n"
printf "\t-f: skips appending _footer.html to .html files\n" printf "\t-e: Do not prepend _header.html to .html files\n"
printf "\t-l: skips the generation of .html file list\n" printf "\t-f: Do not prepend _footer.html to .html files\n"
printf "\t-s: skips sitemap.xml creation\n" printf "\t-l: Do not generate \"Pages\" section in index.html\n"
printf "\t-u: makes all references to the url 'http' instead of 'https'\n" printf "\t-s: Do not generate sitemap.xml\n"
printf "\t-u: Makes all references to the url 'http' instead of 'https'\n"
exit 2 exit 2
} }
@ -39,16 +40,8 @@ fi
destdir='dst' destdir='dst'
prefix='https' prefix='https'
# Get arguments using getopts linksec='Pages'
# rivet [src] [-vhelf] [-o dir] while getopts 'o:vhelfsup:' c
# -o [dir]: set the destination directory, defaults to "dst"
# -v: verbose, sets x so it prints every line
# -h: prints usage
# -e: skip prepend header
# -l: skip article list
# -f: skip append footer
# -s: skip sitemap creation
while getopts 'o:vhelfsu' c
do do
case "$c" in case "$c" in
o) destdir=${OPTARG%%\/} ;; o) destdir=${OPTARG%%\/} ;;
@ -59,6 +52,7 @@ do
f) SKIP_FOOTER=true ;; f) SKIP_FOOTER=true ;;
s) SKIP_SITEMAP=true ;; s) SKIP_SITEMAP=true ;;
u) prefix='http' ;; u) prefix='http' ;;
p) linksec="$OPTARG" ;;
*) ;; *) ;;
esac esac
done done
@ -72,6 +66,27 @@ src="$1"
srcdir=${src%%\/} srcdir=${src%%\/}
unset src unset src
# Check if index.md is present
if ! [ -e "$srcdir"/index.md ]; then
echo "Missing index.md in $srcdir"
exit 1
fi
# Check header and footer files
if ! [ -e "$headerfile" ]; then
echo "Missing _header.html in $srcdir"
exit 1
fi
if ! [ -e "$footerfile" ]; then
echo "Missing _footer.html in $srcdir"
exit 1
fi
# Remove junk from {header,footer} files
sed -i 's/<header.*>//' "$headerfile"
sed -i 's/<\/header>//' "$headerfile"
sed -i 's/<footer.*>//' "$footerfile"
sed -i 's/<\/footer>//' "$footerfile"
# Remove any junk from the domain eg. [https://]domain.com[/] # Remove any junk from the domain eg. [https://]domain.com[/]
url="$(echo "$2" | url="$(echo "$2" |
sed -e 's/^https*:\/\///' | sed -e 's/^https*:\/\///' |
@ -138,7 +153,7 @@ if ! [ "$SKIP_SITEMAP" ] || ! [ "$SKIP_LIST" ]; then
rm -f "$tmpfile" rm -f "$tmpfile"
cat << EOF >> "$tmpfile" cat << EOF >> "$tmpfile"
<div id="map"> <div id="map">
<h2 id="Pages">Pages</h2> <h2 id="Pages">"$linksec"</h2>
EOF EOF
while IFS="" read -r line; do while IFS="" read -r line; do
if echo "$line" | grep -q 'index\.html'; then if echo "$line" | grep -q 'index\.html'; then

Loading…
Cancel
Save