Files

Class Index [+]

Quicksearch

Ubiquo::Helpers::CoreUbiquoHelpers

Public Instance Methods

box(name, options={}, &block) click to toggle source

surrounds the block between the specified box.

    # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 57
57:       def box(name, options={}, &block)
58:         options.merge!(:body=>capture(&block))
59:         concat(render(:partial => "shared/ubiquo/boxes/#{name}", :locals => options), block.binding)
60:       end
calendar_includes(options = {}) click to toggle source

Include calendar_date_select javascript and stylesheets with a default theme, basedir and locale

     # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 105
105:       def calendar_includes(options = {})
106:         iso639_locale = options[:locale] || I18n.locale.to_s
107:         CalendarDateSelect.format = options[:format] || :italian
108:         calendar_date_select_includes "ubiquo", :locale => iso639_locale
109:       end
help_block_sidebar(message) click to toggle source

Renders a message in a help block in the sidebar

     # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 112
112:       def help_block_sidebar(message)
113:         ubiquo_sidebar_box(t("ubiquo.help"), :class => "help-box") do
114:           "<p>#{message}</p>"
115:         end
116:       end
is_valid_date?(string_date, format="%d/%m/%Y") click to toggle source

Return true if string_date is a valid date representation with a given format (the so-called italian format by default: %d/%m/%Y)

     # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 94
 94:       def is_valid_date?(string_date, format="%d/%m/%Y")
 95:         begin
 96:           time = Date.strptime(string_date, format)
 97:         rescue ArgumentError
 98:           return false
 99:         end
100:         true
101:       end
show_preview(model_class, options = {}, &block) click to toggle source

Renders a preview A preview is usually used to show the values of an instance somewhere, in an unobtrusive way The instance to preview is taken from params[:preview_id]

     # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 122
122:       def show_preview(model_class, options = {}, &block)
123:         return unless params[:preview_id]
124:         previewed = model_class.find(params[:preview_id], options)
125:         return unless previewed
126:         locals = {:body=>capture(previewed, &block)}
127:         concat(render(:partial => "shared/ubiquo/preview_box", :locals => locals))
128:       end
ubiquo_boolean_image(value) click to toggle source

Returns a “tick” or “cross” image, useful to display boolean values

    # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 74
74:       def ubiquo_boolean_image(value)
75:         content_tag(:span, value, :class => "state_#{value}")
76:       end
ubiquo_image_path(name) click to toggle source

Returns the path for an ubiquo image

    # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 69
69:       def ubiquo_image_path(name)
70:         "#{Ubiquo::Config.get(:ubiquo_path)}/#{name}"
71:       end
ubiquo_image_tag(source, options={}) click to toggle source

This is a wrapper for image_tag for images inside the “ubiquo” directory This folder can be changed using the :ubiquo_path configuration option

    # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 64
64:       def ubiquo_image_tag(source, options={})
65:         image_tag(ubiquo_image_path(source), options)
66:       end
ubiquo_javascript_include_tag(*sources) click to toggle source

(Not documented)

    # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 41
41:       def ubiquo_javascript_include_tag(*sources)
42:         javascripts_dir = ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR + '/ubiquo'
43:         options = sources.extract_options!.stringify_keys
44:         default_sources = []
45:         if sources.include?(:defaults)
46:           default_sources += [:ubiquo, :lightwindow, :lightwindow_ubiquo]
47:           default_sources += collect_asset_files("#{javascripts_dir}", "plugins/*.js")
48:         end
49:         ubiquo_sources = (sources + default_sources).collect do |source|
50:           next if source == :defaults
51:           "ubiquo/#{source}"
52:         end.compact
53:         javascript_include_tag(ubiquo_sources, options)
54:       end
ubiquo_sidebar_box(title, options, &block) click to toggle source

Returns a properly marked up ubiquo sidebar box. Used to display sidebar items like filters, help boxes, etc.

    # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 80
80:       def ubiquo_sidebar_box(title, options, &block)
81:         css_class = "sidebar_box #{options[:class]}".strip
82:         extra_header = options[:extra_header] || ''
83:         result = content_tag(:div, :class => css_class, :id => options[:id]) do
84:           content_tag(:div, :class => "header") do
85:             content_tag(:h3, title) + extra_header
86:           end + \
87:           content_tag(:div, capture(&block), :class => "content")
88:         end
89:         block_called_from_erb?(block) ? concat(result) : result
90:       end
ubiquo_table_headerfy(column, klass = nil) click to toggle source

converts symbol to ubiquo standard table head with order_by and sort_order strings

     # File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 131
131:       def ubiquo_table_headerfy(column, klass = nil)
132:         name = klass.nil? ? params[:controller].split("/").last.tableize : klass
133: 
134:         case column
135:           when Symbol
136:             link = params.clone
137:             if link[:order_by] == "#{name.to_s.pluralize}.#{column.to_s}"
138:               link[:sort_order] = link[:sort_order] == "asc" ? "desc" : "asc"
139:             else
140:               link[:order_by] = "#{name.pluralize}.#{column.to_s}"
141:               link[:sort_order] = "asc"
142:             end
143:             #name.classify.human_attribute_name(column.to_s.humanize)
144:             #t("#{name.classify}|#{column.to_s.humanize}").humanize
145: 
146:             column_segments = column.to_s.split('.') # Example column: :"author.name"
147:             column_header = if column_segments.size > 1
148:               begin
149:                 # Here we are dealing with relation columns
150:                 assoc_model = column_segments.first.classify.constantize
151:                 column_name = assoc_model.human_attribute_name(column_segments.last)
152:                 assoc_model.human_name.downcase
153:               rescue NameError
154:                 # Here we are dealing with relation columns using categories
155:                 category = CategorySet.find_by_key(column_segments.first)
156:                 msg = "Couldn't find #{column_segments.first} association for #{column_name} column."
157:                 raise AssociationNotFound, msg unless category
158:                 category.name
159:               end
160:             else
161:               name.classify.constantize.human_attribute_name(column.to_s)
162:             end
163: 
164:             link_to content_tag(:span, column_header),
165:                     link,
166:                     { :class => (params[:order_by] == "#{name.pluralize}.#{column.to_s}" ?
167:                                 (params[:sort_order] == "asc" ? "order_desc" : "order_asc") : "order" )}
168:           when String
169:             column.humanize
170:         end
171:       end

Disabled; run with $DEBUG to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.