Last active
October 12, 2015 16:07
-
-
Save tomekc/4052398 to your computer and use it in GitHub Desktop.
Sinatra kickstart boilerplate: HTML5 + Bootstrap + jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
get '/' do | |
@name = ENV['USER'] | |
erb :main | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<h1>Hello, <%= @name %></h1> | |
<p>This is Sinatra app.</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
one-liner to execute kickstart script:
bash -c "$(curl -fsSkL https://gist.github.com/raw/4052398/sinatra-kickstart.sh)"