app/controllers/cms/content_controller.rb in browsercms-3.3.4 vs app/controllers/cms/content_controller.rb in browsercms-3.4.0.rc1
- old
+ new
@@ -1,6 +1,7 @@
-class Cms::ContentController < Cms::ApplicationController
+module Cms
+class ContentController < Cms::ApplicationController
include Cms::ContentRenderingSupport
skip_before_filter :redirect_to_cms_site
before_filter :redirect_non_cms_users_to_public_site, :only => [:show, :show_page_route]
before_filter :construct_path, :only => [:show]
@@ -49,10 +50,11 @@
cache_page if perform_caching
end
# ----- Before Filters -------------------------------------------------------
def construct_path
+ # @paths = params[:cms_page_path] || params[:path] || []
@path = "/#{params[:path]}"
@paths = @path.split("/")
end
def construct_path_from_route
@@ -92,19 +94,23 @@
if redirect = Redirect.find_by_from_path(@path)
redirect_to redirect.to_path, :status=>:moved_permanently
end
end
- def try_to_stream_file
- split = @paths.last.to_s.split('.')
+ # Determines if the current request is file that needs to be streamed.
+ # Any URL with a . in it is considered a file.
+ def is_file?
+ split = request.url.split('.')
ext = split.size > 1 ? split.last.to_s.downcase : nil
-
- #Only try to stream cache file if it has an extension
- unless ext.blank?
+ !ext.blank?
+ end
+
+ def try_to_stream_file
+ if is_file?
#Check access to file
- @attachment = Attachment.find_live_by_file_path(@path)
+ @attachment = Attachment.find_live_by_file_path(request.fullpath)
if @attachment
raise Cms::Errors::AccessDenied unless current_user.able_to_view?(@attachment)
#Construct a path to where this file would be if it were cached
@file = @attachment.full_file_location
@@ -172,6 +178,7 @@
session[:page_mode] = @mode
end
+end
end