From d9bf4a2fa674b0fdc1df4a98829fcca16598b7c0 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Wed, 18 Mar 2015 20:30:24 +0100 Subject: [PATCH] Remove layout 'centered_with_header_with_footer' --- app/controllers/application_controller.rb | 2 +- app/controllers/contacts_controller.rb | 2 -- app/controllers/help_controller.rb | 2 -- app/controllers/notifications_controller.rb | 2 -- app/controllers/passwords_controller.rb | 3 -- app/controllers/people_controller.rb | 2 -- app/controllers/photos_controller.rb | 2 -- app/controllers/posts_controller.rb | 11 ++++--- app/controllers/profiles_controller.rb | 1 - app/controllers/services_controller.rb | 2 -- app/controllers/sessions_controller.rb | 3 -- app/controllers/statistics_controller.rb | 3 +- app/controllers/streams_controller.rb | 2 -- app/controllers/tags_controller.rb | 2 -- app/controllers/users_controller.rb | 11 ++----- app/views/{ => devise}/passwords/edit.haml | 0 .../{ => devise}/passwords/edit.mobile.haml | 0 app/views/{ => devise}/passwords/new.haml | 0 .../{ => devise}/passwords/new.mobile.haml | 0 app/views/layouts/_header.html.haml | 2 +- app/views/layouts/application.html.haml | 6 +--- ...centered_with_header_with_footer.html.haml | 4 --- config/routes.rb | 1 - spec/controllers/passwords_controller_spec.rb | 4 +-- .../controllers/statistics_controller_spec.rb | 33 +++++++++++-------- 25 files changed, 35 insertions(+), 65 deletions(-) delete mode 100644 app/controllers/passwords_controller.rb rename app/views/{ => devise}/passwords/edit.haml (100%) rename app/views/{ => devise}/passwords/edit.mobile.haml (100%) rename app/views/{ => devise}/passwords/new.haml (100%) rename app/views/{ => devise}/passwords/new.mobile.haml (100%) delete mode 100644 app/views/layouts/centered_with_header_with_footer.html.haml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e6525cdb3..b56427ba6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -24,7 +24,7 @@ class ApplicationController < ActionController::Base :tags, :open_publisher - layout ->(c) { request.format == :mobile ? "application" : "centered_with_header_with_footer" } + layout proc { request.format == :mobile ? "application" : "with_header_with_footer" } private diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 3f474aafe..1b8c91d2b 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -5,8 +5,6 @@ class ContactsController < ApplicationController before_action :authenticate_user! - layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" } - def index respond_to do |format| diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 33733bf00..3d65e1f0d 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -1,6 +1,4 @@ class HelpController < ApplicationController - layout -> (c) { request.format == :mobile ? "application" : "with_header_with_footer" } - def faq gon.chatEnabled = AppConfig.chat.enabled? end diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 88e94a30b..a9a873c2e 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -5,8 +5,6 @@ class NotificationsController < ApplicationController before_action :authenticate_user! - layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" } - def update note = Notification.where(:recipient_id => current_user.id, :id => params[:id]).first if note diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb deleted file mode 100644 index 7d604568a..000000000 --- a/app/controllers/passwords_controller.rb +++ /dev/null @@ -1,3 +0,0 @@ -class PasswordsController < Devise::PasswordsController - layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" } -end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 74a02a240..a1feaede6 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -6,8 +6,6 @@ class PeopleController < ApplicationController before_action :authenticate_user!, except: [:show, :stream] before_action :find_person, only: [:show, :stream, :hovercard] - layout ->(c){ request.format == :mobile ? "application" : "with_header_with_footer" } - respond_to :html, :except => [:tag_index] respond_to :json, :only => [:index, :show] respond_to :js, :only => [:tag_index] diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 2993b5dbf..674d1ff4a 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -4,8 +4,6 @@ class PhotosController < ApplicationController before_action :authenticate_user!, :except => :show - - layout ->(c){ request.format == :mobile ? "application" : "with_header_with_footer" } respond_to :html, :json def show diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index c02826fef..ec31639b3 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -24,10 +24,13 @@ class PostsController < ApplicationController mark_corresponding_notifications_read if user_signed_in? respond_to do |format| - format.html{ gon.post = PostPresenter.new(@post, current_user); render 'posts/show', layout: 'with_header_with_footer' } - format.xml{ render :xml => @post.to_diaspora_xml } - format.mobile{render 'posts/show' } - format.json{ render :json => PostPresenter.new(@post, current_user) } + format.html { + gon.post = PostPresenter.new(@post, current_user) + render "posts/show" + } + format.xml { render xml: @post.to_diaspora_xml } + format.mobile { render "posts/show" } + format.json { render json: PostPresenter.new(@post, current_user) } end end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index f78540a95..2c2bdf2c2 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -4,7 +4,6 @@ class ProfilesController < ApplicationController before_action :authenticate_user!, :except => ['show'] - layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, only: [:show, :edit] respond_to :html, :except => [:show] respond_to :js, :only => :update diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 4d397b6bd..ccc82c28d 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -9,8 +9,6 @@ class ServicesController < ApplicationController before_action :authenticate_user! before_action :abort_if_already_authorized, :abort_if_read_only_access, :only => :create - layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, only: [:index] - respond_to :html respond_to :json, :only => :inviter diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b50a743fb..05016d2a7 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -3,9 +3,6 @@ # the COPYRIGHT file. class SessionsController < Devise::SessionsController - - layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, :only => [:new] - after_filter :reset_authentication_token, :only => [:create] before_filter :reset_authentication_token, :only => [:destroy] diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb index ba564dff6..567a81745 100644 --- a/app/controllers/statistics_controller.rb +++ b/app/controllers/statistics_controller.rb @@ -9,8 +9,7 @@ class StatisticsController < ApplicationController @statistics = StatisticsPresenter.new respond_to do |format| format.json { render json: @statistics } - format.mobile { render layout: 'application' } - format.html { render layout: 'with_header_with_footer' } + format.all end end end diff --git a/app/controllers/streams_controller.rb b/app/controllers/streams_controller.rb index e830bee70..22c2ecc37 100644 --- a/app/controllers/streams_controller.rb +++ b/app/controllers/streams_controller.rb @@ -7,8 +7,6 @@ class StreamsController < ApplicationController before_action :save_selected_aspects, :only => :aspects before_action :redirect_unless_admin, :only => :public - layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" } - respond_to :html, :mobile, :json diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index b493c5e45..9cea03112 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -6,8 +6,6 @@ class TagsController < ApplicationController skip_before_action :set_grammatical_gender before_action :ensure_page, :only => :show - layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, :only => [:show] - helper_method :tag_followed? respond_to :html, :only => [:show] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 70b635a1a..eff00e138 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,10 +4,6 @@ class UsersController < ApplicationController before_action :authenticate_user!, :except => [:new, :create, :public, :user_photo] - - layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }, - only: [:privacy_settings, :edit, :update] - respond_to :html def edit @@ -127,10 +123,7 @@ class UsersController < ApplicationController @person = @user.person @profile = @user.profile - respond_to do |format| - format.mobile { render "users/getting_started" } - format.all { render "users/getting_started", layout: "with_header_with_footer" } - end + render "users/getting_started" end def getting_started_completed @@ -159,7 +152,7 @@ class UsersController < ApplicationController def download_photos redirect_to current_user.exported_photos_file.url end - + def user_photo username = params[:username].split('@')[0] user = User.find_by_username(username) diff --git a/app/views/passwords/edit.haml b/app/views/devise/passwords/edit.haml similarity index 100% rename from app/views/passwords/edit.haml rename to app/views/devise/passwords/edit.haml diff --git a/app/views/passwords/edit.mobile.haml b/app/views/devise/passwords/edit.mobile.haml similarity index 100% rename from app/views/passwords/edit.mobile.haml rename to app/views/devise/passwords/edit.mobile.haml diff --git a/app/views/passwords/new.haml b/app/views/devise/passwords/new.haml similarity index 100% rename from app/views/passwords/new.haml rename to app/views/devise/passwords/new.haml diff --git a/app/views/passwords/new.mobile.haml b/app/views/devise/passwords/new.mobile.haml similarity index 100% rename from app/views/passwords/new.mobile.haml rename to app/views/devise/passwords/new.mobile.haml diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 1eb722411..d9a1b079e 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -8,7 +8,7 @@ = link_to content_tag(:div, nil, class: 'diaspora_header_logo branding-header-logo'), root_path %ul#landing_nav - - if AppConfig.settings.enable_registrations? && !current_page?(controller: :registrations, action: :new) + - if AppConfig.settings.enable_registrations? && !current_page?(controller: '/registrations', action: :new) %li= link_to t('devise.shared.links.sign_up'), new_user_registration_path, class: 'login' %li= link_to t('devise.shared.links.sign_in'), new_user_session_path, class: 'login' #lightbox diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index dc62d1354..12b09b559 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -52,11 +52,7 @@ = yield :before_content - - if content_for?(:container_content) - .container - = yield(:container_content) - - else - = content_for?(:content) ? yield(:content) : yield + = content_for?(:content) ? yield(:content) : yield = yield :after_content diff --git a/app/views/layouts/centered_with_header_with_footer.html.haml b/app/views/layouts/centered_with_header_with_footer.html.haml deleted file mode 100644 index 2e43cd97d..000000000 --- a/app/views/layouts/centered_with_header_with_footer.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -- content_for :container_content do - = yield - -= render template: "layouts/with_header_with_footer" diff --git a/config/routes.rb b/config/routes.rb index a43effa5c..bce7e3e6a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -120,7 +120,6 @@ Diaspora::Application.routes.draw do get 'users/edit' => redirect('/user/edit') devise_for :users, :controllers => {:registrations => "registrations", - :passwords => "passwords", :sessions => "sessions"} #legacy routes to support old invite routes diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb index 3d00b17b8..30794cc07 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/passwords_controller_spec.rb @@ -2,9 +2,9 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require 'spec_helper' +require "spec_helper" -describe PasswordsController, :type => :controller do +describe Devise::PasswordsController, type: :controller do include Devise::TestHelpers before do diff --git a/spec/controllers/statistics_controller_spec.rb b/spec/controllers/statistics_controller_spec.rb index 6d7566714..07abf7370 100644 --- a/spec/controllers/statistics_controller_spec.rb +++ b/spec/controllers/statistics_controller_spec.rb @@ -2,22 +2,29 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require 'spec_helper' +require "spec_helper" -describe StatisticsController, :type => :controller do - - describe '#statistics' do - - it 'responds to format json' do - get :statistics, :format => 'json' - expect(response.code).to eq('200') +describe StatisticsController, type: :controller do + describe "#statistics" do + it "responds to format json" do + get :statistics, format: "json" + expect(response.code).to eq("200") end - - it 'contains json' do - get :statistics, :format => 'json' + + it "contains json" do + get :statistics, format: "json" json = JSON.parse(response.body) - expect(json['name']).to be_present + expect(json["name"]).to be_present + end + + it "responds to html" do + get :statistics, format: "html" + expect(response.code).to eq("200") + end + + it "responds to mobile" do + get :statistics, format: "mobile" + expect(response.code).to eq("200") end end - end