<% if @page && @page.title != 'Access Denied' %> <% content_for :js do %> <%= gzip_javascript_include_tag "caboose/application" %> <%= gzip_javascript_include_tag @site.name == 'application' ? 'application' : "#{@site.name}/js/application" %> <% Caboose::javascripts.each do |js| %><%= javascript_include_tag(js) %><% end %> <% @page.linked_resources_map[:js].each do |r| %><%= gzip_javascript_include_tag r %><% end %> <% if @site.date_js_updated %><% end %> <% if @page.custom_js && @page.custom_js.strip.length > 0 %><% end %> <%= yield :caboose_js %> <% end %> <% content_for :css do %> <%= gzip_stylesheet_link_tag 'caboose/application' %> <%= gzip_stylesheet_link_tag @site.name == 'application' ? 'application' : "#{@site.name}/css/application" %> <% Caboose::stylesheets.each do |css| %><%= gzip_stylesheet_link_tag(css) %><% end %> <% @page.linked_resources_map[:css].each do |r| %><%= gzip_stylesheet_link_tag r %><% end %> <% if @site.date_css_updated %><% end %> <% if @page.custom_css && @page.custom_css.strip.length > 0 %><% end %> <%= yield :caboose_css %> <% end %> <% b = @post ? @post.block : @page.block #Caboose.log(@post) #Caboose.log(@page.block.inspect) if b.nil? bt = @site.default_layout if @post Caboose::Block.create(:post_id => @post.id, :block_type_id => bt.id) b = @post.block else Caboose::Block.create(:page_id => @page.id, :block_type_id => bt.id) b = @page.block end b.create_children end #b.log_helper options = { :request => @request, :post => @post, :page => @page, :view => self, :controller_view_content => yield, :modal => false, :empty_text => defined?(@editing) && @editing ? (defined?(@empty_text) ? @empty_text : 'Empty, click to edit') : "", :editing => defined?(@editing) ? @editing : false, :css => '|CABOOSE_CSS|', :js => '|CABOOSE_JAVASCRIPT|', :csrf_meta_tags => '|CABOOSE_CSRF|', :csrf_meta_tags2 => '|CABOOSE_CSRF|', :logged_in_user => @logged_in_user, :site => @site, :ga_events => @ga_events } @block_options.each{ |k,v| options[k] = v } if @block_options str = nil #if @use_page_cache # pc = Caboose::PageCache.where(:page_id => @page.id).first # if pc # If the page is cached, send it to the user # # require_dependency "#{Caboose.root}/app/models/caboose/block_cache.rb" # require_dependency "#{Caboose.root}/app/models/caboose/block_cache_file.rb" # require_dependency "#{Caboose.root}/app/models/caboose/block_cache_image.rb" # # @block = Marshal.load(pc.block) # @view = options[:view ] # @controller_view_content = options[:controller_view_content ] # @modal = options[:modal ] # @empty_text = options[:empty_text ] # @editing = options[:editing ] # @css = options[:css ] # @js = options[:js ] # @csrf_meta_tags = options[:csrf_meta_tags ] # @csrf_meta_tags2 = options[:csrf_meta_tags2 ] # # str = render(:inline => pc.render_function) # end #end # Render the blocks if we don't have it cached str = b.render(b, options) if str.nil? protocol = request.protocol #protocol = Caboose.plugin_hook('request_protocol', protocol, request) # See if we're using cloudflare if request.env['HTTP_CF_VISITOR'] && request.env['HTTP_CF_VISITOR'].include?('https') protocol = 'https://' request.env['REQUEST_URI'] = "https://#{request.env['REQUEST_URI'][7..-1]}" if (request.env['REQUEST_URI'] =~ %r"http://") == 0 request.env['SERVER_PORT'] = '443' if request.env['SERVER_PORT'] == '80' request.env['HTTP_REFERER'] = "https://#{request.env['HTTP_REFERER'][7..-1]}" if (request.env['HTTP_REFERER'] =~ %r"http://") == 0 request.env['rack.url_scheme'] = 'https' request.env['HTTPS'] = 'on' end css = yield(:css) css.gsub!("<%= raw str %><% end %>