главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
path: root/bb.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bb.sh')
-rw-r--r--[-rwxr-xr-x]bb.sh25
1 files changed, 20 insertions, 5 deletions
diff --git a/bb.sh b/bb.sh
index cddfd43..d4e45d6 100755..100644
--- 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.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">'