Module: BaseHelper
- Defined in:
- app/helpers/base_helper.rb
Instance Method Summary collapse
- #author_options(users) ⇒ Object
- #author_selected(content = nil) ⇒ Object
- #buttons(&block) ⇒ Object
- #column(&block) ⇒ Object
- #datetime_with_microformat(datetime, options = {}) ⇒ Object
- #filter_options ⇒ Object
- #link_path(section, link, *args) ⇒ Object
-
#split_form_for(*args, &block) ⇒ Object
does exactly the same as the form_for helper does, but splits off the form head tag and captures it to the content_for :form collector.
Instance Method Details
#author_options(users) ⇒ Object
40 41 42 43 44 |
# File 'app/helpers/base_helper.rb', line 40 def (users) = [[current_user.name, current_user.id]] += users.map { || [.name, .id] } .uniq end |
#author_selected(content = nil) ⇒ Object
46 47 48 49 50 51 |
# File 'app/helpers/base_helper.rb', line 46 def (content = nil) # FIXME why would we want to preselect the previous author of the # content when we are editing it? # content.try(:author_id) || current_user.id current_user.id end |
#buttons(&block) ⇒ Object
6 7 8 |
# File 'app/helpers/base_helper.rb', line 6 def (&block) content_tag(:p, :class => 'buttons', &block) end |
#column(&block) ⇒ Object
2 3 4 |
# File 'app/helpers/base_helper.rb', line 2 def column(&block) content_tag(:div, :class => 'col', &block) end |
#datetime_with_microformat(datetime, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/base_helper.rb', line 22 def datetime_with_microformat(datetime, ={}) return datetime unless datetime.respond_to?(:strftime) .symbolize_keys! [:format] ||= :default [:type] ||= :time # yuck ... use the localized_dates plugin as soon as we're on Rails 2.2? # formatted_datetime = options[:format].is_a?(Symbol) ? datetime.clone.in_time_zone.to_s(options[:format]) : datetime.clone.in_time_zone.strftime(options[:format]) formatted_datetime = l(datetime.in_time_zone.send([:type].to_sym == :time ? :to_time : :to_date), :format => [:format]) %{<abbr class="datetime" title="#{datetime.utc.xmlschema}">#{formatted_datetime}</abbr>}.html_safe end |
#filter_options ⇒ Object
34 35 36 37 38 |
# File 'app/helpers/base_helper.rb', line 34 def FilteredColumn.filters.keys.inject([]) do |arr, key| arr << [FilteredColumn.filters[key].filter_name, key.to_s] end.unshift ["Plain HTML", ''] end |
#link_path(section, link, *args) ⇒ Object
53 54 55 |
# File 'app/helpers/base_helper.rb', line 53 def link_path(section, link, *args) link.body_html end |
#split_form_for(*args, &block) ⇒ Object
does exactly the same as the form_for helper does, but splits off the form head tag and captures it to the content_for :form collector
12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/base_helper.rb', line 12 def split_form_for(*args, &block) # for some weird reasons Passenger and Mongrel behave differently when using Rails' capture method # with_output_buffer -> works, so we use it for now lines = (form_for(*args, &block) || '').split("\n") content_for :form, lines.shift.html_safe lines.pop lines.join("\n").html_safe end |