Skip to content

Commit

Permalink
Merge branch 'feature/federate-search-page' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal committed Sep 12, 2024
2 parents 93fe2a8 + d1b228a commit 8f3385c
Show file tree
Hide file tree
Showing 37 changed files with 341 additions and 172 deletions.
19 changes: 10 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ GEM
json
redcarpet (3.6.0)
regexp_parser (2.9.2)
reline (0.5.9)
reline (0.5.10)
io-console (~> 0.5)
request_store (1.7.0)
rack (>= 1.4)
Expand All @@ -433,7 +433,7 @@ GEM
rouge (4.3.0)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.2)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
Expand All @@ -448,17 +448,17 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.66.0)
rubocop (1.66.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.1, < 2.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.2)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
Expand Down Expand Up @@ -489,7 +489,7 @@ GEM
simplecov-cobertura (2.1.0)
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
snaky_hash (2.0.1)
hashie
Expand All @@ -502,11 +502,12 @@ GEM
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sshkit (1.23.0)
sshkit (1.23.1)
base64
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
ostruct
stimulus-rails (1.3.4)
railties (>= 6.0.0)
string-similarity (2.1.0)
Expand All @@ -518,7 +519,7 @@ GEM
execjs (>= 0.3.0, < 3)
thor (1.3.2)
tilt (2.4.0)
time (0.3.0)
time (0.4.0)
date
timeout (0.4.1)
turbo-rails (2.0.6)
Expand Down Expand Up @@ -550,7 +551,7 @@ GEM
will_paginate (3.3.1)
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.36)
yard (0.9.37)
zeitwerk (2.6.18)

PLATFORMS
Expand Down
4 changes: 2 additions & 2 deletions app/assets/images/icons/slices.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
@import "agent_tooltip";
@import "content_finder";
@import "tools";
@import "taxonomy";
@import "portal_configuration";

/* Bootstrap and Font Awesome */
Expand Down
101 changes: 101 additions & 0 deletions app/assets/stylesheets/taxonomy.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
.taxonomy-page-container {
display: flex;
justify-content: center;
}
.taxonomy-page-subcontainer {
width: 1248px;
padding: 20px 50px;
}
.taxonomy-page-title .text{
font-size: 25px;
font-weight: 700;
}

.taxonomy-page-title .line{
height: 2px;
width: 57px;
background-color: var(--primary-color);
border-radius: 10px;
}
.taxonomy-page-decription{
color: #888888;
margin: 20px 0;
}
.taxonomy-section{
display: flex;
}
.taxonomy-section .second-row{
margin-left: 10px;
}
.taxonomy-card{
border: 1px solid #DFDFDF;
padding: 15px 20px;
width: 569px;
border-radius: 5px;
margin-top: 10px;
}

.taxonomy-card .title-bar{
display: flex;
justify-content: space-between;
align-items: center;
}
.taxonomy-card .title{
color: var(--primary-color);
font-size: 18px;
font-weight: bold;
}

.taxonomy-card .ontologies{
display: flex;
align-items: center;
color: var(--primary-color);
margin: 3px 0;
}
.taxonomy-card .ontologies svg{
width: 15px;
height: 15px;
margin-right: 10px;
}

.taxonomy-card .ontologies svg path{
fill: var(--primary-color);
}
.taxonomy-card .description{
color: #666666;
padding-bottom: 5px;
}
.taxonomy-slice-svg{
width: 35px;
height: 35px;
margin-bottom: 2px;
}

.taxonomy-children-reveal{
display: flex;
align-items: center;
cursor: pointer;
color: var(--primary-color);
}
.taxonomy-children-reveal svg{
margin-left: 5px;
margin-top: 3px;
}

.taxonomy-children .taxonomy-card{
border: none;
padding: 0px 18px;
width: unset;
}

.taxonomy-children-container{
display: flex;
margin-top: 10px
}

.taxonomy-children-line{
width: 1px;
background-color: var(--primary-color);
}


8 changes: 4 additions & 4 deletions app/components/display/search_result_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def reuses_id

def details_button
link_to_modal(nil, "/ajax/class_details?modal=true&ontology=#{@ontology_acronym}&conceptid=#{@uri}&styled=false", data: { show_modal_title_value: @title, show_modal_size_value: 'modal-xl' }) do
content_tag(:div, class: 'button', style: @portal_color ? "background-color: #{@portal_light_color} !important" : '') do
content_tag(:div, class: 'button') do
concat inline_svg_tag('icons/details.svg')
concat content_tag(:div, class: 'text', style: @portal_color ? "color: #{@portal_color} !important" : '') { t('search.result_component.details') }
concat content_tag(:div, class: 'text') { t('search.result_component.details') }
end
end
end
Expand All @@ -57,9 +57,9 @@ def mappings_button

