playing with assets, jammit and compass

This commit is contained in:
Timothy N. Tsvetkov 2011-03-29 20:35:42 +04:00
parent db2e3dfd81
commit c7fe38c6a8
8 changed files with 47 additions and 18 deletions

View File

@ -44,3 +44,5 @@ gem 'factory_girl_rails'
gem "hoptoad_notifier", "~> 2.3" gem "hoptoad_notifier", "~> 2.3"
gem "russian" gem "russian"
gem "grit" gem "grit"
gem 'jammit'

View File

@ -39,6 +39,7 @@ GEM
net-ssh-gateway (>= 1.0.0) net-ssh-gateway (>= 1.0.0)
capistrano-ext (1.2.1) capistrano-ext (1.2.1)
capistrano (>= 1.0.0) capistrano (>= 1.0.0)
closure-compiler (1.1.1)
compass (0.10.6) compass (0.10.6)
haml (>= 3.0.4) haml (>= 3.0.4)
devise (1.1.7) devise (1.1.7)
@ -67,6 +68,9 @@ GEM
html5-boilerplate (0.3.2) html5-boilerplate (0.3.2)
compass (>= 0.10.0) compass (>= 0.10.0)
i18n (0.5.0) i18n (0.5.0)
jammit (0.6.0)
closure-compiler (>= 0.1.0)
yui-compressor (>= 0.9.1)
mail (2.2.15) mail (2.2.15)
activesupport (>= 2.3.6) activesupport (>= 2.3.6)
i18n (>= 0.4.0) i18n (>= 0.4.0)
@ -122,6 +126,7 @@ GEM
warden (1.0.3) warden (1.0.3)
rack (>= 1.0.0) rack (>= 1.0.0)
will_paginate (3.0.pre2) will_paginate (3.0.pre2)
yui-compressor (0.9.5)
PLATFORMS PLATFORMS
ruby ruby
@ -137,6 +142,7 @@ DEPENDENCIES
haml-rails haml-rails
hoptoad_notifier (~> 2.3) hoptoad_notifier (~> 2.3)
html5-boilerplate html5-boilerplate
jammit
pg pg
rails (= 3.0.5) rails (= 3.0.5)
rspec-rails (>= 2.0.1) rspec-rails (>= 2.0.1)

View File

@ -22,6 +22,7 @@
= render :partial => 'layouts/stylesheets' = render :partial => 'layouts/stylesheets'
-# All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects -# All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects
= include_javascripts :application
= javascript_include_tag 'modernizr.min' = javascript_include_tag 'modernizr.min'
= csrf_meta_tag = csrf_meta_tag

View File

@ -1,6 +1,6 @@
-# CSS: implied media="all" -# CSS: implied media="all"
-# stylesheet_link_tag 'style', :media => 'all' -# stylesheet_link_tag 'style', :media => 'all'
= stylesheet_link_tag 'compiled/style.css', :media => 'all' = include_stylesheets :application
-# Append your own using content_for :stylesheets -# Append your own using content_for :stylesheets
= yield :stylesheets = yield :stylesheets

9
config/assets.yml Normal file
View File

@ -0,0 +1,9 @@
javascripts:
application:
- public/javascripts/rails.js
- public/javascripts/application.js
stylesheets:
application:
- public/stylesheets/style.css
- public/stylesheets/handheld.css

View File

@ -4,10 +4,13 @@ require 'html5-boilerplate'
project_type = :rails project_type = :rails
project_path = Compass::AppIntegration::Rails.root project_path = Compass::AppIntegration::Rails.root
environment = Compass::AppIntegration::Rails.env
# Set this to the root of your project when deployed: # Set this to the root of your project when deployed:
http_path = "/" http_path = "/"
css_dir = "public/stylesheets/compiled" css_dir = "public/stylesheets"
sass_dir = "app/stylesheets" sass_dir = "app/stylesheets"
environment = Compass::AppIntegration::Rails.env javascripts_dir = "public/javascripts"
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true http_stylesheets_path = "/stylesheets"
http_javascripts_path = "/javascripts"

View File

@ -66,6 +66,25 @@ namespace :deploy do
task :rude_restart, :roles => :web do task :rude_restart, :roles => :web do
run "cd #{deploy_to}/current ; pkill unicorn; sleep 0.5; pkill -9 unicorn; sleep 0.5 ; unicorn_rails -c config/unicorn.rb -E production -D " run "cd #{deploy_to}/current ; pkill unicorn; sleep 0.5; pkill -9 unicorn; sleep 0.5 ; unicorn_rails -c config/unicorn.rb -E production -D "
end end
desc 'Bundle and minify the JS and CSS files'
task :build_assets, :roles => :app do
root_path = File.expand_path(File.dirname(__FILE__) + '/..')
assets_path = "#{root_path}/public/assets"
envs = "RAILS_ENV=production"
# Precaching assets
run_locally "bash -c '" +
"#{envs} compass compile && " +
"#{envs} jammit'"
# Uploading prechached assets
top.upload assets_path, "#{current_release}/public", :via => :scp, :recursive => true
# run_locally "scp -P 222 #{assets_path}/* rosa_build@abs.rosalab.ru:#{current_release}/public/"
end
after "deploy:update_code", :roles => :web do
build_assets
end
end end
#namespace :delayed_job do #namespace :delayed_job do

View File

@ -1,11 +0,0 @@
/* line 1, ../../../app/stylesheets/handheld.scss */
* {
float: none;
background: #fff;
color: #000;
}
/* line 8, ../../../app/stylesheets/handheld.scss */
body {
font-size: 80%;
}