@@ -71,17 +71,15 @@ def display_attribute(resource, attribute, show_label: true, title: nil, markdow
7171 ] . any?
7272
7373 value = resource . send ( attribute )
74- if markdown
75- value = render_markdown ( value )
76- end
74+ value = render_markdown ( value ) if markdown
7775 if value . present?
78- if list
79- value = value . map do |v |
80- html_escape ( block_given? ? yield ( v ) : v )
81- end
82- else
83- value = html_escape ( block_given? ? yield ( value ) : value )
84- end
76+ value = if list
77+ value . map do |v |
78+ html_escape ( block_given? ? yield ( v ) : v )
79+ end
80+ else
81+ html_escape ( block_given? ? yield ( value ) : value )
82+ end
8583 end
8684 string = "<p class=\" #{ attribute } #{ show_label ? ' no-spacing' : '' } \" >"
8785 unless value . blank? || value . try ( :strip ) == 'License Not Specified'
@@ -135,18 +133,31 @@ def embed_youtube(material)
135133 def keywords_and_topics ( resource , limit : nil )
136134 tags = [ ]
137135
138- %i[ scientific_topic_names operation_names keywords ] . each do |field |
139- tags |= resource . send ( field ) if resource . respond_to? ( field )
136+ if resource . respond_to? ( :scientific_topics )
137+ tags += resource . scientific_topics . map do |term |
138+ content_tag ( :span , class : 'label label-info tag-topic' ) do
139+ content_tag ( :i , '' , class : 'fa fa-flask' ) + ' ' + term . preferred_label
140+ end
141+ end
140142 end
141143
142- limit_exceeded = limit && ( tags . length > limit )
143- tags = tags . first ( limit ) if limit
144+ if resource . respond_to? ( :operations )
145+ tags += resource . operations . map do |term |
146+ content_tag ( :span , class : 'label label-info tag-operation' ) do
147+ content_tag ( :i , '' , class : 'fa fa-cogs' ) + ' ' + term . preferred_label
148+ end
149+ end
150+ end
144151
145- elements = tags . map do |tag |
146- content_tag ( :span , tag , class : 'label label-info' )
152+ if resource . respond_to? ( :keywords )
153+ tags += resource . keywords . map do |tag |
154+ content_tag ( :span , tag , class : 'label label-info tag-keyword' )
155+ end
147156 end
148- elements << '…' if limit_exceeded
149157
150- elements . join ( ' ' ) . html_safe
158+ limit_exceeded = limit && ( tags . length > limit )
159+ tags = tags . first ( limit ) if limit
160+ tags << '…' . html_safe if limit_exceeded
161+ safe_join ( tags , ' ' )
151162 end
152163end
0 commit comments