Class: Jekyll::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/octopress-multilingual/jekyll.rb

Instance Method Summary collapse

Instance Method Details

#crosspost_languagesObject



108
109
110
# File 'lib/octopress-multilingual/jekyll.rb', line 108

def crosspost_languages
  data['lang_crosspost']
end

#langObject



102
103
104
105
106
# File 'lib/octopress-multilingual/jekyll.rb', line 102

def lang
  if data['lang']
    data['lang'].downcase
  end
end

#nextObject



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/octopress-multilingual/jekyll.rb', line 118

def next
  language = lang || site.config['lang']
  posts = Octopress::Multilingual.posts_by_language[language]

  pos = posts.index {|post| post.equal?(self) }
  if pos && pos < posts.length - 1
    posts[pos + 1]
  else
    nil
  end
end

#previousObject



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/octopress-multilingual/jekyll.rb', line 130

def previous
  language = lang || site.config['lang']
  posts = Octopress::Multilingual.posts_by_language[language]

  pos = posts.index {|post| post.equal?(self) }
  if pos && pos > 0
    posts[pos - 1]
  else
    nil
  end
end

#templateObject



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/octopress-multilingual/jekyll.rb', line 80

def template
  template = template_orig

  if self.site.config['lang']
    if [:pretty, :none, :date, :ordinal].include? site.permalink_style
      template = File.join('/:lang', template)
    end
  end

  template
end

#template_origObject



77
# File 'lib/octopress-multilingual/jekyll.rb', line 77

alias :template_orig :template

#translatedObject



92
93
94
# File 'lib/octopress-multilingual/jekyll.rb', line 92

def translated
  data['translation_id'] && !translations.empty?
end

#translationsObject



96
97
98
99
100
# File 'lib/octopress-multilingual/jekyll.rb', line 96

def translations
  if data['translation_id']
    @translations ||= Octopress::Multilingual.translated_posts[data['translation_id']].reject {|p| p == self}
  end
end

#url_placeholdersObject



112
113
114
115
116
# File 'lib/octopress-multilingual/jekyll.rb', line 112

def url_placeholders
  url_placeholders_orig.merge({
    :lang => lang
  })
end

#url_placeholders_origObject



78
# File 'lib/octopress-multilingual/jekyll.rb', line 78

alias :url_placeholders_orig :url_placeholders