FIX: reduce scope of ExtraLocalesController override
Dieser Commit ist enthalten in:
Ursprung
ef81a07918
Commit
642e3cca98
1 geänderte Dateien mit 17 neuen und 12 gelöschten Zeilen
29
plugin.rb
29
plugin.rb
|
@ -191,20 +191,25 @@ after_initialize do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
## TODO: We shouldn't be overriding the entire method here. Make this more lightweight.
|
module CustomWizardExtraLocalesController
|
||||||
add_to_class(:extra_locales_controller, :show) do
|
def show
|
||||||
bundle = params[:bundle]
|
if request.referer && URI(request.referer).path.include?('/w/')
|
||||||
|
bundle = params[:bundle]
|
||||||
unless URI(request.referer).path.include? '/w/'
|
|
||||||
raise Discourse::InvalidAccess.new if bundle !~ /^(admin|wizard)$/ || !current_user&.staff?
|
if params[:v]&.size == 32
|
||||||
end
|
hash = ExtraLocalesController.bundle_js_hash(bundle)
|
||||||
|
immutable_for(1.year) if hash == params[:v]
|
||||||
|
end
|
||||||
|
|
||||||
if params[:v]&.size == 32
|
render plain: ExtraLocalesController.bundle_js(bundle), content_type: "application/javascript"
|
||||||
hash = ExtraLocalesController.bundle_js_hash(bundle)
|
else
|
||||||
immutable_for(24.hours) if hash == params[:v]
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
render plain: ExtraLocalesController.bundle_js(bundle), content_type: "application/javascript"
|
|
||||||
|
class ::ExtraLocalesController
|
||||||
|
prepend CustomWizardExtraLocalesController
|
||||||
end
|
end
|
||||||
|
|
||||||
DiscourseEvent.trigger(:custom_wizard_ready)
|
DiscourseEvent.trigger(:custom_wizard_ready)
|
||||||
|
|
Laden …
In neuem Issue referenzieren