avoid exploding on new files

This commit is contained in:
James Tomasino 2018-09-24 22:24:31 -04:00
parent 3fed90daef
commit 2cfeda0340
1 changed files with 14 additions and 11 deletions

25
burrow
View File

@ -132,7 +132,7 @@ parse_input () {
"gophermap") "gophermap")
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
shift shift
arg_gophermap="$1" arg_gophermap="${1%/}/"
else else
arg_gophermap="/" arg_gophermap="/"
fi fi
@ -377,14 +377,17 @@ make_post_temp () {
# Populate tempfile with either template or default template # Populate tempfile with either template or default template
if [ -f "${post_dir}/.template" ]; then if [ -f "${post_dir}/.template" ]; then
cat "${post_dir}/.template" > "$temp_post" cat "${post_dir}/.template" > "$temp_post"
else elif [ -n "$title" ]; then
{ { printf "%s\\n%s\\n" "----------------------------------------" "$title"
printf "%s\\n%s\\n" "----------------------------------------" "$title"
if $use_date; then if $use_date; then
date +"%B %d$(day_suffix), %Y" date +"%B %d$(day_suffix), %Y"
fi fi
printf "%s\\n\\n\\n" "----------------------------------------" printf "%s\\n\\n\\n" "----------------------------------------"
} > "$temp_post" } > "$temp_post"
else
{ printf "%s\\n%s\\n" "----------------------------------------" "$post_type"
printf "%s\\n\\n\\n" "----------------------------------------"
} > "$temp_post"
fi fi
# Check timestamp before editing file # Check timestamp before editing file
@ -446,6 +449,7 @@ make_post () {
use_date="$4" use_date="$4"
update_root="$5" update_root="$5"
create_rss="$6" create_rss="$6"
create_gophermap="$7"
check_directory "$config_dir_gopher" check_directory "$config_dir_gopher"
@ -477,7 +481,9 @@ make_post () {
die "Aborted post" 0 die "Aborted post" 0
fi fi
make_post_process_formatting make_post_process_formatting
make_post_gophermap if $create_gophermap; then
make_post_gophermap
fi
fi fi
if $update_root; then if $update_root; then
@ -631,16 +637,12 @@ main () {
fi fi
if [ "$arg_gophermap" != "" ]; then if [ "$arg_gophermap" != "" ]; then
# If we don't have a gophermap, create one to avoid
# accidentally sorting the file on first-time generation
if [ ! -f "${config_dir_gopher}${arg_gophermap}gophermap" ]; then
touch "${config_dir_gopher}${arg_gophermap}gophermap"
fi
make_post "" \ make_post "" \
"${arg_gophermap}" \ "${arg_gophermap}" \
true \ true \
false \ false \
true \ true \
false \
false false
fi fi
@ -650,7 +652,8 @@ main () {
"$config_phlog_gophermap" \ "$config_phlog_gophermap" \
"$config_phlog_usedate" \ "$config_phlog_usedate" \
true \ true \
${config_phlog_autorss} ${config_phlog_autorss} \
true
fi fi
if [ $arg_rss -gt 0 ]; then if [ $arg_rss -gt 0 ]; then