bugfix: keep old page filename in the page's title link to itself
pass proper filename through parse_file to create_html_page Bug was that when editing with "bb edit page.html" and changing title, regenerated page.html had <h3><a class="ablack"> linking to newtitle.html (non-existing file)
This commit is contained in:
parent
99fea81fcb
commit
74537033f3
1 changed files with 27 additions and 19 deletions
20
bb.sh
20
bb.sh
|
@ -365,12 +365,12 @@ edit() {
|
||||||
get_html_file_content 'text' 'text' <$1 | sed "s|<a href='$prefix_tags\([^']*\).html'>\\1</a>|\\1|g" >> "$TMPFILE"
|
get_html_file_content 'text' 'text' <$1 | sed "s|<a href='$prefix_tags\([^']*\).html'>\\1</a>|\\1|g" >> "$TMPFILE"
|
||||||
rm $1
|
rm $1
|
||||||
$EDITOR "$TMPFILE"
|
$EDITOR "$TMPFILE"
|
||||||
parse_file "$TMPFILE" "$edit_timestamp" # this command sets $filename as the html processed file
|
|
||||||
rm "$TMPFILE"
|
|
||||||
if [ "$2" = "keep" ]; then
|
if [ "$2" = "keep" ]; then
|
||||||
mv $filename $1
|
parse_file "$TMPFILE" "$edit_timestamp" "$1"
|
||||||
filename="$1"
|
else
|
||||||
|
parse_file "$TMPFILE" "$edit_timestamp" # this command sets $filename as the html processed file
|
||||||
fi
|
fi
|
||||||
|
rm "$TMPFILE"
|
||||||
fi
|
fi
|
||||||
touch -t "$touch_timestamp" "$filename"
|
touch -t "$touch_timestamp" "$filename"
|
||||||
chmod 644 "$filename"
|
chmod 644 "$filename"
|
||||||
|
@ -487,8 +487,12 @@ create_html_page() {
|
||||||
|
|
||||||
# Parse the plain text file into an html file
|
# Parse the plain text file into an html file
|
||||||
#
|
#
|
||||||
# $1 file name
|
# $1 source file name
|
||||||
# $2 (optional) timestamp for the file
|
# $2 (optional) timestamp for the file
|
||||||
|
# $3 (optional) destination file name
|
||||||
|
# note that although timestamp is optional, something must be provided at its
|
||||||
|
# place if destination file name is provided, i.e:
|
||||||
|
# parse_file source.txt "" destination.html
|
||||||
parse_file() {
|
parse_file() {
|
||||||
# Read for the title and check that the filename is ok
|
# Read for the title and check that the filename is ok
|
||||||
title=""
|
title=""
|
||||||
|
@ -497,6 +501,9 @@ parse_file() {
|
||||||
# set title and
|
# set title and
|
||||||
# remove extra <p> and </p> added by markdown
|
# remove extra <p> and </p> added by markdown
|
||||||
title=$(echo "$line" | sed 's/<\/*p>//g')
|
title=$(echo "$line" | sed 's/<\/*p>//g')
|
||||||
|
if [ "$3" ]; then
|
||||||
|
filename=$3
|
||||||
|
else
|
||||||
filename="$(echo $title | tr [:upper:] [:lower:])"
|
filename="$(echo $title | tr [:upper:] [:lower:])"
|
||||||
filename="$(echo $filename | sed 's/\ /-/g')"
|
filename="$(echo $filename | sed 's/\ /-/g')"
|
||||||
filename="$(echo $filename | sed 'y/йцукенгшщзхъфывапролджэячсмитьбю/jcukengsszh-fyvaproldzeahsmit-by/')"
|
filename="$(echo $filename | sed 'y/йцукенгшщзхъфывапролджэячсмитьбю/jcukengsszh-fyvaproldzeahsmit-by/')"
|
||||||
|
@ -505,13 +512,14 @@ parse_file() {
|
||||||
filename="$(echo $filename | sed 's/^-*//')" # unix utilities are unhappy if filename starts with -
|
filename="$(echo $filename | sed 's/^-*//')" # unix utilities are unhappy if filename starts with -
|
||||||
[ "$filename" ] || filename=$RANDOM # if filename gets empty, put something in it
|
[ "$filename" ] || filename=$RANDOM # if filename gets empty, put something in it
|
||||||
filename="$filename.html"
|
filename="$filename.html"
|
||||||
content="$filename.tmp"
|
|
||||||
|
|
||||||
# Check for duplicate file names
|
# Check for duplicate file names
|
||||||
while [ -f "$filename" ]; do
|
while [ -f "$filename" ]; do
|
||||||
suffix="$RANDOM"
|
suffix="$RANDOM"
|
||||||
filename="$(echo $filename | sed 's/\.html/'$suffix'\.html/g')"
|
filename="$(echo $filename | sed 's/\.html/'$suffix'\.html/g')"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
content="$filename.tmp"
|
||||||
# Parse possible tags
|
# Parse possible tags
|
||||||
elif [[ "$line" = "<p>$template_tags_line_header"* ]]; then
|
elif [[ "$line" = "<p>$template_tags_line_header"* ]]; then
|
||||||
tags="$(echo "$line" | cut -d ":" -f 2- | sed -e 's/<\/p>//g' -e 's/^ *//' -e 's/ *$//' -e 's/, /,/g')"
|
tags="$(echo "$line" | cut -d ":" -f 2- | sed -e 's/<\/p>//g' -e 's/^ *//' -e 's/ *$//' -e 's/, /,/g')"
|
||||||
|
|
Loading…
Add table
Reference in a new issue