Sha256: 10ccc95df6eff084ce1041ac779fc5ac9486bf28f9b6e780573a2f692803bcca

Contents?: true

Size: 1.57 KB

Versions: 11

Compression:

Stored size: 1.57 KB

Contents

=begin
  Camaleon CMS is a content management system
  Copyright (C) 2015 by Owen Peredo Diaz
  Email: owenperedo@gmail.com
  This program is free software: you can redistribute it and/or modify   it under the terms of the GNU Affero General Public License as  published by the Free Software Foundation, either version 3 of the  License, or (at your option) any later version.
  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the  GNU Affero General Public License (GPLv3) for more details.
=end
module ActionController
  module Caching
    module Pages extend ActiveSupport::Concern
      module ClassMethods
        # get page cache content
        def page_cache_get(path, extension = nil)
          return "" unless page_cache_exist?(path, extension)
          # File.read(path)
          path = page_cache_path(path, extension)
        end

        # verify if this cache is already saved
        def page_cache_exist?(path, extension = nil)
          path = page_cache_path(path, extension)
          File.exist?(path)
        end
      end

      def page_cache_exist?(path, extension = nil)
        self.class.page_cache_exist?(path, extension || get_cache_extension)
      end

      def page_cache_get(path, extension = nil)
        self.class.page_cache_get(path, extension || get_cache_extension)
      end

      private
      def get_cache_extension
        # request.accept_encoding.include?("gzip")?".html.gz":""
        nil
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
camaleon_cms-1.1.0 config/initializers/page_caching.rb
camaleon_cms-1.0.9 config/initializers/page_caching.rb
camaleon_cms-1.0.8 config/initializers/page_caching.rb
camaleon_cms-1.0.7 config/initializers/page_caching.rb
camaleon_cms-1.0.6 config/initializers/page_caching.rb
camaleon_cms-1.0.5 config/initializers/page_caching.rb
camaleon_cms-1.0.4 config/initializers/page_caching.rb
camaleon_cms-1.0.3 config/initializers/page_caching.rb
camaleon_cms-1.0.2 config/initializers/page_caching.rb
camaleon_cms-1.0.1 config/initializers/page_caching.rb
camaleon_cms-1.0 config/initializers/page_caching.rb