Skip to content

Commit

Permalink
detect if the taxonomy description is a link and handle that
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal committed Nov 12, 2024
1 parent fe4c800 commit b961561
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
13 changes: 12 additions & 1 deletion app/assets/stylesheets/taxonomy.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,18 @@
}
.taxonomy-card .description{
color: #666666;
padding-bottom: 5px;
}

.taxonomy-card .descriptionlink svg{
margin: 0px 2px;
height: 19px;
}

.taxonomy-card .descriptionlink svg path{
fill: #666666;
}
.category-link{
color: #666666 !important;
}
.taxonomy-slice-svg{
width: 35px;
Expand Down
6 changes: 6 additions & 0 deletions app/components/display/taxonomy_card_component.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Display::TaxonomyCardComponent < ViewComponent::Base
require 'uri'
def initialize(taxonomy: , ontologies_names: )
@taxonomy = taxonomy
@ontologies_names = ontologies_names
Expand All @@ -7,4 +8,9 @@ def initialize(taxonomy: , ontologies_names: )
def reveal_id
@taxonomy.id
end

def description_is_url?
uri_regex = URI::DEFAULT_PARSER.make_regexp
@taxonomy.description.match?(/\A#{uri_regex}\z/)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
= "#{@taxonomy.name} (#{@taxonomy.acronym})"
%a{href: "https://#{@taxonomy.acronym}.#{$UI_URL.sub("https://", "")}"}
= inline_svg_tag('icons/slices.svg', class: "taxonomy-slice-svg #{@taxonomy.is_slice ? '' : 'd-none'}")

- if description_is_url?
.descriptionlink
%a.category-link{href: @taxonomy.description, target: '_blank'}
= @taxonomy.description
= inline_svg_tag 'icons/external-link.svg'

%a.ontologies{href: "/ontologies?#{@taxonomy.id.split('/')[-2]}=#{@taxonomy.acronym}"}
= inline_svg_tag('icons/ontology.svg')
.number-of-ontologies
= "#{@taxonomy.ontologies.length} ontologies"
.description
= render TextAreaFieldComponent.new(value: @taxonomy.description)

- unless description_is_url?
.description.mb-1
= render TextAreaFieldComponent.new(value: @taxonomy.description)

.ontologies-cards
- @taxonomy.ontologies.each_with_index do |ontology, index|
- if index>10
Expand Down

0 comments on commit b961561

Please sign in to comment.