Sha256: 3a63fb3523c8182b05d75dc259d60810823c4c0b2f85d380addfa6a5c190471d

Contents?: true

Size: 791 Bytes

Versions: 5

Compression:

Stored size: 791 Bytes

Contents

require 'tilt'

module Staticpress::Content
  module StaticContent
    # layout not needed for binary files
    def layout
      static? ? nil : super
    end

    def parse_slug(path, base_path)
      path_string = path.to_s

      clean = lambda { |str| str.sub(base_path.to_s, '').sub(/^\//, '') }

      if Staticpress::Content::StaticContent.supported_extensions.any? { |ext| path_string.end_with? ext.to_s }
        [ clean.call(extensionless_path(path).to_s), path.extname.sub(/^\./, '').to_sym ]
      else
        [ clean.call(path_string), nil ]
      end
    end

    def render_partial(locals = {})
      static? ? template_path_content : super
    end

    def self.supported_extensions
      Tilt.mappings.keys.reject { |mapping| mapping == '' }.map &:to_sym
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
staticpress-0.7.1 lib/staticpress/content/static_content.rb
staticpress-0.7.0 lib/staticpress/content/static_content.rb
staticpress-0.6.2 lib/staticpress/content/static_content.rb
staticpress-0.6.1 lib/staticpress/content/static_content.rb
staticpress-0.6.0 lib/staticpress/content/static_content.rb