1 module ApplicationHelper
3 controller.current_user
6 def render_content_from_database(markup)
7 raw RedCloth.new(markup).to_html
10 def human_readable_bytes_html(n)
11 return h(n) unless n.is_a? Fixnum
15 cooked = ',' + raw[-3..-1] + cooked
21 def link_to_if_arvados_object(attrvalue, opts={}, style_opts={})
22 if (resource_class = ArvadosBase::resource_class_for_uuid(attrvalue, opts))
23 link_uuid = attrvalue.is_a?(ArvadosBase) ? attrvalue.uuid : attrvalue
24 link_name = opts[:link_text]
27 if !opts[:with_prefixes]
28 link_name = link_name.sub /^.{5}-.{5}-/, ''
30 if opts[:with_class_name]
31 link_name = "#{resource_class.to_s} #{link_name}"
33 style_opts = style_opts.merge(style: 'font-family: monospace')
35 link_to link_name, { controller: resource_class.to_s.underscore.pluralize, action: 'show', id: link_uuid }, style_opts
41 def render_editable_attribute(object, attr, attrvalue=nil, htmloptions={})
42 attrvalue = object.send(attr) if attrvalue.nil?
43 return attrvalue if !object.attribute_editable? attr
46 case object.class.attribute_info[attr.to_sym][:type]
48 input_type = 'textarea'
55 link_to attrvalue.to_s, '#', {
56 "data-emptytext" => "none",
57 "data-placement" => "bottom",
58 "data-type" => input_type,
59 "data-resource" => object.class.to_s.underscore,
61 "data-value" => object.send(attr),
62 "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore),
63 "data-original-title" => "Update #{attr.gsub '_', ' '}",