lib/enju_leaf/helper.rb in enju_leaf-1.1.0.rc17 vs lib/enju_leaf/helper.rb in enju_leaf-1.1.0.rc18
- old
+ new
@@ -27,19 +27,19 @@
def link_to_wikipedia(string)
link_to "Wikipedia", "http://#{I18n.locale}.wikipedia.org/wiki/#{URI.escape(string)}"
end
def locale_display_name(locale)
- Language.where(:iso_639_1 => locale).first.display_name
+ Language.where(iso_639_1: locale).first.display_name
end
def locale_native_name(locale)
- Language.where(:iso_639_1 => locale).first.native_name
+ Language.where(iso_639_1: locale).first.native_name
end
def move_position(object)
- render :partial => 'page/position', :locals => {:object => object}
+ render partial: 'page/position', locals: {object: object}
end
def localized_state(state)
case state
when 'pending'
@@ -89,28 +89,27 @@
else
options.reject!{|key, value| value.blank?}
options.delete(:page) if options[:page].to_i == 1
end
unless controller_name == 'test'
- link_to t('page.listing', :model => t("activerecord.models.#{controller_name.singularize}")), url_for(params.merge(:controller => controller_name, :action => :index, :id => nil, :only_path => true).merge(options))
+ link_to t('page.listing', model: t("activerecord.models.#{controller_name.singularize}")), url_for(params.merge(controller: controller_name, action: :index, id: nil, only_path: true).merge(options))
end
end
def set_focus_on_search_form
javascript_tag("$(function(){$('#search_form').focus()})") if @query.blank?
end
def markdown_helper(string)
return unless string
- if defined?(JRUBY_VERSION)
- string
- # Kramdown::Document.new(string.to_s).to_html.html_safe
- else
+ if defined?(Redcarpet)
markdown = Redcarpet::Markdown.new(
Redcarpet::Render::HTML,
- :autolink => true, :safe_links_only => true
+ autolink: true, safe_links_only: true
)
markdown.render(string.to_s).html_safe
+ else
+ Kramdown::Document.new(string.to_s).to_html.html_safe
end
end
def messages_count(user)
Message.search do