From fc6635f8938b89bc9884800ee82a4a73766f1ff3 Mon Sep 17 00:00:00 2001 From: Syphax Date: Fri, 30 Aug 2024 10:45:00 +0200 Subject: [PATCH] update home endpoint to add portal config information --- Gemfile | 4 ++-- Gemfile.lock | 20 +++++++++--------- config/environments/config.rb.sample | 31 ++++++++++++++++++++++++++++ controllers/home_controller.rb | 18 +++++++++++----- docker-compose.yml | 2 +- 5 files changed, 57 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index adaeb43a..2410452a 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'json-ld' # Rack middleware -gem 'ffi' +gem 'ffi', '~> 1.16.3' gem 'rack-accept', '~> 0.4' gem 'rack-attack', '~> 6.6.1', require: 'rack/attack' gem 'rack-cache', '~> 1.13.0' @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/add-portal-config-model' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index b2273ce2..23175a03 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,8 +57,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 9605eb44c4271c60bedda0520e85d8c3fa2513ac - branch: development + revision: d893c08a2c2f11c743fad520873b7f98b0805240 + branch: feature/add-portal-config-model specs: ontologies_linked_data (0.0.1) activesupport @@ -108,7 +108,7 @@ GEM multi_json (~> 1.0) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) - airbrussh (1.5.2) + airbrussh (1.5.3) sshkit (>= 1.6.1, != 1.7.0) backports (3.25.0) base64 (0.2.0) @@ -164,7 +164,7 @@ GEM faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - ffi (1.17.0) + ffi (1.16.3) gapic-common (0.21.1) faraday (>= 1.9, < 3.a) faraday-retry (>= 1.0, < 3.a) @@ -178,7 +178,7 @@ GEM google-analytics-data (0.6.1) google-analytics-data-v1beta (>= 0.11, < 2.a) google-cloud-core (~> 1.6) - google-analytics-data-v1beta (0.13.0) + google-analytics-data-v1beta (0.13.1) gapic-common (>= 0.21.1, < 2.a) google-cloud-errors (~> 1.0) google-apis-analytics_v3 (0.16.0) @@ -236,7 +236,7 @@ GEM kgio (2.11.4) libxml-ruby (5.0.3) link_header (0.0.8) - logger (1.6.0) + logger (1.6.1) macaddr (1.7.2) systemu (~> 2.6.5) mail (2.8.1) @@ -247,7 +247,7 @@ GEM method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2024.0820) + mime-types-data (3.2024.0903) mini_mime (1.1.5) minitest (4.7.5) minitest-stub_any_instance (1.0.3) @@ -258,7 +258,7 @@ GEM mutex_m (0.2.0) net-http-persistent (4.0.2) connection_pool (~> 2.2) - net-imap (0.4.14) + net-imap (0.4.15) date net-protocol net-pop (0.1.2) @@ -273,7 +273,7 @@ GEM net-protocol net-ssh (7.2.3) netrc (0.11.0) - newrelic_rpm (9.12.0) + newrelic_rpm (9.13.0) oj (3.16.1) omni_logger (0.1.4) logger @@ -419,7 +419,7 @@ DEPENDENCIES cube-ruby ed25519 (>= 1.2, < 2.0) faraday (~> 1.9) - ffi + ffi (~> 1.16.3) goo! haml (~> 5.2.2) json-ld diff --git a/config/environments/config.rb.sample b/config/environments/config.rb.sample index f143b8f9..4e7900b7 100644 --- a/config/environments/config.rb.sample +++ b/config/environments/config.rb.sample @@ -87,6 +87,37 @@ LinkedData.config do |config| link: 'https://www.googleapis.com/oauth2/v3/userinfo' } } + config.ui_name = 'Bioportal' + config.title = 'NCBO BioPortal' + config.description = "The world's most comprehensive repository of biomedical ontologies " + config.color = '#234979' + config.logo = '' + config.fundedBy = [ + { + img_src: 'https://identity.stanford.edu/wp-content/uploads/sites/3/2020/07/block-s-right.png', + url: 'https://www.stanford.edu', + + }, + { + img_src: 'https://ontoportal.org/images/logo.png', + url: 'https://ontoportal.org/', + } + ] + config.federated_portals = { + 'agroportal' => { + api: 'http://data.agroportal.lirmm.fr', + ui: 'http://agroportal.lirmm.fr', + apikey: '1cfae05f-9e67-486f-820b-b393dec5764b', + color: '#1e2251' + }, + 'bioportal' => { + api: 'http://data.bioontology.org', + ui: 'http://bioportal.bioontology.org', + apikey: '4a5011ea-75fa-4be6-8e89-f45c8c84844e', + color: '#234979' + }, + + } end Annotator.config do |config| diff --git a/controllers/home_controller.rb b/controllers/home_controller.rb index a44fd22e..140d4522 100644 --- a/controllers/home_controller.rb +++ b/controllers/home_controller.rb @@ -4,7 +4,7 @@ class HomeController < ApplicationController CLASS_MAP = { - Property: "LinkedData::Models::ObjectProperty" + Property: "LinkedData::Models::ObjectProperty" } namespace "/" do @@ -28,14 +28,22 @@ class HomeController < ApplicationController next if route.length < 3 || route.split("/").length > 2 route_no_slash = route.gsub("/", "") context[route_no_slash] = route_to_class_map[route].type_uri.to_s if route_to_class_map[route] && route_to_class_map[route].respond_to?(:type_uri) - routes_hash[route_no_slash] = LinkedData.settings.rest_url_prefix+route_no_slash + routes_hash[route_no_slash] = LinkedData.settings.rest_url_prefix + route_no_slash end - routes_hash["@context"] = context - reply ({links: routes_hash}) + + config = LinkedData::Models::PortalConfig.current_portal_config + + federated_portals = config.federated_portals + federated_portals. transform_values! { |v| v.delete(:apikey) ; v } + config.init_federated_portals_settings(federated_portals) + + config.class.link_to *routes_hash.map { |key, url| LinkedData::Hypermedia::Link.new(key, url, context[key]) } + + reply config end get "documentation" do - @metadata_all = metadata_all.sort {|a,b| a[0].name <=> b[0].name} + @metadata_all = metadata_all.sort { |a, b| a[0].name <=> b[0].name } haml "documentation/documentation".to_sym, :layout => "documentation/layout".to_sym end diff --git a/docker-compose.yml b/docker-compose.yml index 564fc8d2..07b0cda1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,7 +49,7 @@ services: - "9393:9393" volumes: # bundle volume for hosting gems installed by bundle; it speeds up gem install in local development - - app_api:/srv/ontoportal/ontologies_api + - .:/srv/ontoportal/ontologies_api - repository:/srv/ontoportal/data/repository ncbo_cron: