From adfcd9801259017c5f9e7b9c6fd14589669506b3 Mon Sep 17 00:00:00 2001 From: Carlos Fenollosa Date: Mon, 15 Sep 2014 19:23:12 +0200 Subject: [PATCH] Twitter cards. Fixes #36 --- README.md | 1 + bb.sh | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed31077..0da47fd 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,7 @@ As a guideline, pull requests should: Changelog --------- +- 2.4 Added Twitter summaries metadata for posts (#36) - 2.3.3 Removed big comment header. Added option to display tags for cut articles on index pages (#61) Cleaned up "all posts" page (#57) diff --git a/bb.sh b/bb.sh index b0072b4..028042a 100755 --- a/bb.sh +++ b/bb.sh @@ -17,7 +17,7 @@ global_config=".config" # by the 'global_config' file contents global_variables() { global_software_name="BashBlog" - global_software_version="2.3.3" + global_software_version="2.4" # Blog title global_title="My fancy blog" @@ -73,7 +73,7 @@ global_variables() { # "cut" blog entry when putting it to index page. Leave blank for full articles in front page # i.e. include only up to first '
', or '----' in markdown cut_do="cut" - # When cutting, cut also tags? If blank, tags will appear in index page for cut articles + # When cutting, cut also tags? If "no", tags will appear in index page for cut articles cut_tags="yes" # Regexp matching the HTML line where to do the cut # note that slash is regexp separator so you need to prepend it with backslash @@ -326,6 +326,24 @@ edit() { 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' | head -c 250 | tr '\n' ' ') + echo "" + image=$(sed -n 's/.*" +} + # Adds the code needed by the twitter button # # $1 the post URL @@ -406,6 +424,7 @@ create_html_page() { cat ".header.html" > "$filename" echo "$title" >> "$filename" google_analytics >> "$filename" + twitter_card "$content" "$title" >> "$filename" echo "" >> "$filename" # stuff to add before the actual body content [[ -n "$body_begin_file" ]] && cat "$body_begin_file" >> "$filename"