Sha256: 2e2901a2b2ccad5b1456bdc842161af72b453d9dfd66f34f8352190cd4021a7b

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

module Amiba
  module Source
    class Entry
      extend Amiba::Source::EntryFinder
      include Amiba::Source
      
      attr_accessor :category
      metadata_fields :title, :slug, :state, :layout

      validates_presence_of :title, :state, :layout

      def initialize(category, name, format, metadata = nil, content = nil)
        self.category = category
        self.name = name
        self.format = format
        self.metadata = metadata
        self.content = content
      end

      def filename
        File.join("entries", category.to_s.downcase.pluralize, name + ".#{format.to_s}")
      end
      
      def staged_filename
        File.join(Amiba::Configuration.staged_dir, filename)
      end

      def output_filename
        File.join(Amiba::Configuration.site_dir, 'public', category.to_s.downcase.pluralize, "#{name}.html")
      end

      def link
        URI.escape( ["", category.to_s.downcase.pluralize, "#{name}.html"].join("/") )
      end

      def render
        Tilt.new(self.staged_filename).render(Amiba::Scope.new(self))
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amiba-0.0.2 lib/amiba/source/entry.rb