Sha256: 289b4f0af5b323c58905457799b33ef85c96cfb934e93384b8a2c45f4ffef64b

Contents?: true

Size: 773 Bytes

Versions: 12

Compression:

Stored size: 773 Bytes

Contents

module Siteleaf
  class Post < Page

    attr_accessor :taxonomy
    
    def create_endpoint
      "pages/#{self.parent_id}/posts"
    end
    
    def parent
      Page.find(self.parent_id)
    end
    
    def assets
      result = Client.get "posts/#{self.id}/assets"
      result.map { |r| Asset.new(r) } if result
    end
    
    def filename(posts_path = 'posts')
      paths = url.sub('/','').split('/')
      basename = "#{paths.pop}.markdown"
      path = paths.join('_')
      if path == posts_path 
        if draft?
          path = 'drafts'
        else
          path = 'posts'
          date = Time.parse(published_at).strftime('%Y-%m-%d')
          basename = "#{date}-#{basename}"
        end
      end
      "_#{path}/#{basename}"
    end
    
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
siteleaf-1.0.11 lib/siteleaf/post.rb
siteleaf-1.0.10 lib/siteleaf/post.rb
siteleaf-1.0.9 lib/siteleaf/post.rb
siteleaf-1.0.8 lib/siteleaf/post.rb
siteleaf-1.0.7 lib/siteleaf/post.rb
siteleaf-1.0.6 lib/siteleaf/post.rb
siteleaf-1.0.5 lib/siteleaf/post.rb
siteleaf-1.0.4 lib/siteleaf/post.rb
siteleaf-1.0.3 lib/siteleaf/post.rb
siteleaf-1.0.2 lib/siteleaf/post.rb
siteleaf-1.0.1 lib/siteleaf/post.rb
siteleaf-1.0.0 lib/siteleaf/post.rb