Skip to content

Commit

Permalink
Added a readme, updated the app to not compile sass and to use compas…
Browse files Browse the repository at this point in the history
…s watch instead, added new rake tasks, javascripts, and updated gem versions
  • Loading branch information
adamstac committed Apr 20, 2011
1 parent a05fef2 commit 80dfbfd
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 59 deletions.
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source "http://rubygems.org"

gem "sinatra", "1.0"
gem "shotgun", "~> 0.8"
gem "sinatra", "~> 1.2.3"
gem "shotgun", "~> 0.9"
gem "haml", "~> 3.0"
gem "compass", "~> 0.10.1"
gem "compass", "~> 0.10.6"
gem "grid-coordinates", "~> 1.1.4"
gem "meyer-reset", "~> 2.0"
gem "meyer-reset", "~> 2.0.0"
18 changes: 10 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ GEM
haml (3.0.24)
meyer-reset (2.0.0)
compass (>= 0.10.5)
rack (1.2.1)
shotgun (0.8)
rack (>= 1.0)
sinatra (1.0)
rack (1.2.2)
shotgun (0.9)
rack (>= 1.0)
sinatra (1.2.3)
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
tilt (1.2.2)

PLATFORMS
ruby

DEPENDENCIES
compass (~> 0.10.1)
compass (~> 0.10.6)
grid-coordinates (~> 1.1.4)
haml (~> 3.0)
meyer-reset (~> 2.0)
shotgun (~> 0.8)
sinatra (= 1.0)
meyer-reset (~> 2.0.0)
shotgun (~> 0.9)
sinatra (~> 1.2.3)
74 changes: 74 additions & 0 deletions README.mdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Sinatra Bootstrap

## A simple Sinatra starting point

Sinatra Bootstrap supports:

* [Haml](http://haml-lang.com/)
* [Sass](http://sass-lang.com/)
* [Compass](https://github.com/chriseppstein/compass)
* [Grid Coordinates](https://github.com/adamstac/grid-coordinates)
* [Meyer Reset](https://github.com/adamstac/meyer-reset)
* [jQuery](http://jquery.com/)
* [Modernizr](http://www.modernizr.com/)

## What is the purpose of Sinatra Bootstrap?

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 and a few JavaScripts make their way into every production as well. I also include a number of helpful rake tasks. Also, because we compile our

## How do I get started?

First we need to clone Sinatra Bootstrap and run [Bundler](http://gembundler.com/) to get the required gems installed.

If you don't have Bundler installed, run the following at the command prompt:

gem install bundler

To get started with using Sinatra Bootstrap, fork the repo and pull down a copy from your fork to your local machine. It makes sense to store this where you store your other codes, for example:

cd Code/path/to/codes
git clone git@github.com:USERNAME/sinatra-bootstrap.git

From inside the root of your newly cloned repo, run the following at the command prompt:

bundle install

## How do I start the application?

After you've ran `bundle install` and Sinatra as well as the other required gems are installed, start it up by running this command:

# runs `bundle exec shotgun config.ru` behind the scenes
rake start

This will start Sinatra Bootstrap 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).

You'll also want to open a new terminal window to the same directory and run the Compass watch rake task so we can monitor our Sass files for changes.

rake styles:watch

Or you just run `compass watch`, either work.

## Helper Rake Tasks

There are a few helper Rake tasks that will aid you in clearing and compiling your Sass/Compass stylesheets. There is also a task to generate a new project at a specified directory so you can keep your copy of the Serve Bootstrap pristine.

rake -T

rake generate # Generate a new project at dir=foo
rake styles:clear # Clear the styles
rake styles:compile # Compile new styles
rake styles:compile:production # Compile new styles for production
rake styles:list # List the styles
rake styles:stats # Run compass stats
rake styles:stats:log # Create a log of compass stats
rake styles:watch # Watch the styles and compile new changes

## License

Copyright (c) 2011 Adam Stacoviak

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.
24 changes: 5 additions & 19 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
require 'rubygems'
require 'sinatra'
require 'haml'

# Require partial helper
# Helpers
require 'lib/render_partial'

# Haml and Compass
require 'haml'
require 'compass'

# Set Sinatra variables
set :app_file, __FILE__
set :root, File.dirname(__FILE__)
set :views, 'views'
set :public, 'public'
set :haml, {:format => :html5} # default Haml format is :xhtml

# Configure Compass
configure do
Compass.add_project_configuration(File.join(Sinatra::Application.root, 'config.rb'))
end

# Render stylesheets
get '/stylesheets/:file.css' do
content_type 'text/css', :charset => 'utf-8'
sass(:"stylesheets/#{params[:file]}", Compass.sass_engine_options)
# Application routes
get '/' do
haml :index, :layout => :'layouts/application'
end

# Application routes
get '/about' do
haml :about, :layout => :'layouts/page'
end

get '/' do
haml :index, :layout => :'layouts/application'
end
10 changes: 5 additions & 5 deletions public/javascripts/site.js → public/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ $(document).ready(function() {
// Open external links in a new window
hostname = window.location.hostname
$("a[href^=http]")
.not("a[href*='" + hostname + "']")
.addClass('link external')
.attr('target', '_blank');
});
.not("a[href*='" + hostname + "']")
.addClass('link external')
.attr('target', '_blank');

});
19 changes: 0 additions & 19 deletions public/javascripts/lib/jquery-1.3.2.min.js

This file was deleted.

16 changes: 16 additions & 0 deletions public/javascripts/lib/jquery-1.5.min.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions public/javascripts/lib/modernizr-1.6.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tasks/application.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
desc 'Start the application'
task :start do
system "bundle exec shotgun config.ru"
end
1 change: 0 additions & 1 deletion tasks/generate.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
desc 'Generate a new project at dir=foo'

task :generate do
# Generate the new 'dir' if it's not already created
system "mkdir #{(ENV['dir'])}" unless File.exists?(ENV['dir'])
Expand Down
5 changes: 5 additions & 0 deletions tasks/styles.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ namespace :styles do

desc "Clear the styles"
task :clear => ["compile:clear"]

desc "Watch the styles and compile new changes"
task :watch do
system "compass watch"
end

desc "List the styles"
task :list do
Expand Down
8 changes: 5 additions & 3 deletions views/layouts/application.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
%meta{:'http-equiv' => "Content-Type", :content => "text/html; charset=utf-8"}
%meta{:name => "lang", :content => "en"}
%title Sinatra Bootstrap
%link{:href=>'/stylesheets/application.css', :rel => 'stylesheet', :media => "screen", :type => "text/css"}
%script{:type => "text/javascript", :src => "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"}
%script{:type => "text/javascript", :src => "/javascripts/site.js"}
%link{:href=>'/stylesheets/application.css', :media => "screen", :rel => 'stylesheet', :type => "text/css"}
%script{:type => "text/javascript", :src => "http://code.jquery.com/jquery-1.5.min.js"}
%script{:type => "text/javascript", :src => "/javascripts/lib/modernizr-1.6.min.js"}
%script{:type => "text/javascript", :src => "/javascripts/application.js"}

%body
= partial :_nav_main
= yield
Expand Down

0 comments on commit 80dfbfd

Please sign in to comment.