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_class_name]
28 link_name = "#{resource_class.to_s} #{link_name}"
30 style_opts = style_opts.merge(style: 'font-family: monospace')
32 link_to link_name, { controller: resource_class.to_s.underscore.pluralize, action: 'show', id: link_uuid }, style_opts
38 def render_editable_attribute(object, attr, attrvalue=nil, htmloptions={})
39 attrvalue = object.send(attr) if attrvalue.nil?
40 return attrvalue if !object.attribute_editable? attr
43 case object.class.attribute_info[attr.to_sym][:type]
45 input_type = 'textarea'
52 link_to attrvalue.to_s, '#', {
53 "data-emptytext" => "none",
54 "data-placement" => "bottom",
55 "data-type" => input_type,
56 "data-resource" => object.class.to_s.underscore,
58 "data-value" => object.send(attr),
59 "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore),
60 "data-original-title" => "Update #{attr.gsub '_', ' '}",