Skip to content

Instantly share code, notes, and snippets.

@mowat27
Last active October 16, 2016 21:05
Show Gist options
  • Save mowat27/3b420d6df72120075b4d01efcf57a0e2 to your computer and use it in GitHub Desktop.
Save mowat27/3b420d6df72120075b4d01efcf57a0e2 to your computer and use it in GitHub Desktop.
Simple utilities for use with the Ghost blogging patform (https://ghost.io)

To download and then use a script

wget https://raw/gist/url/script.sh
chmod +x script.sh

to execute directly

bash <(curl -s http://raw/gist/url/script.sh) <args>
#!/usr/bin/env bash
# Create an empty theme at the specified location
# e.g. ./mktheme.sh mytheme
# THIS WILL OVERWRITE ANY EXISTING FILES!
# You have been warned - it is not a clever script
function dirs {
cat <<EOF
assets/css
assets/fonts
assets/images
assets/js
partials
EOF
}
function files {
cat <<EOF
assets/css/screen.css
default.hbs <h1>Hello World</h1>
post.hbs {{!< default}}
index.hbs {{!< default}}
package.json
EOF
}
function package_json_for {
theme=$1
cat<<EOF
{
"name" : "$theme",
"version": "0.0.1"
}
EOF
}
THEME=$1
[[ -z $THEME ]] && exit 1
echo "Making new theme at $PWD/$THEME"
dirs | sed "s@^@$THEME/@" | while read dir ; do
mkdir -p $dir && echo "Added dir $dir"
[[ $? -ne 0 ]] && exit 1
done
files | sed "s@^@$THEME/@" | while read file content; do
touch $file
[[ $? -ne 0 ]] && exit 1
[[ ! -z $content ]] && echo $content > $file
echo "Added file $file"
done
echo "Added package.json"
package_json_for $THEME | tee $THEME/package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment