Create a gist now

Instantly share code, notes, and snippets.

@tholman /Post Generator Secret
Last active Jun 22, 2017

What would you like to do?
#!/bin/sh
# Vars
base_image_directory="/Users/tim/Tims/inspiring-online/assets/post-images"
base_post_directory="/Users/tim/Tims/inspiring-online/_posts"
image_type=".png"
author_name="Tim Holman"
author_url="http://tholman.com"
author_github="tholman"
underscore="_"
todays_date=$(date +%Y-%m-%d)
# Post Title
echo "What is the post title: "
read post_title
post_title_string=${post_title// /-}
post_title_string="$(tr [A-Z] [a-z] <<< "$post_title_string")"
full_post_file=$base_post_directory/$todays_date-$post_title_string.md
# Screenshot
echo "Lets do this. First, take a screenshot!"
read screenshot_taken
# Move the screenshot to the correct directory
image_name=$post_title_string$image_type
cd /Users/tim/Desktop
latest_file=$(ls -t | head -n1)
new_directory=$base_image_directory/$image_name
mv "$latest_file" $new_directory
image_width=`identify "$new_directory" | cut -f 3 -d " " | sed s/x.*//` #width
image_height=`identify "$new_directory" | cut -f 3 -d " " | sed s/.*x//` #height
# Get more details about the post
echo "What type is the post (Beautiful, Inspiration, Coding, Typography, WideWeirdWeb, Resource): "
read post_type
# Websites url
echo "What is the websites url: "
read post_url
# Main Blurb
echo "What is the main blurb: "
read post_blurb
# Creators Name
echo "What is the creators name: "
read creators_name
# Creators Url
echo "What is the creators url: "
read creators_url
cat > $full_post_file <<- EOM
---
layout: post
title: $post_title
type: $post_type
image: $image_name
link: $post_url
authorName: $author_name
authorUrl: $author_url
authorGithub: $author_github
imgWidth: $image_width
imgHeight: $image_height
---
$underscore$post_blurb$underscore
[$post_title]($post_url) - by [$creators_name]($creators_url)
EOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment