Skip to content

Instantly share code, notes, and snippets.

@guypursey guypursey/autoscrp.sh
Last active Aug 29, 2015

Embed
What would you like to do?
Add or remove post on Scriptogram, pulling in relevant metadata from a separate file
# Usage: ./autoscrp.sh [OPTION]... [FILE]
# Publish FILE to Scriptogr.am account (grabbing metadata as we go).
# FILE should have no extension.
#
# Expects metascrp.txt accompanying named file to pull metadata from.
# Expects there two text files in location of script,
# one containing app key for Scriptogram,
# the other containing the user ID.
#
# -d Delete file.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$1" == "-d" ]
then
echo "Deleting..."
URL="http://scriptogr.am/api/article/delete/"
fileparam="-d filename=$2.md"
filedata=""
echo $2
else
echo "Adding..."
URL="http://scriptogr.am/api/article/post/"
fileparam="-d name=$1"
filedata=$(<metascrp.txt)$'\n\n'$(<$1.md)
echo $1
fi
curl \
--data-urlencode app_key@"$DIR/scrpakey.txt" \
--data-urlencode user_id@"$DIR/scrpuser.txt" \
"$fileparam" \
--data-urlencode text="$filedata" \
$URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.