diff --git a/download.html b/download.html index 1ba9700..be9e716 100644 --- a/download.html +++ b/download.html @@ -30,19 +30,27 @@
Fork of Conversations XMPP client with additional features
line 1
\n\nline 2
' ]] || + [[ $("$markdown_bin" <<< $'line 1\n\nline 2') == $'line 1
\nline 2
' ]] + ) +} + + +# Parse a Markdown file into HTML and return the generated file +markdown() { + out=${1%.md}.html + while [[ -f $out ]]; do out=${out%.html}.$RANDOM.html; done + $markdown_bin "$1" > "$out" + echo "$out" +} + + +# Prints the required google analytics code +google_analytics() { + [[ -z $global_analytics && -z $global_analytics_file ]] && return + + if [[ -z $global_analytics_file ]]; then + echo "" + else + cat "$global_analytics_file" + fi +} + +# Prints the required code for disqus comments +disqus_body() { + [[ -z $global_disqus_username ]] && return + + echo ' + + + comments powered by Disqus' +} + +# Prints the required code for disqus in the footer +disqus_footer() { + [[ -z $global_disqus_username ]] && return + echo '' +} + +# Reads HTML file from stdin, prints its content to stdout +# $1 where to start ("text" or "entry") +# $2 where to stop ("text" or "entry") +# $3 "cut" to remove text from$template_tags_line_header/ ) print
+ }
+ }
+ }"
+}
+
+# Edit an existing, published .html file while keeping its original timestamp
+# Please note that this function does not automatically republish anything, as
+# it is usually called from 'main'.
+#
+# Note that it edits HTML file, even if you wrote the post as markdown originally
+# 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() {
+ [[ ! -f "${1%%.*}.html" ]] && echo "Can't edit post "${1%%.*}.html", did you mean to use \"bb.sh post $template_tags_line_header/s|\\1|\\1|g" >> "$TMPFILE"
+ $EDITOR "$TMPFILE"
+ filename=$1
+ fi
+ rm "$filename"
+ if [[ $2 == keep ]]; then
+ parse_file "$TMPFILE" "$edit_timestamp" "$filename"
+ else
+ parse_file "$TMPFILE" "$edit_timestamp" # this command sets $filename as the html processed file
+ [[ ${1##*.} == md ]] && mv "$1" "${filename%%.*}.md" 2>/dev/null
+ fi
+ rm "$TMPFILE"
+ fi
+ touch -t "$touch_timestamp" "$filename"
+ touch -t "$touch_timestamp" "$1"
+ chmod 644 "$filename"
+ echo "Posted $filename"
+ tags_after=$(tags_in_post "$filename")
+ relevant_tags=$(echo "$tags_before $tags_after" | tr ',' ' ' | tr ' ' '\n' | sort -u | tr '\n' ' ')
+ if [[ ! -z $relevant_tags ]]; then
+ relevant_posts="$(posts_with_tags $relevant_tags) $filename"
+ rebuild_tags "$relevant_posts" "$relevant_tags"
+ fi
+}
+
+# Create a Twitter summary (twitter "card") for the post
+#
+# $1 the post file
+# $2 the title
+twitter_card() {
+ [[ -z $global_twitter_username ]] && return
+
+ echo ""
+ echo ""
+ echo "" # Twitter truncates at 70 char
+ description=$(grep -v "^ $template_tags_line_header" "$1" | sed -e 's/<[^>]*>//g' | tr '\n' ' ' | sed "s/\"/'/g" | head -c 250)
+ echo ""
+
+ # For the image we try to locate the first image in the article
+ image=$(sed -n '2,$ d; s/.* $template_comments $template_twitter_button "
+ echo " $template_comments ";
+ fi
+ else
+ echo " $template_comments "
+ fi
+
+ echo "$template_twitter_button "
+ echo " 's on the title because of markdown conversion
+ title=${title// /}
+ title=${title//<\/p>/}
+ echo "$title"
+ echo '"
+ # remove possible
'
+ if [[ -z $timestamp ]]; then
+ echo ""
+ else
+ echo ""
+ fi
+ if [[ -z $timestamp ]]; then
+ echo -n "