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

44 lines
1.1 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
include SnippetsActions
2016-09-29 09:46:39 +05:30
include ToggleAwardEmoji
2017-08-17 22:00:37 +05:30
include SpammableActions
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
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
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
2014-09-02 18:07:02 +05:30
end