@@ -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'
@@ -119,18 +117,26 @@ def embed_youtube(material)
119117 def keywords_and_topics ( resource , limit : nil )
120118 tags = [ ]
121119
122- %i[ scientific_topic_names operation_names keywords ] . each do |field |
123- tags |= resource . send ( field ) if resource . respond_to? ( field )
120+ if resource . respond_to? ( :scientific_topics )
121+ tags += resource . scientific_topics . map do |term |
122+ link_to ( term . preferred_label , term . uri , class : 'label label-info tag-topic link-overlay-link' , target : '_blank' )
123+ end
124124 end
125125
126- limit_exceeded = limit && ( tags . length > limit )
127- tags = tags . first ( limit ) if limit
126+ if resource . respond_to? ( :operations )
127+ tags += resource . operations . map do |term |
128+ link_to ( term . preferred_label , term . uri , class : 'label label-info tag-operation link-overlay-link' , target : '_blank' )
129+ end
130+ end
128131
129- elements = tags . map do |tag |
130- content_tag ( :span , tag , class : 'label label-info' )
132+ if resource . respond_to? ( :keywords )
133+ tags += resource . keywords . map do |tag |
134+ content_tag ( :span , tag , class : 'label label-info tag-keyword' )
135+ end
131136 end
132- elements << '…' if limit_exceeded
133137
134- elements . join ( ' ' ) . html_safe
138+ tags = tags . first ( limit ) if limit
139+ tags << '…' if limit && ( tags . length > limit )
140+ safe_join ( tags , ' ' )
135141 end
136142end
0 commit comments