Skip to content

Commit

Permalink
Merge branch 'fix/federated-search-merging-results' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal committed Nov 25, 2024
2 parents fd9e330 + 21fdebb commit 0441ac8
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 19 deletions.
1 change: 0 additions & 1 deletion app/assets/stylesheets/components/tree_view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions app/components/federated_portal_button_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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")
9 changes: 6 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 15 additions & 12 deletions app/controllers/concerns/search_aggregator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/federation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 0441ac8

Please sign in to comment.