1 module ApplicationHelper
3 controller.current_user
7 Rails.configuration.arvados_v1_base.gsub /https?:\/\/|\/arvados\/v1/,''
10 def render_content_from_database(markup)
11 raw RedCloth.new(markup).to_html
14 def human_readable_bytes_html(n)
15 return h(n) unless n.is_a? Fixnum
19 cooked = ',' + raw[-3..-1] + cooked
25 def resource_class_for_uuid(attrvalue, opts={})
26 ArvadosBase::resource_class_for_uuid(attrvalue, opts)
29 def link_to_if_arvados_object(attrvalue, opts={}, style_opts={})
30 if (resource_class = resource_class_for_uuid(attrvalue, opts))
31 link_uuid = attrvalue.is_a?(ArvadosBase) ? attrvalue.uuid : attrvalue
32 link_name = opts[:link_text]
36 if opts[:friendly_name] and resource_class.column_names.include? "name" and resource_class.find(link_uuid).name != nil and not resource_class.find(link_uuid).name.empty?
37 link_name = "#{resource_class.to_s} #{resource_class.find(link_uuid).name}"
38 elsif opts[:friendly_name] and resource_class.column_names.include? "hostname" and resource_class.find(link_uuid).hostname != nil and not resource_class.find(link_uuid).hostname.empty?
39 link_name = "#{resource_class.to_s} #{resource_class.find(link_uuid).hostname}"
40 elsif opts[:friendly_name] and resource_class.column_names.include? "first_name"
41 link_name = "#{resource_class.to_s} #{resource_class.find(link_uuid).first_name} #{resource_class.find(link_uuid).last_name}"
43 if opts[:with_class_name]
44 link_name = "#{resource_class.to_s} #{link_name}"
48 link_to link_name, { controller: resource_class.to_s.underscore.pluralize, action: 'show', id: link_uuid }, style_opts
54 def render_editable_attribute(object, attr, attrvalue=nil, htmloptions={})
55 attrvalue = object.send(attr) if attrvalue.nil?
56 return attrvalue if !object.attribute_editable? attr
59 case object.class.attribute_info[attr.to_sym].andand[:type]
61 input_type = 'textarea'
68 attrvalue = attrvalue.to_json if attrvalue.is_a? Hash or attrvalue.is_a? Array
70 link_to attrvalue.to_s, '#', {
71 "data-emptytext" => "none",
72 "data-placement" => "bottom",
73 "data-type" => input_type,
74 "data-resource" => object.class.to_s.underscore,
76 "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore),
77 "data-original-title" => "Update #{attr.gsub '_', ' '}",