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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.2 KiB
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
class Projects::StaticSiteEditorController < Projects::ApplicationController
include ExtractsPath
include CreatesCommit
2022-06-21 17:19:12 +05:30
include BlobHelper
2020-04-22 19:07:51 +05:30
layout 'fullscreen'
2021-01-29 00:20:46 +05:30
content_security_policy do |policy|
next if policy.directives.blank?
frame_src_values = Array.wrap(policy.directives['frame-src']) | ['https://www.youtube.com']
policy.frame_src(*frame_src_values)
end
2020-04-22 19:07:51 +05:30
prepend_before_action :authenticate_user!, only: [:show]
before_action :assign_ref_and_path, only: [:show]
before_action :authorize_edit_tree!, only: [:show]
2021-01-03 14:25:43 +05:30
feature_category :static_site_editor
2021-02-22 17:27:13 +05:30
def index
render_404
end
2020-04-22 19:07:51 +05:30
def show
2022-06-21 17:19:12 +05:30
redirect_to ide_edit_path(project, @ref, @path)
2020-04-22 19:07:51 +05:30
end
private
2021-01-03 14:25:43 +05:30
def serialize_necessary_payload_values_to_json(payload)
# This will convert booleans, Array-like and Hash-like objects to JSON
payload.transform_values do |value|
if value.is_a?(String) || value.is_a?(Integer)
value
2021-01-29 00:20:46 +05:30
elsif value.nil?
''
2021-01-03 14:25:43 +05:30
else
value.to_json
end
end
end
2020-04-22 19:07:51 +05:30
def assign_ref_and_path
2020-11-24 15:15:51 +05:30
@ref, @path = extract_ref(params.fetch(:id))
2020-04-22 19:07:51 +05:30
render_404 if @ref.blank? || @path.blank?
end
end