diff options
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r--[-rwxr-xr-x] | bb.sh | 25 |
2 files changed, 28 insertions, 6 deletions
@@ -42,6 +42,12 @@ When you're done, access the public URL for that folder (e.g. `http://server.co and you should see the index file and a new page for that post! +How to... +--------- + +Please [read the wiki](https://github.com/cfenollosa/bashblog/wiki) to learn how to use the advanced features of Bashblog, such as headers and footers, static pages, and more. + + Features -------- @@ -131,7 +137,8 @@ As a guideline, pull requests should: Changelog --------- - +- 2.10 Added `global_twitter_card_image` +- 2.9 Added `body_begin_file_index` - 2.8 Bugfixes<br/> Slavic language support thanks to Tomasz Jadowski<br/> Removed the now defunct Twitter JSON API share count<br/> @@ -17,7 +17,7 @@ global_config=".config" # by the 'global_config' file contents global_variables() { global_software_name="BashBlog" - global_software_version="2.8" + global_software_version="2.10" # Blog title global_title="My fancy blog" @@ -49,6 +49,8 @@ global_variables() { # Change this to your username if you want to use twitter for comments global_twitter_username="" + # Default image for the Twitter cards. Use an absolute URL + global_twitter_card_image="" # Set this to false for a Twitter button with share count. The cookieless version # is just a link. global_twitter_cookieless="true" @@ -95,9 +97,11 @@ global_variables() { # extra content to add just after we open the <body> tag # and before the actual blog content body_begin_file="" - # extra content to add just before we cloese <body tag (just before - # </body>) + # extra content to add just before we close </body> body_end_file="" + # extra content to ONLY on the index page AFTER `body_begin_file` contents + # and before the actual content + body_begin_file_index="" # CSS files to include on every page, f.ex. css_include=('main.css' 'blog.css') # leave empty to use generated css_include=() @@ -338,13 +342,23 @@ edit() { twitter_card() { [[ -z $global_twitter_username ]] && return + echo "<meta name='twitter:card' content='summary'>" echo "<meta name='twitter:site' content='@$global_twitter_username'>" echo "<meta name='twitter:title' content='$2'>" # Twitter truncates at 70 char - description=$(grep -v "^<p>$template_tags_line_header" "$1" | sed -e 's/<[^>]*>//g' | head -c 250 | tr '\n' ' ' | sed "s/\"/'/g") + description=$(grep -v "^<p>$template_tags_line_header" "$1" | sed -e 's/<[^>]*>//g' | tr '\n' ' ' | sed "s/\"/'/g" | head -c 250) echo "<meta name='twitter:description' content=\"$description\">" - image=$(sed -n 's/.*<img.*src="\([^"]*\)".*/\1/p' "$1" | head -n 1) # First image is fine + + # For the image we try to locate the first image in the article + image=$(sed -n '2,$ d; s/.*<img.*src="\([^"]*\)".*/\1/p' "$1") + + # If none, then we try a global setting image + [[ -z $image ]] && [[ -n $global_twitter_card_image ]] && image=$global_twitter_card_image + + # If none, return [[ -z $image ]] && return + + # Final housekeeping [[ $image =~ ^https?:// ]] || image=$global_url/$image # Check that URL is absolute echo "<meta name='twitter:image' content='$image'>" } @@ -433,6 +447,7 @@ create_html_page() { echo "</head><body>" # stuff to add before the actual body content [[ -n $body_begin_file ]] && cat "$body_begin_file" + [[ $filename = $index_file* ]] && [[ -n $body_begin_file_index ]] && cat "$body_begin_file_index" # body divs echo '<div id="divbodyholder">' echo '<div class="headerholder"><div class="header">' |