Skip to content

Instantly share code, notes, and snippets.

@dinkengraven
Forked from xionon/sinatra-new
Created October 10, 2015 14:58
Show Gist options
  • Save dinkengraven/b54b1fc979733dac33fe to your computer and use it in GitHub Desktop.
Save dinkengraven/b54b1fc979733dac33fe to your computer and use it in GitHub Desktop.
#! /usr/bin/env sh
# Generate a new, simple sinatra app
# Usage: sinatra-new name_of_app
set -e
dir=$1
mkdir -p $dir/{views,public}
cd $dir
bundle init
echo "gem 'sinatra'" >> Gemfile
echo "web: bundle exec ruby main.rb" >> Procfile
(
cat <<HEREDOC
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
HEREDOC
) > views/index.erb
(
cat <<HEREDOC
require 'sinatra'
get '/' do
erb :index
end
HEREDOC
) > main.rb
git init .
git add -A
git commit -m"Initial setup"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment