summaryrefslogtreecommitdiff
path: root/app/controllers/snippets_controller.rb
diff options
context:
space:
mode:
authorLong Nguyen <long.polyglot@gmail.com>2016-05-08 15:27:33 +0700
committerLong Nguyen <long.polyglot@gmail.com>2016-05-08 15:27:33 +0700
commitffda8a1a0eb273e62fcb0197f352400946571778 (patch)
treebe1465d224f13c603d0ee80f12dcb0f161bea0d7 /app/controllers/snippets_controller.rb
parent5f60841d7e4aea2b6298df7ea0423e3baa769df1 (diff)
downloadgitlab-ce-ffda8a1a0eb273e62fcb0197f352400946571778.tar.gz
user routings refactor
Diffstat (limited to 'app/controllers/snippets_controller.rb')
-rw-r--r--app/controllers/snippets_controller.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index 2c038bdfda5..2a17c1f34db 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -10,11 +10,29 @@ class SnippetsController < ApplicationController
# Allow destroy snippet
before_action :authorize_admin_snippet!, only: [:destroy]
- skip_before_action :authenticate_user!, only: [:show, :raw]
+ skip_before_action :authenticate_user!, only: [:index, :show, :raw]
layout 'snippets'
respond_to :html
+ def 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])
+
+ render 'index'
+ else
+ redirect_to(current_user ? dashboard_snippets_path : explore_snippets_path)
+ end
+ end
+
def new
@snippet = PersonalSnippet.new
end
@@ -43,7 +61,7 @@ class SnippetsController < ApplicationController
@snippet.destroy
- redirect_to dashboard_snippets_path
+ redirect_to snippets_path
end
def raw