diff options
| author | mo khan <mo@mokhan.ca> | 2013-12-30 08:00:28 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-12-30 08:00:28 -0700 |
| commit | 5eebdb6942e7a5ae291ab41b8e3906add0953b42 (patch) | |
| tree | 40ff5a69f388cb2c38436254045083fe9298963b | |
| parent | c56a474faf41b403d38c92519a204019c979c80e (diff) | |
| parent | d0b0d98479e3f1bba2dbfebdab767ce99609923c (diff) | |
merge with master.
29 files changed, 43 insertions, 126 deletions
@@ -46,7 +46,6 @@ group :development, :test do gem 'sqlite3' gem 'rspec-rails' gem 'teaspoon' - gem 'rack-mini-profiler' gem 'database_cleaner' gem 'factory_girl_rails' gem 'capybara' @@ -58,10 +57,6 @@ group :development, :test do gem 'binding_of_caller' end -group :staging do - gem 'rack-mini-profiler' -end - group :production, :staging do gem 'newrelic_rpm' gem 'dalli' diff --git a/Gemfile.lock b/Gemfile.lock index c331783e..66e52f2f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -174,8 +174,6 @@ GEM websocket-driver (>= 0.2.0) polyglot (0.3.3) rack (1.5.2) - rack-mini-profiler (0.1.31) - rack (>= 1.1.3) rack-test (0.6.2) rack (>= 1.0) rails (4.0.2) @@ -313,7 +311,6 @@ DEPENDENCIES newrelic_rpm pg poltergeist - rack-mini-profiler rails (~> 4.0.0) rmagick (~> 2.13.0) rspec-rails diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 39476b91..932b2a7f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,7 +2,6 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception - before_filter :profile_application before_filter :load_categories before_filter :load_user before_filter :configure_permitted_parameters, if: :devise_controller? @@ -13,10 +12,6 @@ class ApplicationController < ActionController::Base target.new(current_user) end - def profile_application - Rack::MiniProfiler.authorize_request if ENV['PROFILE_APPLICATION'] == true - end - def load_categories @categories = Category.all end diff --git a/app/controllers/creation_tags_controller.rb b/app/controllers/creation_tags_controller.rb index 44d3077a..8bdf9e68 100644 --- a/app/controllers/creation_tags_controller.rb +++ b/app/controllers/creation_tags_controller.rb @@ -1,6 +1,8 @@ class CreationTagsController < ApplicationController def index @tags = Creation.tag_counts_on(:tags) + expires_in(6.hours) + fresh_when(@tags) if @tags.any? end def show @@ -8,5 +10,7 @@ class CreationTagsController < ApplicationController @total_tutorials = Tutorial.tagged_with(@tag).count @total_creations = Creation.tagged_with(@tag).count @creations = Creation.includes([:user, :tags, :photos]).tagged_with([@tag]).where('photos_count > 0').page(params[:page]).per(15) + expires_in(6.hours) + fresh_when(@creations) end end diff --git a/app/controllers/creations_controller.rb b/app/controllers/creations_controller.rb index ff20e86e..ff8c8f73 100644 --- a/app/controllers/creations_controller.rb +++ b/app/controllers/creations_controller.rb @@ -3,11 +3,15 @@ class CreationsController < ApplicationController def index @creations = FindAllCreationsQuery.new.fetch(params) + expires_in(10.minutes) + fresh_when(Creation.maximum(:updated_at)) if Creation.any? end def show @creation = Creation.find(params[:id]) @primary_photo = @creation.primary_image + expires_in(1.minute) + fresh_when(@creation) end def new diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 0b5f0efd..4c1d49ae 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -3,6 +3,8 @@ class ProfilesController < ApplicationController def index @profiles = User.includes(:avatar).where('creations_count > 0').order(:creations_count => :desc).page(params[:page]).per(12) + expires_in(1.hour) + fresh_when(User.maximum(:updated_at)) if User.any? end def show @@ -13,6 +15,8 @@ class ProfilesController < ApplicationController @nearby_users.each do |user| @map_url += "&markers=#{user.latitude}%2C#{user.longitude}" end + expires_in(1.hour) + fresh_when(@user) end def favorites diff --git a/app/controllers/sitemap_controller.rb b/app/controllers/sitemap_controller.rb index e529c2d6..3b207a1b 100644 --- a/app/controllers/sitemap_controller.rb +++ b/app/controllers/sitemap_controller.rb @@ -6,6 +6,8 @@ class SitemapController < ApplicationController @tutorials = Tutorial.all @base_url = "https://#{request.host_with_port}" headers['Content-Type'] = 'application/xml' + expires_in(1.hour) + fresh_when(@creations) if @creations.any? respond_to do |format| format.xml end diff --git a/app/controllers/tutorial_tags_controller.rb b/app/controllers/tutorial_tags_controller.rb index d13d5067..c65c7d3a 100644 --- a/app/controllers/tutorial_tags_controller.rb +++ b/app/controllers/tutorial_tags_controller.rb @@ -1,6 +1,8 @@ class TutorialTagsController < ApplicationController def index @tags = Tutorial.tag_counts_on(:tags) + expires_in(6.hours) + fresh_when(@tags) if @tags.any? end def show @@ -8,5 +10,7 @@ class TutorialTagsController < ApplicationController @total_tutorials = Tutorial.tagged_with(@tag).count @total_creations = Creation.tagged_with(@tag).count @tutorials = Tutorial.includes(:tags).tagged_with(@tag).page(params[:page]).per(15) + expires_in(6.hours) + fresh_when(@tutorials) end end diff --git a/app/controllers/tutorials_controller.rb b/app/controllers/tutorials_controller.rb index 6080f275..b9b70653 100644 --- a/app/controllers/tutorials_controller.rb +++ b/app/controllers/tutorials_controller.rb @@ -3,10 +3,14 @@ class TutorialsController < ApplicationController def index @tutorials = Tutorial.includes(:tags).page(params[:page]).per(15) + expires_in(10.minutes) + fresh_when(Tutorial.maximum(:updated_at)) if Tutorial.any? end def show @tutorial = Tutorial.find(params[:id]) + expires_in(24.hours) + fresh_when(@tutorial) end def new diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb deleted file mode 100644 index 4ecea9e2..00000000 --- a/app/views/notifications/index.html.erb +++ /dev/null @@ -1,8 +0,0 @@ - -<div class="row"> - <div class="span12"> - <% @activities.each do |activity| %> - <%= activity.render(self) %> - <% end %> - </div> -</div> diff --git a/app/views/public_activity/avatar/_create.html.erb b/app/views/public_activity/avatar/_create.html.erb deleted file mode 100644 index 4431b72f..00000000 --- a/app/views/public_activity/avatar/_create.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> added a new avatar named <%= activity.trackable.avatar.url if activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/avatar/_destroy.html.erb b/app/views/public_activity/avatar/_destroy.html.erb deleted file mode 100644 index bea6f78a..00000000 --- a/app/views/public_activity/avatar/_destroy.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> removed an avatar at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/avatar/_update.html.erb b/app/views/public_activity/avatar/_update.html.erb deleted file mode 100644 index 471731c8..00000000 --- a/app/views/public_activity/avatar/_update.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> updated their avatar <%= activity.trackable.avatar.url if activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/comment/_create.html.erb b/app/views/public_activity/comment/_create.html.erb deleted file mode 100644 index b7a3fb83..00000000 --- a/app/views/public_activity/comment/_create.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name %> commented on <%= activity.trackable.commentable.name %> at <%= activity.created_at %> - <blockquote> - <%= activity.trackable.body %> - </blockquote> - </div> -</div> diff --git a/app/views/public_activity/creation/_create.html.erb b/app/views/public_activity/creation/_create.html.erb deleted file mode 100644 index ea9faa5d..00000000 --- a/app/views/public_activity/creation/_create.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - a new user named <%= activity.trackable.name if activity.trackable %> signed up at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/creation/_destroy.html.erb b/app/views/public_activity/creation/_destroy.html.erb deleted file mode 100644 index 64cbcf4d..00000000 --- a/app/views/public_activity/creation/_destroy.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - a user cancelled their account at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/creation/_update.html.erb b/app/views/public_activity/creation/_update.html.erb deleted file mode 100644 index aa0aa8c5..00000000 --- a/app/views/public_activity/creation/_update.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> updated their account <%= activity.trackable.name if activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/favorite/_create.html.erb b/app/views/public_activity/favorite/_create.html.erb deleted file mode 100644 index fe7d3117..00000000 --- a/app/views/public_activity/favorite/_create.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> added a new creation to their favorites <%= activity.trackable if activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/photo/_create.html.erb b/app/views/public_activity/photo/_create.html.erb deleted file mode 100644 index 17667640..00000000 --- a/app/views/public_activity/photo/_create.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name %> added a new photo <%= activity.trackable.image.url if activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/photo/_destroy.html.erb b/app/views/public_activity/photo/_destroy.html.erb deleted file mode 100644 index 80c2c213..00000000 --- a/app/views/public_activity/photo/_destroy.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name %> removed a photo <%= activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/tutorial/_create.html.erb b/app/views/public_activity/tutorial/_create.html.erb deleted file mode 100644 index b300ba76..00000000 --- a/app/views/public_activity/tutorial/_create.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> added a new tutorial named <%= activity.trackable.head if activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/tutorial/_destroy.html.erb b/app/views/public_activity/tutorial/_destroy.html.erb deleted file mode 100644 index 30d3850a..00000000 --- a/app/views/public_activity/tutorial/_destroy.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> removed a tutorial at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/tutorial/_update.html.erb b/app/views/public_activity/tutorial/_update.html.erb deleted file mode 100644 index e76c5140..00000000 --- a/app/views/public_activity/tutorial/_update.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> updated a tutorial named <%= activity.trackable.head if activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/user/_create.html.erb b/app/views/public_activity/user/_create.html.erb deleted file mode 100644 index 2cec13e2..00000000 --- a/app/views/public_activity/user/_create.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> added a new creation named <%= activity.trackable.name if activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/user/_destroy.html.erb b/app/views/public_activity/user/_destroy.html.erb deleted file mode 100644 index 0db2588e..00000000 --- a/app/views/public_activity/user/_destroy.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> removed creation <%= activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/app/views/public_activity/user/_update.html.erb b/app/views/public_activity/user/_update.html.erb deleted file mode 100644 index f4c40e1b..00000000 --- a/app/views/public_activity/user/_update.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<div class="row"> - <div class="span12"> - <%= activity.owner.name if activity.owner %> updated creation named <%= activity.trackable.name if activity.trackable %> at <%= activity.created_at %> - </div> -</div> diff --git a/config/recipes/templates/logrotate.erb b/config/recipes/templates/logrotate.erb index 9fea806f..c5712f07 100644 --- a/config/recipes/templates/logrotate.erb +++ b/config/recipes/templates/logrotate.erb @@ -6,4 +6,5 @@ delaycompress notifempty copytruncate + dateext } diff --git a/config/recipes/templates/nginx_unicorn.erb b/config/recipes/templates/nginx_unicorn.erb index fb87d642..ea3ceed4 100644 --- a/config/recipes/templates/nginx_unicorn.erb +++ b/config/recipes/templates/nginx_unicorn.erb @@ -7,30 +7,11 @@ client_max_body_size 4G; server { listen 80 default deferred; server_name <%= domain %>; - root <%= current_path %>/public; - error_log off; - access_log off; - - location ^~ /assets/ { - gzip_static on; - expires max; - add_header Cache-Control public; - } - - try_files $uri/index.html $uri @unicorn; - location @unicorn { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header HOST $http_host; - proxy_redirect off; - proxy_pass http://unicorn; - } - - error_page 500 502 503 504 /500.html; - keepalive_timeout 10; + rewrite ^ https://$server_name$request_uri? permanent; } server { - listen 443; + listen 443; server_name <%= domain %>; root <%= current_path %>/public; ssl on; @@ -39,7 +20,17 @@ server { error_log /var/log/nginx/<%= application %>.error.log; access_log /var/log/nginx/<%= application %>.access.log; + if ($host = 'cakeside.com' ) { + rewrite ^/(.*)$ https://<%= domain %>/$1 permanent; + } + try_files $uri/index.html $uri @unicorn; + location ^~ /assets/ { + gzip_static on; + expires max; + add_header Cache-Control public; + } + location @unicorn { proxy_set_header X_FORWARDED_PROTO https; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -48,5 +39,7 @@ server { proxy_redirect off; proxy_pass http://unicorn; } -} + error_page 500 502 503 504 /500.html; + keepalive_timeout 10; +} diff --git a/db/migrate/20131229022014_drop_table_activities.rb b/db/migrate/20131229022014_drop_table_activities.rb new file mode 100644 index 00000000..e0bf13eb --- /dev/null +++ b/db/migrate/20131229022014_drop_table_activities.rb @@ -0,0 +1,5 @@ +class DropTableActivities < ActiveRecord::Migration + def change + drop_table :activities + end +end |
