Class: Jekyll::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/localization.rb

Instance Method Summary collapse

Instance Method Details

#_localization_original_destinationObject



203
# File 'lib/jekyll/localization.rb', line 203

alias_method :_localization_original_destination, :destination

#_localization_original_processObject



219
# File 'lib/jekyll/localization.rb', line 219

alias_method :_localization_original_process, :process

#_localization_original_urlObject



196
# File 'lib/jekyll/localization.rb', line 196

alias_method :_localization_original_url, :url

#destination(dest) ⇒ Object

Overwrites the original method to cater for language extension in output file name.



207
208
209
210
211
212
213
214
215
216
217
# File 'lib/jekyll/localization.rb', line 207

def destination(dest)
  # The url needs to be unescaped in order to preserve the correct filename
  path = File.join(dest, @dir, CGI.unescape(url))

  if ext == '.html' && _localization_original_url !~ /\.html\z/
    path.sub!(Localization::LANG_END_RE, '')
    File.join(path, "index#{ext}#{@lang_ext}")
  else
    path
  end
end

#process(name) ⇒ Object

Overwrites the original method to filter the language extension from basename



223
224
225
226
227
# File 'lib/jekyll/localization.rb', line 223

def process(name)
  self.ext      = File.extname(name)
  self.basename = name[0 .. -self.ext.length-1].
    sub(Localization::LANG_END_RE, '')
end

#url(lang = nil) ⇒ Object

Overwrites the original method to include the language extension.



199
200
201
# File 'lib/jekyll/localization.rb', line 199

def url(lang = nil)
  "#{_localization_original_url}#{lang ? '.' + lang : @lang_ext}"
end