├── .gitignore ├── Gemfile ├── Gemfile.lock ├── Rakefile ├── app.rb ├── config.rb ├── config.ru ├── helpers └── render_partial.rb ├── public ├── images │ └── .gitkeep ├── javascripts │ └── application.js └── stylesheets │ └── application.css ├── readme.md ├── stylesheets └── application.scss ├── tasks ├── application.rake ├── generate.rake └── styles.rake └── views ├── index.haml └── layout.haml /.gitignore: -------------------------------------------------------------------------------- 1 | .bundle/ 2 | .sass-cache/ 3 | .DS_Store 4 | tmp/**/* -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'rake' 4 | gem 'sinatra' 5 | gem 'shotgun' 6 | gem 'haml' 7 | 8 | # Sass & Compass 9 | gem 'sass' 10 | gem 'compass' 11 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | chunky_png (1.2.8) 5 | compass (0.12.2) 6 | chunky_png (~> 1.2) 7 | fssm (>= 0.2.7) 8 | sass (~> 3.1) 9 | fssm (0.2.10) 10 | haml (4.0.3) 11 | tilt 12 | rack (1.5.2) 13 | rack-protection (1.5.0) 14 | rack 15 | rake (10.1.0) 16 | sass (3.2.9) 17 | shotgun (0.9) 18 | rack (>= 1.0) 19 | sinatra (1.4.3) 20 | rack (~> 1.4) 21 | rack-protection (~> 1.4) 22 | tilt (~> 1.3, >= 1.3.4) 23 | tilt (1.4.1) 24 | 25 | PLATFORMS 26 | ruby 27 | 28 | DEPENDENCIES 29 | compass 30 | haml 31 | rake 32 | sass 33 | shotgun 34 | sinatra 35 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'bundler' 3 | require 'rake' 4 | Bundler.setup 5 | 6 | Dir["tasks/*.rake"].sort.each { |ext| load ext } 7 | -------------------------------------------------------------------------------- /app.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'sinatra/base' 3 | require 'haml' 4 | 5 | class SinatraBootstrap < Sinatra::Base 6 | require './helpers/render_partial' 7 | 8 | get '/' do 9 | haml :index 10 | end 11 | 12 | # start the server if ruby file executed directly 13 | run! if app_file == $0 14 | end 15 | -------------------------------------------------------------------------------- /config.rb: -------------------------------------------------------------------------------- 1 | require './app' 2 | 3 | # Configuration to use when running within Sinatra 4 | project_path = Sinatra::Application.root 5 | 6 | # HTTP paths 7 | http_path = '/' 8 | http_stylesheets_path = '/stylesheets' 9 | http_images_path = '/images' 10 | http_javascripts_path = '/javascripts' 11 | 12 | # File system locations 13 | css_dir = File.join 'public', 'stylesheets' 14 | sass_dir = File.join 'stylesheets' 15 | images_dir = File.join 'public', 'images' 16 | javascripts_dir = File.join 'public', 'javascripts' 17 | 18 | # Syntax preference 19 | preferred_syntax = :scss 20 | 21 | # Determine whether Compass generates relative or absolute paths 22 | relative_assets = false 23 | 24 | # Determines whether line comments should be added to compiled css for easier debugging 25 | line_comments = false 26 | 27 | # CSS output style - :nested, :expanded, :compact, or :compressed 28 | output_style = :expanded 29 | 30 | # Learn more: http://beta.compass-style.org/help/tutorials/configuration-reference/ 31 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'sinatra' 3 | require './app' 4 | 5 | run SinatraBootstrap 6 | -------------------------------------------------------------------------------- /helpers/render_partial.rb: -------------------------------------------------------------------------------- 1 | module RenderPartial 2 | def partial(page, options={}) 3 | haml page, options.merge!(:layout => false) 4 | end 5 | end 6 | 7 | helpers RenderPartial 8 | -------------------------------------------------------------------------------- /public/images/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamstac/sinatra-bootstrap/db2cbdcf1b73ab78bbb74367c795851fc787fd10/public/images/.gitkeep -------------------------------------------------------------------------------- /public/javascripts/application.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | 3 | // Open external links in a new window 4 | hostname = window.location.hostname 5 | $("a[href^=http]") 6 | .not("a[href*='" + hostname + "']") 7 | .addClass('link external') 8 | .attr('target', '_blank'); 9 | 10 | }); 11 | -------------------------------------------------------------------------------- /public/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}html{line-height:1}ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0}caption,th,td{text-align:left;font-weight:normal;vertical-align:middle}q,blockquote{quotes:none}q:before,q:after,blockquote:before,blockquote:after{content:"";content:none}a img{border:none}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{display:block}body{font:62.5% Arial, Helvetica, sans-serif;background:#fff;color:#0d0d0d;padding:50px}h1{font-size:3em;font-weight:bold;text-align:center} 2 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Sinatra Bootstrap 2 | 3 | ## A simple Sinatra starting point 4 | 5 | Sinatra Bootstrap supports: 6 | 7 | * [Haml](http://haml-lang.com/) 8 | * [Sass](http://sass-lang.com/) 9 | * [Compass](https://github.com/chriseppstein/compass) 10 | * [jQuery](http://jquery.com/) 11 | 12 | ## What is the purpose of Sinatra Bootstrap? 13 | 14 | I created Sinatra Bootstrap in order to have a consistent starting point for my Sinatra projects. I like having Haml, Sass and Compass available to me in every project, likewise jQuery makes its way into every production as well. A number of helpful rake tasks have also been included. 15 | 16 | ## How do I get started? 17 | 18 | bundle install 19 | 20 | ## How do I start the application? 21 | 22 | Start the app by running: 23 | 24 | rake s 25 | 26 | This rake command runs `bundle exec shotgun config.ru` behind the scenes for you and starts the app on Sinatra's default port 9393 and will now be able to view the application in your web browser at this URL [http://localhost:9393](http://localhost:9393). 27 | 28 | You'll also want to open a new terminal window to the same directory and run `compass watch` to watch the Sass files for changes. 29 | 30 | ## Helper Rake Tasks 31 | 32 | There are a few helper Rake tasks that will help you to clear and compile your Sass stylesheets as well as a few other helpful tasks. There is also a generate task, so you can generate a new project at a defined location based on the bootstrap. 33 | 34 | rake -T 35 | 36 | rake css:clear # Clear the CSS 37 | rake css:compile # Compile CSS 38 | rake css:compile:prod # Compile CSS for production 39 | rake generate # Generate a new project at dir=foo 40 | rake s # Run the app 41 | 42 | ## License 43 | 44 | Copyright (c) Adam Stacoviak 45 | 46 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 47 | 48 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 49 | 50 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 51 | -------------------------------------------------------------------------------- /stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | @import "compass/reset"; 2 | @import "compass/utilities"; 3 | @import "compass/css3"; 4 | 5 | body { 6 | font: 62.5% Arial, Helvetica, sans-serif; 7 | background: #fff; 8 | color: #0d0d0d; 9 | padding: 50px; 10 | } 11 | 12 | h1 { 13 | font-size: 3em; 14 | font-weight: bold; 15 | text-align: center; 16 | } 17 | -------------------------------------------------------------------------------- /tasks/application.rake: -------------------------------------------------------------------------------- 1 | desc 'Run the app' 2 | task :s do 3 | system "rackup -p 4567" 4 | end 5 | -------------------------------------------------------------------------------- /tasks/generate.rake: -------------------------------------------------------------------------------- 1 | desc 'Generate a new project at dir=foo' 2 | task :generate do 3 | # Create the new directory 4 | system "mkdir #{(ENV['dir'])}" # unless File.exists?(ENV['dir']) 5 | 6 | # Copy this directory's contents to the new directory 7 | system "cp -R * #{ENV['dir']}" 8 | 9 | # Remove waste from the generated project 10 | system "cd #{ENV['dir']}; rm -Rf .bundle .git .sass-cache #{File.join("tasks", "generate.rake")} Gemfile.lock readme.md" 11 | 12 | # Add the readme back 13 | system "cd #{ENV['dir']}; touch readme.md" 14 | 15 | # Success! 16 | puts "A copy of this project has been generated at: #{(ENV['dir'])}" 17 | end 18 | -------------------------------------------------------------------------------- /tasks/styles.rake: -------------------------------------------------------------------------------- 1 | namespace :css do 2 | 3 | desc "Clear the CSS" 4 | task :clear => ["compile:clear"] 5 | 6 | desc "Compile CSS" 7 | task :compile => ["compile:default"] 8 | 9 | namespace :compile do 10 | 11 | task :clear do 12 | puts "*** Clearing CSS ***" 13 | system "rm -Rfv public/stylesheets/*" 14 | end 15 | 16 | task :default => :clear do 17 | puts "*** Compiling CSS ***" 18 | system "compass compile" 19 | end 20 | 21 | desc "Compile CSS for production" 22 | task :prod => :clear do 23 | puts "*** Compiling CSS ***" 24 | system "compass compile --output-style compressed --force" 25 | end 26 | 27 | end 28 | 29 | end 30 | -------------------------------------------------------------------------------- /views/index.haml: -------------------------------------------------------------------------------- 1 | %h1 Sinatra has taken the stage 2 | -------------------------------------------------------------------------------- /views/layout.haml: -------------------------------------------------------------------------------- 1 | !!! 5 2 | %html{html_attrs} 3 | %head 4 | %meta{:'http-equiv' => "Content-Type", :content => "text/html; charset=utf-8"} 5 | %meta{:name => "lang", :content => "en"} 6 | %title Sinatra Bootstrap 7 | %link{:href=>'/stylesheets/application.css', :media => "screen", :rel => 'stylesheet', :type => "text/css"} 8 | %script{:type => "text/javascript", :src => "//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"} 9 | %script{:type => "text/javascript", :src => "/javascripts/application.js"} 10 | %body 11 | = yield 12 | --------------------------------------------------------------------------------