Skip to content

Instantly share code, notes, and snippets.

@paganotoni
Created August 27, 2013 01:44
Show Gist options
  • Save paganotoni/6348786 to your computer and use it in GitHub Desktop.
Save paganotoni/6348786 to your computer and use it in GitHub Desktop.
Script to init Ruby static Heroku site.
init_static_site(){
PROJECT_NAME=$1
if [[ -z "$PROJECT_NAME" ]] then
PROJECT_NAME="site"
echo "| You didn't define a name for the site folder, setting it to 'site' by default"
fi
mkdir -p $PROJECT_NAME/public/{images,js,css}
touch $PROJECT_NAME/{config.ru,public/index.html}i
cd $PROJECT_NAME && touch Gemfile && echo "source \"https://rubygems.org\"\ngem 'rack'" >> Gemfile
echo "use Rack::Static, :urls => [\"/images\", \"/js\", \"/css\"],:root => \"public\"\nrun lambda { |env|\n[200, {'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=86400' },File.open('public/index.html', File::RDONLY)]}" >> config.ru
bundle install
cd ..
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment