sitios privados en producción

This commit is contained in:
f 2020-10-10 14:14:02 -03:00
parent b761de9e36
commit 0473c9fc2e

View file

@ -19,11 +19,9 @@ class PrivateController < ApplicationController
return
end
if deploy_private && File.exist?(path)
send_file path, disposition: 'inline'
else
head :not_found
end
raise PageNotFound if deploy_private && File.exist?(path)
send_file path, disposition: 'inline'
end
private
@ -47,15 +45,9 @@ class PrivateController < ApplicationController
# Devuelve la ruta completa del archivo
def path
return @path if @path
@path = Pathname.new(File.join(deploy_private.destination, file)).realpath.to_s
raise Errno::ENOENT unless @path.starts_with? deploy_private.destination
@path
@path ||= Pathname.new(File.join(deploy_private.destination, file)).realpath.to_s
rescue Errno::ENOENT
not_found_path
site_not_found_path
end
# Devuelve la ruta del archivo, limpieza copiada desde Jekyll
@ -76,12 +68,6 @@ class PrivateController < ApplicationController
end
# Devuelve una página 404.html
def not_found_path
return site_not_found_path if File.exist? site_not_found_path
raise PageNotFound
end
def site_not_found_path
@site_not_found_path ||= File.join(deploy_private.destination, '404.html')
end