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