diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/dashboard/snippets_controller.rb | 14 | ||||
-rw-r--r-- | app/controllers/explore/snippets_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/projects/snippets_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/snippets_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/users_controller.rb | 12 |
5 files changed, 38 insertions, 21 deletions
diff --git a/app/controllers/dashboard/snippets_controller.rb b/app/controllers/dashboard/snippets_controller.rb index 161c22046f9..382f54c6c00 100644 --- a/app/controllers/dashboard/snippets_controller.rb +++ b/app/controllers/dashboard/snippets_controller.rb @@ -1,14 +1,16 @@ # frozen_string_literal: true class Dashboard::SnippetsController < Dashboard::ApplicationController + include Gitlab::NoteableMetadata + skip_cross_project_access_check :index def index - @snippets = SnippetsFinder.new( - current_user, - author: current_user, - scope: params[:scope] - ).execute - @snippets = @snippets.page(params[:page]) + @snippets = SnippetsFinder.new(current_user, author: current_user, scope: params[:scope]) + .execute + .page(params[:page]) + .inc_author + + @noteable_meta_data = noteable_meta_data(@snippets, 'Snippet') end end diff --git a/app/controllers/explore/snippets_controller.rb b/app/controllers/explore/snippets_controller.rb index 76ed142c939..6192b594593 100644 --- a/app/controllers/explore/snippets_controller.rb +++ b/app/controllers/explore/snippets_controller.rb @@ -1,8 +1,14 @@ # frozen_string_literal: true class Explore::SnippetsController < Explore::ApplicationController + include Gitlab::NoteableMetadata + def index - @snippets = SnippetsFinder.new(current_user).execute - @snippets = @snippets.page(params[:page]) + @snippets = SnippetsFinder.new(current_user) + .execute + .page(params[:page]) + .inc_author + + @noteable_meta_data = noteable_meta_data(@snippets, 'Snippet') end end diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index 59f948959d6..c84e9fbc2d7 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -6,6 +6,7 @@ class Projects::SnippetsController < Projects::ApplicationController include SpammableActions include SnippetsActions include RendersBlob + include Gitlab::NoteableMetadata skip_before_action :verify_authenticity_token, if: -> { action_name == 'show' && js_request? } @@ -28,15 +29,16 @@ class Projects::SnippetsController < Projects::ApplicationController respond_to :html def index - @snippets = SnippetsFinder.new( - current_user, - project: @project, - scope: params[:scope] - ).execute - @snippets = @snippets.page(params[:page]) + @snippets = SnippetsFinder.new(current_user, project: @project, scope: params[:scope]) + .execute + .page(params[:page]) + .inc_author + if @snippets.out_of_range? && @snippets.total_pages != 0 - redirect_to project_snippets_path(@project, page: @snippets.total_pages) + return redirect_to project_snippets_path(@project, page: @snippets.total_pages) end + + @noteable_meta_data = noteable_meta_data(@snippets, 'Snippet') end def new diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 869655e9550..c1e05b72b37 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -7,6 +7,7 @@ class SnippetsController < ApplicationController include SnippetsActions include RendersBlob include PreviewMarkdown + include Gitlab::NoteableMetadata skip_before_action :verify_authenticity_token, if: -> { action_name == 'show' && js_request? } @@ -32,7 +33,11 @@ class SnippetsController < ApplicationController @user = UserFinder.new(params[:username]).find_by_username! @snippets = SnippetsFinder.new(current_user, author: @user, scope: params[:scope]) - .execute.page(params[:page]) + .execute + .page(params[:page]) + .inc_author + + @noteable_meta_data = noteable_meta_data(@snippets, 'Snippet') render 'index' else diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 91e0efcf45f..e38d4073de3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,6 +4,7 @@ class UsersController < ApplicationController include RoutableActions include RendersMemberAccess include ControllerWithCrossProjectAccessCheck + include Gitlab::NoteableMetadata requires_cross_project_access show: false, groups: false, @@ -165,11 +166,12 @@ class UsersController < ApplicationController end def load_snippets - @snippets = SnippetsFinder.new( - current_user, - author: user, - scope: params[:scope] - ).execute.page(params[:page]) + @snippets = SnippetsFinder.new(current_user, author: user, scope: params[:scope]) + .execute + .page(params[:page]) + .inc_author + + @noteable_meta_data = noteable_meta_data(@snippets, 'Snippet') end def build_canonical_path(user) |