Sha256: f478d42ec9d291348f6d25d33297693bd90fe43f77ab2b795f7ae55c6cbb6fc5

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

module Wiselinks
  module Headers    
    
    def self.included(base)      
      base.helper_method :wiselinks_title
    end

  protected

    def wiselinks_layout
      'wiselinks'
    end

    def render(options = {}, *args, &block)
      if self.request.wiselinks?        
        response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
        response.headers['Pragma'] = 'no-cache'

        if self.request.wiselinks_partial?
          Wiselinks.log("processing partial request")
          options[:partial] ||= action_name
        else
          Wiselinks.log("processing template request")
          
          if Wiselinks.options[:layout] != false
            options[:layout] = self.wiselinks_layout 
          end
        end

        if Wiselinks.options[:assets_digest].present?
          Wiselinks.log("assets digest #{Wiselinks.options[:assets_digest]}")

          self.headers['X-Assets-Digest'] = Wiselinks.options[:assets_digest]          
        end
      end

      super
    end

    def wiselinks_title(value)
      if self.request.wiselinks? && value.present?
        Wiselinks.log("title: #{value}")        
        response.headers['X-Title'] = URI.encode(value)
      end
    end    

    def wiselinks_request?
      Wiselinks::Logger.log "DEPRECATION WARNING: Method `wiselinks_request?` is deprecated. Please use `request.wiselinks?` instead."

      self.request.wiselinks?
    end

    def wiselinks_template_request?
      Wiselinks::Logger.log "DEPRECATION WARNING: Method `wiselinks_template_request?` is deprecated. Please use `request.wiselinks_template?` instead."

      self.request.wiselinks_template?
    end

    def wiselinks_partial_request?
      Wiselinks::Logger.log "DEPRECATION WARNING: Method `wiselinks_partial_request?` is deprecated. Please use `request.wiselinks_partial?` instead."

      self.request.wiselinks_partial?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wiselinks-0.4.0 lib/wiselinks/headers.rb