add options to bring back old behavior and keep old filename
This commit is contained in:
parent
b365aec797
commit
773c5fa363
1 changed files with 23 additions and 10 deletions
15
bb.sh
15
bb.sh
|
@ -342,8 +342,16 @@ get_html_file_content() {
|
|||
# Note that if you edit title then filename might also change
|
||||
#
|
||||
# $1 the file to edit
|
||||
# $2 (optional) edit mode:
|
||||
# "keep" to keep old filename
|
||||
# "full" to edit full HTML, and not only text part (keeps old filename)
|
||||
# leave empty for default behavior (edit only text part and change name)
|
||||
edit() {
|
||||
edit_timestamp="$(date -r $1 +'%Y%m%d%H%M')"
|
||||
if [ "$2" = "full" ]; then
|
||||
$EDITOR "$1"
|
||||
filename="$1"
|
||||
else
|
||||
# Create the content file
|
||||
TMPFILE="$1.$RANDOM"
|
||||
# Title
|
||||
|
@ -353,8 +361,13 @@ edit() {
|
|||
rm $1
|
||||
$EDITOR "$TMPFILE"
|
||||
parse_file "$TMPFILE" # this command sets $filename as the html processed file
|
||||
touch -t $edit_timestamp "$filename"
|
||||
rm "$TMPFILE"
|
||||
if [ "$2" = "keep" ]; then
|
||||
mv $filename $1
|
||||
filename="$1"
|
||||
fi
|
||||
fi
|
||||
touch -t $edit_timestamp "$filename"
|
||||
chmod 644 "$filename"
|
||||
echo "Posted $filename"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue