Sha256: 925b83fe14cbbcbabbc8cdb667bfc355d0ce575845cd38b576bd7ebe871c1944

Contents?: true

Size: 797 Bytes

Versions: 16

Compression:

Stored size: 797 Bytes

Contents

require 'alula/contents/item'

module Alula
  class Content
    class Post < Item
      has_payload
      
      def previous(locale = nil)
        pos = self.navigation(locale).index(self)
        if pos and pos < (self.navigation(locale).count - 1)
          self.navigation(locale)[pos + 1]
        else
          nil
        end
      end
      
      def next(locale = nil)
        pos = self.navigation(locale).index(self)
        if pos and pos > 0
          self.navigation(locale)[pos - 1]
        else
          nil
        end
      end
      
      def navigation(locale = nil)
        locale ||= self.current_locale || self.site.config.locale
        @navigation[locale] ||= self.site.content.posts.select { |item| item.languages.include?(locale) }        
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
alula-0.4.13 lib/alula/contents/post.rb
alula-0.4.12 lib/alula/contents/post.rb
alula-0.4.11 lib/alula/contents/post.rb
alula-0.4.11a lib/alula/contents/post.rb
alula-0.4.10 lib/alula/contents/post.rb
alula-0.4.9 lib/alula/contents/post.rb
alula-0.4.8 lib/alula/contents/post.rb
alula-0.4.7 lib/alula/contents/post.rb
alula-0.4.6 lib/alula/contents/post.rb
alula-0.4.5 lib/alula/contents/post.rb
alula-0.4.4 lib/alula/contents/post.rb
alula-0.4.3 lib/alula/contents/post.rb
alula-0.4.2 lib/alula/contents/post.rb
alula-0.4.1 lib/alula/contents/post.rb
alula-0.4.0 lib/alula/contents/post.rb
alula-0.4.0b lib/alula/contents/post.rb