diff --git a/Gemfile b/Gemfile index 162510fd3..cb44732b1 100644 --- a/Gemfile +++ b/Gemfile @@ -43,4 +43,6 @@ gem "will_paginate", "~> 3.0.pre2" gem 'factory_girl_rails' gem "hoptoad_notifier", "~> 2.3" gem "russian" -gem "grit" \ No newline at end of file +gem "grit" + +gem 'jammit' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index c4f8ee430..9874ed87d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,6 +39,7 @@ GEM net-ssh-gateway (>= 1.0.0) capistrano-ext (1.2.1) capistrano (>= 1.0.0) + closure-compiler (1.1.1) compass (0.10.6) haml (>= 3.0.4) devise (1.1.7) @@ -67,6 +68,9 @@ GEM html5-boilerplate (0.3.2) compass (>= 0.10.0) i18n (0.5.0) + jammit (0.6.0) + closure-compiler (>= 0.1.0) + yui-compressor (>= 0.9.1) mail (2.2.15) activesupport (>= 2.3.6) i18n (>= 0.4.0) @@ -122,6 +126,7 @@ GEM warden (1.0.3) rack (>= 1.0.0) will_paginate (3.0.pre2) + yui-compressor (0.9.5) PLATFORMS ruby @@ -137,6 +142,7 @@ DEPENDENCIES haml-rails hoptoad_notifier (~> 2.3) html5-boilerplate + jammit pg rails (= 3.0.5) rspec-rails (>= 2.0.1) diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 9bb70668d..7eaf0b328 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -22,6 +22,7 @@ = render :partial => 'layouts/stylesheets' -# All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects + = include_javascripts :application = javascript_include_tag 'modernizr.min' = csrf_meta_tag \ No newline at end of file diff --git a/app/views/layouts/_stylesheets.html.haml b/app/views/layouts/_stylesheets.html.haml index ee7ef171d..5450f3762 100644 --- a/app/views/layouts/_stylesheets.html.haml +++ b/app/views/layouts/_stylesheets.html.haml @@ -1,6 +1,6 @@ -# CSS: implied 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 -= yield :stylesheets += yield :stylesheets \ No newline at end of file diff --git a/config/assets.yml b/config/assets.yml new file mode 100644 index 000000000..22ea6d02b --- /dev/null +++ b/config/assets.yml @@ -0,0 +1,9 @@ +javascripts: + application: + - public/javascripts/rails.js + - public/javascripts/application.js + +stylesheets: + application: + - public/stylesheets/style.css + - public/stylesheets/handheld.css \ No newline at end of file diff --git a/config/compass.rb b/config/compass.rb index c4267f487..720464b75 100644 --- a/config/compass.rb +++ b/config/compass.rb @@ -4,10 +4,13 @@ require 'html5-boilerplate' project_type = :rails project_path = Compass::AppIntegration::Rails.root +environment = Compass::AppIntegration::Rails.env + # Set this to the root of your project when deployed: http_path = "/" -css_dir = "public/stylesheets/compiled" +css_dir = "public/stylesheets" sass_dir = "app/stylesheets" -environment = Compass::AppIntegration::Rails.env -# To enable relative paths to assets via compass helper functions. Uncomment: -# relative_assets = true +javascripts_dir = "public/javascripts" + +http_stylesheets_path = "/stylesheets" +http_javascripts_path = "/javascripts" \ No newline at end of file diff --git a/config/deploy.rb b/config/deploy.rb index 2bf5832a8..b44107a82 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -66,6 +66,25 @@ namespace :deploy 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 " 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 #namespace :delayed_job do diff --git a/public/stylesheets/compiled/handheld.css b/public/stylesheets/compiled/handheld.css deleted file mode 100644 index de1265434..000000000 --- a/public/stylesheets/compiled/handheld.css +++ /dev/null @@ -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%; -}