From 9429305733ee10d7dae371d3e70b3aec828fe590 Mon Sep 17 00:00:00 2001 From: Syphax bouazzouni Date: Thu, 21 Nov 2024 11:16:43 +0100 Subject: [PATCH 01/20] Fix: users edition and login_as with the `@` symbol in there usernames (#857) * fix username with the `@` in the usernames * make the user edit as login as work --- app/controllers/application_controller.rb | 9 ++++++--- app/controllers/users_controller.rb | 1 + config/routes.rb | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1a8a3c827..c27651a48 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -253,12 +253,15 @@ def authorize_and_redirect end def authorize_admin - admin = session[:user] && session[:user].admin? - redirect_to_home unless admin + redirect_to_home unless current_user_admin? end def current_user_admin? - session[:user] && session[:user].admin? + session[:user]&.admin? || current_login_as_admin? + end + + def current_login_as_admin? + session[:admin_user]&.admin? end def ontology_restricted?(acronym) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 520ab1b86..5b4eb817e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -226,6 +226,7 @@ def unescape_id def verify_owner return if current_user_admin? + if session[:user].nil? || (!session[:user].id.eql?(params[:id]) && !session[:user].username.eql?(params[:id])) redirect_to controller: 'login', action: 'index', redirect: "/accounts/#{params[:id]}" end diff --git a/config/routes.rb b/config/routes.rb index 0a06e8913..4894165a6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,7 +25,7 @@ resources :projects, constraints: { id: /[^\/]+/ } - resources :users, path: :accounts, constraints: { id: /[\d\w\.\-\%\+ ]+/ } + resources :users, path: :accounts, constraints: { id: /[\d\w\.\@\-\%\+ ]+/ } get '/users/subscribe/:username', to: 'users#subscribe' get '/users/un-subscribe/:email', to: 'users#un_subscribe' @@ -204,7 +204,7 @@ get '/lost_pass_success' => 'login#lost_password_success' get '/reset_password' => 'login#reset_password' post '/accounts/:id/custom_ontologies' => 'users#custom_ontologies', :as => :custom_ontologies - get '/login_as/:login_as' => 'login#login_as', constraints: { login_as: /[\d\w\.\-\%\+ ]+/ } + get '/login_as/:login_as' => 'login#login_as', constraints: { login_as: /[\d\w\.\@\-\%\+ ]+/ } post '/login/send_pass', to: 'login#send_pass' get '/groups' => 'taxonomy#index' From afff32174f6e39a87a0bdc45985608c35c182099 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Fri, 22 Nov 2024 17:09:07 +0100 Subject: [PATCH 02/20] Fix: prevent word break for the tree view elements (#855) --- app/assets/stylesheets/components/tree_view.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/components/tree_view.scss b/app/assets/stylesheets/components/tree_view.scss index 1582b9c3a..4393281f9 100644 --- a/app/assets/stylesheets/components/tree_view.scss +++ b/app/assets/stylesheets/components/tree_view.scss @@ -35,7 +35,6 @@ padding:0; a.tree-link { display: inline-block; padding: 5px; - word-break: break-all; text-wrap: wrap; color: var(--primary-color) !important; } From df623f02fbdef0e93979fe6887599985c1ed45b9 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:17:31 +0100 Subject: [PATCH 03/20] Fix: Federation portal button link (#854) * fix federated portal button opening in current portal in browse page * make internal federated portal button open in the current tab --- app/components/federated_portal_button_component.rb | 5 +++++ .../federated_portal_button_component.html.haml | 2 +- app/helpers/federation_helper.rb | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/components/federated_portal_button_component.rb b/app/components/federated_portal_button_component.rb index 4d8a1e886..920407bb4 100644 --- a/app/components/federated_portal_button_component.rb +++ b/app/components/federated_portal_button_component.rb @@ -2,6 +2,7 @@ class FederatedPortalButtonComponent < ViewComponent::Base attr_reader :name, :tooltip, :link, :color, :light_color + include UrlsHelper def initialize(name:, link:, color:, tooltip:, light_color:) @name = name @@ -10,4 +11,8 @@ def initialize(name:, link:, color:, tooltip:, light_color:) @color = color @light_color = light_color end + + def internal? + !link?(@link) + end end diff --git a/app/components/federated_portal_button_component/federated_portal_button_component.html.haml b/app/components/federated_portal_button_component/federated_portal_button_component.html.haml index e45a6f052..b59554ff8 100644 --- a/app/components/federated_portal_button_component/federated_portal_button_component.html.haml +++ b/app/components/federated_portal_button_component/federated_portal_button_component.html.haml @@ -1,7 +1,7 @@ %span{'data-controller': 'federation-portals-colors', 'data-federation-portals-colors-color-value': color, 'data-federation-portals-colors-portal-name-value': name.downcase} -%a{ href: link, target: '_blank', 'data-controller' => 'tooltip', title: tooltip, class: 'federation-portal-button button icon-right', style: color ? "background-color: #{light_color} !important" : '' } +%a{ href: link, target: internal? ? '_top' : '_blank', 'data-controller' => 'tooltip', title: tooltip, class: 'federation-portal-button button icon-right', style: color ? "background-color: #{light_color} !important" : '' } = inline_svg_tag('logos/ontoportal.svg', class: "federated-icon-#{name.downcase}") %div{ class: 'text', style: color ? "color: #{color} !important" : '' } = name.humanize.gsub("portal", "Portal") diff --git a/app/helpers/federation_helper.rb b/app/helpers/federation_helper.rb index d961712bc..6b52b7a6b 100644 --- a/app/helpers/federation_helper.rb +++ b/app/helpers/federation_helper.rb @@ -53,6 +53,10 @@ def ontology_portal_color(id) end def ontoportal_ui_link(id) + if id.include?($REST_URL) + return id.gsub($REST_URL,'') + end + portal_key, config = ontology_portal_config(id) return nil unless portal_key From 462dc6d1dfa488bbf99c3d44ce756f635304b3b4 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Mon, 25 Nov 2024 20:09:44 +0100 Subject: [PATCH 04/20] fix can't change portal language --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c27651a48..e6182c033 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,7 +27,7 @@ def set_locale cookies.permanent[:locale] = I18n.locale if cookies[:locale].nil? logger.debug "* Locale set to '#{I18n.locale}'" - I18n.locale = portal_lang if portal_language_enabled?(I18n.locale) + I18n.locale = portal_lang unless portal_language_enabled?(I18n.locale) session[:locale] = I18n.locale end @@ -430,7 +430,7 @@ def json_link(url, optional_params) optional_params_str = filtered_params.map { |param, value| "#{param}=#{value}" }.join("&") return base_url + optional_params_str + "&apikey=#{$API_KEY}" end - + def set_federated_portals RequestStore.store[:federated_portals] = params[:portals]&.split(',') end From f095c5934102d1d5c8f10eb51d719b496d0afd81 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Mon, 25 Nov 2024 20:11:16 +0100 Subject: [PATCH 05/20] Revert "fix can't change portal language" This reverts commit 462dc6d1dfa488bbf99c3d44ce756f635304b3b4. --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e6182c033..c27651a48 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,7 +27,7 @@ def set_locale cookies.permanent[:locale] = I18n.locale if cookies[:locale].nil? logger.debug "* Locale set to '#{I18n.locale}'" - I18n.locale = portal_lang unless portal_language_enabled?(I18n.locale) + I18n.locale = portal_lang if portal_language_enabled?(I18n.locale) session[:locale] = I18n.locale end @@ -430,7 +430,7 @@ def json_link(url, optional_params) optional_params_str = filtered_params.map { |param, value| "#{param}=#{value}" }.join("&") return base_url + optional_params_str + "&apikey=#{$API_KEY}" end - + def set_federated_portals RequestStore.store[:federated_portals] = params[:portals]&.split(',') end From 2b4e8823098452bba2ddd10ceab633545a2a2fc5 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:20:34 +0100 Subject: [PATCH 06/20] Fix: Taxonomy empty list (#858) * fix nil parentCategory issue in nest_categories_children method * add empty illustration if a taxonomy list is empty * remove random code in taxonomy index view file * treat the case when a category is deleted while keeping its id as a parent for a certain category * use empty_state helper in taxonomies page * internationalize no taxonomy is created * use current_user_admin? helper in taxonomies page * use regular button helper in taxonomies page * remove added code just to test in taxonomy page --- app/assets/stylesheets/taxonomy.scss | 19 ++++++++++++++++++ app/controllers/taxonomy_controller.rb | 3 ++- app/helpers/components_helper.rb | 4 ++-- app/views/taxonomy/_taxonomies.html.haml | 25 +++++++++++++++--------- app/views/taxonomy/index.html.haml | 4 ++-- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 ++ 7 files changed, 44 insertions(+), 15 deletions(-) diff --git a/app/assets/stylesheets/taxonomy.scss b/app/assets/stylesheets/taxonomy.scss index bf5c679ff..077b5bcda 100644 --- a/app/assets/stylesheets/taxonomy.scss +++ b/app/assets/stylesheets/taxonomy.scss @@ -109,4 +109,23 @@ background-color: var(--primary-color); } +.taxonomy-empty-illustration{ + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: 100%; + .browse-empty-illustration { + margin-top: 40px; + } +} + + +.taxonomy-empty-illustration-text{ + color: var(--gray-color); + +} +.taxonomy-empty-illustration-button{ + width: 168px; +} diff --git a/app/controllers/taxonomy_controller.rb b/app/controllers/taxonomy_controller.rb index b3afa2542..8696c3e08 100644 --- a/app/controllers/taxonomy_controller.rb +++ b/app/controllers/taxonomy_controller.rb @@ -32,8 +32,9 @@ def nest_categories_children(categories) category_index[category[:id]] = category end categories.each do |category| - category[:parentCategory].each do |parent_id| + category[:parentCategory]&.each do |parent_id| parent = category_index[parent_id] + next if parent.nil? parent[:children] ||= [] parent[:children] << category end diff --git a/app/helpers/components_helper.rb b/app/helpers/components_helper.rb index 8c04a869d..53a5e34cb 100644 --- a/app/helpers/components_helper.rb +++ b/app/helpers/components_helper.rb @@ -274,8 +274,8 @@ def properties_dropdown(id, title, tooltip, properties, is_open: false, &block) end end - def regular_button(id, value, variant: "secondary", state: "regular", size: "slim", &block) - render Buttons::RegularButtonComponent.new(id:id, value: value, variant: variant, state: state, size: size) do |btn| + def regular_button(id, value, variant: "secondary", state: "regular", size: "slim", href: nil, &block) + render Buttons::RegularButtonComponent.new(id:id, value: value, variant: variant, state: state, size: size, href: href) do |btn| capture(btn, &block) if block_given? end end diff --git a/app/views/taxonomy/_taxonomies.html.haml b/app/views/taxonomy/_taxonomies.html.haml index 0dd56f687..f6c0b3eb8 100644 --- a/app/views/taxonomy/_taxonomies.html.haml +++ b/app/views/taxonomy/_taxonomies.html.haml @@ -1,10 +1,17 @@ .taxonomy-section - - pairs, impairs = taxonomies.each_with_index.partition { |_, index| index.even? } - - taxonomies_first_row = pairs.map(&:first) - - taxonomies_second_row = impairs.map(&:first) - .first-row - - taxonomies_first_row.each do |taxonomy| - = render Display::TaxonomyCardComponent.new(taxonomy: taxonomy, ontologies_names: @ontologies_names) - .second-row - - taxonomies_second_row.each do |taxonomy| - = render Display::TaxonomyCardComponent.new(taxonomy: taxonomy, ontologies_names: @ontologies_names) \ No newline at end of file + - if taxonomies.blank? + .taxonomy-empty-illustration + = empty_state(t('taxonomy.no_taxonomy_created', type: type)) + - if current_user_admin? + .taxonomy-empty-illustration-button + = regular_button('create-taxonomy', "Create #{type}", variant: "secondary", size: "slim", href: "/admin?section=#{type}") + - else + - pairs, impairs = taxonomies.each_with_index.partition { |_, index| index.even? } + - taxonomies_first_row = pairs.map(&:first) + - taxonomies_second_row = impairs.map(&:first) + .first-row + - taxonomies_first_row.each do |taxonomy| + = render Display::TaxonomyCardComponent.new(taxonomy: taxonomy, ontologies_names: @ontologies_names) + .second-row + - taxonomies_second_row.each do |taxonomy| + = render Display::TaxonomyCardComponent.new(taxonomy: taxonomy, ontologies_names: @ontologies_names) \ No newline at end of file diff --git a/app/views/taxonomy/index.html.haml b/app/views/taxonomy/index.html.haml index b9b2b3a10..706e212e5 100644 --- a/app/views/taxonomy/index.html.haml +++ b/app/views/taxonomy/index.html.haml @@ -10,11 +10,11 @@ = render TabsContainerComponent.new do |c| - c.item(title: 'Groups', selected: !@category_section_active) - c.item_content do - = render partial: '/taxonomy/taxonomies', locals: { taxonomies: @groups } + = render partial: '/taxonomy/taxonomies', locals: { taxonomies: @groups, type: 'groups' } - c.item(title: 'Categories', selected: @category_section_active) - c.item_content do - = render partial: '/taxonomy/taxonomies', locals: { taxonomies: @categories } + = render partial: '/taxonomy/taxonomies', locals: { taxonomies: @categories, type: 'categories' } :javascript document.getElementById('categories_tab').addEventListener('click', function(event) { window.history.pushState({ path: '/categories' }, '', '/categories'); diff --git a/config/locales/en.yml b/config/locales/en.yml index 5269b506b..8bcd055c9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1480,7 +1480,7 @@ en: groups_and_categories: Groups and Categories description: "In %{portal}, ontologies are organized in groups and tagged with categories. Typically, groups associate ontologies from the same project or organization for better identification of the provenance. Whereas categories are about subjects/topics and enable to classify ontologies. As of 2016, %{portal}'s categories were established in cooperation with FAO AIMS. In 2024, we moved to UNESCO Thesaurus (https://vocabularies.unesco.org). Groups and categories, along with other metadata, can be used on the “Browse” page of %{portal} to filter out the list of ontologies." show_sub_categories: Show sub categories - + no_taxonomy_created: "No %{type} are created yet" federation: results_from_external_portals: Results from external portals not_responding: is not responding. diff --git a/config/locales/fr.yml b/config/locales/fr.yml index dc4724702..d471829cf 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1516,6 +1516,8 @@ fr: groups_and_categories: Groupes et Catégories description: "Dans %{portal}, les ontologies sont organisées en groupes et étiquetées avec des catégories. Typiquement, les groupes associent des ontologies provenant du même projet ou de la même organisation pour une meilleure identification de la provenance. Tandis que les catégories concernent des sujets/thématiques et permettent de classifier les ontologies. En 2016, les catégories d'%{portal} ont été établies en coopération avec FAO AIMS. En 2024, nous sommes passés au Thésaurus de l'UNESCO (https://vocabularies.unesco.org). Les groupes et les catégories, ainsi que d'autres métadonnées, peuvent être utilisés sur la page “Parcourir” d'%{portal} pour filtrer la liste des ontologies." show_sub_categories: Afficher les sous-catégories + no_taxonomy_created: "Aucun %{type} n'a encore été créé" + federation: results_from_external_portals: Résultats provenant de portails externes not_responding: ne répond pas. From 450ddf4116bf7084be47f4175ff65b3ae231792f Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:45:50 +0100 Subject: [PATCH 07/20] fix the logic of federated search results merging (#872) --- app/controllers/concerns/search_aggregator.rb | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/controllers/concerns/search_aggregator.rb b/app/controllers/concerns/search_aggregator.rb index f1f074272..a4c8699f2 100644 --- a/app/controllers/concerns/search_aggregator.rb +++ b/app/controllers/concerns/search_aggregator.rb @@ -251,18 +251,21 @@ def blacklist_cls_id_components(cls_id, blacklist_words) def merge_federated_results(search_results) search_results.each do |element| element[:root][:other_portals] = [] - - element[:reuses].reject! do |reuse| - element_ontology_id = element[:root][:ontology_id].split('/').last - element_uri = element[:root][:uri] - reuse_ontology_id = reuse[:root][:ontology_id].split('/').last - reuse_uri = reuse[:root][:uri] - - if element_ontology_id == reuse_ontology_id && element_uri == reuse_uri - element[:root][:other_portals] << build_other_portal_entry(reuse) - true - else - false + element_ontology_id = element[:root][:ontology_id].split('/').last + element_uri = element[:root][:uri] + [element[:reuses], search_results].each do |collection| + collection.reject! do |entry| + next if entry == element + + entry_ontology_id = entry[:root][:ontology_id].split('/').last + entry_uri = entry[:root][:uri] + + if element_ontology_id == entry_ontology_id && element_uri == entry_uri + element[:root][:other_portals] << build_other_portal_entry(entry) + true + else + false + end end end end From e9bf264ba33ac33be37b9e5d4e707d80df3438d6 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:33:13 +0100 Subject: [PATCH 08/20] Fix: Browse page links multi slashes (#873) * fix multislashes added in browse page federation links * ensure trailing slash in federation portals ui and api links * undo extracting normalizing portals urls to a separate function --- app/helpers/federation_helper.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/helpers/federation_helper.rb b/app/helpers/federation_helper.rb index 6b52b7a6b..b1f785c18 100644 --- a/app/helpers/federation_helper.rb +++ b/app/helpers/federation_helper.rb @@ -3,6 +3,11 @@ module FederationHelper def federated_portals $FEDERATED_PORTALS ||= LinkedData::Client.settings.federated_portals + $FEDERATED_PORTALS.each do |key, portal| + portal[:ui] += "/" unless portal[:ui].end_with?("/") + portal[:api] += "/" unless portal[:api].end_with?("/") + end + $FEDERATED_PORTALS end def internal_portal_config(id) @@ -63,7 +68,7 @@ def ontoportal_ui_link(id) ui_link = config[:ui] api_link = config[:api] - id.gsub(api_link, "#{ui_link}/") rescue id + id.gsub(api_link, "#{ui_link}") rescue id end def internal_ontology?(id) From edd1cc0dbaea7ccdb0f1df514c526be3df10f6bf Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:42:13 +0100 Subject: [PATCH 09/20] fix can't change portal language (#871) --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c27651a48..e6182c033 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,7 +27,7 @@ def set_locale cookies.permanent[:locale] = I18n.locale if cookies[:locale].nil? logger.debug "* Locale set to '#{I18n.locale}'" - I18n.locale = portal_lang if portal_language_enabled?(I18n.locale) + I18n.locale = portal_lang unless portal_language_enabled?(I18n.locale) session[:locale] = I18n.locale end @@ -430,7 +430,7 @@ def json_link(url, optional_params) optional_params_str = filtered_params.map { |param, value| "#{param}=#{value}" }.join("&") return base_url + optional_params_str + "&apikey=#{$API_KEY}" end - + def set_federated_portals RequestStore.store[:federated_portals] = params[:portals]&.split(',') end From aec6da841d210289d6eab018b48ba73ffe108956 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:45:40 +0100 Subject: [PATCH 10/20] Fix: `Federated search/browse` results count by portal (#870) * include non canonical portals in counting results for each portal * include non canonical portals in counting results for each portal in federated search * use portal_api and portal_ui in counting federation results instead of portal_name --- app/helpers/federation_helper.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/helpers/federation_helper.rb b/app/helpers/federation_helper.rb index b1f785c18..f0b2fc409 100644 --- a/app/helpers/federation_helper.rb +++ b/app/helpers/federation_helper.rb @@ -219,14 +219,18 @@ def init_federation_portals_status end def federated_search_counts(search_results) - ids = search_results.map do |result| - result.dig(:root, :ontology_id) || rest_url - end + ids = search_results.flat_map do |result| + ontology_id = result.dig(:root, :ontology_id) || rest_url + other_portal_ids = result.dig(:root, :other_portals)&.map { |portal| portal[:link].split('?').first } || [] + [ontology_id] + other_portal_ids + end.uniq counts_ontology_ids_by_portal_name(ids) end def federated_browse_counts(ontologies) - ids = ontologies.map { |ontology| ontology[:id] } + ids = ontologies.flat_map do |ontology| + [ontology[:id]] + (ontology[:sources] || []) + end.uniq counts_ontology_ids_by_portal_name(ids) end @@ -239,8 +243,9 @@ def counts_ontology_ids_by_portal_name(portals_ids) counts[current_portal.downcase] += 1 if id.include?(current_portal.to_s.downcase) federation_portals.each do |portal| - portal_api = federated_portals[portal.downcase.to_sym][:api] - counts[portal.downcase] += 1 if id.include?(portal_api) + portal_api = federated_portals[portal.downcase.to_sym][:api].sub(/^https?:\/\//, '') + portal_ui = federated_portals[portal.downcase.to_sym][:ui].sub(/^https?:\/\//, '') + counts[portal.downcase] += 1 if (id.include?(portal_api) || id.include?(portal_ui)) end end From 34ce85ef2e9a0c12ef6d85bd173c68cd294c8536 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:46:28 +0100 Subject: [PATCH 11/20] Fix: Prevent display home portal tooltip if we get a non complete response (#851) * prevent display home portal tooltip if we get a non complete data * show any info we get from the api in portals home page tooltips --- app/controllers/home_controller.rb | 2 ++ app/views/home/portal_config.html.haml | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 068d217b8..b9737ae8a 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -48,6 +48,8 @@ def portal_config @config = $PORTALS_INSTANCES.select { |x| x[:name].downcase.eql?((params[:portal] || helpers.portal_name).downcase) }.first if @config && @config[:api] @portal_config = LinkedData::Client::Models::Ontology.top_level_links(@config[:api]).to_h + @color = @portal_config[:color].present? ? @portal_config[:color] : @config[:color] + @name = @portal_config[:title].present? ? @portal_config[:title] : @config[:name] else @portal_config = {} end diff --git a/app/views/home/portal_config.html.haml b/app/views/home/portal_config.html.haml index b484e9431..15f04baf1 100644 --- a/app/views/home/portal_config.html.haml +++ b/app/views/home/portal_config.html.haml @@ -4,21 +4,21 @@ .div.d-flex.align-items-center %div %div.text-center - = link_to @portal_config[:ui] || @config[:ui], target: '_blank', class: 'home-logo-instances mr-1 m-0', style: "background-color: #{@portal_config[:color] || @config[:color]}" do + = link_to @portal_config[:ui] || @config[:ui], target: '_blank', class: 'home-logo-instances mr-1 m-0', style: "background-color: #{@color}" do = inline_svg 'logo-white.svg', width: "35", height: "26" %div - %div.portal-configuration-title{style: "color: #{@portal_config[:color] || @config[:color]}"} + %div.portal-configuration-title{style: "color: #{@color}"} %h3 - = @portal_config[:title] || @config[:name] + = @name - if @portal_config[:numberOfArtefacts] .portal-config-ontologies = inline_svg_tag 'icons/ontology.svg' %span = "#{@portal_config[:numberOfArtefacts]} ontologies" - - if @portal_config[:description] + - if @portal_config[:description].present? .portal-description = @portal_config[:description] - - if @portal_config[:federated_portals] + - if @portal_config[:federated_portals].present? %div.mb-1 .home-section-title .text @@ -31,7 +31,7 @@ %p{style: "color: #{portal[:color]}"} = portal[:name] - - if @portal_config[:fundedBy] + - if @portal_config[:fundedBy].present? %div.mb-1 .home-section-title .portal-config-title-text From 0c9adacad094c6897a86373b1980161fe56d0a80 Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Thu, 5 Dec 2024 15:59:41 +0100 Subject: [PATCH 12/20] check FAIRNESS_DISABLED variable when it's string --- app/helpers/fair_score_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/fair_score_helper.rb b/app/helpers/fair_score_helper.rb index ef5b81e2d..b5daf0b3a 100644 --- a/app/helpers/fair_score_helper.rb +++ b/app/helpers/fair_score_helper.rb @@ -5,7 +5,7 @@ def user_apikey end def fairness_service_enabled? - !$FAIRNESS_DISABLED + $FAIRNESS_DISABLED == 'false' || !$FAIRNESS_DISABLED end def get_fairness_service_url(apikey = user_apikey) From 00c804b3a0b937838bfbb1f36c25f06c1fe6ab4d Mon Sep 17 00:00:00 2001 From: MUH <58882014+muhammedBkf@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:08:46 +0100 Subject: [PATCH 13/20] Update `link_to_property` to include `propertyid` in the URL parameters of instances subtab (#878) --- app/helpers/instances_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/instances_helper.rb b/app/helpers/instances_helper.rb index 79e5b1758..18a4dddd2 100644 --- a/app/helpers/instances_helper.rb +++ b/app/helpers/instances_helper.rb @@ -52,7 +52,7 @@ def link_to_class(ontology_acronym, conceptid) def link_to_property(property, ontology_acronym) link_to extract_label_from(property), - ontology_path(ontology_acronym, p: 'properties'), + ontology_path(ontology_acronym, p: 'properties', propertyid: property), { target: '_blank'} end From 6d3f0fa96070bf1fc60d958b6881cb62b09347a8 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:13:54 +0100 Subject: [PATCH 14/20] Fix: display only root categories coming from federation portals in browse page (#877) --- app/controllers/ontologies_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/ontologies_controller.rb b/app/controllers/ontologies_controller.rb index 9d5f26777..92a807fe7 100644 --- a/app/controllers/ontologies_controller.rb +++ b/app/controllers/ontologies_controller.rb @@ -60,11 +60,12 @@ def ontologies_filter end end.flatten - unless request_portals.empty? + unless request_portals.length == 1 streams += [ replace('categories_refresh_for_federation') do key = "categories" objects, checked_values, _ = @filters[key.to_sym] + objects = keep_only_root_categories(objects) helpers.browse_filter_section_body(checked_values: checked_values, key: key, objects: objects, counts: @count_objects[key.to_sym]) @@ -583,4 +584,9 @@ def search_first_instance_id return !results.blank? ? results.first[:name] : nil end + def keep_only_root_categories(categories) + categories.select do |category| + category.id.start_with?(rest_url) || category.parentCategory.blank? + end + end end From c2fa08b045ab12687be3cd9805ee9a0f49cc19af Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Tue, 10 Dec 2024 22:58:00 +0100 Subject: [PATCH 15/20] Feature: add option to enable or disable twitter section (#880) * enable and disable twitter news in home page * make the block as an empty white space --- .env.sample | 2 ++ app/views/home/index.html.haml | 18 +++++++++--------- config/bioportal_config_env.rb.sample | 3 +++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.env.sample b/.env.sample index 6a8e41d24..d63ef287a 100644 --- a/.env.sample +++ b/.env.sample @@ -10,6 +10,8 @@ API_KEY= UI_THEME=ontoportal +TWITTER_NEWS= + BIOMIXER_URL= BIOMIXER_APIKEY= diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 43fc5ff02..b99138af6 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -165,15 +165,15 @@ %a{:href => "/landscape#fairness_assessment"} %div.home-fair-details %p= t('home.fair_details') - - .home-sub-section-right - %h4= t('home.twitter_news') - %hr.home-section-line - .home-card.home-twitter-news - %a.twitter-timeline{"data-height" => "360", :href => "https://twitter.com/lagroportal?ref_src=twsrc%5Etfw"} - .home-twitter-loader - = render LoaderComponent.new(type: 'pulsing') - %script{:async => "", :charset => "utf-8", :src => "https://platform.twitter.com/widgets.js"} + - if !$TWITTER_NEWS.blank? + .home-sub-section-right + %h4= t('home.twitter_news') + %hr.home-section-line + .home-card.home-twitter-news + %a.twitter-timeline{"data-height" => "360", :href => $TWITTER_NEWS} + .home-twitter-loader + = render LoaderComponent.new(type: 'pulsing') + %script{:async => "", :charset => "utf-8", :src => "https://platform.twitter.com/widgets.js"} - if slices_enabled? .home-section diff --git a/config/bioportal_config_env.rb.sample b/config/bioportal_config_env.rb.sample index 8d6c4b52e..80091a5a5 100644 --- a/config/bioportal_config_env.rb.sample +++ b/config/bioportal_config_env.rb.sample @@ -8,6 +8,9 @@ $ORG_URL = ENV['ORG_URL'] # Site name (required) $SITE = ENV['SITE'] +# Twitter section +$TWITTER_NEWS = ENV["TWITTER_NEWS"] + # Full string for site, EX: "NCBO BioPortal", do not modify $ORG_SITE = $ORG.nil? || $ORG.empty? ? $SITE : "#{$ORG} #{$SITE}" From 1576f20c13c15002464661b1af05885ae19048dc Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 10 Dec 2024 23:02:40 +0100 Subject: [PATCH 16/20] Fix: Prevent delete category if still used as parent category (#876) * prevent delete category if still used as parent category * internationalize can't delete category, used as parent category message * extract prevent delete category parent to a helper * rename is_parent? to category_is_parent? --------- Co-authored-by: Syphax --- app/controllers/admin/categories_controller.rb | 9 +++++++++ app/helpers/application_helper.rb | 9 +++++++++ app/views/admin/categories/_category.html.haml | 12 ++++++++---- config/locales/en.yml | 1 + config/locales/fr.yml | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index 1e3ba2ed8..f704248c6 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -11,6 +11,15 @@ class Admin::CategoriesController < ApplicationController def index @categories = _categories + + @parents_list = Hash.new { |hash, key| hash[key] = [] } + @categories.each do |category| + category.parentCategory.each do |parent| + @parents_list[parent] << category.acronym + end + end + + end def new diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c41d1734f..6f66044aa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -451,4 +451,13 @@ def categories_select(id: nil, name: nil, selected: 'None') render Input::SelectComponent.new(id: id, name: name, value: categories_for_select, selected: selected, multiple: true) end + def category_is_parent?(parents_list, category) + is_parent = parents_list.keys.include?(category.id) + parent_error_message = t('admin.categories.category_used_parent') + parents_list[category.id].each do |c| + parent_error_message = "#{parent_error_message} #{c}" + end + [is_parent,parent_error_message] + end + end diff --git a/app/views/admin/categories/_category.html.haml b/app/views/admin/categories/_category.html.haml index 649149ed1..0e812309f 100644 --- a/app/views/admin/categories/_category.html.haml +++ b/app/views/admin/categories/_category.html.haml @@ -1,5 +1,6 @@ %tr.human{:id => category.id.split('/').last} - - count = category.ontologies&.size || 0 + - count = category.ontologies&.size || 0 + - is_parent, parent_error_message = category_is_parent?(@parents_list, category) %td %div{style: 'width: 250px'} %div.text-truncate{title: category.name} @@ -18,8 +19,11 @@ = link_to_modal(nil, edit_admin_category_path(category.id.split('/').last), data: {show_modal_title_value: category.name}) do = t('admin.categories.edit_button') %span - - if count.zero? - = button_to t('admin.categories.delete'), CGI.unescape(admin_category_path(category.id.split('/').last)), method: :delete, class: 'btn btn-link', form: {data: { turbo: true, turbo_confirm: t('admin.categories.turbo_confirm'), turbo_frame: '_top'}} - - else + - if !count.zero? %span{data: { controller: 'tooltip' }, title: t('admin.categories.info_error_delete')} = link_to t('admin.categories.delete'), "", class: 'btn btn-link disabled' + - elsif is_parent + %span{data: { controller: 'tooltip' }, title: parent_error_message} + = link_to t('admin.categories.delete'), "", class: 'btn btn-link disabled' + - else + = button_to t('admin.categories.delete'), CGI.unescape(admin_category_path(category.id.split('/').last)), method: :delete, class: 'btn btn-link', form: {data: { turbo: true, turbo_confirm: t('admin.categories.turbo_confirm'), turbo_frame: '_top'}} diff --git a/config/locales/en.yml b/config/locales/en.yml index 8bcd055c9..188ee057d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -193,6 +193,7 @@ en: problem_of_updating: Problem updating the category - %{message} category_deleted_successfully: Category successfully deleted in %{time}s problem_of_deleting: Problem deleting the category - %{message} + category_used_parent: "Can't delete category, used as a parent category for:" edit_button: "Edit" delete: Delete info_error_delete: Can't delete this category because still used diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d471829cf..8f16f56b3 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -199,6 +199,7 @@ fr: problem_of_updating: Problème lors de la mise à jour de la catégorie - %{message} category_deleted_successfully: Catégorie supprimée avec succès en %{time}s problem_of_deleting: Problème lors de la suppression de la catégorie - %{message} + category_used_parent: "Impossible de supprimer la catégorie, utilisée comme catégorie parente pour:" edit_button: Éditer delete: Supprimer info_error_delete: Impossible de supprimer cette catégorie car elle est encore utilisée From 6fb4988ac947f5663d038941d0774d9d9c960c3b Mon Sep 17 00:00:00 2001 From: Syphax Date: Wed, 11 Dec 2024 04:09:32 +0100 Subject: [PATCH 17/20] update browse page categories_refresh_for_federation condition to work to reset to not federated mod --- app/controllers/ontologies_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/ontologies_controller.rb b/app/controllers/ontologies_controller.rb index 92a807fe7..f47a16500 100644 --- a/app/controllers/ontologies_controller.rb +++ b/app/controllers/ontologies_controller.rb @@ -60,18 +60,20 @@ def ontologies_filter end end.flatten - unless request_portals.length == 1 + if federated_request? streams += [ replace('categories_refresh_for_federation') do - key = "categories" + key = 'categories' objects, checked_values, _ = @filters[key.to_sym] objects = keep_only_root_categories(objects) + helpers.browse_filter_section_body(checked_values: checked_values, key: key, objects: objects, counts: @count_objects[key.to_sym]) end ] end + else streams = [replace("ontologies_list_view-page-#{@page.page}", partial: 'ontologies/browser/ontologies')] end From 7ad09abcbe802748f408691478243272017981b8 Mon Sep 17 00:00:00 2001 From: Syphax Date: Thu, 12 Dec 2024 03:22:19 +0100 Subject: [PATCH 18/20] remove username input from user edit form --- app/views/users/edit.html.haml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index d00e8c61b..570f6e4f4 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -88,10 +88,11 @@ = t('users.edit.last_name') %font{:color => "red"} * = text_field :user, :lastName, value: @user.lastName, class: "register-input-short" - %p.register-input-title - = t('users.edit.username') - %font{:color => "red"} * - = text_field :user, :username, value: @user.username, class: "register-input-long" + %div.hidden + %p.register-input-title + = t('users.edit.username') + %font{:color => "red"} * + = text_field :user, :username, value: @user.username, class: "register-input-long" %p.register-input-title = t('users.edit.email') %font{:color => "red"} * @@ -129,4 +130,4 @@ - unless params[:password].eql?("true") .change-password %a{:href => edit_user_path(@user.username, password: true)} - = t('users.edit.change_password') \ No newline at end of file + = t('users.edit.change_password') From afd56c0e38e2b779702f51d2c7eaf1674cf2aafe Mon Sep 17 00:00:00 2001 From: Syphax Date: Tue, 10 Dec 2024 00:04:17 +0100 Subject: [PATCH 19/20] fix visits page error after changing analytics last month method --- app/views/visits/index.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/visits/index.html.haml b/app/views/visits/index.html.haml index 98c9847fb..1cfc2e5a7 100644 --- a/app/views/visits/index.html.haml +++ b/app/views/visits/index.html.haml @@ -1,7 +1,7 @@ %div.px-3.py-3.pt-md-5.pb-md-4.text-center - %h1.display-4 + %h1.display-4 = t('visits.ontology_visits') - %p.lead (#{@analytics.date.strftime("%B %Y")}) + %p.lead (#{DateTime.now.prev_month.strftime("%B %Y")}) %div.container.pb-3.pb-md-4 %div.table-responsive From 80fc27d50135e125bb4242de97bb39f0627e9fb1 Mon Sep 17 00:00:00 2001 From: Syphax Date: Fri, 13 Dec 2024 00:36:03 +0100 Subject: [PATCH 20/20] fix visits page showing an empty table --- app/views/visits/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/visits/index.html.haml b/app/views/visits/index.html.haml index 1cfc2e5a7..b777d8bef 100644 --- a/app/views/visits/index.html.haml +++ b/app/views/visits/index.html.haml @@ -14,7 +14,7 @@ %tbody - count = 0 - @analytics.onts.each do |visits| - - ont = @ontologies_hash[visits[:ont].to_s] + - ont = @ontologies_hash[visits[:ont].to_s.split('/').last] - next if ont.nil? - count += 1 %tr