главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Shpakovsky <alexey@shpakovsky.ru>2014-03-01 14:34:52 +0100
committerAleksei Shpakovskii <alekseis@opera.com>2014-03-10 09:22:20 +0100
commit773c5fa363c3878c072bd5673821ee20cf2861bd (patch)
tree03ef7dc6b030fd11d193fff85d94d795f9f395a7
parentb365aec7978f663f21c3560e82ada7f0b49cdc1d (diff)
add options to bring back old behavior and keep old filename
-rwxr-xr-xbb.sh33
1 files changed, 23 insertions, 10 deletions
diff --git a/bb.sh b/bb.sh
index c2a0f77..32856d0 100755
--- a/bb.sh
+++ b/bb.sh
@@ -342,19 +342,32 @@ 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')"
- # Create the content file
- TMPFILE="$1.$RANDOM"
- # Title
- echo "$(get_post_title $1)" > "$TMPFILE"
- # Post text with plaintext tags
- get_html_file_content 'text' 'text' <$1 | sed "s|<a href='$prefix_tags\([^']*\).html'>\\1</a>|\\1|g" >> "$TMPFILE"
- rm $1
- $EDITOR "$TMPFILE"
- parse_file "$TMPFILE" # this command sets $filename as the html processed file
+ if [ "$2" = "full" ]; then
+ $EDITOR "$1"
+ filename="$1"
+ else
+ # Create the content file
+ TMPFILE="$1.$RANDOM"
+ # Title
+ echo "$(get_post_title $1)" > "$TMPFILE"
+ # Post text with plaintext tags
+ get_html_file_content 'text' 'text' <$1 | sed "s|<a href='$prefix_tags\([^']*\).html'>\\1</a>|\\1|g" >> "$TMPFILE"
+ rm $1
+ $EDITOR "$TMPFILE"
+ parse_file "$TMPFILE" # this command sets $filename as the html processed file
+ rm "$TMPFILE"
+ if [ "$2" = "keep" ]; then
+ mv $filename $1
+ filename="$1"
+ fi
+ fi
touch -t $edit_timestamp "$filename"
- rm "$TMPFILE"
chmod 644 "$filename"
echo "Posted $filename"
}