e5bc0bfe92cbaff770368fba68b0920fea49fac7
[arvados.git] / apps / workbench / app / helpers / application_helper.rb
1 module ApplicationHelper
2   def current_user
3     controller.current_user
4   end
5
6   def self.match_uuid(uuid)
7     /^([0-9a-z]{5})-([0-9a-z]{5})-([0-9a-z]{15})$/.match(uuid.to_s)
8   end
9
10   def current_api_host
11     Rails.configuration.arvados_v1_base.gsub /https?:\/\/|\/arvados\/v1/,''
12   end
13
14   def render_markup(markup)
15     raw RedCloth.new(markup.to_s).to_html(:refs_arvados, :textile) if markup
16   end
17
18   def human_readable_bytes_html(n)
19     return h(n) unless n.is_a? Fixnum
20     return "0 bytes" if (n == 0)
21
22     orders = {
23       1 => "bytes",
24       1024 => "KiB",
25       (1024*1024) => "MiB",
26       (1024*1024*1024) => "GiB",
27       (1024*1024*1024*1024) => "TiB"
28     }
29
30     orders.each do |k, v|
31       sig = (n.to_f/k)
32       if sig >=1 and sig < 1024
33         if v == 'bytes'
34           return "%i #{v}" % sig
35         else
36           return "%0.1f #{v}" % sig
37         end
38       end
39     end
40
41     return h(n)
42     #raw = n.to_s
43     #cooked = ''
44     #while raw.length > 3
45     #  cooked = ',' + raw[-3..-1] + cooked
46     #  raw = raw[0..-4]
47     #end
48     #cooked = raw + cooked
49   end
50
51   def resource_class_for_uuid(attrvalue, opts={})
52     ArvadosBase::resource_class_for_uuid(attrvalue, opts)
53   end
54
55   # When using {remote:true}, or using {method:...} to use an HTTP
56   # method other than GET, move the target URI from href to
57   # data-remote-href. Otherwise, browsers offer features like "open in
58   # new window" and "copy link address" which bypass Rails' click
59   # handler and therefore end up at incorrect/nonexistent routes (by
60   # ignoring data-method) and expect to receive pages rather than
61   # javascript responses.
62   #
63   # See assets/javascripts/link_to_remote.js for supporting code.
64   def link_to *args, &block
65     if (args.last and args.last.is_a? Hash and
66         (args.last[:remote] or
67          (args.last[:method] and
68           args.last[:method].to_s.upcase != 'GET')))
69       if Rails.env.test?
70         # Capybara/phantomjs can't click_link without an href, even if
71         # the click handler means it never gets used.
72         raw super.gsub(' href="', ' href="#" data-remote-href="')
73       else
74         # Regular browsers work as desired: users can click A elements
75         # without hrefs, and click handlers fire; but there's no "copy
76         # link address" option in the right-click menu.
77         raw super.gsub(' href="', ' data-remote-href="')
78       end
79     else
80       super
81     end
82   end
83
84   ##
85   # Returns HTML that links to the Arvados object specified in +attrvalue+
86   # Provides various output control and styling options.
87   #
88   # +attrvalue+ an Arvados model object or uuid
89   #
90   # +opts+ a set of flags to control output:
91   #
92   # [:link_text] the link text to use (may include HTML), overrides everything else
93   #
94   # [:friendly_name] whether to use the "friendly" name in the link text (by
95   # calling #friendly_link_name on the object), otherwise use the uuid
96   #
97   # [:with_class_name] prefix the link text with the class name of the model
98   #
99   # [:no_tags] disable tags in the link text (default is to show tags).
100   # Currently tags are only shown for Collections.
101   #
102   # [:thumbnail] if the object is a collection, show an image thumbnail if the
103   # collection consists of a single image file.
104   #
105   # [:no_link] don't create a link, just return the link text
106   #
107   # +style_opts+ additional HTML properties for the anchor tag, passed to link_to
108   #
109   def link_to_if_arvados_object(attrvalue, opts={}, style_opts={})
110     if (resource_class = resource_class_for_uuid(attrvalue, opts))
111       if attrvalue.is_a? ArvadosBase
112         object = attrvalue
113         link_uuid = attrvalue.uuid
114       else
115         object = nil
116         link_uuid = attrvalue
117       end
118       link_name = opts[:link_text]
119       tags = ""
120       if !link_name
121         link_name = object.andand.default_name || resource_class.default_name
122
123         if opts[:friendly_name]
124           if attrvalue.respond_to? :friendly_link_name
125             link_name = attrvalue.friendly_link_name opts[:lookup]
126           else
127             begin
128               if resource_class.name == 'Collection'
129                 link_name = collections_for_object(link_uuid).andand.first.andand.friendly_link_name
130               else
131                 link_name = object_for_dataclass(resource_class, link_uuid).andand.friendly_link_name
132               end
133             rescue ArvadosApiClient::NotFoundException
134               # If that lookup failed, the link will too. So don't make one.
135               return attrvalue
136             end
137           end
138         end
139         if link_name.nil? or link_name.empty?
140           link_name = attrvalue
141         end
142         if opts[:with_class_name]
143           link_name = "#{resource_class.to_s}: #{link_name}"
144         end
145         if !opts[:no_tags] and resource_class == Collection
146           links_for_object(link_uuid).each do |tag|
147             if tag.link_class.in? ["tag", "identifier"]
148               tags += ' <span class="label label-info">'
149               tags += link_to tag.name, controller: "links", filters: [["link_class", "=", "tag"], ["name", "=", tag.name]].to_json
150               tags += '</span>'
151             end
152           end
153         end
154         if opts[:thumbnail] and resource_class == Collection
155           # add an image thumbnail if the collection consists of a single image file.
156           collections_for_object(link_uuid).each do |c|
157             if c.files.length == 1 and CollectionsHelper::is_image c.files.first[1]
158               link_name += " "
159               link_name += image_tag "#{url_for c}/#{CollectionsHelper::file_path c.files.first}", style: "height: 4em; width: auto"
160             end
161           end
162         end
163       end
164       style_opts[:class] = (style_opts[:class] || '') + ' nowrap'
165       if opts[:no_link] or (resource_class == User && !current_user)
166         raw(link_name)
167       else
168         controller_class = resource_class.to_s.tableize
169         if controller_class.eql?('groups') and object.andand.group_class.eql?('project')
170           controller_class = 'projects'
171         end
172         (link_to raw(link_name), { controller: controller_class, action: 'show', id: ((opts[:name_link].andand.uuid) || link_uuid) }, style_opts) + raw(tags)
173       end
174     else
175       # just return attrvalue if it is not recognizable as an Arvados object or uuid.
176       if attrvalue.nil? or (attrvalue.is_a? String and attrvalue.empty?)
177         "(none)"
178       else
179         attrvalue
180       end
181     end
182   end
183
184   def link_to_arvados_object_if_readable(attrvalue, link_text_if_not_readable, opts={})
185     resource_class = resource_class_for_uuid(attrvalue.split('/')[0]) if attrvalue.is_a?(String)
186     if !resource_class
187       return link_to_if_arvados_object attrvalue, opts
188     end
189
190     readable = object_readable attrvalue, resource_class
191     if readable
192       link_to_if_arvados_object attrvalue, opts
193     elsif opts[:required] and current_user # no need to show this for anonymous user
194       raw('<div><input type="text" style="border:none;width:100%;background:#ffdddd" disabled=true class="required unreadable-input" value="') + link_text_if_not_readable + raw('" ></input></div>')
195     else
196       link_text_if_not_readable
197     end
198   end
199
200   # This method takes advantage of preloaded collections and objects.
201   # Hence you can improve performance by first preloading objects
202   # related to the page context before using this method.
203   def object_readable attrvalue, resource_class=nil
204     # if it is a collection filename, check readable for the locator
205     attrvalue = attrvalue.split('/')[0] if attrvalue
206
207     resource_class = resource_class_for_uuid(attrvalue) if resource_class.nil?
208     return if resource_class.nil?
209
210     return_value = nil
211     if resource_class.to_s == 'Collection'
212       if CollectionsHelper.match(attrvalue)
213         found = collection_for_pdh(attrvalue)
214         return_value = found.first if found.any?
215       else
216         found = collections_for_object(attrvalue)
217         return_value = found.first if found.any?
218       end
219     else
220       return_value = object_for_dataclass(resource_class, attrvalue)
221     end
222     return_value
223   end
224
225   # Render an editable attribute with the attrvalue of the attr.
226   # The htmloptions are added to the editable element's list of attributes.
227   # The nonhtml_options are only used to customize the display of the element.
228   def render_editable_attribute(object, attr, attrvalue=nil, htmloptions={}, nonhtml_options={})
229     attrvalue = object.send(attr) if attrvalue.nil?
230     if not object.attribute_editable?(attr)
231       if attrvalue && attrvalue.length > 0
232         return render_attribute_as_textile( object, attr, attrvalue, false )
233       else
234         return (attr == 'name' and object.andand.default_name) ||
235                 '(none)'
236       end
237     end
238
239     input_type = 'text'
240     attrtype = object.class.attribute_info[attr.to_sym].andand[:type]
241     if attrtype == 'text' or attr == 'description'
242       input_type = 'textarea'
243     elsif attrtype == 'datetime'
244       input_type = 'date'
245     else
246       input_type = 'text'
247     end
248
249     attrvalue = attrvalue.to_json if attrvalue.is_a? Hash or attrvalue.is_a? Array
250     rendervalue = render_attribute_as_textile( object, attr, attrvalue, false )
251
252     ajax_options = {
253       "data-pk" => {
254         id: object.uuid,
255         key: object.class.to_s.underscore
256       }
257     }
258     if object.uuid
259       ajax_options['data-url'] = url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore)
260     else
261       ajax_options['data-url'] = url_for(action: "create", controller: object.class.to_s.pluralize.underscore)
262       ajax_options['data-pk'][:defaults] = object.attributes
263     end
264     ajax_options['data-pk'] = ajax_options['data-pk'].to_json
265     @unique_id ||= (Time.now.to_f*1000000).to_i
266     span_id = object.uuid.to_s + '-' + attr.to_s + '-' + (@unique_id += 1).to_s
267
268     span_tag = content_tag 'span', rendervalue, {
269       "data-emptytext" => '(none)',
270       "data-placement" => "bottom",
271       "data-type" => input_type,
272       "data-title" => "Edit #{attr.to_s.gsub '_', ' '}",
273       "data-name" => attr,
274       "data-object-uuid" => object.uuid,
275       "data-toggle" => "manual",
276       "data-value" => attrvalue,
277       "id" => span_id,
278       :class => "editable #{is_textile?( object, attr ) ? 'editable-textile' : ''}"
279     }.merge(htmloptions).merge(ajax_options)
280
281     edit_tiptitle = 'edit'
282     edit_tiptitle = 'Warning: do not use hyphens in the repository name as they will be stripped' if (object.class.to_s == 'Repository' and attr == 'name')
283
284     edit_button = raw('<a href="#" class="btn btn-xs btn-' + (nonhtml_options[:btnclass] || 'default') + ' btn-nodecorate" data-toggle="x-editable tooltip" data-toggle-selector="#' + span_id + '" data-placement="top" title="' + (nonhtml_options[:tiptitle] || edit_tiptitle) + '"><i class="fa fa-fw fa-pencil"></i>' + (nonhtml_options[:btntext] || '') + '</a>')
285
286     if nonhtml_options[:btnplacement] == :left
287       edit_button + ' ' + span_tag
288     elsif nonhtml_options[:btnplacement] == :top
289       edit_button + raw('<br/>') + span_tag
290     else
291       span_tag + ' ' + edit_button
292     end
293   end
294
295   def render_pipeline_component_attribute(object, attr, subattr, value_info, htmloptions={})
296     datatype = nil
297     required = true
298     attrvalue = value_info
299
300     if value_info.is_a? Hash
301       if value_info[:output_of]
302         return raw("<span class='label label-default'>#{value_info[:output_of]}</span>")
303       end
304       if value_info[:dataclass]
305         dataclass = value_info[:dataclass]
306       end
307       if value_info[:optional] != nil
308         required = (value_info[:optional] != "true")
309       end
310       if value_info[:required] != nil
311         required = value_info[:required]
312       end
313
314       # Pick a suitable attrvalue to show as the current value (i.e.,
315       # the one that would be used if we ran the pipeline right now).
316       if value_info[:value]
317         attrvalue = value_info[:value]
318       elsif value_info[:default]
319         attrvalue = value_info[:default]
320       else
321         attrvalue = ''
322       end
323       preconfigured_search_str = value_info[:search_for]
324     end
325
326     if not object.andand.attribute_editable?(attr)
327       return link_to_arvados_object_if_readable(attrvalue, attrvalue, {friendly_name: true, required: required})
328     end
329
330     if dataclass
331       begin
332         dataclass = dataclass.constantize
333       rescue NameError
334       end
335     else
336       dataclass = ArvadosBase.resource_class_for_uuid(attrvalue)
337     end
338
339     id = "#{object.uuid}-#{subattr.join('-')}"
340     dn = "[#{attr}]"
341     subattr.each do |a|
342       dn += "[#{a}]"
343     end
344     if value_info.is_a? Hash
345       dn += '[value]'
346     end
347
348     if (dataclass == Collection) or (dataclass == File)
349       selection_param = object.class.to_s.underscore + dn
350       display_value = attrvalue
351       if value_info.is_a?(Hash)
352         if (link = Link.find? value_info[:link_uuid])
353           display_value = link.name
354         elsif value_info[:link_name]
355           display_value = value_info[:link_name]
356         elsif value_info[:selection_name]
357           display_value = value_info[:selection_name]
358         end
359       end
360       if (attr == :components) and (subattr.size > 2)
361         chooser_title = "Choose a #{dataclass == Collection ? 'dataset' : 'file'} for #{object.component_input_title(subattr[0], subattr[2])}:"
362       else
363         chooser_title = "Choose a #{dataclass == Collection ? 'dataset' : 'file'}:"
364       end
365       modal_path = choose_collections_path \
366       ({ title: chooser_title,
367          filters: [['owner_uuid', '=', object.owner_uuid]].to_json,
368          action_name: 'OK',
369          action_href: pipeline_instance_path(id: object.uuid),
370          action_method: 'patch',
371          preconfigured_search_str: (preconfigured_search_str || ""),
372          action_data: {
373            merge: true,
374            use_preview_selection: dataclass == File ? true : nil,
375            selection_param: selection_param,
376            success: 'page-refresh'
377          }.to_json,
378         })
379
380       return content_tag('div', :class => 'input-group') do
381         html = text_field_tag(dn, display_value,
382                               :class =>
383                               "form-control #{'required' if required} #{'unreadable-input' if attrvalue.present? and !object_readable(attrvalue, Collection)}")
384         html + content_tag('span', :class => 'input-group-btn') do
385           link_to('Choose',
386                   modal_path,
387                   { :class => "btn btn-primary",
388                     :remote => true,
389                     :method => 'get',
390                   })
391         end
392       end
393     end
394
395     if attrvalue.is_a? String
396       datatype = 'text'
397     elsif attrvalue.is_a?(Array) or dataclass.andand.is_a?(Class)
398       # TODO: find a way to edit with x-editable
399       return attrvalue
400     end
401
402     # When datatype is a String or Fixnum, link_to the attrvalue
403     lt = link_to attrvalue, '#', {
404       "data-emptytext" => "none",
405       "data-placement" => "bottom",
406       "data-type" => datatype,
407       "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore, merge: true),
408       "data-title" => "Set value for #{subattr[-1].to_s}",
409       "data-name" => dn,
410       "data-pk" => "{id: \"#{object.uuid}\", key: \"#{object.class.to_s.underscore}\"}",
411       "data-value" => attrvalue,
412       # "clear" button interferes with form-control's up/down arrows
413       "data-clear" => false,
414       :class => "editable #{'required' if required} form-control",
415       :id => id
416     }.merge(htmloptions)
417
418     lt
419   end
420
421   def cwl_input_info(input_schema)
422     required = !(input_schema[:type].include? "null")
423     if input_schema[:type].is_a? Array
424       primary_type = input_schema[:type].select { |n| n != "null" }[0]
425     elsif input_schema[:type].is_a? String
426       primary_type = input_schema[:type]
427     elsif input_schema[:type].is_a? Hash
428       primary_type = input_schema[:type]
429     end
430     param_id = input_schema[:id]
431     return required, primary_type, param_id
432   end
433
434   def cwl_input_value(object, input_schema, set_attr_path)
435     dn = ""
436     attrvalue = object
437     set_attr_path.each do |a|
438       dn += "[#{a}]"
439       attrvalue = attrvalue[a.to_sym]
440     end
441     return dn, attrvalue
442   end
443
444   def cwl_inputs_required(object, inputs_schema, set_attr_path)
445     r = 0
446     inputs_schema.each do |input|
447       required, primary_type, param_id = cwl_input_info(input)
448       dn, attrvalue = cwl_input_value(object, input, set_attr_path + [param_id])
449       r += 1 if required and attrvalue.nil?
450     end
451     r
452   end
453
454   def render_cwl_input(object, input_schema, set_attr_path, htmloptions={})
455     required, primary_type, param_id = cwl_input_info(input_schema)
456
457     dn, attrvalue = cwl_input_value(object, input_schema, set_attr_path + [param_id])
458     attrvalue = if attrvalue.nil? then "" else attrvalue end
459
460     id = "#{object.uuid}-#{param_id}"
461
462     opt_empty_selection = if required then [] else [{value: "", text: ""}] end
463
464     if ["Directory", "File"].include? primary_type
465       chooser_title = "Choose a #{primary_type == 'Directory' ? 'dataset' : 'file'}:"
466       selection_param = object.class.to_s.underscore + dn
467       if attrvalue.is_a? Hash
468         display_value = attrvalue[:"arv:collection"] || attrvalue[:location]
469         re = CollectionsHelper.match_uuid_with_optional_filepath(display_value)
470         if re
471           if re[4]
472             display_value = "#{Collection.find(re[1]).name} / #{re[4][1..-1]}"
473           else
474             display_value = Collection.find(re[1]).name
475           end
476         end
477       end
478       modal_path = choose_collections_path \
479       ({ title: chooser_title,
480          filters: [['owner_uuid', '=', object.owner_uuid]].to_json,
481          action_name: 'OK',
482          action_href: container_request_path(id: object.uuid),
483          action_method: 'patch',
484          preconfigured_search_str: "",
485          action_data: {
486            merge: true,
487            use_preview_selection: primary_type == 'File' ? true : nil,
488            selection_param: selection_param,
489            success: 'page-refresh'
490          }.to_json,
491         })
492
493       return content_tag('div', :class => 'input-group') do
494         html = text_field_tag(dn, display_value,
495                               :class =>
496                               "form-control #{'required' if required}")
497         html + content_tag('span', :class => 'input-group-btn') do
498           link_to('Choose',
499                   modal_path,
500                   { :class => "btn btn-primary",
501                     :remote => true,
502                     :method => 'get',
503                   })
504         end
505       end
506     elsif "boolean" == primary_type
507       return link_to attrvalue.to_s, '#', {
508                      "data-emptytext" => "none",
509                      "data-placement" => "bottom",
510                      "data-type" => "select",
511                      "data-source" => (opt_empty_selection + [{value: "true", text: "true"}, {value: "false", text: "false"}]).to_json,
512                      "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore, merge: true),
513                      "data-title" => "Set value for #{input_schema[:id]}",
514                      "data-name" => dn,
515                      "data-pk" => "{id: \"#{object.uuid}\", key: \"#{object.class.to_s.underscore}\"}",
516                      "data-value" => attrvalue.to_s,
517                      # "clear" button interferes with form-control's up/down arrows
518                      "data-clear" => false,
519                      :class => "editable #{'required' if required} form-control",
520                      :id => id
521                    }.merge(htmloptions)
522     elsif primary_type.is_a? Hash and primary_type[:type] == "enum"
523       return link_to attrvalue, '#', {
524                      "data-emptytext" => "none",
525                      "data-placement" => "bottom",
526                      "data-type" => "select",
527                      "data-source" => (opt_empty_selection + primary_type[:symbols].map {|i| {:value => i, :text => i} }).to_json,
528                      "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore, merge: true),
529                      "data-title" => "Set value for #{input_schema[:id]}",
530                      "data-name" => dn,
531                      "data-pk" => "{id: \"#{object.uuid}\", key: \"#{object.class.to_s.underscore}\"}",
532                      "data-value" => attrvalue,
533                      # "clear" button interferes with form-control's up/down arrows
534                      "data-clear" => false,
535                      :class => "editable #{'required' if required} form-control",
536                      :id => id
537                    }.merge(htmloptions)
538     elsif primary_type.is_a? String
539       if ["float", "double", "int", "long"].include? primary_type
540         datatype = "number"
541       else
542         datatype = "text"
543       end
544
545       return link_to attrvalue, '#', {
546                      "data-emptytext" => "none",
547                      "data-placement" => "bottom",
548                      "data-type" => datatype,
549                      "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore, merge: true),
550                      "data-title" => "Set value for #{input_schema[:id]}",
551                      "data-name" => dn,
552                      "data-pk" => "{id: \"#{object.uuid}\", key: \"#{object.class.to_s.underscore}\"}",
553                      "data-value" => attrvalue,
554                      # "clear" button interferes with form-control's up/down arrows
555                      "data-clear" => false,
556                      :class => "editable #{'required' if required} form-control",
557                      :id => id
558                      }.merge(htmloptions)
559     else
560       return "Unable to render editing control for parameter type #{primary_type}"
561     end
562   end
563
564   def render_arvados_object_list_start(list, button_text, button_href,
565                                        params={}, *rest, &block)
566     show_max = params.delete(:show_max) || 3
567     params[:class] ||= 'btn btn-xs btn-default'
568     list[0...show_max].each { |item| yield item }
569     unless list[show_max].nil?
570       link_to(h(button_text) +
571               raw(' &nbsp; <i class="fa fa-fw fa-arrow-circle-right"></i>'),
572               button_href, params, *rest)
573     end
574   end
575
576   def render_controller_partial partial, opts
577     cname = opts.delete :controller_name
578     begin
579       render opts.merge(partial: "#{cname}/#{partial}")
580     rescue ActionView::MissingTemplate
581       render opts.merge(partial: "application/#{partial}")
582     end
583   end
584
585   RESOURCE_CLASS_ICONS = {
586     "Collection" => "fa-archive",
587     "Group" => "fa-users",
588     "Human" => "fa-male",  # FIXME: Use a more inclusive icon.
589     "Job" => "fa-gears",
590     "KeepDisk" => "fa-hdd-o",
591     "KeepService" => "fa-exchange",
592     "Link" => "fa-arrows-h",
593     "Node" => "fa-cloud",
594     "PipelineInstance" => "fa-gears",
595     "PipelineTemplate" => "fa-gears",
596     "Repository" => "fa-code-fork",
597     "Specimen" => "fa-flask",
598     "Trait" => "fa-clipboard",
599     "User" => "fa-user",
600     "VirtualMachine" => "fa-terminal",
601   }
602   DEFAULT_ICON_CLASS = "fa-cube"
603
604   def fa_icon_class_for_class(resource_class, default=DEFAULT_ICON_CLASS)
605     RESOURCE_CLASS_ICONS.fetch(resource_class.to_s, default)
606   end
607
608   def fa_icon_class_for_uuid(uuid, default=DEFAULT_ICON_CLASS)
609     fa_icon_class_for_class(resource_class_for_uuid(uuid), default)
610   end
611
612   def fa_icon_class_for_object(object, default=DEFAULT_ICON_CLASS)
613     case class_name = object.class.to_s
614     when "Group"
615       object.group_class ? 'fa-folder' : 'fa-users'
616     else
617       RESOURCE_CLASS_ICONS.fetch(class_name, default)
618     end
619   end
620
621   def chooser_preview_url_for object, use_preview_selection=false
622     case object.class.to_s
623     when 'Collection'
624       polymorphic_path(object, tab_pane: 'chooser_preview', use_preview_selection: use_preview_selection)
625     else
626       nil
627     end
628   end
629
630   def render_attribute_as_textile( object, attr, attrvalue, truncate )
631     if attrvalue && (is_textile? object, attr)
632       markup = render_markup attrvalue
633       markup = markup[0,markup.index('</p>')+4] if (truncate && markup.index('</p>'))
634       return markup
635     else
636       return attrvalue
637     end
638   end
639
640   def render_localized_date(date, opts="")
641     raw("<span class='utc-date' data-utc-date='#{date}' data-utc-date-opts='noseconds'>#{date}</span>")
642   end
643
644   def render_time duration, use_words, round_to_min=true
645     render_runtime duration, use_words, round_to_min
646   end
647
648 private
649   def is_textile?( object, attr )
650     is_textile = object.textile_attributes.andand.include?(attr)
651   end
652 end