class Humpyard::NewsItem

Public Instance Methods

human_url(options={}) click to toggle source

Return the human readable URL for the page.

Posible options values are

:locale

A locale given in the Humpyard::Config.locales. If no :locale is given the option will be ::I18n.locale by default

# File app/models/humpyard/news_item.rb, line 21
def human_url(options={})
  options[:locale] ||= ::I18n.locale
  options[:format] ||= :html
  
  unless Humpyard::config.locales.include? options[:locale].to_sym
    options[:locale] = Humpyard::config.locales.first
  end
  
  if options[:path_format]
    format = "/"
  else
    format = ".#{options[:format].to_s}" 
  end
  
  page_options = options
  page_options[:path_format] = true
  
  "#{news_page.page.human_url(page_options)}#{created_at.strftime '%Y/%m/%d'}/#{query_title_for_url(options[:locale])}#{format}"
end