Skip to content

Instantly share code, notes, and snippets.

@tomekc
Last active Oct 12, 2015
Embed
What would you like to do?
Sinatra kickstart boilerplate: HTML5 + Bootstrap + jQuery
require 'sinatra'
get '/' do
@name = ENV['USER']
erb :main
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My site</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="/css/bootstrap.css" rel="stylesheet">
<link href="/css/bootstrap-responsive.css" rel="stylesheet">
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/jquery.min.js"></script>
</head>
<body>
<%= yield %>
</body>
</html>
<div class="container">
<h1>Hello, <%= @name %></h1>
<p>This is Sinatra app.</p>
#!/bin/bash
function fail() {
echo Something went wrong. Exiting.
exit
}
echo Checking if you have wget
which -s wget || fail
echo Checking if you have unzip
which -s unzip || fail
mkdir -p public/css
mkdir -p public/js
mkdir -p public/img
mkdir -p views
# Skeleton app files
echo Downloading app stub
wget -q https://gist.github.com/raw/4052398/app.rb || fail
echo Downloading layout.erb
wget -q -P views https://gist.github.com/raw/4052398/layout.erb || fail
echo Downloading main.erb
wget -q -P views https://gist.github.com/raw/4052398/main.erb || fail
# Download jQuery and Twitter Bootstrap
echo Downloading jQuery
wget -q -P public/js https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js || fail
echo Downloading Bootstrap
wget -q http://twitter.github.com/bootstrap/assets/bootstrap.zip || fail
unzip -q bootstrap.zip
mv bootstrap/css/* public/css/
mv bootstrap/js/* public/js/
mv bootstrap/img/* public/img/
# clean up
echo Cleaning up
rm bootstrap.zip
rm -rf bootstrap
echo Done!
echo
echo You can run your app with
echo
echo ruby -rubygems app.rb
echo
@tomekc

This comment has been minimized.

Copy link
Owner Author

@tomekc tomekc commented Nov 11, 2012

one-liner to execute kickstart script:

bash -c "$(curl -fsSkL https://gist.github.com/raw/4052398/sinatra-kickstart.sh)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment