mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: Apply syntax_tree formatting to app/*
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PublishedPagesController < ApplicationController
|
||||
|
||||
skip_before_action :preload_json
|
||||
skip_before_action :check_xhr, :verify_authenticity_token, only: [:show]
|
||||
before_action :ensure_publish_enabled
|
||||
@ -19,12 +18,14 @@ class PublishedPagesController < ApplicationController
|
||||
begin
|
||||
guardian.ensure_can_see!(pp.topic)
|
||||
rescue Discourse::InvalidAccess => e
|
||||
return rescue_discourse_actions(
|
||||
:invalid_access,
|
||||
403,
|
||||
include_ember: false,
|
||||
custom_message: e.custom_message,
|
||||
group: e.group
|
||||
return(
|
||||
rescue_discourse_actions(
|
||||
:invalid_access,
|
||||
403,
|
||||
include_ember: false,
|
||||
custom_message: e.custom_message,
|
||||
group: e.group,
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -37,18 +38,19 @@ class PublishedPagesController < ApplicationController
|
||||
|
||||
TopicViewItem.add(pp.topic.id, request.remote_ip, current_user ? current_user.id : nil)
|
||||
|
||||
@body_classes = Set.new([
|
||||
'published-page',
|
||||
params[:slug],
|
||||
"topic-#{@topic.id}",
|
||||
@topic.tags.pluck(:name)
|
||||
].flatten.compact)
|
||||
@body_classes =
|
||||
Set.new(
|
||||
[
|
||||
"published-page",
|
||||
params[:slug],
|
||||
"topic-#{@topic.id}",
|
||||
@topic.tags.pluck(:name),
|
||||
].flatten.compact,
|
||||
)
|
||||
|
||||
if @topic.category
|
||||
@body_classes << @topic.category.slug
|
||||
end
|
||||
@body_classes << @topic.category.slug if @topic.category
|
||||
|
||||
render layout: 'publish'
|
||||
render layout: "publish"
|
||||
end
|
||||
|
||||
def details
|
||||
@ -60,12 +62,13 @@ class PublishedPagesController < ApplicationController
|
||||
def upsert
|
||||
pp_params = params.require(:published_page)
|
||||
|
||||
result, pp = PublishedPage.publish!(
|
||||
current_user,
|
||||
fetch_topic,
|
||||
pp_params[:slug].strip,
|
||||
pp_params.permit(:public)
|
||||
)
|
||||
result, pp =
|
||||
PublishedPage.publish!(
|
||||
current_user,
|
||||
fetch_topic,
|
||||
pp_params[:slug].strip,
|
||||
pp_params.permit(:public),
|
||||
)
|
||||
|
||||
json_result(pp, serializer: PublishedPageSerializer) { result }
|
||||
end
|
||||
@ -85,7 +88,7 @@ class PublishedPagesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def fetch_topic
|
||||
topic = Topic.find_by(id: params[:topic_id])
|
||||
@ -94,18 +97,13 @@ private
|
||||
end
|
||||
|
||||
def ensure_publish_enabled
|
||||
if !SiteSetting.enable_page_publishing? || SiteSetting.secure_uploads
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
raise Discourse::NotFound if !SiteSetting.enable_page_publishing? || SiteSetting.secure_uploads
|
||||
end
|
||||
|
||||
def enforce_login_required!
|
||||
if SiteSetting.login_required? &&
|
||||
!current_user &&
|
||||
!SiteSetting.show_published_pages_login_required? &&
|
||||
redirect_to_login
|
||||
if SiteSetting.login_required? && !current_user &&
|
||||
!SiteSetting.show_published_pages_login_required? && redirect_to_login
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user