Sha256: 38a73b690cfb0aa8cead86dac9584e80952b207299c39067889d028c380d663a

Contents?: true

Size: 993 Bytes

Versions: 12

Compression:

Stored size: 993 Bytes

Contents

module Plate
  # A static page is left unmodified and is transferred over to the published
  # site exactly as it is.
  class StaticPage < Page
    def file_path
      base = Pathname.new(File.join(self.site.source, 'content'))
      current = Pathname.new(self.file)
      
      dirs = current.relative_path_from(base)
      
      "/#{dirs}"
    end
    
    def layout
      nil
    end
    
    # If we need for some reason, read this file's contents 
    def rendered_content
      @rendered_content ||= File.read(self.file)
    end
    
    # Write this page to the destination. For static files this just results
    # in copying the file over to the destination
    def write!      
      path = File.join(site.build_destination, file_path)
      FileUtils.mkdir_p(File.dirname(path))
      FileUtils.cp(self.file, path)
    end
    
    protected
      # Don't read any meta data for static files, leave them as-is.
      def read_metadata!
        self.meta = {}
      end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
plate-0.7.0.pre3 lib/plate/static_page.rb
plate-0.7.0.pre2 lib/plate/static_page.rb
plate-0.7.0.pre lib/plate/static_page.rb
plate-0.6.3 lib/plate/static_page.rb
plate-0.6.2 lib/plate/static_page.rb
plate-0.6.1 lib/plate/static_page.rb
plate-0.6.0 lib/plate/static_page.rb
plate-0.5.4 lib/plate/static_page.rb
plate-0.5.3 lib/plate/static_page.rb
plate-0.5.2 lib/plate/static_page.rb
plate-0.5.1 lib/plate/static_page.rb
plate-0.5.0 lib/plate/static_page.rb