debian-mirror-gitlab/app/controllers/projects/snippets_controller.rb

53 lines
1.3 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2020-06-23 00:09:42 +05:30
class Projects::SnippetsController < Projects::Snippets::ApplicationController
2021-10-27 15:23:28 +05:30
extend ::Gitlab::Utils::Override
2020-06-23 00:09:42 +05:30
include SnippetsActions
2016-09-29 09:46:39 +05:30
include ToggleAwardEmoji
2021-10-27 15:23:28 +05:30
include SpammableActions::AkismetMarkAsSpamAction
2018-10-15 14:42:47 +05:30
2017-09-10 17:25:29 +05:30
before_action :check_snippets_available!
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
before_action :snippet, only: [:show, :edit, :raw, :toggle_award_emoji, :mark_as_spam]
2014-09-02 18:07:02 +05:30
2021-01-03 14:25:43 +05:30
before_action :authorize_create_snippet!, only: :new
before_action :authorize_read_snippet!, except: [:new, :index]
before_action :authorize_update_snippet!, only: :edit
2020-10-24 23:57:45 +05:30
2022-11-25 23:54:43 +05:30
urgency :low, [:index, :show]
2021-06-08 01:23:25 +05:30
2014-09-02 18:07:02 +05:30
def index
2020-07-28 23:09:34 +05:30
@snippet_counts = ::Snippets::CountService
2020-03-13 15:44:24 +05:30
.new(current_user, project: @project)
.execute
2020-07-28 23:09:34 +05:30
@snippets = SnippetsFinder.new(current_user, project: @project, scope: params[:scope], sort: sort_param)
2019-12-04 20:38:33 +05:30
.execute
.page(params[:page])
.inc_author
2021-04-17 20:07:23 +05:30
.inc_statistics
2019-12-04 20:38:33 +05:30
return if redirect_out_of_range(@snippets)
@noteable_meta_data = noteable_meta_data(@snippets, 'Snippet')
2014-09-02 18:07:02 +05:30
end
def new
@snippet = @noteable = @project.snippets.build
2014-09-02 18:07:02 +05:30
end
protected
2016-09-29 09:46:39 +05:30
alias_method :awardable, :snippet
2017-08-17 22:00:37 +05:30
alias_method :spammable, :snippet
2014-09-02 18:07:02 +05:30
2017-09-10 17:25:29 +05:30
def spammable_path
project_snippet_path(@project, @snippet)
end
2021-10-27 15:23:28 +05:30
override :snippet_find_params
def snippet_find_params
super.merge(project_id: project.id)
end
2014-09-02 18:07:02 +05:30
end