def visualize_button
link_to_modal(nil, "/ajax/biomixer/?ontology=#{@ontology_acronym}&conceptid=#{@uri}", data: { show_modal_title_value: @title, show_modal_size_value: 'modal-xl' }) do
content_tag(:div, class: 'button', style: @portal_color ? "background-color: #{@portal_light_color} !important" : '') do
content_tag(:div, class: 'button') do
concat inline_svg_tag('icons/visualize.svg')
concat content_tag(:div, class: 'text', style: @portal_color ? "color: #{@portal_color} !important" : '') { t('search.result_component.visualize') }
concat content_tag(:div, class: 'text') { t('search.result_component.visualize') }
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions app/components/display/taxonomy_card_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Display::TaxonomyCardComponent < ViewComponent::Base
def initialize(taxonomy: , ontologies_names: )
@taxonomy = taxonomy
@ontologies_names = ontologies_names
end

def reveal_id
@taxonomy.id
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.taxonomy-card{'data-controller': 'reveal-component'}
.title-bar
.title
= "#{@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'}")
%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)
.ontologies-cards
- @taxonomy.ontologies.each do |ontology|
= render ChipButtonComponent.new(url: "/ontologies/#{ontology.split('/').last}", text: ontology.split('/').last, tooltip: @ontologies_names[ontology], type: "clickable")

- if @taxonomy.children
.taxonomy-children-reveal{'data-action': "click->reveal-component#toggle", 'data-id': reveal_id}
.text
= t('taxonomy.show_sub_categories')
= inline_svg_tag 'icons/arrow-down.svg'
.taxonomy-children-container
.taxonomy-children-line
.taxonomy-children.d-none{id: reveal_id}
- @taxonomy.children.each do |child|
= render Display::TaxonomyCardComponent.new(taxonomy: child, ontologies_names: @ontologies_names)
6 changes: 1 addition & 5 deletions app/components/ontology_browse_card_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ def ontology
end

def external_ontology?
!@portal_name.blank?
end

def external_portal_name
@portal_name
!internal_ontology?(@ontology[:id]) || (Array(@ontology[:sources]).size > 1)
end

def onto_link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
= t('components.show_more')


- unless ontology[:fairScore].nil? || ontology[:fairScore].zero? || ontology[:acronym] == 'AGROVOC'
- unless ontology[:fairScore].nil? || ontology[:fairScore].zero? || ontology[:acronym] == 'AGROVOC'
.browse-fair
%p.browse-fair-title
= t('components.fair_score')
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def index

def new
@category = LinkedData::Client::Models::Category.new

respond_to do |format|
format.html { render "new", :layout => false }
end
Expand Down
27 changes: 0 additions & 27 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,33 +183,6 @@ def request_portals
helpers.request_portals
end

def check_http_file(url)
session = Net::HTTP.new(url.host, url.port)
session.use_ssl = true if url.port == 443
session.start do |http|
response_valid = http.head(url.request_uri).code.to_i < 400
return response_valid
end
end

def check_ftp_file(uri)
ftp = Net::FTP.new(uri.host, uri.user, uri.password)
ftp.login
begin
file_exists = ftp.size(uri.path) > 0
rescue
# Check using another method
path = uri.path.split("/")
filename = path.pop
path = path.join("/")
ftp.chdir(path)
files = ftp.dir
# Dumb check, just see if the filename is somewhere in the list
files.each { |file| return true if file.include?(filename) }
end
file_exists
end

def parse_response_body(response)
return nil if response.nil?

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/concerns/search_aggregator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def aggregate_results(query, results, is_federate)
ontologies = aggregate_by_ontology(results)
grouped_results = add_subordinate_ontologies(query, ontologies)

all_ontologies = LinkedData::Client::Models::Ontology.all(include: 'acronym,name', include_views: true, display_links: false, display_context: false, federate: is_federate)
all_ontologies = LinkedData::Client::Models::Ontology.all(include: 'acronym,name', include_views: true, display_links: false, display_context: false)

search_results = grouped_results.map do |group|
format_search_result(group, all_ontologies)
Expand Down Expand Up @@ -77,7 +77,7 @@ def search_result_elem(class_object, ontology_acronym, title)
portal_name = portal_name_from_uri(class_object.links['ui'])
{
uri: class_object.id.to_s,
title: title.empty? ? label : "#{label} - #{title}",
title: title.nil? || title.empty? ? "#{label} - #{ontology_acronym}" : "#{label} - #{title}",
ontology_acronym: ontology_acronym,
link: link,
definition: class_object.definition,
Expand All @@ -93,7 +93,7 @@ def is_federation_external_class(class_object)

def ontology_name_acronym(ontologies, selected_acronym)
ontology = ontologies.select { |x| x.acronym.eql?(selected_acronym.split('/').last) }.first
"#{ontology.name} (#{ontology.acronym})"
"#{ontology.name} (#{ontology.acronym})" if ontology
end

def aggregate_by_ontology(results)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/submission_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def submissions_paginate_filter(params)
[@page.collection, @page.totalCount, count, filter_params]
end

def ontologies_filter_url(filters, page: 1, count: false)
helpers.ontologies_filter_url(filters, page: page, count: count)
def ontologies_with_filters_url(filters, page: 1, count: false)
helpers.ontologies_with_filters_url(filters, page: page, count: count)
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def index
end

def set_cookies
session[:cookies_accepted] = params[:cookies] if params[:cookies]
cookies.permanent[:cookies_accepted] = params[:cookies] if params[:cookies]
render 'cookies', layout: nil
end

Expand Down
Loading

0 comments on commit 8f3385c

Please sign in to comment.