Skip to content

Add Coffeescript #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ gem 'sinatra', '~> 1.2.3'
gem 'shotgun', '~> 0.9'
gem 'haml', '~> 3.1.4'

# Coffeescript
gem 'coffee-script', '~> 2.2.0'

# Sass & Compass
gem 'sass', '~> 3.1.12'
gem 'compass', '~> 0.11.6'

# Sass libraries
gem 'grid-coordinates', '~> 1.1.4'
gem 'grid-coordinates', '~> 1.1.4'
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ GEM
remote: http://rubygems.org/
specs:
chunky_png (1.2.5)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.4.0)
compass (0.11.6)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
execjs (1.4.0)
multi_json (~> 1.0)
fssm (0.2.7)
grid-coordinates (1.1.9)
compass (>= 0.11.5)
haml (3.1.4)
multi_json (1.5.0)
rack (1.4.0)
rake (0.9.2)
sass (3.1.12)
Expand All @@ -24,6 +31,7 @@ PLATFORMS
ruby

DEPENDENCIES
coffee-script (~> 2.2.0)
compass (~> 0.11.6)
grid-coordinates (~> 1.1.4)
haml (~> 3.1.4)
Expand Down
5 changes: 3 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'rubygems'
require 'sinatra'
require 'haml'
require 'coffee-script'

# Helpers
require './lib/render_partial'
Expand All @@ -9,7 +10,7 @@
set :app_file, __FILE__
set :root, File.dirname(__FILE__)
set :views, 'views'
set :public, 'public'
set :public_folder, 'public'
set :haml, {:format => :html5} # default Haml format is :xhtml

# Application routes
Expand All @@ -19,4 +20,4 @@

get '/about' do
haml :about, :layout => :'layouts/page'
end
end
16 changes: 8 additions & 8 deletions public/javascripts/application.js

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

71 changes: 71 additions & 0 deletions tasks/scripts.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
namespace :scripts do
desc "Watch the scripts and compile new changes"
task :watch => ["watch:default"]

desc "List the scripts"
task :list do
system "ls -lh public/javascripts"
end

desc "Compile the scripts"
task :compile => ["compile:default"]

desc "Clear the scripts"
task :clear do
puts "*** Clearing scripts ***"
system "rm -Rfv public/javascripts/*.js"
end

namespace :watch do
task :default => :clear do
system "coffee -o public/javascripts/ -cw views/javascripts/"
end

desc "Watch the scripts and join and compile changes"
task :join => :clear do
puts "*** Compiling scripts ***"
system "coffee -j public/javascripts/application.js -cw views/javascripts/*.coffee"
end

desc "Watch the scripts and compile changes without closures"
task :bare => :clear do
system "coffee -o public/javascripts/ -cbw views/javascripts/"
end

desc "Watch the scripts and join and compile changes without closures"
task :barejoin => :clear do
system "coffee -j public/javascripts/application.js -cbw views/javascripts/*.coffee"
end

desc "Watch the scripts and join and compile changes without closures"
task :joinbare => ["compile:barejoin"]
end

namespace :compile do
task :default => :clear do
puts "*** Compiling scripts ***"
system "coffee -o public/javascripts/ -c views/javascripts/*.coffee"
end

desc "Join and compile the scripts"
task :join => :clear do
puts "*** Compiling scripts ***"
system "coffee -j public/javascripts/application.js -c views/javascripts/*.coffee"
end

desc "Compile the scripts without closures"
task :bare => :clear do
puts "*** Compiling scripts ***"
system "coffee -o public/javascripts/ -cb views/javascripts/*.coffee"
end

desc "Join and compile the scripts without closures"
task :barejoin => :clear do
puts "*** Compiling scripts ***"
system "coffee -j public/javascripts/application.js -cb views/javascripts/*.coffee"
end

desc "Join and compile the scripts without closures"
task :joinbare => ["compile:barejoin"]
end
end
4 changes: 4 additions & 0 deletions views/javascripts/application.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ ->
# Open external links in a new window
hostname = window.location.hostname
$("a[href^=http]").not("a[href*=#{hostname}]").addClass('link external').attr('target', '_blank')