Seperate static dir from template dir.

This commit is contained in:
Paul van Tilburg 2011-11-03 11:39:58 +01:00
parent 4819a50a6e
commit 55b40bf0b6
1 changed files with 4 additions and 3 deletions

View File

@ -19,8 +19,9 @@ require "pathname"
Markaby::Builder.set(:indent, 2)
Camping.goes :StopTime
unless defined? BASE_DIR
BASE_DIR = Pathname.new(__FILE__).dirname.expand_path + "public"
unless defined? PUBLIC_DIR
PUBLIC_DIR = Pathname.new(__FILE__).dirname.expand_path + "public"
TEMPLATE_DIR = Pathname.new(__FILE__).dirname.expand_path + "templates"
# Set the default date(/time) format.
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
@ -261,7 +262,7 @@ module StopTime::Controllers
mime_type = MIME::Types.type_for(path).first
@headers['Content-Type'] = mime_type.nil? ? "text/plain" : mime_type.to_s
unless path.include? ".."
@headers['X-Sendfile'] = (BASE_DIR + path).to_s
@headers['X-Sendfile'] = (PUBLIC_DIR + path).to_s
else
@status = "403"
"Error 403: Invalid path: #{path}"