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
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
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
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
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
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
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
(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
Adds the default stylesheet tags needed for ubiquo options:
color: by default is red, but you can replace it calling another color
css file
rest of options: this helper doesn't user more options, the rest are
send to stylesheet_link_tag generic helper
# File vendor/plugins/ubiquo_core/lib/ubiquo/helpers/core_ubiquo_helpers.rb, line 13
13: def ubiquo_stylesheet_link_tag(*sources)
14: stylesheets_dir = ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR + '/ubiquo'
15: options = sources.extract_options!.stringify_keys
16: color = options.delete("color") || :red
17: default_sources = []
18: if sources.include?(:defaults)
19: default_sources += [:ubiquo, :ubiquo_application, :lightwindow, :listings, color]
20: default_sources += collect_asset_files("#{stylesheets_dir}", "plugins/*.css")
21: end
22: ubiquo_sources = (sources + default_sources).collect do |source|
23: next if source == :defaults
24: "ubiquo/#{source}"
25: end.compact
26: output = stylesheet_link_tag(ubiquo_sources, options)
27: if sources.include?(:defaults)
28: output += "<!--[if IE]>\n\#{stylesheet_link_tag 'ubiquo/ubiquo_ie'}\n<![endif]-->\n<!--[if lte IE 6]>\n\#{stylesheet_link_tag 'ubiquo/ubiquo_ie6'}\n<![endif]-->\n"
29: end
30: output
31: end
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.
Generated with the Darkfish Rdoc Generator 1.1.6.