diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-03 04:22:54 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-22 18:17:43 +0300 |
commit | 4a63573b21dedaebaf0722b819926c5a468bcc5d (patch) | |
tree | a2c067fb640bf7cb7c3c66edd8b2c46824f3cd07 /app/controllers/snippets_controller.rb | |
parent | 27919e25e8059c644a79ef8b1f5f04d213999295 (diff) |
Start applying new layout to snippets pages
Diffstat (limited to 'app/controllers/snippets_controller.rb')
-rw-r--r-- | app/controllers/snippets_controller.rb | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index cd52556b203..6c84dbbb998 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,10 +1,6 @@ class SnippetsController < ApplicationController before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] - - # Allow modify snippet before_filter :authorize_modify_snippet!, only: [:edit, :update] - - # Allow destroy snippet before_filter :authorize_admin_snippet!, only: [:destroy] before_filter :set_title @@ -16,24 +12,24 @@ class SnippetsController < ApplicationController layout :determine_layout def index - @snippets = SnippetsFinder.new.execute(current_user, filter: :all).page(params[:page]).per(PER_PAGE) - end - - def user_index - @user = User.find_by(username: params[:username]) - - render_404 and return unless @user - - @snippets = SnippetsFinder.new.execute(current_user, { - filter: :by_user, - user: @user, - scope: params[:scope] }). - page(params[:page]).per(PER_PAGE) - - if @user == current_user - render 'current_user_index' + if params[:username].present? + @user = User.find_by(username: params[:username]) + + render_404 and return unless @user + + @snippets = SnippetsFinder.new.execute(current_user, { + filter: :by_user, + user: @user, + scope: params[:scope] }). + page(params[:page]).per(PER_PAGE) + + if @user == current_user + render 'current_user_index' + else + render 'user_index' + end else - render 'user_index' + @snippets = SnippetsFinder.new.execute(current_user, filter: :all).page(params[:page]).per(PER_PAGE) end end @@ -108,6 +104,6 @@ class SnippetsController < ApplicationController end def determine_layout - current_user ? 'navless' : 'public_users' + current_user ? 'snippets' : 'public_users' end end |