Skip to content

Instantly share code, notes, and snippets.

@TJScalzo
Forked from tholman/Post Generator
Last active April 19, 2018 11:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TJScalzo/86b139d3865b102e5d358e36b54b4a25 to your computer and use it in GitHub Desktop.
Save TJScalzo/86b139d3865b102e5d358e36b54b4a25 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Vars
base_image_directory="/Users/tjscalzo/Github/inspiring-online/assets/post-images"
base_post_directory="/Users/tjscalzo/Github/inspiring-online/_posts"
image_type=".png"
author_name="Tim Scalzo"
author_url=""
author_github="TJScalzo"
underscore="_"
todays_date1=$(date +%Y-%m-%d)
todays_date2=$(date +"%Y-%m-%d %T")
# # 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")"
post_title_string=$(echo "$post_title_string" | sed 's/[^a-z0-9.-]//g')
full_post_file=$base_post_directory/$todays_date1-$post_title_string.md
# Screenshot
echo "Let's 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/tjscalzo/Desktop
latest_file=$(ls -t | head -n1)
new_directory=$base_image_directory/$image_name
mv "$latest_file" $new_directory
# Find out the image's dimensions
image_width=`identify -format %w $new_directory` #width
image_height=`identify -format %h $new_directory` #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 website's url: "
read post_url
# Main Blurb
echo "What is the main blurb: "
read post_blurb
# Creators Name
echo "What is the creator's name: "
read creators_name
# Creators Url
echo "What is the creator's url: "
read creators_url
cat > $full_post_file <<- EOM
---
layout: post
title: $post_title
date: $todays_date2
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_text
[$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