From 0fe90bafbc7d3fad73400e038f36300364e2c9c8 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Thu, 17 Oct 2024 14:57:35 -0700 Subject: [PATCH 01/28] add application-esbuild to asset manifest --- app/assets/config/manifest.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 2c35fb2c34..fa68bb112b 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -5,3 +5,4 @@ //= link bp_annotatorplus.js //= link vendor.js //= link_directory ../stylesheets .css +//= link application-esbuild.js From 0fce2aaeeb776fad2944f2b4b312f20c81d41aeb Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Thu, 17 Oct 2024 15:25:03 -0700 Subject: [PATCH 02/28] use ncbo/ontologies_api_ruby_client --- Gemfile | 2 +- Gemfile.lock | 40 +++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Gemfile b/Gemfile index 9e0a869317..19656dc700 100644 --- a/Gemfile +++ b/Gemfile @@ -104,7 +104,7 @@ gem 'flag-icons-rails', '~> 3.4' gem 'iso-639', '~> 0.3.6' # Custom API client -gem 'ontologies_api_client', git: 'https://github.com/ontoportal-lirmm/ontologies_api_ruby_client.git', branch: 'master' +gem 'ontologies_api_client', github: 'ncbo/ontologies_api_ruby_client', tag: 'v2.4.0' # Ruby 2.7.8 pinned gems (to remove when migrating to Ruby >= 3.0) gem 'ffi', '~> 1.16.3' diff --git a/Gemfile.lock b/Gemfile.lock index 604a4594ac..602d39cc31 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,18 +1,18 @@ GIT - remote: https://github.com/ontoportal-lirmm/ontologies_api_ruby_client.git - revision: 24fb2549f7b69841e052491439bc8375ed5acfd9 - branch: master + remote: https://github.com/ncbo/ontologies_api_ruby_client.git + revision: f589b13dfbbc133ea67cbae1a8f92b41ea85c14b + tag: v2.4.0 specs: - ontologies_api_client (2.2.0) - activesupport + ontologies_api_client (2.4.0) + activesupport (= 7.0.8) + addressable (~> 2.8) excon faraday - faraday-excon (~> 2.0.0) + faraday-excon faraday-multipart lz4-ruby multi_json oj - spawnling (= 2.1.5) GEM remote: https://rubygems.org/ @@ -92,6 +92,7 @@ GEM execjs (~> 2) base64 (0.2.0) bcrypt_pbkdf (1.1.1) + bcrypt_pbkdf (1.1.1-arm64-darwin) bigdecimal (3.1.8) bindata (2.5.0) bindex (0.8.1) @@ -160,17 +161,15 @@ GEM erubis (2.7.0) excon (0.112.0) execjs (2.9.1) - faraday (2.0.1) - faraday-net_http (~> 2.0) + faraday (2.0.0) ruby2_keywords (>= 0.0.4) - faraday-excon (2.0.0) + faraday-excon (2.1.0) excon (>= 0.27.4) - faraday (~> 2.0.0.alpha.pre.2) + faraday (~> 2.0) faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (2.1.0) ffi (1.16.3) flag-icons-rails (3.4.6.1) sass-rails @@ -238,7 +237,7 @@ GEM jsbundling-rails (1.3.1) railties (>= 6.0.0) json (2.7.2) - json-jwt (1.16.6) + json-jwt (1.16.7) activesupport (>= 4.2) aes_key_wrap base64 @@ -303,7 +302,7 @@ GEM time net-http (0.3.2) uri - net-imap (0.4.16) + net-imap (0.4.17) date net-protocol net-pop (0.1.2) @@ -320,6 +319,8 @@ GEM netrc (0.11.0) newrelic_rpm (9.14.0) nio4r (2.7.3) + nokogiri (1.15.6-arm64-darwin) + racc (~> 1.4) nokogiri (1.15.6-x86_64-linux) racc (~> 1.4) oauth2 (2.0.9) @@ -373,7 +374,7 @@ GEM puma (5.6.9) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.9) + rack (2.2.10) rack-protection (3.2.0) base64 (>= 0.1.0) rack (~> 2.2, >= 2.2.4) @@ -447,7 +448,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - rubocop (1.66.1) + rubocop (1.67.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -494,7 +495,6 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - spawnling (2.1.5) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -502,7 +502,7 @@ GEM actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) - sshkit (1.23.1) + sshkit (1.23.2) base64 net-scp (>= 1.1.2) net-sftp (>= 2.1.2) @@ -521,7 +521,7 @@ GEM time (0.4.0) date timeout (0.4.1) - turbo-rails (2.0.10) + turbo-rails (2.0.11) actionpack (>= 6.0.0) railties (>= 6.0.0) tzinfo (2.0.6) @@ -553,6 +553,8 @@ GEM zeitwerk (2.6.18) PLATFORMS + arm64-darwin-22 + x86_64-linux x86_64-linux-musl DEPENDENCIES From eb6a4b404645e2f8c010cde0daebc99f669b112a Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Thu, 17 Oct 2024 21:54:02 -0700 Subject: [PATCH 03/28] Disable BPIDResolver The pull request https://github.com/ontoportal/ontoportal_web_ui/pull/21 removed files that this class depends on. This is a temporary workaround until https://github.com/ncbo/bioportal_web_ui/issues/337 is implemented. --- app/models/bpid_resolver.rb | 43 ++----------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/app/models/bpid_resolver.rb b/app/models/bpid_resolver.rb index 644a84c476..db73b4b7e0 100644 --- a/app/models/bpid_resolver.rb +++ b/app/models/bpid_resolver.rb @@ -1,45 +1,6 @@ # frozen_string_literal: true -require 'cgi' -require 'ostruct' -require 'json' -require 'open-uri' - class BPIDResolver - require "#{Rails.root}/lib/resolver/acronym_from_virtual" - require "#{Rails.root}/lib/resolver/virtual_from_acronym" - require "#{Rails.root}/lib/resolver/virtual_from_version" - - def self.id_to_acronym(id) - acronym_from_virtual_id(id) or acronym_from_version_id(id) - end - - def self.acronym_to_virtual_id(acronym) - virtual_id_from_acronym(acronym) - end - - class << self - private - - def acronym_from_id(id) - acronym_from_virtual_id(id) or acronym_from_version_id(id) - end - - def acronym_from_virtual_id(virtual_id) - ACRONYM_FROM_VIRTUAL["old:acronym_from_virtual:#{virtual_id}"] - end - - def acronym_from_version_id(version_id) - virtual = virtual_id_from_version_id(version_id) - acronym_from_virtual_id(virtual) - end - - def virtual_id_from_version_id(version_id) - VIRTUAL_FROM_VERSION["old:virtual_from_version:#{version_id}"] - end - - def virtual_id_from_acronym(acronym) - VIRTUAL_FROM_ACRONYM["old:virtual_from_acronym:#{acronym}"] - end - end + # deprecated; see https://github.com/ncbo/bioportal_web_ui/issues/337 + nil end From 4a972b542672f6f71738ab9f157da944ab222184 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Thu, 17 Oct 2024 23:01:25 -0700 Subject: [PATCH 04/28] pin gem for compatibility --- Gemfile | 22 +++++++++++++--------- Gemfile.lock | 10 ++++++---- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index 19656dc700..d73752663d 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,7 @@ gem 'sassc-rails' # sass-rails replacement gem 'terser' # uglifier replacement # Bootstrap front-end framework -gem 'bootstrap', '~> 5.2.3' +gem 'bootstrap', '~> 5.2.3' # jQuery integration for Rails gem 'jquery-rails' @@ -67,7 +67,6 @@ gem 'dalli' gem 'graphql', '~> 2.0.27' gem 'graphql-client' - # Haml template engine for Ruby on Rails gem 'haml', '~> 5.1' @@ -106,10 +105,19 @@ gem 'iso-639', '~> 0.3.6' # Custom API client gem 'ontologies_api_client', github: 'ncbo/ontologies_api_ruby_client', tag: 'v2.4.0' +# compatibilty pin https://github.com/ncbo/bioportal_web_ui/issues/293 +gem 'base64', '0.1.0' +gem 'rexml', '~> 3' + # Ruby 2.7.8 pinned gems (to remove when migrating to Ruby >= 3.0) -gem 'ffi', '~> 1.16.3' -gem 'net-ftp', '~> 0.2.0', require: false -gem 'net-http', '~> 0.3.2' +# gem 'ffi', '~> 1.16.3' +# gem 'net-ftp', '~> 0.2.0', require: false +# gem 'net-http', '~> 0.3.2' + +gem 'ffi' +gem 'net-ftp', require: false +gem 'net-http' + # Multi-Provider Authentication gem 'omniauth' @@ -125,10 +133,6 @@ group :staging, :production, :appliance do # Error monitoring gem 'bugsnag', '~> 6.26' - - # Logs in JSON format, useful for shipping logs to logstash - # gem 'rackstash', git: 'https://github.com/planio-gmbh/rackstash.git' - # gem 'logstash-logger' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 602d39cc31..94b5c03887 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,7 +90,7 @@ GEM ast (2.4.2) autoprefixer-rails (10.4.19.0) execjs (~> 2) - base64 (0.2.0) + base64 (0.1.0) bcrypt_pbkdf (1.1.1) bcrypt_pbkdf (1.1.1-arm64-darwin) bigdecimal (3.1.8) @@ -558,6 +558,7 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES + base64 (= 0.1.0) bcrypt_pbkdf (>= 1.0, < 2.0) bootsnap bootstrap (~> 5.2.3) @@ -576,7 +577,7 @@ DEPENDENCIES debug deepl-rb ed25519 (>= 1.2, < 2.0) - ffi (~> 1.16.3) + ffi flag-icons-rails (~> 3.4) graphql (~> 2.0.27) graphql-client @@ -596,8 +597,8 @@ DEPENDENCIES lookbook (~> 1.5.5) multi_json mysql2 - net-ftp (~> 0.2.0) - net-http (~> 0.3.2) + net-ftp + net-http newrelic_rpm oj omniauth @@ -613,6 +614,7 @@ DEPENDENCIES rails-i18n (~> 7.0.0) recaptcha (~> 5.9.0) rest-client + rexml (~> 3) rspec-rails rubocop sassc-rails From b6cfd5af40265da9dda60d8a62514b5763d8076a Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Mon, 21 Oct 2024 22:30:38 -0700 Subject: [PATCH 05/28] disable tests for features that are not yet implemented --- .../controllers/ontologies_controller_test.rb | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/controllers/ontologies_controller_test.rb b/test/controllers/ontologies_controller_test.rb index b286994b0e..9364348bc7 100644 --- a/test/controllers/ontologies_controller_test.rb +++ b/test/controllers/ontologies_controller_test.rb @@ -4,7 +4,11 @@ class OntologiesControllerTest < ActionDispatch::IntegrationTest ONTOLOGIES = LinkedData::Client::Models::Ontology.all(include: 'acronym') - PAGES = %w[summary classes properties notes mappings schemes collections widgets].freeze + # ONTOLOGIES = LinkedData::Client::Models::Ontology.find_by_acronym('NCIT', include: 'acronym') + # + # PAGES: schemes, collections are not yet implemented + #PAGES = %w[summary classes properties notes mappings schemes collections widgets].freeze + PAGES = %w[summary classes properties notes mappings widgets].freeze test 'should return all the ontologies' do get ontologies_path @@ -24,6 +28,7 @@ class OntologiesControllerTest < ActionDispatch::IntegrationTest end test "should open the tree views of #{ont.acronym} ontology" do + skip('functionality not yet implemented') paths = [ ajax_classes_treeview_path(ontology: ont.acronym), "/ontologies/#{ont.acronym}/properties" @@ -41,12 +46,14 @@ class OntologiesControllerTest < ActionDispatch::IntegrationTest end test 'test get STY in html format' do + skip('functionality not yet implemented') get '/ontologies/STY', headers: { 'Accept' => 'text/html' } assert_response :success assert_equal 'text/html; charset=utf-8', response.content_type end test 'test get STY in json format' do + skip('functionality not yet implemented') get '/ontologies/STY', headers: { 'Accept' => 'application/json' } assert_response :success assert_equal 'application/json', response.content_type @@ -54,52 +61,60 @@ class OntologiesControllerTest < ActionDispatch::IntegrationTest end test 'test get STY in xml format' do + skip('functionality not yet implemented') get '/ontologies/STY', headers: { 'Accept' => 'application/xml' } assert_equal 500, response.status # STY has only Turtle end test 'test get STY in csv format' do + skip('functionality not yet implemented') get '/ontologies/STY', headers: { 'Accept' => 'text/csv' } assert_response :success end test 'test get STY in turtle format' do + skip('functionality not yet implemented') get '/ontologies/STY', headers: { 'Accept' => 'text/turtle' } assert_response :success end test 'test get STY in ntriples format' do + skip('functionality not yet implemented') get '/ontologies/STY', headers: { 'Accept' => 'application/ntriples' } assert_response :not_acceptable end - test 'test get STY resource in html format' do + skip('test does not account for variation of PURL settings across OntoPortal instances') get '/ontologies/STY/T071', headers: { 'Accept' => 'text/html' } assert_includes ["http://www.example.com/ontologies/STY?conceptid=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FSTY%2FT071&p=classes", "http://www.example.com/ontologies/STY?conceptid=http%3A%2F%2Fpurl.lirmm.fr%2Fontology%2FSTY%2FT071&p=classes"], response.location assert_response :redirect assert_equal "text/html; charset=utf-8" , response.content_type end - + test 'test get STY resource in json format' do + skip('functionality not yet implemented') get '/ontologies/STY/T071', headers: { 'Accept' => 'application/json' } assert_response :success assert_equal "application/ld+json; charset=utf-8" , response.content_type end test 'test get STY resource in xml format' do + skip('functionality not yet implemented') get '/ontologies/STY/T071', headers: { 'Accept' => 'application/xml' } assert_response :success assert_equal "application/rdf+xml; charset=utf-8" , response.content_type end test 'test get STY resource in ntriples format' do + skip('functionality not yet implemented') get '/ontologies/STY/T071', headers: { 'Accept' => 'application/n-triples' } assert_response :success assert_equal "application/n-triples; charset=utf-8" , response.content_type end test 'test get STY resource in turtle format' do + skip('functionality not yet implemented') get '/ontologies/STY/T071', headers: { 'Accept' => 'text/turtle' } assert_response :success assert_equal "text/turtle; charset=utf-8" , response.content_type From 9fa10f2f135a97ffd101f0d62500e4b3fa9da5a7 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 23 Oct 2024 11:24:15 -0700 Subject: [PATCH 06/28] remove temp workaround --- app/assets/config/manifest.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 0aa3e0594e..6240ea468e 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -7,4 +7,3 @@ //= link_tree ../images //= link_directory ../javascripts .js //= link_directory ../stylesheets .css -//= link application-esbuild.js From 6466658479fbe19a28ca67398688f4e8267753c0 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 23 Oct 2024 15:47:31 -0700 Subject: [PATCH 07/28] Add option to test a specific set of ontologies Provide the ability to specify a list of ontologies to test instead of testing all ontologies. This is useful when testing APIs with a large number of ontologies. --- .env.sample | 4 +++- test/controllers/ontologies_controller_test.rb | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.env.sample b/.env.sample index e8c76bf363..5259fdb7e9 100644 --- a/.env.sample +++ b/.env.sample @@ -40,4 +40,6 @@ API_IMAGE_REPOSITORY=agroportal ## Image tag/version from which the ontoportal api will be built API_IMAGE_TAG=master - +## Tests +# List of Ontologies to test in test/controllers/ontologies_controller_test.rb +# ONTOLOGIES_TO_TEST="NCIT,GO,SNOMEDCT" diff --git a/test/controllers/ontologies_controller_test.rb b/test/controllers/ontologies_controller_test.rb index 9364348bc7..e1cd39cc3b 100644 --- a/test/controllers/ontologies_controller_test.rb +++ b/test/controllers/ontologies_controller_test.rb @@ -3,9 +3,16 @@ require 'test_helper' class OntologiesControllerTest < ActionDispatch::IntegrationTest - ONTOLOGIES = LinkedData::Client::Models::Ontology.all(include: 'acronym') - # ONTOLOGIES = LinkedData::Client::Models::Ontology.find_by_acronym('NCIT', include: 'acronym') - # + ONTOLOGIES = [] + if ENV['ONTOLOGIES_TO_TEST'].nil? + ONTOLOGIES.concat(LinkedData::Client::Models::Ontology.all(include: 'acronym')) + else + ontologies_to_test = ENV['ONTOLOGIES_TO_TEST']&.split(',')&.map(&:strip) + ontologies_to_test.each do | ont | + ONTOLOGIES << LinkedData::Client::Models::Ontology.find(ont, include: 'acronym') + end + end + # PAGES: schemes, collections are not yet implemented #PAGES = %w[summary classes properties notes mappings schemes collections widgets].freeze PAGES = %w[summary classes properties notes mappings widgets].freeze From f730111e6c53acc57d281383cdf903e9359acf73 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Tue, 29 Oct 2024 16:56:49 -0700 Subject: [PATCH 08/28] docker refactor Dockerfile: * Change ruby image OS from Alpine to Debian slim-bookworm. Alpine is effective for reducing image size; however, using the slim version of Debian achieves a similar reduction. We can further reduce image size by adopting staged builds and moving Node/Yarn into a separate build stage. * Use ruby 3.2 * Removed docker binaries from the image. * Set bundler gem path to /usr/local/bundle docker-compose: * Add internal/external networks * Make node a non-runtime dependency * Do not expose ports for caching/db by default config: * Add development and test config files. Config files are redesigend to be used with .env so is safe to add --- .dockerignore | 7 +- Dockerfile | 61 ++--- config/bioportal_config_development.rb | 309 +++++++++++++++++++++++++ config/bioportal_config_test.rb | 219 ++++++++++++++++++ docker-compose.yml | 70 +++--- 5 files changed, 601 insertions(+), 65 deletions(-) create mode 100644 config/bioportal_config_development.rb create mode 100644 config/bioportal_config_test.rb diff --git a/.dockerignore b/.dockerignore index 8cdea307d3..6fb9c295b3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ .git/ +.github/ log/* !log/.keep app/assets/builds/* @@ -21,5 +22,9 @@ yarn-error.log yarn-debug.log* .yarn-integrity +# Ruby version is set in Dockerfile +.ruby-version + config/credentials/* -config/credentials.yml.enc \ No newline at end of file +config/credentials.yml.enc + diff --git a/Dockerfile b/Dockerfile index 2eb0ea3ba7..a4e20e4ab2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,53 +1,54 @@ # Make sure it matches the Ruby version in .ruby-version and Gemfile -ARG RUBY_VERSION=3.2.0 -FROM ruby:${RUBY_VERSION}-alpine - -# Install libvips for Active Storage preview support -RUN apk add --no-cache build-base \ - libxml2-dev \ - libxslt-dev \ - mariadb-dev \ - git \ - tzdata \ - nodejs yarn \ - less \ - bash \ - docker \ - docker-compose \ - && mkdir /node_modules - -# Rails app lives here +ARG RUBY_VERSION=3.2 +FROM ruby:${RUBY_VERSION}-slim-bookworm + WORKDIR /app -# Set production environment +RUN bash -c "set -o pipefail && apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential \ + libxml2 \ + libxslt-dev \ + libmariadb-dev \ + git \ + curl \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /etc/apt/keyrings/nodesource.asc \ + && echo 'deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.com/node_20.x nodistro main' | tee /etc/apt/sources.list.d/nodesource.list \ + && apt-get update \ + && apt-get install -y --no-install-recommends nodejs \ + && corepack enable \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ + && mkdir /node_modules" + ARG RAILS_ENV="production" +ARG NODE_ENV="production" ARG BUNDLE_WITHOUT="development test" ENV RAILS_LOG_TO_STDOUT="1" \ RAILS_SERVE_STATIC_FILES="true" \ RAILS_ENV="${RAILS_ENV}" \ + NODE_ENV="${NODE_ENV}" \ BUNDLE_PATH=/usr/local/bundle \ BUNDLE_WITHOUT="${BUNDLE_WITHOUT}" -RUN gem update --system 3.4.22 # the 3.4.22 can be removed if we support Ruby version > 3.0 - -COPY . . - +#PATH="${PATH}:/node_modules/.bin" +COPY Gemfile* . RUN bundle install -RUN yarn install && yarn build +COPY package.json *yarn* . +RUN yarn install +COPY . . RUN cp config/bioportal_config_env.rb.sample config/bioportal_config_production.rb RUN cp config/bioportal_config_env.rb.sample config/bioportal_config_development.rb RUN cp config/database.yml.sample config/database.yml -# Precompile bootsnap code for faster boot times -RUN bundle exec bootsnap precompile --gemfile app/ lib/ - -RUN SECRET_KEY_BASE_DUMMY="1" ./bin/rails assets:precompile +RUN if [ "${RAILS_ENV}" != "development" ]; then \ + bundle exec bootsnap precompile --gemfile app/ lib/ && \ + SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile; fi -ENV BINDING="0.0.0.0" EXPOSE 3000 -CMD ["bash"] \ No newline at end of file +CMD ["rails", "s"] diff --git a/config/bioportal_config_development.rb b/config/bioportal_config_development.rb new file mode 100644 index 0000000000..2e09613a1e --- /dev/null +++ b/config/bioportal_config_development.rb @@ -0,0 +1,309 @@ +# Organization info +$ORG = ENV['ORG'] +$ORG_URL = ENV['ORG_URL'] + +# Site name (required) +$SITE = ENV['SITE'] + +# Full string for site, EX: "NCBO BioPortal", do not modify +$ORG_SITE = $ORG.nil? || $ORG.empty? ? $SITE : "#{$ORG} #{$SITE}" + +# The URL for the BioPortal Rails UI (this application) +$UI_URL = ENV['UI_URL'] + +# If you are running a PURL server to provide URLs for ontologies in your BioPortal instance, enable this option +$PURL_ENABLED = false +# The PURL URL is generated using this prefix + the abbreviation for an ontology. +# The PURL URL generation algorithm can be altered in app/models/ontology_wrapper.rb +$PURL_PREFIX = 'http://purl.bioontology.org/ontology' + + +# If your BioPortal installation includes Annotator set this to false +$ANNOTATOR_DISABLED = false +# Unique string representing the UI's id for use with the BioPortal Core +$API_KEY = ENV['API_KEY'] +# BioPortal API service address +$REST_URL = ENV['API_URL'] + +# Annotator REST service address +# $ANNOTATOR_URL = "http://services.stageportal.lirmm.fr/annotator" +$ANNOTATOR_URL = $PROXY_URL = ENV['ANNOTATOR_URL'] +# NCBO annotator URL and apikey +$NCBO_ANNOTATORPLUS_ENABLED = ENV['NCBO_ANNOTATORPLUS_ENABLED'] +$NCBO_ANNOTATOR_URL = ENV['NCBO_ANNOTATOR_URL'] +$NCBO_API_KEY = ENV['NCBO_API_KEY'] + +# Fairness Assessment. +$FAIRNESS_DISABLED = ENV['FAIRNESS_DISABLED'] +$FAIRNESS_URL = ENV['FAIRNESS_URL'] + +# Used to define other bioportal that can be mapped to +# Example to map to ncbo bioportal : {"ncbo" => {"api" => "http://data.bioontology.org", "ui" => "http://bioportal.bioontology.org", "apikey" => ""} +# Then create the mapping using the following class in JSON : "http://purl.bioontology.org/ontology/MESH/C585345": "ncbo:MESH" +# Where "ncbo" is the namespace used as key in the interportal_hash +$INTERPORTAL_HASH = {} + +$NOT_DOWNLOADABLE = {} + +# Bugsnag API key for monitoring exception +#$BUGSNAG_API_KEY= + +# OAuth2 authentication +$OMNIAUTH_PROVIDERS = { + github: { + client_id: 'CLIENT_ID', + client_secret: 'CLIENT_SECRET', + icon: 'github.svg', + enable: true + }, + google: { + strategy: :google_oauth2, + client_id: 'CLIENT_ID', + client_secret: 'CLIENT_SECRET', + icon: 'google.svg', + enable: true + }, + orcid: { + client_id: 'CLIENT_SECRET', + client_secret: 'CLIENT_SECRET', + icon: 'orcid.svg', + enable: false + }, + keycloak: { + strategy: :keycloak_openid, + client_id: 'YOUR_KEYCLOAK_CLIENT_ID', + client_secret: 'YOUR_KEYCLOAK_CLIENT_SECRET', + client_options: { site: 'KEYCLOAK_SITE', realm: 'KEYCLOAK_REALM' }, + name: 'keycloak', + icon: 'keycloak.svg', + enable: false + } +}.freeze + +# Don't load and don't display recent mappings if false, in case of too many mappings (take longer to load homepage) +$DISPLAY_RECENT = false + +# If true then the UI will get available recognize at API_URL/annotators/recognizers +$MULTIPLE_RECOGNIZERS = false + +# Remove download for these ontologies. Default: +# ["CPT","ICD10","ICNP","ICPC2P","MDDB","MEDDRA","MSHFRE","MSHSPA_1","NDDF","NDFRT","NIC","RCD","SCTSPA","SNOMEDCT","WHO-ART"] +$RESTRICTED_DOWNLOADS = [] + +# Ontolobridge endpoint url +$ONTOLOBRIDGE_BASE_URL = 'https://ontolobridge.ccs.miami.edu/api-test/requests' +# Ontolobridge authentication token +$ONTOLOBRIDGE_AUTHENTICATION_TOKEN = 'Token Uq2pae73ktMtmgjUgtnhEOuHxr9sZeuK' + +# Ontologies for which to enable the new term request (Ontolobridge) tab +$NEW_TERM_REQUEST_ONTOLOGIES = [] + +# Legacy REST core service address (BioPortal v3.x and lower) +$LEGACY_REST_URL = 'http://example.org:8080/bioportal' + +# Release version text (appears in footer of all pages, except 404 and 500 errors) +$RELEASE_VERSION = ENV['RELEASE_VERSION'] + +# Enable Slices, filtering of ontologies based on subdomain and ontology groups +$ENABLE_SLICES = false + +# Google Analytics ID (optional) +$ANALYTICS_ID = ENV['ANALYTICS_ID'] + +# Enable client request caching +$CLIENT_REQUEST_CACHING = true + +# Email settings +ActionMailer::Base.smtp_settings = { + address: '', # smtp server address, ex: smtp.example.org + port: 25, # smtp server port + domain: '' # fqdn of rails server, ex: rails.example.org +} +# Announcements mailman mailing list REQUEST address, EX: list-request@lists.example.org +# NOTE: You must use the REQUEST address for the mailing list. ONLY WORKS WITH MAILMAN LISTS. +$ANNOUNCE_LIST = ENV['SUPPORT_EMAIL'] +# Email addresses used for sending notifications (errors, feedback, support) +$SUPPORT_EMAIL = ENV['SUPPORT_EMAIL'] +# Email used to send notifications +$NOTIFICATION_EMAIL = ENV['SUPPORT_EMAIL'] + + + +# reCAPTCHA +# In order to use reCAPTCHA on the account creation and feedback submission pages: +# 1. Obtain a reCAPTCHA v2 key from: https://www.google.com/recaptcha/admin +# 2. Put the site and secret keys in the encrypted credentials file: +# +# recaptcha: +# site_key: your_site_key +# secret_key: your_secret_key +# +# 3. Set the USE_RECAPTCHA option to 'true' +ENV['USE_RECAPTCHA'] = 'false' +# Custom BioPortal logging +require 'log' + +# URL where BioMixer GWT app is located +# $BIOMIXER_URL = "http://bioportal-integration.bio-mixer.appspot.com" +$BIOMIXER_URL = ENV['BIOMIXER_URL'] +$BIOMIXER_APIKEY = ENV['BIOMIXER_APIKEY'] + +## +# Custom Ontology Details +# Custom details can be added on a per ontology basis using a key/value pair as columns of the details table +# +# Example: +# $ADDITIONAL_ONTOLOGY_DETAILS = { "STY" => { "Additional Detail" => "Text to be shown in the right-hand column." } } +## +$ADDITIONAL_ONTOLOGY_DETAILS = {} + +# Front notice appears on the front page only and is closable by the user. It remains closed for seven days (stored in cookie) +$FRONT_NOTICE = '' +# Site notice appears on all pages and remains closed indefinitely. Stored below as a hash with a unique key and a string message +# EX: $SITE_NOTICE = { :unique_key => 'Put your message here (can include html if you use single quotes).' } +$SITE_NOTICE = {} + +$TERMS_AND_CONDITIONS_LINK = 'https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq' +$CITE_ANNOTATOR = 'https://hal.science/hal-00492024' +$ANNOTATOR_API_DOC = 'https://data.agroportal.lirmm.fr/documentation#nav_annotator' +$CITE_RECOMMENDER = 'https://doi.org/10.1186/s13326-017-0128-y' +# Resource term +$RESOURCE_TERM = ENV['RESOURCE_TERM'] || 'ontology' + +$HOME_PAGE_LOGOS = [ + { + img_src: 'logos/supports/numev.png', + url: 'http://www.lirmm.fr/numev', + target: '_blank' + }, + { + img_src: 'logos/supports/anr.png', + url: 'https://anr.fr/en', + target: '_blank' + }, + { + img_src: 'logos/supports/eu.png', + url: 'https://commission.europa.eu/research-and-innovation_en', + target: '_blank' + }, + { + img_src: 'logos/collaboration/d2kab.png', + url: 'http://d2kab.mystrikingly.com', + target: '_blank' + }, + { + img_src: 'logos/collaboration/lirmm.png', + url: 'http://www.lirmm.fr', + target: '_blank' + }, + { + img_src: 'logos/collaboration/inrae.png', + url: 'https://www.inrae.fr/enm', + target: '_blank' + }, + { + img_src: 'logos/collaboration/stanford.png', + url: 'https://www.stanford.edu', + target: '_blank' + } +] + +$PORTALS_INSTANCES = [ + { + color: '#31b403', + portal: 'AgroPortal', + link: 'https://agroportal.lirmm.fr/' + }, + { + color: '#234979', + portal: 'BioPortal', + link: 'https://bioportal.bioontology.org/' + }, + { + color: '#74a9cb', + portal: 'SIFR BioPortal', + link: 'https://bioportal.lirmm.fr/' + }, + { + color: '#0d508a', + portal: 'EcoPortal', + link: 'https://ecoportal.lifewatch.eu/' + }, + { + color: '#234979', + portal: 'MedPortal', + link: 'http://medportal.bmicc.cn/' + }, + { + color: '#009574', + portal: 'MatPortal', + link: 'https://matportal.org/' + }, + { + color: '#1c0f5d', + portal: 'IndustryPortal', + link: 'http://industryportal.enit.fr' + }, + { + color: '#1e2251', + portal: 'EarthPortal', + link: 'https://earthportal.eu/' + }, + { + color: '#33691B', + portal: 'BiodivPortal', + link: 'https://biodivportal.gfbio.org/' + } +] + +$ONTOPORTAL_WEBSITE_LINK = "https://ontoportal.org/" +$ONTOPORTAL_GITHUB_REPO = "https://github.com/ontoportal" + +$GITHUB_ISSUES = "https://github.com/agroportal/project-management/issues" +$FOOTER_LINKS = { + social: [ + { logo: "social/people.svg", link: "https://github.com/orgs/agroportal/people" }, + { logo: "social/github.svg", link: "https://github.com/agroportal" }, + { logo: "social/twitter.svg", link: "https://twitter.com/lagroportal" }, + { logo: "json.svg", link: $REST_URL }, + { logo: "summary/sparql.svg", link: "#{$SPARQL_URL}"}, + { logo: "social/email.svg", link: "mailto:#{$ANNOUNCE_LIST}" }, + ], + sections: { + products: { + release_notes: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/release-notes-btKjZk5tU2", + api: "https://data.agroportal.lirmm.fr/", + tools: "/tools", + sparql: "https://sparql.agroportal.lirmm.fr/test/", + ontoportal: $ONTOPORTAL_WEBSITE_LINK + }, + support: { + contact_us: "https://#{$SITE}.lirmm.fr/feedback", + documentation: "https://ontoportal.github.io/documentation/", + agro_documentation: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/public-documentation-QMpsC9aVBb", + issues_and_requests: $GITHUB_ISSUES + }, + agreements: { + terms: $TERMS_AND_CONDITIONS_LINK, + privacy_policy: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq#h-privacy-policy", + legal_notices: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq#h-legal-notice" + }, + about: { + about_us: "https://github.com/agroportal/project-management", + team: "https://github.com/orgs/agroportal/people", + cite_us: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/publications-and-references-87tEoeoGKy", + acknowledgments: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/acknowledgments-15GdRXLQdm" + } + } +} + +$UI_THEME = ENV['UI_THEME'] || 'ontoportal' +$HOSTNAME = ENV['API_URL'] + +if $HOSTNAME + $HOSTNAME = ENV['API_URL'].split('data.').last + # add custom stage server configuration if needed (e.g bioportal_config_development_stageportal.lirmm.fr) + if File.exist?("config/bioportal_config_development_#{$HOSTNAME}") + require_relative "bioportal_config_development_#{$HOSTNAME}" + end +end diff --git a/config/bioportal_config_test.rb b/config/bioportal_config_test.rb new file mode 100644 index 0000000000..91ed16b4df --- /dev/null +++ b/config/bioportal_config_test.rb @@ -0,0 +1,219 @@ +# frozen_string_literal: true + +$SITE = 'Testportal' +$HOSTNAME = 'testportal' +$UI_HOSTNAME = 'localhost' +$UI_URL = "http://#{$UI_HOSTNAME}:3000" + +$API_KEY = ENV['API_KEY'] +$REST_URL = ENV['API_URL'] +$BIOMIXER_URL = ENV['BIOMIXER_URL'] +$ANNOTATOR_URL = $PROXY_URL = ENV['ANNOTATOR_URL'].blank? ? "https://services.tesportal.lirmm.fr/annotator" : ENV['ANNOTATOR_URL'] +$FAIRNESS_URL = ENV['FAIRNESS_URL'] + +# Resource term +$RESOURCE_TERM = ENV['RESOURCE_TERM'] || 'ontology' + +# config/initializers/omniauth_providers.rb +$OMNIAUTH_PROVIDERS = { + github: { + client_id: 'CLIENT_ID', + client_secret: 'CLIENT_SECRET', + icon: 'github.svg', + enable: true + }, + google: { + strategy: :google_oauth2, + client_id: 'CLIENT_ID', + client_secret: 'CLIENT_SECRET', + icon: 'google.svg', + enable: true + }, + orcid: { + client_id: 'CLIENT_SECRET', + client_secret: 'CLIENT_SECRET', + icon: 'orcid.svg', + enable: false + }, + keycloak: { + strategy: :keycloak_openid, + client_id: 'YOUR_KEYCLOAK_CLIENT_ID', + client_secret: 'YOUR_KEYCLOAK_CLIENT_SECRET', + client_options: { site: 'KEYCLOAK_SITE', realm: 'KEYCLOAK_REALM' }, + name: 'keycloak', + icon: 'keycloak.svg', + enable: false + } +}.freeze + +$INTERPORTAL_HASH = {} + +# If your BioPortal installation includes Fairness score set this to true +$FAIRNESS_DISABLED = false + +# Pairing a name with an array of ontology virtual ids will allow you to filter ontologies based on a subdomain. +# If your main UI is hosted at example.org and you add custom.example.org pointing to the same Rails installation +# you could filter the ontologies visible at custom.example.org by adding this to the hash: "custom" => { :name => "Custom Slice", :ontologies => [1032, 1054, 1099] } +# Any number of slices can be added. Groups are added automatically using the group acronym as the subdomain. +$ENABLE_SLICES = false +$ONTOLOGY_SLICES = {} + + +$NOT_DOWNLOADABLE = {} +# Enable client request caching +$CLIENT_REQUEST_CACHING = true + +# If you don't use Airbrake you can have exceptions emailed to the $ERROR_EMAIL address by setting this to 'true' +$EMAIL_EXCEPTIONS = false + +# Announcements mailman mailing list REQUEST address, EX: list-request@lists.example.org +# NOTE: You must use the REQUEST address for the mailing list. ONLY WORKS WITH MAILMAN LISTS. +$ANNOUNCE_LIST ||= 'appliance-users-request@localhost' + +# Email addresses used for sending notifications (errors, feedback, support) +$SUPPORT_EMAIL ||= 'support@localhost' +$ADMIN_EMAIL ||= 'admin@localhost' +$ERROR_EMAIL ||= 'errors@localhost' + +# Custom BioPortal logging +require 'log' +$REMOTE_LOGGING = false + +## +# Custom Ontology Details +# Custom details can be added on a per ontology basis using a key/value pair as columns of the details table +# +# Example: +# $ADDITIONAL_ONTOLOGY_DETAILS = { 1000 => { "Additional Detail" => "Text to be shown in the right-hand column." } } +## +$ADDITIONAL_ONTOLOGY_DETAILS = {} + +# Site notice appears on all pages and remains closed indefinitely. Stored below as a hash with a unique key and a +# EX: $SITE_NOTICE = { :unique_key => 'Put your message here (can include html if you use +$SITE_NOTICE = {} +################################ +## AUTO-GENERATED DO NOT MODIFY +################################# + +# Full string for site, EX: "NCBO BioPortal" +$ORG_SITE = $ORG.nil? || $ORG.empty? ? $SITE : "#{$ORG} #{$SITE}" + +$HOME_PAGE_LOGOS = [ + { + img_src: 'logos/supports/numev.png', + url: 'http://www.lirmm.fr/numev', + target: '_blank' + }, + { + img_src: 'logos/supports/anr.png', + url: 'https://anr.fr/en', + target: '_blank' + }, + { + img_src: 'logos/supports/eu.png', + url: 'https://commission.europa.eu/research-and-innovation_en', + target: '_blank' + }, + { + img_src: 'logos/collaboration/d2kab.png', + url: 'http://d2kab.mystrikingly.com', + target: '_blank' + }, + { + img_src: 'logos/collaboration/lirmm.png', + url: 'http://www.lirmm.fr', + target: '_blank' + }, + { + img_src: 'logos/collaboration/inrae.png', + url: 'https://www.inrae.fr/enm', + target: '_blank' + }, + { + img_src: 'logos/collaboration/stanford.png', + url: 'https://www.stanford.edu', + target: '_blank' + } +] + +$FOOTER_LINKS = { + social: [ + { logo: 'social/people.svg', link: 'https://github.com/orgs/agroportal/people' }, + { logo: 'social/github.svg', link: 'https://github.com/agroportal' }, + { logo: 'social/twitter.svg', link: 'https://twitter.com/lagroportal' } + ], + sections: { + products: { + ontoportal: 'https://ontoportal.org/', + release_notes: 'https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/release-notes-btKjZk5tU2', + api: 'https://data.agroportal.lirmm.fr/', + sparql: 'https://sparql.agroportal.lirmm.fr/test/' + }, + support: { + contact_us: 'https://agroportal.lirmm.fr/feedback', + wiki: 'https://www.bioontology.org/wiki/', + documentation: 'https://ontoportal.github.io/documentation/' + }, + agreements: { + terms: '', + privacy_policy: '', + cite_us: '', + acknowledgments: '' + }, + about: { + about_us: 'https://github.com/agroportal/project-management', + projects: 'https://d2kab.mystrikingly.com/', + team: 'https://github.com/orgs/agroportal/people' + } + } +} + +$PORTALS_INSTANCES = [ + { + color: '#31b403', + portal: 'AgroPortal', + link: 'https://agroportal.lirmm.fr/' + }, + { + color: '#234979', + portal: 'BioPortal', + link: 'https://bioportal.bioontology.org/' + }, + { + color: '#74a9cb', + portal: 'SIFR BioPortal', + link: 'https://bioportal.lirmm.fr/' + }, + { + color: '#0d508a', + portal: 'EcoPortal', + link: 'https://ecoportal.lifewatch.eu/' + }, + { + color: '#234979', + portal: 'MedPortal', + link: 'http://medportal.bmicc.cn/' + }, + { + color: '#009574', + portal: 'MatPortal', + link: 'https://matportal.org/' + }, + { + color: '#1c0f5d', + portal: 'IndustryPortal', + link: 'http://industryportal.enit.fr' + }, + { + color: '#1e2251', + portal: 'EarthPortal', + link: 'https://earthportal.eu/' + }, + { + color: '#33691B', + portal: 'BiodivPortal', + link: 'https://biodivportal.gfbio.org/' + } +] + +$UI_THEME = :stageportal \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 3c70bbe887..85abfe54ae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,25 +1,22 @@ x-app: &default-app - image: agroportal/ontoportal_web_ui:master + image: bioportal/ontoportal_web_ui:0.0.7 env_file: - ".env" tty: true volumes: - - bundle:/srv/ontoportal/bundle + - bundle:/usr/local/bundle - node:/node_modules - rails_cache:/app/tmp/cache - assets:/app/public/assets - - /var/run/docker.sock:/var/run/docker.sock - .:/app depends_on: db: condition: service_healthy cache: condition: service_started - node: - condition: service_started environment: &env BUNDLE_WITHOUT: "" - BUNDLE_PATH: /srv/ontoportal/bundle + BUNDLE_PATH: /usr/local/bundle DB_HOST: db CACHE_HOST: cache tmpfs: @@ -30,11 +27,11 @@ services: db: image: "mysql:8.0" networks: - - default + - internal volumes: - mysql-data:/var/lib/mysql - ports: - - "3306:3306" + # ports: + # - "3306:3306" environment: MYSQL_ROOT_PASSWORD: root healthcheck: @@ -47,27 +44,28 @@ services: restart: unless-stopped command: ["-m", "1024"] networks: - - default - ports: - - "11211:11211" + - internal + # ports: + # - "11211:11211" + node: <<: *default-app command: "yarn build --watch" - depends_on: - - cache - - db dev: <<: *default-app + networks: + - internal + - external ports: - "3000:3000" - links: - - db - - cache production: <<: *default-app command: "bundle exec puma -C config/puma.rb" + networks: + - internal + - external environment: <<: *env RAILS_ENV: "production" @@ -79,14 +77,11 @@ services: MEMCACHE_SERVERS: "cache:11211" ports: - "3000:3000" - links: - - db - - cache - depends_on: - db: - condition: service_healthy - cache: - condition: service_started + # depends_on: + # db: + # condition: service_healthy + # cache: + # condition: service_started volumes: - node:/node_modules - rails_cache:/app/tmp/cache @@ -95,15 +90,18 @@ services: test: <<: *default-app - depends_on: - - db - - cache - - chrome-server - network_mode: "host" environment: - BUNDLE_WITHOUT: "" - DB_HOST: 127.0.0.1 - CACHE_HOST: 127.0.0.1 + <<: *env + depends_on: + db: + condition: service_healthy + cache: + condition: service_started + chrome-server: + condition: service_started + networks: + - internal + - external chrome-server: image: selenium/standalone-chrome:112.0-chromedriver-112.0-grid-4.9.0-20230421 @@ -113,6 +111,10 @@ services: # - "4444:4444" # - "7900:7900" +networks: + internal: + external: + volumes: mysql-data: bundle: From 6d4169a15f3cc054734f1445f7e7fd1d415ef366 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 31 Oct 2024 13:56:59 -0700 Subject: [PATCH 09/28] Initial commit of change request attribution --- app/controllers/change_requests_controller.rb | 4 +++- app/lib/kgcl/renderers/new_synonym_content.rb | 8 ++++++++ app/lib/kgcl/renderers/node_obsoletion_content.rb | 8 ++++++++ app/lib/kgcl/renderers/node_rename_content.rb | 8 ++++++++ app/lib/kgcl/renderers/remove_synonym_content.rb | 8 ++++++++ app/lib/kgcl/templates/footer.erb | 9 +++++++++ app/lib/kgcl/templates/new_synonym_body.erb | 5 ++--- app/lib/kgcl/templates/node_obsoletion_body.erb | 5 ++--- app/lib/kgcl/templates/node_rename_body.erb | 5 ++--- app/lib/kgcl/templates/remove_synonym_body.erb | 5 ++--- app/views/change_requests/_create_synonym.html.haml | 4 +++- app/views/change_requests/_node_obsoletion.html.haml | 4 +++- app/views/change_requests/_node_rename.html.haml | 4 +++- app/views/change_requests/_remove_synonym.html.haml | 4 +++- 14 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 app/lib/kgcl/templates/footer.erb diff --git a/app/controllers/change_requests_controller.rb b/app/controllers/change_requests_controller.rb index d46738a251..80fbe96081 100644 --- a/app/controllers/change_requests_controller.rb +++ b/app/controllers/change_requests_controller.rb @@ -60,6 +60,8 @@ def set_common_instance_variables @concept_label = params[:concept_label] @concept_id = params[:concept_id] @ont_acronym = params[:ont_acronym] - @username = session[:user].username + @user = LinkedData::Client::Models::User.get( + session[:user].id, include: 'username,githubId,orcidId', display_links: 'false', display_context: 'false' + ) end end diff --git a/app/lib/kgcl/renderers/new_synonym_content.rb b/app/lib/kgcl/renderers/new_synonym_content.rb index d8da90f477..7871ba4df9 100644 --- a/app/lib/kgcl/renderers/new_synonym_content.rb +++ b/app/lib/kgcl/renderers/new_synonym_content.rb @@ -48,6 +48,14 @@ def get_binding binding end + def github_id + @params[:github_id] + end + + def orcid_id + @params[:orcid_id] + end + def qualifier @params[:create_synonym][:qualifier] end diff --git a/app/lib/kgcl/renderers/node_obsoletion_content.rb b/app/lib/kgcl/renderers/node_obsoletion_content.rb index cf51fbc0de..86506e51f6 100644 --- a/app/lib/kgcl/renderers/node_obsoletion_content.rb +++ b/app/lib/kgcl/renderers/node_obsoletion_content.rb @@ -45,6 +45,14 @@ def get_binding binding end + def github_id + @params[:github_id] + end + + def orcid_id + @params[:orcid_id] + end + def username @params[:username] end diff --git a/app/lib/kgcl/renderers/node_rename_content.rb b/app/lib/kgcl/renderers/node_rename_content.rb index c2dfd4c97a..4f2e24e568 100644 --- a/app/lib/kgcl/renderers/node_rename_content.rb +++ b/app/lib/kgcl/renderers/node_rename_content.rb @@ -41,6 +41,14 @@ def get_binding binding end + def github_id + @params[:github_id] + end + + def orcid_id + @params[:orcid_id] + end + def new_concept_label @params[:node_rename][:new_preferred_name] end diff --git a/app/lib/kgcl/renderers/remove_synonym_content.rb b/app/lib/kgcl/renderers/remove_synonym_content.rb index f8ae83b003..cddefd8aea 100644 --- a/app/lib/kgcl/renderers/remove_synonym_content.rb +++ b/app/lib/kgcl/renderers/remove_synonym_content.rb @@ -43,6 +43,14 @@ def get_binding binding end + def github_id + @params[:github_id] + end + + def orcid_id + @params[:orcid_id] + end + def synonym_label @params[:remove_synonym][:synonym] end diff --git a/app/lib/kgcl/templates/footer.erb b/app/lib/kgcl/templates/footer.erb new file mode 100644 index 0000000000..e6aaf8d3f9 --- /dev/null +++ b/app/lib/kgcl/templates/footer.erb @@ -0,0 +1,9 @@ +**Comment:** <%= comment %> + +<% if github_id.present? %> +Proposal generated by: @<%= github_id %> +<% else %> +Proposal generated by: BioPortal user '<%= username %>' +<% end %> + +ORCID: <%= orcid_id %> \ No newline at end of file diff --git a/app/lib/kgcl/templates/new_synonym_body.erb b/app/lib/kgcl/templates/new_synonym_body.erb index b36f06ed68..ddd9d7d472 100644 --- a/app/lib/kgcl/templates/new_synonym_body.erb +++ b/app/lib/kgcl/templates/new_synonym_body.erb @@ -4,6 +4,5 @@ --- -Comment: <%= comment %> - -This request comes from BioPortal user: <%= username %> \ No newline at end of file +<% footer_template = File.read("#{Rails.root}/app/lib/kgcl/templates/footer.erb") %> +<%= ERB.new(footer_template, trim_mode: '<>', eoutvar: 'footer').result(binding) %> \ No newline at end of file diff --git a/app/lib/kgcl/templates/node_obsoletion_body.erb b/app/lib/kgcl/templates/node_obsoletion_body.erb index e293952193..7702614461 100644 --- a/app/lib/kgcl/templates/node_obsoletion_body.erb +++ b/app/lib/kgcl/templates/node_obsoletion_body.erb @@ -4,6 +4,5 @@ --- -Comment: <%= comment %> - -This request comes from BioPortal user: <%= username %> \ No newline at end of file +<% footer_template = File.read("#{Rails.root}/app/lib/kgcl/templates/footer.erb") %> +<%= ERB.new(footer_template, trim_mode: '<>', eoutvar: 'footer').result(binding) %> \ No newline at end of file diff --git a/app/lib/kgcl/templates/node_rename_body.erb b/app/lib/kgcl/templates/node_rename_body.erb index f84a22c3fb..c748d11369 100644 --- a/app/lib/kgcl/templates/node_rename_body.erb +++ b/app/lib/kgcl/templates/node_rename_body.erb @@ -4,6 +4,5 @@ --- -Comment: <%= comment %> - -This request comes from BioPortal user: <%= username %> \ No newline at end of file +<% footer_template = File.read("#{Rails.root}/app/lib/kgcl/templates/footer.erb") %> +<%= ERB.new(footer_template, trim_mode: '<>', eoutvar: 'footer').result(binding) %> \ No newline at end of file diff --git a/app/lib/kgcl/templates/remove_synonym_body.erb b/app/lib/kgcl/templates/remove_synonym_body.erb index c8a9b49d37..bf730ed590 100644 --- a/app/lib/kgcl/templates/remove_synonym_body.erb +++ b/app/lib/kgcl/templates/remove_synonym_body.erb @@ -4,6 +4,5 @@ --- -Comment: <%= comment %> - -This request comes from BioPortal user: <%= username %> \ No newline at end of file +<% footer_template = File.read("#{Rails.root}/app/lib/kgcl/templates/footer.erb") %> +<%= ERB.new(footer_template, trim_mode: '<>', eoutvar: 'footer').result(binding) %> \ No newline at end of file diff --git a/app/views/change_requests/_create_synonym.html.haml b/app/views/change_requests/_create_synonym.html.haml index 7c00f40bdf..ddb5b32fda 100644 --- a/app/views/change_requests/_create_synonym.html.haml +++ b/app/views/change_requests/_create_synonym.html.haml @@ -5,8 +5,10 @@ = form_with scope: :create_synonym, url: change_requests_path, local: false do |f| = hidden_field_tag 'concept_id', @concept_id = hidden_field_tag 'concept_label', @concept_label + = hidden_field_tag 'github_id', @user.githubId = hidden_field_tag 'ont_acronym', @ont_acronym - = hidden_field_tag 'username', @username + = hidden_field_tag 'orcid_id', @user.orcidId + = hidden_field_tag 'username', @user.username = hidden_field_tag 'operation', KGCL::Operations::NEW_SYNONYM %div{class: 'modal-body'} %div.mb-3 diff --git a/app/views/change_requests/_node_obsoletion.html.haml b/app/views/change_requests/_node_obsoletion.html.haml index 80f98f4a9b..c59877fb60 100644 --- a/app/views/change_requests/_node_obsoletion.html.haml +++ b/app/views/change_requests/_node_obsoletion.html.haml @@ -1,8 +1,10 @@ = form_with scope: :node_obsoletion, url: change_requests_path, local: false, class: 'mb-5' do |f| = hidden_field_tag 'concept_id', @concept_id = hidden_field_tag 'concept_label', @concept_label + = hidden_field_tag 'github_id', @user.githubId = hidden_field_tag 'ont_acronym', @ont_acronym - = hidden_field_tag 'username', @username + = hidden_field_tag 'orcid_id', @user.orcidId + = hidden_field_tag 'username', @user.username = hidden_field_tag 'operation', KGCL::Operations::NODE_OBSOLETION %div.mb-2 = f.label :comment, "Proposal: obsolete '#{@concept_label}'", for: 'node_obsoletion_comment', class: 'form-label' diff --git a/app/views/change_requests/_node_rename.html.haml b/app/views/change_requests/_node_rename.html.haml index dca4e874fe..ba1da7251f 100644 --- a/app/views/change_requests/_node_rename.html.haml +++ b/app/views/change_requests/_node_rename.html.haml @@ -2,8 +2,10 @@ = form_with scope: :node_rename, url: change_requests_path, local: false, class: 'mb-5' do |f| = hidden_field_tag 'concept_id', @concept_id = hidden_field_tag 'concept_label', @concept_label + = hidden_field_tag 'github_id', @user.githubId = hidden_field_tag 'ont_acronym', @ont_acronym - = hidden_field_tag 'username', @username + = hidden_field_tag 'orcid_id', @user.orcidId + = hidden_field_tag 'username', @user.username = hidden_field_tag 'operation', KGCL::Operations::NODE_RENAME %div.mb-3 = f.label :new_preferred_name, 'Preferred name', class: 'form-label' diff --git a/app/views/change_requests/_remove_synonym.html.haml b/app/views/change_requests/_remove_synonym.html.haml index 39254fad3d..1e53b342d5 100644 --- a/app/views/change_requests/_remove_synonym.html.haml +++ b/app/views/change_requests/_remove_synonym.html.haml @@ -5,8 +5,10 @@ = form_with scope: :remove_synonym, url: change_requests_path, local: false do |f| = hidden_field_tag 'concept_id', @concept_id = hidden_field_tag 'concept_label', @concept_label + = hidden_field_tag 'github_id', @user.githubId = hidden_field_tag 'ont_acronym', @ont_acronym - = hidden_field_tag 'username', @username + = hidden_field_tag 'orcid_id', @user.orcidId + = hidden_field_tag 'username', @user.username = hidden_field_tag 'operation', KGCL::Operations::REMOVE_SYNONYM %div{class: 'modal-body'} %div.mb-3 From 571410b8cc9724d100fbeac4eac11f37d164892b Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Fri, 1 Nov 2024 14:48:05 -0700 Subject: [PATCH 10/28] Add a base class for common methods --- app/lib/kgcl/renderers/issue_content.rb | 56 +++++++++++++++++++ app/lib/kgcl/renderers/new_synonym_content.rb | 45 +++------------ .../kgcl/renderers/node_obsoletion_content.rb | 41 ++------------ app/lib/kgcl/renderers/node_rename_content.rb | 41 +++----------- .../kgcl/renderers/remove_synonym_content.rb | 41 +++----------- 5 files changed, 82 insertions(+), 142 deletions(-) create mode 100644 app/lib/kgcl/renderers/issue_content.rb diff --git a/app/lib/kgcl/renderers/issue_content.rb b/app/lib/kgcl/renderers/issue_content.rb new file mode 100644 index 0000000000..597e81d23c --- /dev/null +++ b/app/lib/kgcl/renderers/issue_content.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module KGCL + module Renderers + # Base class for generating GitHub issue content for ontology change requests + class IssueContent + attr_reader :params + + def initialize(params) + @params = params + end + + def render + tr = KGCL::TemplateRenderer.new( + title_template: title_template, + body_template: body_template, + bind_klass: self + ) + tr.render + end + + def concept_id + @params[:concept_id] + end + + def concept_label + @params[:concept_label] + end + + def curie + @params[:curie] + end + + def github_id + @params[:github_id] + end + + def orcid_id + @params[:orcid_id] + end + + def username + @params[:username] + end + + # These methods should be defined in subclasses to provide unique templates + def title_template + raise NotImplementedError, 'Subclasses must define a title_template' + end + + def body_template + raise NotImplementedError, 'Subclasses must define a body_template' + end + end + end +end diff --git a/app/lib/kgcl/renderers/new_synonym_content.rb b/app/lib/kgcl/renderers/new_synonym_content.rb index 7871ba4df9..de149adafe 100644 --- a/app/lib/kgcl/renderers/new_synonym_content.rb +++ b/app/lib/kgcl/renderers/new_synonym_content.rb @@ -12,50 +12,15 @@ module Renderers # # @see https://github.com/INCATools/kgcl KGCL documentation # - class NewSynonymContent - attr_reader :params - - def initialize(params) - @params = params - end - - def render - tr = KGCL::TemplateRenderer.new( - title_template: 'new_synonym_title.erb', - body_template: 'new_synonym_body.erb', - bind_klass: self - ) - tr.render - end - + class NewSynonymContent < IssueContent def comment @params[:create_synonym][:comment] end - def concept_id - @params[:concept_id] - end - - def concept_label - @params[:concept_label] - end - - def curie - @params[:curie] - end - def get_binding binding end - def github_id - @params[:github_id] - end - - def orcid_id - @params[:orcid_id] - end - def qualifier @params[:create_synonym][:qualifier] end @@ -64,8 +29,12 @@ def synonym_label @params[:create_synonym][:preferred_label] end - def username - @params[:username] + def title_template + 'new_synonym_title.erb' + end + + def body_template + 'new_synonym_body.erb' end end end diff --git a/app/lib/kgcl/renderers/node_obsoletion_content.rb b/app/lib/kgcl/renderers/node_obsoletion_content.rb index 86506e51f6..ca0b8fe3fb 100644 --- a/app/lib/kgcl/renderers/node_obsoletion_content.rb +++ b/app/lib/kgcl/renderers/node_obsoletion_content.rb @@ -9,52 +9,21 @@ module Renderers # # @see https://github.com/INCATools/kgcl KGCL documentation # - class NodeObsoletionContent - attr_reader :params - - def initialize(params) - @params = params - end - - def render - tr = KGCL::TemplateRenderer.new( - title_template: 'node_obsoletion_title.erb', - body_template: 'node_obsoletion_body.erb', - bind_klass: self - ) - tr.render - end - + class NodeObsoletionContent < IssueContent def comment @params[:node_obsoletion][:comment] end - def concept_id - @params[:concept_id] - end - - def concept_label - @params[:concept_label] - end - - def curie - @params[:curie] - end - def get_binding binding end - def github_id - @params[:github_id] - end - - def orcid_id - @params[:orcid_id] + def title_template + 'node_obsoletion_title.erb' end - def username - @params[:username] + def body_template + 'node_obsoletion_body.erb' end end end diff --git a/app/lib/kgcl/renderers/node_rename_content.rb b/app/lib/kgcl/renderers/node_rename_content.rb index 4f2e24e568..9315284f89 100644 --- a/app/lib/kgcl/renderers/node_rename_content.rb +++ b/app/lib/kgcl/renderers/node_rename_content.rb @@ -9,52 +9,25 @@ module Renderers # # @see https://github.com/INCATools/kgcl KGCL documentation # - class NodeRenameContent - attr_reader :params - - def initialize(params) - @params = params - end - - def render - tr = KGCL::TemplateRenderer.new( - title_template: 'node_rename_title.erb', - body_template: 'node_rename_body.erb', - bind_klass: self - ) - tr.render - end - + class NodeRenameContent < IssueContent def comment @params[:node_rename][:comment] end - def concept_label - @params[:concept_label] - end - - def curie - @params[:curie] - end - def get_binding binding end - def github_id - @params[:github_id] - end - - def orcid_id - @params[:orcid_id] - end - def new_concept_label @params[:node_rename][:new_preferred_name] end - def username - @params[:username] + def title_template + 'node_rename_title.erb' + end + + def body_template + 'node_rename_body.erb' end end end diff --git a/app/lib/kgcl/renderers/remove_synonym_content.rb b/app/lib/kgcl/renderers/remove_synonym_content.rb index cddefd8aea..84d9e4da23 100644 --- a/app/lib/kgcl/renderers/remove_synonym_content.rb +++ b/app/lib/kgcl/renderers/remove_synonym_content.rb @@ -11,52 +11,25 @@ module Renderers # # @see https://github.com/INCATools/kgcl KGCL documentation # - class RemoveSynonymContent - attr_reader :params - - def initialize(params) - @params = params - end - - def render - tr = KGCL::TemplateRenderer.new( - title_template: 'remove_synonym_title.erb', - body_template: 'remove_synonym_body.erb', - bind_klass: self - ) - tr.render - end - + class RemoveSynonymContent < IssueContent def comment @params[:remove_synonym][:comment] end - def concept_label - @params[:concept_label] - end - - def curie - @params[:curie] - end - def get_binding binding end - def github_id - @params[:github_id] - end - - def orcid_id - @params[:orcid_id] - end - def synonym_label @params[:remove_synonym][:synonym] end - def username - @params[:username] + def title_template + 'remove_synonym_title.erb' + end + + def body_template + 'remove_synonym_body.erb' end end end From fdab109d8dd6cf27bc2804383efa8ac909fe7907 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Fri, 1 Nov 2024 15:34:54 -0700 Subject: [PATCH 11/28] Fix unit tests --- spec/lib/issue_content_generator_spec.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/lib/issue_content_generator_spec.rb b/spec/lib/issue_content_generator_spec.rb index 1f6298b6e5..4198a8f923 100644 --- a/spec/lib/issue_content_generator_spec.rb +++ b/spec/lib/issue_content_generator_spec.rb @@ -20,9 +20,11 @@ --- - Comment: Please add this! + **Comment:** Please add this! - This request comes from BioPortal user: Daenerys Targaryen + Proposal generated by: BioPortal user 'Daenerys Targaryen' + + ORCID: HEREDOC content = KGCL::IssueContentGenerator.call(params) @@ -36,6 +38,8 @@ curie: 'MONDO:0009662', concept_label: 'mucopolysaccharidosis type 7', username: 'Sansa Stark', + github_id: 'sstark', + orcid_id: '0000-1234-5678-0000', remove_synonym: { synonym: 'Gus deficiency', comment: "I don't think this is correct!" } } @@ -47,9 +51,11 @@ --- - Comment: I don't think this is correct! + **Comment:** I don't think this is correct! + + Proposal generated by: @sstark - This request comes from BioPortal user: Sansa Stark + ORCID: 0000-1234-5678-0000 HEREDOC content = KGCL::IssueContentGenerator.call(params) From 14942a16c298f30aed972f132f6c5b1359b0dd89 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Wed, 6 Nov 2024 16:39:52 -0800 Subject: [PATCH 12/28] Convert some UJS to Turbo Streams and Stimulus --- app/controllers/change_requests_controller.rb | 6 +++--- .../controllers/change_requests_controller.js | 10 ++++++++++ app/javascript/controllers/index.js | 3 +++ app/views/change_requests/_node_obsoletion.html.haml | 5 +++-- app/views/change_requests/_node_rename.html.haml | 5 +++-- app/views/change_requests/create.js.erb | 3 --- app/views/change_requests/create.turbo_stream.haml | 4 ++++ app/views/change_requests/node_obsoletion.js.erb | 10 ---------- .../change_requests/node_obsoletion.turbo_stream.haml | 2 ++ app/views/change_requests/node_rename.js.erb | 10 ---------- .../change_requests/node_rename.turbo_stream.haml | 2 ++ app/views/concepts/_details.html.haml | 7 ++++--- 12 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 app/javascript/controllers/change_requests_controller.js delete mode 100644 app/views/change_requests/create.js.erb create mode 100644 app/views/change_requests/create.turbo_stream.haml delete mode 100644 app/views/change_requests/node_obsoletion.js.erb create mode 100644 app/views/change_requests/node_obsoletion.turbo_stream.haml delete mode 100644 app/views/change_requests/node_rename.js.erb create mode 100644 app/views/change_requests/node_rename.turbo_stream.haml diff --git a/app/controllers/change_requests_controller.rb b/app/controllers/change_requests_controller.rb index 80fbe96081..33833e11b8 100644 --- a/app/controllers/change_requests_controller.rb +++ b/app/controllers/change_requests_controller.rb @@ -5,11 +5,11 @@ class ChangeRequestsController < ApplicationController before_action :set_common_instance_variables, except: [:create] def node_obsoletion - respond_to :js + respond_to :turbo_stream end def node_rename - respond_to :js + respond_to :turbo_stream end def create_synonym @@ -27,7 +27,7 @@ def create @issue = IssueCreatorService.call(params) flash.now.notice = helpers.change_request_success_message if @issue['id'].present? - respond_to :js + respond_to :turbo_stream end private diff --git a/app/javascript/controllers/change_requests_controller.js b/app/javascript/controllers/change_requests_controller.js new file mode 100644 index 0000000000..d573ad58fb --- /dev/null +++ b/app/javascript/controllers/change_requests_controller.js @@ -0,0 +1,10 @@ +import { Controller } from "@hotwired/stimulus" + +// Connects to data-controller="change-requests" +export default class extends Controller { + static targets = [ 'addProposalForm' ] + + clearProposalForm() { + this.addProposalFormTarget.innerHTML = ''; + } +} diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index c4d0fd2b2e..dc2be48f56 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -4,5 +4,8 @@ import { application } from "./application" +import ChangeRequestsController from "./change_requests_controller" +application.register("change-requests", ChangeRequestsController) + import ClipboardController from "./clipboard_controller" application.register("clipboard", ClipboardController) diff --git a/app/views/change_requests/_node_obsoletion.html.haml b/app/views/change_requests/_node_obsoletion.html.haml index c59877fb60..182a0e2fac 100644 --- a/app/views/change_requests/_node_obsoletion.html.haml +++ b/app/views/change_requests/_node_obsoletion.html.haml @@ -1,4 +1,4 @@ -= form_with scope: :node_obsoletion, url: change_requests_path, local: false, class: 'mb-5' do |f| += form_with scope: :node_obsoletion, url: change_requests_path, data: {turbo: true}, class: 'mb-5' do |f| = hidden_field_tag 'concept_id', @concept_id = hidden_field_tag 'concept_label', @concept_label = hidden_field_tag 'github_id', @user.githubId @@ -11,4 +11,5 @@ = f.text_area :comment, rows: 5, class: 'form-control' %div.form-text Optionally enter a comment describing the reason for obsoletion = submit_tag 'Submit', id: 'node_obsoletion_button', class: 'btn btn-primary' - = tag.button 'Cancel', type: 'button', id: 'cancel_kgcl_proposal', class: 'btn btn-primary' + = tag.button('Cancel', type: 'button', + 'data-action': 'click->change-requests#clearProposalForm', class: 'btn btn-primary') diff --git a/app/views/change_requests/_node_rename.html.haml b/app/views/change_requests/_node_rename.html.haml index ba1da7251f..7be776f9b1 100644 --- a/app/views/change_requests/_node_rename.html.haml +++ b/app/views/change_requests/_node_rename.html.haml @@ -1,5 +1,5 @@ = tag.p("Proposal: rename '#{@concept_label}'", class: 'lead') -= form_with scope: :node_rename, url: change_requests_path, local: false, class: 'mb-5' do |f| += form_with scope: :node_rename, url: change_requests_path, data: {turbo: true}, class: 'mb-5' do |f| = hidden_field_tag 'concept_id', @concept_id = hidden_field_tag 'concept_label', @concept_label = hidden_field_tag 'github_id', @user.githubId @@ -18,4 +18,5 @@ = tag.div('Optionally enter a comment giving a reason for the rename', class: 'form-text', id: 'nodeRenameCommentHelpBlock') = submit_tag 'Submit', id: 'node_rename_button', class: 'btn btn-primary' - = tag.button 'Cancel', type: 'button', id: 'cancel_kgcl_proposal', class: 'btn btn-primary' + = tag.button('Cancel', type: 'button', + 'data-action': 'click->change-requests#clearProposalForm', class: 'btn btn-primary') diff --git a/app/views/change_requests/create.js.erb b/app/views/change_requests/create.js.erb deleted file mode 100644 index ce26058fdd..0000000000 --- a/app/views/change_requests/create.js.erb +++ /dev/null @@ -1,3 +0,0 @@ -jQuery("#details_content #change-request-notice").html('<%= j render partial: "notice" %>'); - -document.getElementById('addProposalFormDiv').innerHTML = ''; \ No newline at end of file diff --git a/app/views/change_requests/create.turbo_stream.haml b/app/views/change_requests/create.turbo_stream.haml new file mode 100644 index 0000000000..fd7669d806 --- /dev/null +++ b/app/views/change_requests/create.turbo_stream.haml @@ -0,0 +1,4 @@ += turbo_stream.update 'change-request-notice' do + = render partial: 'notice' + += turbo_stream.update 'addProposalFormDiv' diff --git a/app/views/change_requests/node_obsoletion.js.erb b/app/views/change_requests/node_obsoletion.js.erb deleted file mode 100644 index 4e0fdc21ea..0000000000 --- a/app/views/change_requests/node_obsoletion.js.erb +++ /dev/null @@ -1,10 +0,0 @@ -let forms = document.getElementById('addProposalFormDiv').getElementsByTagName('form'); -if (forms.length === 0) { - document.getElementById('addProposalFormDiv') - .insertAdjacentHTML('afterbegin', '<%= j render 'change_requests/node_obsoletion' %>'); -} - -let button = document.getElementById('cancel_kgcl_proposal'); -button.addEventListener('click', () => { - document.getElementById('addProposalFormDiv').innerHTML = ''; -}); diff --git a/app/views/change_requests/node_obsoletion.turbo_stream.haml b/app/views/change_requests/node_obsoletion.turbo_stream.haml new file mode 100644 index 0000000000..47d4c62e9e --- /dev/null +++ b/app/views/change_requests/node_obsoletion.turbo_stream.haml @@ -0,0 +1,2 @@ += turbo_stream.update 'addProposalFormDiv' do + = render partial: 'node_obsoletion' \ No newline at end of file diff --git a/app/views/change_requests/node_rename.js.erb b/app/views/change_requests/node_rename.js.erb deleted file mode 100644 index dd8e1700a5..0000000000 --- a/app/views/change_requests/node_rename.js.erb +++ /dev/null @@ -1,10 +0,0 @@ -let forms = document.getElementById('addProposalFormDiv').getElementsByTagName('form'); -if (forms.length === 0) { - document.getElementById('addProposalFormDiv') - .insertAdjacentHTML('afterbegin', '<%= j render 'change_requests/node_rename' %>'); -} - -let button = document.getElementById('cancel_kgcl_proposal'); -button.addEventListener('click', () => { - document.getElementById('addProposalFormDiv').innerHTML = ''; -}); diff --git a/app/views/change_requests/node_rename.turbo_stream.haml b/app/views/change_requests/node_rename.turbo_stream.haml new file mode 100644 index 0000000000..f2ddab6c42 --- /dev/null +++ b/app/views/change_requests/node_rename.turbo_stream.haml @@ -0,0 +1,2 @@ += turbo_stream.update 'addProposalFormDiv' do + = render partial: 'node_rename' \ No newline at end of file diff --git a/app/views/concepts/_details.html.haml b/app/views/concepts/_details.html.haml index 4bc9657688..207be3fe9c 100644 --- a/app/views/concepts/_details.html.haml +++ b/app/views/concepts/_details.html.haml @@ -14,12 +14,13 @@ = link_to('Obsolete class', change_requests_node_obsoletion_path(concept_id: @concept.id, concept_label: @concept.prefLabel, ont_acronym: @ontology.acronym), - class: 'dropdown-item', remote: 'true') + class: 'dropdown-item', 'data-turbo': 'true', 'data-turbo-stream': 'true') = link_to('Rename class', change_requests_node_rename_path(concept_id: @concept.id, concept_label: @concept.prefLabel, ont_acronym: @ontology.acronym), - class: 'dropdown-item', remote: 'true') - %div#addProposalFormDiv + class: 'dropdown-item', 'data-turbo': 'true', 'data-turbo-stream': 'true') + %div{'data-controller': 'change-requests'} + %div{id: 'addProposalFormDiv', 'data-change-requests-target': 'addProposalForm'} %table.minimal.concept_details{cellpadding: "0", cellspacing: "0", width: "100%"} %tr From f5c14ea94716358311aec898cd93c7fafcb7564c Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Thu, 7 Nov 2024 10:52:53 -0800 Subject: [PATCH 13/28] config file update sample config file changes: - remove unused/obsolete settings like error email notifications, MAX_CHILDREN, MAX_POSSIBLE_DISPLAY and not yet implemented features - remove Google Analytics ID because it is moded to encypted credentials - use env variables with default values remove development and test config files, create them in docker image during build process. --- Dockerfile | 7 +- Gemfile.lock | 3 + config/bioportal_config_development.rb | 309 ------------------------- config/bioportal_config_env.rb.sample | 254 ++------------------ config/bioportal_config_test.rb | 219 ------------------ docker-compose.yml | 2 +- 6 files changed, 33 insertions(+), 761 deletions(-) delete mode 100644 config/bioportal_config_development.rb delete mode 100644 config/bioportal_config_test.rb diff --git a/Dockerfile b/Dockerfile index a4e20e4ab2..b6ecb28845 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,9 +41,10 @@ RUN yarn install COPY . . -RUN cp config/bioportal_config_env.rb.sample config/bioportal_config_production.rb -RUN cp config/bioportal_config_env.rb.sample config/bioportal_config_development.rb -RUN cp config/database.yml.sample config/database.yml +RUN cp config/bioportal_config_env.rb.sample config/bioportal_config_production.rb \ + && cp config/bioportal_config_env.rb.sample config/bioportal_config_development.rb \ + && cp config/bioportal_config_env.rb.sample config/bioportal_config_test.rb \ + && cp config/database.yml.sample config/database.yml RUN if [ "${RAILS_ENV}" != "development" ]; then \ bundle exec bootsnap precompile --gemfile app/ lib/ && \ diff --git a/Gemfile.lock b/Gemfile.lock index 94b5c03887..7ec1141dfa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -319,6 +319,8 @@ GEM netrc (0.11.0) newrelic_rpm (9.14.0) nio4r (2.7.3) + nokogiri (1.15.6-aarch64-linux) + racc (~> 1.4) nokogiri (1.15.6-arm64-darwin) racc (~> 1.4) nokogiri (1.15.6-x86_64-linux) @@ -553,6 +555,7 @@ GEM zeitwerk (2.6.18) PLATFORMS + aarch64-linux arm64-darwin-22 x86_64-linux x86_64-linux-musl diff --git a/config/bioportal_config_development.rb b/config/bioportal_config_development.rb deleted file mode 100644 index 2e09613a1e..0000000000 --- a/config/bioportal_config_development.rb +++ /dev/null @@ -1,309 +0,0 @@ -# Organization info -$ORG = ENV['ORG'] -$ORG_URL = ENV['ORG_URL'] - -# Site name (required) -$SITE = ENV['SITE'] - -# Full string for site, EX: "NCBO BioPortal", do not modify -$ORG_SITE = $ORG.nil? || $ORG.empty? ? $SITE : "#{$ORG} #{$SITE}" - -# The URL for the BioPortal Rails UI (this application) -$UI_URL = ENV['UI_URL'] - -# If you are running a PURL server to provide URLs for ontologies in your BioPortal instance, enable this option -$PURL_ENABLED = false -# The PURL URL is generated using this prefix + the abbreviation for an ontology. -# The PURL URL generation algorithm can be altered in app/models/ontology_wrapper.rb -$PURL_PREFIX = 'http://purl.bioontology.org/ontology' - - -# If your BioPortal installation includes Annotator set this to false -$ANNOTATOR_DISABLED = false -# Unique string representing the UI's id for use with the BioPortal Core -$API_KEY = ENV['API_KEY'] -# BioPortal API service address -$REST_URL = ENV['API_URL'] - -# Annotator REST service address -# $ANNOTATOR_URL = "http://services.stageportal.lirmm.fr/annotator" -$ANNOTATOR_URL = $PROXY_URL = ENV['ANNOTATOR_URL'] -# NCBO annotator URL and apikey -$NCBO_ANNOTATORPLUS_ENABLED = ENV['NCBO_ANNOTATORPLUS_ENABLED'] -$NCBO_ANNOTATOR_URL = ENV['NCBO_ANNOTATOR_URL'] -$NCBO_API_KEY = ENV['NCBO_API_KEY'] - -# Fairness Assessment. -$FAIRNESS_DISABLED = ENV['FAIRNESS_DISABLED'] -$FAIRNESS_URL = ENV['FAIRNESS_URL'] - -# Used to define other bioportal that can be mapped to -# Example to map to ncbo bioportal : {"ncbo" => {"api" => "http://data.bioontology.org", "ui" => "http://bioportal.bioontology.org", "apikey" => ""} -# Then create the mapping using the following class in JSON : "http://purl.bioontology.org/ontology/MESH/C585345": "ncbo:MESH" -# Where "ncbo" is the namespace used as key in the interportal_hash -$INTERPORTAL_HASH = {} - -$NOT_DOWNLOADABLE = {} - -# Bugsnag API key for monitoring exception -#$BUGSNAG_API_KEY= - -# OAuth2 authentication -$OMNIAUTH_PROVIDERS = { - github: { - client_id: 'CLIENT_ID', - client_secret: 'CLIENT_SECRET', - icon: 'github.svg', - enable: true - }, - google: { - strategy: :google_oauth2, - client_id: 'CLIENT_ID', - client_secret: 'CLIENT_SECRET', - icon: 'google.svg', - enable: true - }, - orcid: { - client_id: 'CLIENT_SECRET', - client_secret: 'CLIENT_SECRET', - icon: 'orcid.svg', - enable: false - }, - keycloak: { - strategy: :keycloak_openid, - client_id: 'YOUR_KEYCLOAK_CLIENT_ID', - client_secret: 'YOUR_KEYCLOAK_CLIENT_SECRET', - client_options: { site: 'KEYCLOAK_SITE', realm: 'KEYCLOAK_REALM' }, - name: 'keycloak', - icon: 'keycloak.svg', - enable: false - } -}.freeze - -# Don't load and don't display recent mappings if false, in case of too many mappings (take longer to load homepage) -$DISPLAY_RECENT = false - -# If true then the UI will get available recognize at API_URL/annotators/recognizers -$MULTIPLE_RECOGNIZERS = false - -# Remove download for these ontologies. Default: -# ["CPT","ICD10","ICNP","ICPC2P","MDDB","MEDDRA","MSHFRE","MSHSPA_1","NDDF","NDFRT","NIC","RCD","SCTSPA","SNOMEDCT","WHO-ART"] -$RESTRICTED_DOWNLOADS = [] - -# Ontolobridge endpoint url -$ONTOLOBRIDGE_BASE_URL = 'https://ontolobridge.ccs.miami.edu/api-test/requests' -# Ontolobridge authentication token -$ONTOLOBRIDGE_AUTHENTICATION_TOKEN = 'Token Uq2pae73ktMtmgjUgtnhEOuHxr9sZeuK' - -# Ontologies for which to enable the new term request (Ontolobridge) tab -$NEW_TERM_REQUEST_ONTOLOGIES = [] - -# Legacy REST core service address (BioPortal v3.x and lower) -$LEGACY_REST_URL = 'http://example.org:8080/bioportal' - -# Release version text (appears in footer of all pages, except 404 and 500 errors) -$RELEASE_VERSION = ENV['RELEASE_VERSION'] - -# Enable Slices, filtering of ontologies based on subdomain and ontology groups -$ENABLE_SLICES = false - -# Google Analytics ID (optional) -$ANALYTICS_ID = ENV['ANALYTICS_ID'] - -# Enable client request caching -$CLIENT_REQUEST_CACHING = true - -# Email settings -ActionMailer::Base.smtp_settings = { - address: '', # smtp server address, ex: smtp.example.org - port: 25, # smtp server port - domain: '' # fqdn of rails server, ex: rails.example.org -} -# Announcements mailman mailing list REQUEST address, EX: list-request@lists.example.org -# NOTE: You must use the REQUEST address for the mailing list. ONLY WORKS WITH MAILMAN LISTS. -$ANNOUNCE_LIST = ENV['SUPPORT_EMAIL'] -# Email addresses used for sending notifications (errors, feedback, support) -$SUPPORT_EMAIL = ENV['SUPPORT_EMAIL'] -# Email used to send notifications -$NOTIFICATION_EMAIL = ENV['SUPPORT_EMAIL'] - - - -# reCAPTCHA -# In order to use reCAPTCHA on the account creation and feedback submission pages: -# 1. Obtain a reCAPTCHA v2 key from: https://www.google.com/recaptcha/admin -# 2. Put the site and secret keys in the encrypted credentials file: -# -# recaptcha: -# site_key: your_site_key -# secret_key: your_secret_key -# -# 3. Set the USE_RECAPTCHA option to 'true' -ENV['USE_RECAPTCHA'] = 'false' -# Custom BioPortal logging -require 'log' - -# URL where BioMixer GWT app is located -# $BIOMIXER_URL = "http://bioportal-integration.bio-mixer.appspot.com" -$BIOMIXER_URL = ENV['BIOMIXER_URL'] -$BIOMIXER_APIKEY = ENV['BIOMIXER_APIKEY'] - -## -# Custom Ontology Details -# Custom details can be added on a per ontology basis using a key/value pair as columns of the details table -# -# Example: -# $ADDITIONAL_ONTOLOGY_DETAILS = { "STY" => { "Additional Detail" => "Text to be shown in the right-hand column." } } -## -$ADDITIONAL_ONTOLOGY_DETAILS = {} - -# Front notice appears on the front page only and is closable by the user. It remains closed for seven days (stored in cookie) -$FRONT_NOTICE = '' -# Site notice appears on all pages and remains closed indefinitely. Stored below as a hash with a unique key and a string message -# EX: $SITE_NOTICE = { :unique_key => 'Put your message here (can include html if you use single quotes).' } -$SITE_NOTICE = {} - -$TERMS_AND_CONDITIONS_LINK = 'https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq' -$CITE_ANNOTATOR = 'https://hal.science/hal-00492024' -$ANNOTATOR_API_DOC = 'https://data.agroportal.lirmm.fr/documentation#nav_annotator' -$CITE_RECOMMENDER = 'https://doi.org/10.1186/s13326-017-0128-y' -# Resource term -$RESOURCE_TERM = ENV['RESOURCE_TERM'] || 'ontology' - -$HOME_PAGE_LOGOS = [ - { - img_src: 'logos/supports/numev.png', - url: 'http://www.lirmm.fr/numev', - target: '_blank' - }, - { - img_src: 'logos/supports/anr.png', - url: 'https://anr.fr/en', - target: '_blank' - }, - { - img_src: 'logos/supports/eu.png', - url: 'https://commission.europa.eu/research-and-innovation_en', - target: '_blank' - }, - { - img_src: 'logos/collaboration/d2kab.png', - url: 'http://d2kab.mystrikingly.com', - target: '_blank' - }, - { - img_src: 'logos/collaboration/lirmm.png', - url: 'http://www.lirmm.fr', - target: '_blank' - }, - { - img_src: 'logos/collaboration/inrae.png', - url: 'https://www.inrae.fr/enm', - target: '_blank' - }, - { - img_src: 'logos/collaboration/stanford.png', - url: 'https://www.stanford.edu', - target: '_blank' - } -] - -$PORTALS_INSTANCES = [ - { - color: '#31b403', - portal: 'AgroPortal', - link: 'https://agroportal.lirmm.fr/' - }, - { - color: '#234979', - portal: 'BioPortal', - link: 'https://bioportal.bioontology.org/' - }, - { - color: '#74a9cb', - portal: 'SIFR BioPortal', - link: 'https://bioportal.lirmm.fr/' - }, - { - color: '#0d508a', - portal: 'EcoPortal', - link: 'https://ecoportal.lifewatch.eu/' - }, - { - color: '#234979', - portal: 'MedPortal', - link: 'http://medportal.bmicc.cn/' - }, - { - color: '#009574', - portal: 'MatPortal', - link: 'https://matportal.org/' - }, - { - color: '#1c0f5d', - portal: 'IndustryPortal', - link: 'http://industryportal.enit.fr' - }, - { - color: '#1e2251', - portal: 'EarthPortal', - link: 'https://earthportal.eu/' - }, - { - color: '#33691B', - portal: 'BiodivPortal', - link: 'https://biodivportal.gfbio.org/' - } -] - -$ONTOPORTAL_WEBSITE_LINK = "https://ontoportal.org/" -$ONTOPORTAL_GITHUB_REPO = "https://github.com/ontoportal" - -$GITHUB_ISSUES = "https://github.com/agroportal/project-management/issues" -$FOOTER_LINKS = { - social: [ - { logo: "social/people.svg", link: "https://github.com/orgs/agroportal/people" }, - { logo: "social/github.svg", link: "https://github.com/agroportal" }, - { logo: "social/twitter.svg", link: "https://twitter.com/lagroportal" }, - { logo: "json.svg", link: $REST_URL }, - { logo: "summary/sparql.svg", link: "#{$SPARQL_URL}"}, - { logo: "social/email.svg", link: "mailto:#{$ANNOUNCE_LIST}" }, - ], - sections: { - products: { - release_notes: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/release-notes-btKjZk5tU2", - api: "https://data.agroportal.lirmm.fr/", - tools: "/tools", - sparql: "https://sparql.agroportal.lirmm.fr/test/", - ontoportal: $ONTOPORTAL_WEBSITE_LINK - }, - support: { - contact_us: "https://#{$SITE}.lirmm.fr/feedback", - documentation: "https://ontoportal.github.io/documentation/", - agro_documentation: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/public-documentation-QMpsC9aVBb", - issues_and_requests: $GITHUB_ISSUES - }, - agreements: { - terms: $TERMS_AND_CONDITIONS_LINK, - privacy_policy: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq#h-privacy-policy", - legal_notices: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq#h-legal-notice" - }, - about: { - about_us: "https://github.com/agroportal/project-management", - team: "https://github.com/orgs/agroportal/people", - cite_us: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/publications-and-references-87tEoeoGKy", - acknowledgments: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/acknowledgments-15GdRXLQdm" - } - } -} - -$UI_THEME = ENV['UI_THEME'] || 'ontoportal' -$HOSTNAME = ENV['API_URL'] - -if $HOSTNAME - $HOSTNAME = ENV['API_URL'].split('data.').last - # add custom stage server configuration if needed (e.g bioportal_config_development_stageportal.lirmm.fr) - if File.exist?("config/bioportal_config_development_#{$HOSTNAME}") - require_relative "bioportal_config_development_#{$HOSTNAME}" - end -end diff --git a/config/bioportal_config_env.rb.sample b/config/bioportal_config_env.rb.sample index 4b94b85fbd..3f93e5cb5e 100644 --- a/config/bioportal_config_env.rb.sample +++ b/config/bioportal_config_env.rb.sample @@ -1,117 +1,47 @@ # Organization info -$ORG = ENV['ORG'] -$ORG_URL = ENV['ORG_URL'] +$ORG = ENV['ORG'] || "NCBO" +$ORG_URL = ENV['ORG_URL'] || "https://www.bioontology.org" # Site name (required) -$SITE = ENV['SITE'] +$SITE = ENV['SITE'] || "BioPortal" # Full string for site, EX: "NCBO BioPortal", do not modify $ORG_SITE = $ORG.nil? || $ORG.empty? ? $SITE : "#{$ORG} #{$SITE}" # The URL for the BioPortal Rails UI (this application) -$UI_URL = ENV['UI_URL'] +$UI_URL = ENV['UI_URL'] || "https://bioportal.bioontology.org" # If you are running a PURL server to provide URLs for ontologies in your BioPortal instance, enable this option -$PURL_ENABLED = false +$PURL_ENABLED = ENV['PURL_ENABLED'] || false # The PURL URL is generated using this prefix + the abbreviation for an ontology. # The PURL URL generation algorithm can be altered in app/models/ontology_wrapper.rb -$PURL_PREFIX = 'http://purl.bioontology.org/ontology' +$PURL_PREFIX = ENV['PURL_PREFIX'] || "https://purl.bioontology.org/ontology" - -# If your BioPortal installation includes Annotator set this to false -$ANNOTATOR_DISABLED = false # Unique string representing the UI's id for use with the BioPortal Core $API_KEY = ENV['API_KEY'] + # BioPortal API service address $REST_URL = ENV['API_URL'] -# Annotator REST service address -# $ANNOTATOR_URL = "http://services.stageportal.lirmm.fr/annotator" -$ANNOTATOR_URL = $PROXY_URL = ENV['ANNOTATOR_URL'] -# NCBO annotator URL and apikey -$NCBO_ANNOTATORPLUS_ENABLED = ENV['NCBO_ANNOTATORPLUS_ENABLED'] -$NCBO_ANNOTATOR_URL = ENV['NCBO_ANNOTATOR_URL'] -$NCBO_API_KEY = ENV['NCBO_API_KEY'] - -# Fairness Assessment. -$FAIRNESS_DISABLED = ENV['FAIRNESS_DISABLED'] -$FAIRNESS_URL = ENV['FAIRNESS_URL'] - - - - -# Used to define other bioportal that can be mapped to -# Example to map to ncbo bioportal : {"ncbo" => {"api" => "http://data.bioontology.org", "ui" => "http://bioportal.bioontology.org", "apikey" => ""} -# Then create the mapping using the following class in JSON : "http://purl.bioontology.org/ontology/MESH/C585345": "ncbo:MESH" -# Where "ncbo" is the namespace used as key in the interportal_hash -$INTERPORTAL_HASH = {} - $NOT_DOWNLOADABLE = {} -# Bugsnag API key for monitoring exception -#$BUGSNAG_API_KEY= - -# OAuth2 authentication -$OMNIAUTH_PROVIDERS = { - github: { - client_id: 'CLIENT_ID', - client_secret: 'CLIENT_SECRET', - icon: 'github.svg', - enable: true - }, - google: { - strategy: :google_oauth2, - client_id: 'CLIENT_ID', - client_secret: 'CLIENT_SECRET', - icon: 'google.svg', - enable: true - }, - orcid: { - client_id: 'CLIENT_SECRET', - client_secret: 'CLIENT_SECRET', - icon: 'orcid.svg', - enable: false - }, - keycloak: { - strategy: :keycloak_openid, - client_id: 'YOUR_KEYCLOAK_CLIENT_ID', - client_secret: 'YOUR_KEYCLOAK_CLIENT_SECRET', - client_options: { site: 'KEYCLOAK_SITE', realm: 'KEYCLOAK_REALM' }, - name: 'keycloak', - icon: 'keycloak.svg', - enable: false - } -}.freeze - -# Don't load and don't display recent mappings if false, in case of too many mappings (take longer to load homepage) -$DISPLAY_RECENT = false - -# If true then the UI will get available recognize at API_URL/annotators/recognizers -$MULTIPLE_RECOGNIZERS = false - -# Remove download for these ontologies. Default: -# ["CPT","ICD10","ICNP","ICPC2P","MDDB","MEDDRA","MSHFRE","MSHSPA_1","NDDF","NDFRT","NIC","RCD","SCTSPA","SNOMEDCT","WHO-ART"] -$RESTRICTED_DOWNLOADS = [] - - -# Ontologies for which to enable the new term request (Ontolobridge) tab -$NEW_TERM_REQUEST_ONTOLOGIES = [] - -# Legacy REST core service address (BioPortal v3.x and lower) -$LEGACY_REST_URL = 'http://example.org:8080/bioportal' - # Release version text (appears in footer of all pages, except 404 and 500 errors) $RELEASE_VERSION = ENV['RELEASE_VERSION'] # Enable Slices, filtering of ontologies based on subdomain and ontology groups -$ENABLE_SLICES = false +$ENABLE_SLICES = ENV['ENABLE_SLICES'] || false -# Google Analytics ID (optional) -$ANALYTICS_ID = ENV['ANALYTICS_ID'] +# A user id for user 'anonymous' for use when a user is required for an action on the REST service but you don't want to require a user to login +$ANONYMOUS_USER = 0 # Enable client request caching $CLIENT_REQUEST_CACHING = true +# Enable debugging of API Ruby client +$DEBUG_RUBY_CLIENT = ENV["DEBUG_RUBY_CLIENT"] || false +# When DEBUG_RUBY_CLIENT is true, this array can limit the cache keys for which to receive debug output. Empty array means output debugging info for ALL keys +$DEBUG_RUBY_CLIENT_KEYS = ENV["DEBUG_RUBY_CLIENT_KEYS"] || [] + # Email settings ActionMailer::Base.smtp_settings = { address: '', # smtp server address, ex: smtp.example.org @@ -120,13 +50,12 @@ ActionMailer::Base.smtp_settings = { } # Announcements mailman mailing list REQUEST address, EX: list-request@lists.example.org # NOTE: You must use the REQUEST address for the mailing list. ONLY WORKS WITH MAILMAN LISTS. -$ANNOUNCE_LIST = ENV['SUPPORT_EMAIL'] +$ANNOUNCE_LIST = ENV['SUPPORT_EMAIL'] || "bioportal-test-announce@example.org" # Email addresses used for sending notifications (errors, feedback, support) -$SUPPORT_EMAIL = ENV['SUPPORT_EMAIL'] -# Email used to send notifications -$NOTIFICATION_EMAIL = ENV['SUPPORT_EMAIL'] - +$SUPPORT_EMAIL = ENV['SUPPORT_EMAIL'] || "bioportal-test-support@example.org" +# Settings for date formatting +CalendarDateSelect.format = :american # reCAPTCHA # In order to use reCAPTCHA on the account creation and feedback submission pages: @@ -139,13 +68,16 @@ $NOTIFICATION_EMAIL = ENV['SUPPORT_EMAIL'] # # 3. Set the USE_RECAPTCHA option to 'true' ENV['USE_RECAPTCHA'] = 'false' + +# Memcached servers +# ENV['MEMCACHE_SERVERS'] = 'localhost' + # Custom BioPortal logging require 'log' # URL where BioMixer GWT app is located -# $BIOMIXER_URL = "http://bioportal-integration.bio-mixer.appspot.com" -$BIOMIXER_URL = ENV['BIOMIXER_URL'] -$BIOMIXER_APIKEY = ENV['BIOMIXER_APIKEY'] +$BIOMIXER_URL = ENV["BIOMIXER_URL"] || "https://biomixer.bioontology.org" +$BIOMIXER_APIKEY = ENV["BIOMIXER_APIKEY"] ## # Custom Ontology Details @@ -162,141 +94,6 @@ $FRONT_NOTICE = '' # EX: $SITE_NOTICE = { :unique_key => 'Put your message here (can include html if you use single quotes).' } $SITE_NOTICE = {} -$TERMS_AND_CONDITIONS_LINK = 'https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq' -$CITE_ANNOTATOR = 'https://hal.science/hal-00492024' -$ANNOTATOR_API_DOC = 'https://data.agroportal.lirmm.fr/documentation#nav_annotator' -$CITE_RECOMMENDER = 'https://doi.org/10.1186/s13326-017-0128-y' -# Resource term -$RESOURCE_TERM = ENV['RESOURCE_TERM'] || 'ontology' - -$HOME_PAGE_LOGOS = [ - { - img_src: 'logos/supports/numev.png', - url: 'http://www.lirmm.fr/numev', - target: '_blank' - }, - { - img_src: 'logos/supports/anr.png', - url: 'https://anr.fr/en', - target: '_blank' - }, - { - img_src: 'logos/supports/eu.png', - url: 'https://commission.europa.eu/research-and-innovation_en', - target: '_blank' - }, - { - img_src: 'logos/collaboration/d2kab.png', - url: 'http://d2kab.mystrikingly.com', - target: '_blank' - }, - { - img_src: 'logos/collaboration/lirmm.png', - url: 'http://www.lirmm.fr', - target: '_blank' - }, - { - img_src: 'logos/collaboration/inrae.png', - url: 'https://www.inrae.fr/enm', - target: '_blank' - }, - { - img_src: 'logos/collaboration/stanford.png', - url: 'https://www.stanford.edu', - target: '_blank' - } -] - -$PORTALS_INSTANCES = [ - { - color: '#31b403', - portal: 'AgroPortal', - link: 'https://agroportal.lirmm.fr/' - }, - { - color: '#234979', - portal: 'BioPortal', - link: 'https://bioportal.bioontology.org/' - }, - { - color: '#74a9cb', - portal: 'SIFR BioPortal', - link: 'https://bioportal.lirmm.fr/' - }, - { - color: '#0d508a', - portal: 'EcoPortal', - link: 'https://ecoportal.lifewatch.eu/' - }, - { - color: '#234979', - portal: 'MedPortal', - link: 'http://medportal.bmicc.cn/' - }, - { - color: '#009574', - portal: 'MatPortal', - link: 'https://matportal.org/' - }, - { - color: '#1c0f5d', - portal: 'IndustryPortal', - link: 'http://industryportal.enit.fr' - }, - { - color: '#1e2251', - portal: 'EarthPortal', - link: 'https://earthportal.eu/' - }, - { - color: '#33691B', - portal: 'BiodivPortal', - link: 'https://biodivportal.gfbio.org/' - } -] -$ONTOPORTAL_WEBSITE_LINK = "https://ontoportal.org/" -$ONTOPORTAL_GITHUB_REPO = "https://github.com/ontoportal" - -$GITHUB_ISSUES = "https://github.com/agroportal/project-management/issues" -$FOOTER_LINKS = { - social: [ - { logo: "social/people.svg", link: "https://github.com/orgs/agroportal/people" }, - { logo: "social/github.svg", link: "https://github.com/agroportal" }, - { logo: "social/twitter.svg", link: "https://twitter.com/lagroportal" }, - { logo: "json.svg", link: $REST_URL }, - { logo: "summary/sparql.svg", link: "#{$SPARQL_URL}"}, - { logo: "social/email.svg", link: "mailto:#{$ANNOUNCE_LIST}" }, - ], - sections: { - products: { - release_notes: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/release-notes-btKjZk5tU2", - api: "https://data.agroportal.lirmm.fr/", - tools: "/tools", - sparql: "https://sparql.agroportal.lirmm.fr/test/", - ontoportal: $ONTOPORTAL_WEBSITE_LINK - }, - support: { - contact_us: "https://#{$SITE}.lirmm.fr/feedback", - documentation: "https://ontoportal.github.io/documentation/", - agro_documentation: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/public-documentation-QMpsC9aVBb", - issues_and_requests: $GITHUB_ISSUES - }, - agreements: { - terms: $TERMS_AND_CONDITIONS_LINK, - privacy_policy: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq#h-privacy-policy", - legal_notices: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq#h-legal-notice" - }, - about: { - about_us: "https://github.com/agroportal/project-management", - team: "https://github.com/orgs/agroportal/people", - cite_us: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/publications-and-references-87tEoeoGKy", - acknowledgments: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/acknowledgments-15GdRXLQdm" - } - } -} - - - $UI_THEME = ENV['UI_THEME'] || 'bioportal' $HOSTNAME = ENV['API_URL'] @@ -307,4 +104,3 @@ if $HOSTNAME require_relative "bioportal_config_development_#{$HOSTNAME}" end end - diff --git a/config/bioportal_config_test.rb b/config/bioportal_config_test.rb deleted file mode 100644 index 91ed16b4df..0000000000 --- a/config/bioportal_config_test.rb +++ /dev/null @@ -1,219 +0,0 @@ -# frozen_string_literal: true - -$SITE = 'Testportal' -$HOSTNAME = 'testportal' -$UI_HOSTNAME = 'localhost' -$UI_URL = "http://#{$UI_HOSTNAME}:3000" - -$API_KEY = ENV['API_KEY'] -$REST_URL = ENV['API_URL'] -$BIOMIXER_URL = ENV['BIOMIXER_URL'] -$ANNOTATOR_URL = $PROXY_URL = ENV['ANNOTATOR_URL'].blank? ? "https://services.tesportal.lirmm.fr/annotator" : ENV['ANNOTATOR_URL'] -$FAIRNESS_URL = ENV['FAIRNESS_URL'] - -# Resource term -$RESOURCE_TERM = ENV['RESOURCE_TERM'] || 'ontology' - -# config/initializers/omniauth_providers.rb -$OMNIAUTH_PROVIDERS = { - github: { - client_id: 'CLIENT_ID', - client_secret: 'CLIENT_SECRET', - icon: 'github.svg', - enable: true - }, - google: { - strategy: :google_oauth2, - client_id: 'CLIENT_ID', - client_secret: 'CLIENT_SECRET', - icon: 'google.svg', - enable: true - }, - orcid: { - client_id: 'CLIENT_SECRET', - client_secret: 'CLIENT_SECRET', - icon: 'orcid.svg', - enable: false - }, - keycloak: { - strategy: :keycloak_openid, - client_id: 'YOUR_KEYCLOAK_CLIENT_ID', - client_secret: 'YOUR_KEYCLOAK_CLIENT_SECRET', - client_options: { site: 'KEYCLOAK_SITE', realm: 'KEYCLOAK_REALM' }, - name: 'keycloak', - icon: 'keycloak.svg', - enable: false - } -}.freeze - -$INTERPORTAL_HASH = {} - -# If your BioPortal installation includes Fairness score set this to true -$FAIRNESS_DISABLED = false - -# Pairing a name with an array of ontology virtual ids will allow you to filter ontologies based on a subdomain. -# If your main UI is hosted at example.org and you add custom.example.org pointing to the same Rails installation -# you could filter the ontologies visible at custom.example.org by adding this to the hash: "custom" => { :name => "Custom Slice", :ontologies => [1032, 1054, 1099] } -# Any number of slices can be added. Groups are added automatically using the group acronym as the subdomain. -$ENABLE_SLICES = false -$ONTOLOGY_SLICES = {} - - -$NOT_DOWNLOADABLE = {} -# Enable client request caching -$CLIENT_REQUEST_CACHING = true - -# If you don't use Airbrake you can have exceptions emailed to the $ERROR_EMAIL address by setting this to 'true' -$EMAIL_EXCEPTIONS = false - -# Announcements mailman mailing list REQUEST address, EX: list-request@lists.example.org -# NOTE: You must use the REQUEST address for the mailing list. ONLY WORKS WITH MAILMAN LISTS. -$ANNOUNCE_LIST ||= 'appliance-users-request@localhost' - -# Email addresses used for sending notifications (errors, feedback, support) -$SUPPORT_EMAIL ||= 'support@localhost' -$ADMIN_EMAIL ||= 'admin@localhost' -$ERROR_EMAIL ||= 'errors@localhost' - -# Custom BioPortal logging -require 'log' -$REMOTE_LOGGING = false - -## -# Custom Ontology Details -# Custom details can be added on a per ontology basis using a key/value pair as columns of the details table -# -# Example: -# $ADDITIONAL_ONTOLOGY_DETAILS = { 1000 => { "Additional Detail" => "Text to be shown in the right-hand column." } } -## -$ADDITIONAL_ONTOLOGY_DETAILS = {} - -# Site notice appears on all pages and remains closed indefinitely. Stored below as a hash with a unique key and a -# EX: $SITE_NOTICE = { :unique_key => 'Put your message here (can include html if you use -$SITE_NOTICE = {} -################################ -## AUTO-GENERATED DO NOT MODIFY -################################# - -# Full string for site, EX: "NCBO BioPortal" -$ORG_SITE = $ORG.nil? || $ORG.empty? ? $SITE : "#{$ORG} #{$SITE}" - -$HOME_PAGE_LOGOS = [ - { - img_src: 'logos/supports/numev.png', - url: 'http://www.lirmm.fr/numev', - target: '_blank' - }, - { - img_src: 'logos/supports/anr.png', - url: 'https://anr.fr/en', - target: '_blank' - }, - { - img_src: 'logos/supports/eu.png', - url: 'https://commission.europa.eu/research-and-innovation_en', - target: '_blank' - }, - { - img_src: 'logos/collaboration/d2kab.png', - url: 'http://d2kab.mystrikingly.com', - target: '_blank' - }, - { - img_src: 'logos/collaboration/lirmm.png', - url: 'http://www.lirmm.fr', - target: '_blank' - }, - { - img_src: 'logos/collaboration/inrae.png', - url: 'https://www.inrae.fr/enm', - target: '_blank' - }, - { - img_src: 'logos/collaboration/stanford.png', - url: 'https://www.stanford.edu', - target: '_blank' - } -] - -$FOOTER_LINKS = { - social: [ - { logo: 'social/people.svg', link: 'https://github.com/orgs/agroportal/people' }, - { logo: 'social/github.svg', link: 'https://github.com/agroportal' }, - { logo: 'social/twitter.svg', link: 'https://twitter.com/lagroportal' } - ], - sections: { - products: { - ontoportal: 'https://ontoportal.org/', - release_notes: 'https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/release-notes-btKjZk5tU2', - api: 'https://data.agroportal.lirmm.fr/', - sparql: 'https://sparql.agroportal.lirmm.fr/test/' - }, - support: { - contact_us: 'https://agroportal.lirmm.fr/feedback', - wiki: 'https://www.bioontology.org/wiki/', - documentation: 'https://ontoportal.github.io/documentation/' - }, - agreements: { - terms: '', - privacy_policy: '', - cite_us: '', - acknowledgments: '' - }, - about: { - about_us: 'https://github.com/agroportal/project-management', - projects: 'https://d2kab.mystrikingly.com/', - team: 'https://github.com/orgs/agroportal/people' - } - } -} - -$PORTALS_INSTANCES = [ - { - color: '#31b403', - portal: 'AgroPortal', - link: 'https://agroportal.lirmm.fr/' - }, - { - color: '#234979', - portal: 'BioPortal', - link: 'https://bioportal.bioontology.org/' - }, - { - color: '#74a9cb', - portal: 'SIFR BioPortal', - link: 'https://bioportal.lirmm.fr/' - }, - { - color: '#0d508a', - portal: 'EcoPortal', - link: 'https://ecoportal.lifewatch.eu/' - }, - { - color: '#234979', - portal: 'MedPortal', - link: 'http://medportal.bmicc.cn/' - }, - { - color: '#009574', - portal: 'MatPortal', - link: 'https://matportal.org/' - }, - { - color: '#1c0f5d', - portal: 'IndustryPortal', - link: 'http://industryportal.enit.fr' - }, - { - color: '#1e2251', - portal: 'EarthPortal', - link: 'https://earthportal.eu/' - }, - { - color: '#33691B', - portal: 'BiodivPortal', - link: 'https://biodivportal.gfbio.org/' - } -] - -$UI_THEME = :stageportal \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 85abfe54ae..621e438b01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ x-app: &default-app - image: bioportal/ontoportal_web_ui:0.0.7 + image: bioportal/ontoportal_web_ui env_file: - ".env" tty: true From 78cb4caec14a8fa3b56b194383a6a35b796c7af8 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Thu, 7 Nov 2024 10:57:11 -0800 Subject: [PATCH 14/28] do not include capistrano deploy configs --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 6fb9c295b3..4316f994d6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -27,4 +27,4 @@ yarn-debug.log* config/credentials/* config/credentials.yml.enc - +config/deploy/* From a5fdb4758f9e48961bec1722987751a2d73e6fa3 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Thu, 7 Nov 2024 13:26:53 -0800 Subject: [PATCH 15/28] publish image to hub.docker --- .github/workflows/docker-image.yml | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000000..0fa485bfc4 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,40 @@ +name: Publish Docker Image to hub.docker.com + +on: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: bioportal/bioportal_web_ui + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 7bca691057760e9b6169edbd94189d33d3bb6cb2 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 7 Nov 2024 14:36:01 -0800 Subject: [PATCH 16/28] Fix an issue with login page rendering --- app/controllers/change_requests_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/change_requests_controller.rb b/app/controllers/change_requests_controller.rb index 33833e11b8..8b687213aa 100644 --- a/app/controllers/change_requests_controller.rb +++ b/app/controllers/change_requests_controller.rb @@ -49,11 +49,12 @@ def generate_curie(ont_acronym, concept_id) def require_login return unless session[:user].blank? - # TODO: Can this implementation be improved? For discussion: - # https://stackoverflow.com/a/18681807 - # https://stackoverflow.com/a/10607511 - # https://stackoverflow.com/a/51275445 - render js: "window.location.href='#{login_index_path}'" + # TODO: remove format.js handling after the create_synonym and remove_synonym actions are converted + # from Rails UJS to Turbo Streams. + respond_to do |format| + format.turbo_stream { redirect_to login_index_path } + format.js { render js: "window.location.href='#{login_index_path}'", status: :found } + end end def set_common_instance_variables From 244a22275d2dfa46863790dcf6b86d1b140d3e01 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 7 Nov 2024 17:50:51 -0800 Subject: [PATCH 17/28] Restore create.js.erb --- app/controllers/change_requests_controller.rb | 7 ++++++- app/views/change_requests/create.js.erb | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 app/views/change_requests/create.js.erb diff --git a/app/controllers/change_requests_controller.rb b/app/controllers/change_requests_controller.rb index 8b687213aa..49439ea37c 100644 --- a/app/controllers/change_requests_controller.rb +++ b/app/controllers/change_requests_controller.rb @@ -27,7 +27,12 @@ def create @issue = IssueCreatorService.call(params) flash.now.notice = helpers.change_request_success_message if @issue['id'].present? - respond_to :turbo_stream + # TODO: remove format.js from this block, and the create.js.erb file after the create_synonym and + # remove_synonym actions are converted from Rails UJS to Turbo Streams. + respond_to do |format| + format.js + format.turbo_stream + end end private diff --git a/app/views/change_requests/create.js.erb b/app/views/change_requests/create.js.erb new file mode 100644 index 0000000000..d1cba95db2 --- /dev/null +++ b/app/views/change_requests/create.js.erb @@ -0,0 +1,2 @@ +document.getElementById('change-request-notice').innerHTML = '<%= j render partial: "notice" %>' +document.getElementById('addProposalFormDiv').innerHTML = ''; \ No newline at end of file From 1ef3ad4d8f60e98df0df36e591dd86579e7cc33d Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 8 Nov 2024 13:37:32 -0800 Subject: [PATCH 18/28] create test env config file if not present --- bin/ontoportal | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/ontoportal b/bin/ontoportal index 3fa5d29391..ceff072dfb 100755 --- a/bin/ontoportal +++ b/bin/ontoportal @@ -176,6 +176,9 @@ test() { bin/run_api fi + # create bioportal config file for test env if its not there. + [ -f config/bioportal_config_test.rb ] || cp config/bioportal_config_env.rb.sample config/bioportal_config_test.rb + echo "Running tests..." echo "Run: API_URL=$api_url bundle exec rails test -v $test_options" From d9dd99eb70ae0cbf3f17391c3214d74edb0e9897 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 8 Nov 2024 13:47:16 -0800 Subject: [PATCH 19/28] add test --- .../workflows/test-real-data-stagedata.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/test-real-data-stagedata.yaml diff --git a/.github/workflows/test-real-data-stagedata.yaml b/.github/workflows/test-real-data-stagedata.yaml new file mode 100644 index 0000000000..933d202c21 --- /dev/null +++ b/.github/workflows/test-real-data-stagedata.yaml @@ -0,0 +1,49 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby +name: "Run remote API (testportal) tests CI" + +on: + push: + pull_request: + types: [ opened, reopened ] +env: + API_URL: https://stagedata.biooontology.org/ # or ${{ secrets.API_URL }} + #API_KEY: ${{ secrets.API_KEY }} # public apikey or ${{ secrets.API_KEY }} + API_KEY: ${{ secrets.API_KEY }} # public apikey or ${{ secrets.API_KEY }} + ONTOLOGIES_TO_TEST: "NCIT,GO,SNOMEDCT" +jobs: + test: + runs-on: ubuntu-latest + services: + mysql: + image: mysql:8.0 + ports: + - "3306:3306" + env: + MYSQL_ROOT_PASSWORD: root + memcached: + image: memcached:1.6 + ports: + - 11211:11211 + steps: + - name: Checkout code + uses: actions/checkout@v3 + # Add or replace dependency steps here + - name: Install Ruby and gems + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + # Add or replace database setup steps here + - name: set up config file + run: cp config/bioportal_config_env.rb.sample config/bioportal_config_test.rb + - name: Set up database schema + run: RAILS_ENV=test bin/rails db:setup + - name: Set up yarn + run: yarn install + # Add or replace test runners here + - name: Run tests + run: RAILS_ENV=test bin/rails test test/controllers/* -v From 0bf4e3b4048c2b9150f2f725584ab9df894621c6 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 8 Nov 2024 13:50:22 -0800 Subject: [PATCH 20/28] remove deprecated setting --- config/bioportal_config_env.rb.sample | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/bioportal_config_env.rb.sample b/config/bioportal_config_env.rb.sample index 3f93e5cb5e..1cb54d1c3b 100644 --- a/config/bioportal_config_env.rb.sample +++ b/config/bioportal_config_env.rb.sample @@ -54,9 +54,6 @@ $ANNOUNCE_LIST = ENV['SUPPORT_EMAIL'] || "bioportal-test-announce@example.org" # Email addresses used for sending notifications (errors, feedback, support) $SUPPORT_EMAIL = ENV['SUPPORT_EMAIL'] || "bioportal-test-support@example.org" -# Settings for date formatting -CalendarDateSelect.format = :american - # reCAPTCHA # In order to use reCAPTCHA on the account creation and feedback submission pages: # 1. Obtain a reCAPTCHA v2 key from: https://www.google.com/recaptcha/admin From 35d77e81e43f7cae2fb45a2ed934cdea9f6d5191 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 8 Nov 2024 14:00:31 -0800 Subject: [PATCH 21/28] create database.yml --- .github/workflows/test-real-data-stagedata.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-real-data-stagedata.yaml b/.github/workflows/test-real-data-stagedata.yaml index 933d202c21..1a1f8745e9 100644 --- a/.github/workflows/test-real-data-stagedata.yaml +++ b/.github/workflows/test-real-data-stagedata.yaml @@ -39,7 +39,9 @@ jobs: bundler-cache: true # Add or replace database setup steps here - name: set up config file - run: cp config/bioportal_config_env.rb.sample config/bioportal_config_test.rb + run: | + cp config/bioportal_config_env.rb.sample config/bioportal_config_test.rb + cp config/database.yml.sample config/database.yml - name: Set up database schema run: RAILS_ENV=test bin/rails db:setup - name: Set up yarn From 3dfe641c50966be6c2727dd68ee7d0360aeee309 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 8 Nov 2024 14:23:33 -0800 Subject: [PATCH 22/28] remove worklow for running unit tests will add it back in seperate PR --- .../workflows/test-real-data-stagedata.yaml | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 .github/workflows/test-real-data-stagedata.yaml diff --git a/.github/workflows/test-real-data-stagedata.yaml b/.github/workflows/test-real-data-stagedata.yaml deleted file mode 100644 index 1a1f8745e9..0000000000 --- a/.github/workflows/test-real-data-stagedata.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake -# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby -name: "Run remote API (testportal) tests CI" - -on: - push: - pull_request: - types: [ opened, reopened ] -env: - API_URL: https://stagedata.biooontology.org/ # or ${{ secrets.API_URL }} - #API_KEY: ${{ secrets.API_KEY }} # public apikey or ${{ secrets.API_KEY }} - API_KEY: ${{ secrets.API_KEY }} # public apikey or ${{ secrets.API_KEY }} - ONTOLOGIES_TO_TEST: "NCIT,GO,SNOMEDCT" -jobs: - test: - runs-on: ubuntu-latest - services: - mysql: - image: mysql:8.0 - ports: - - "3306:3306" - env: - MYSQL_ROOT_PASSWORD: root - memcached: - image: memcached:1.6 - ports: - - 11211:11211 - steps: - - name: Checkout code - uses: actions/checkout@v3 - # Add or replace dependency steps here - - name: Install Ruby and gems - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - # Add or replace database setup steps here - - name: set up config file - run: | - cp config/bioportal_config_env.rb.sample config/bioportal_config_test.rb - cp config/database.yml.sample config/database.yml - - name: Set up database schema - run: RAILS_ENV=test bin/rails db:setup - - name: Set up yarn - run: yarn install - # Add or replace test runners here - - name: Run tests - run: RAILS_ENV=test bin/rails test test/controllers/* -v From 86b9c6b82b325f8bc89962fd278d51f1ec2dd552 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 8 Nov 2024 21:46:51 -0800 Subject: [PATCH 23/28] prevent simple component from initializing if its already done see https://github.com/ncbo/bioportal_web_ui/issues/345#issuecomment-2466016312 --- app/javascript/mixins/useSimpleTree.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/javascript/mixins/useSimpleTree.js b/app/javascript/mixins/useSimpleTree.js index ef61bea2dc..c93f764fe7 100644 --- a/app/javascript/mixins/useSimpleTree.js +++ b/app/javascript/mixins/useSimpleTree.js @@ -1,11 +1,13 @@ -export function useSimpleTree(element, afterClick, afterAjaxError, beforeAjax ) { - return jQuery(element).simpleTree({ - autoclose: false, - drag: false, - animate: true, - timeout: 20000, - afterClick: afterClick, - afterAjaxError: afterAjaxError, - beforeAjax: beforeAjax - }); -} \ No newline at end of file +export function useSimpleTree(element, afterClick, afterAjaxError, beforeAjax) { + if (!jQuery(element).data('simpleTree')) { + return jQuery(element).simpleTree({ + autoclose: false, + drag: false, + animate: true, + timeout: 20000, + afterClick: afterClick, + afterAjaxError: afterAjaxError, + beforeAjax: beforeAjax + }); + } +} From 83c35438988a7eeced0f97eeec90d3cec92bd5ba Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 13 Nov 2024 13:39:55 -0800 Subject: [PATCH 24/28] set defalut theme if $UI_THEME is not set - use hash for theme colors, reduce repetition, simplify adding new theme - provide default theme in case $UI_THEME is missing --- .../stylesheets/theme-variables.scss.erb | 80 +++++++------------ 1 file changed, 27 insertions(+), 53 deletions(-) diff --git a/app/assets/stylesheets/theme-variables.scss.erb b/app/assets/stylesheets/theme-variables.scss.erb index 2b900be72d..54689c7510 100644 --- a/app/assets/stylesheets/theme-variables.scss.erb +++ b/app/assets/stylesheets/theme-variables.scss.erb @@ -1,56 +1,30 @@ <%# This file contains all the color themes of ontoportal alliance%> -<% if (ui_theme = $UI_THEME.to_s.parameterize) - case ui_theme - when "agroportal" %> - :root{ - --primary-color: #3CB371; - --hover-color: #41C67C; - --secondary-color: #ffc107; - --light-color: #F1F6FA; - } - <% when "stageportal" %> - :root{ - --primary-color: #37AEA0; - --hover-color: #3BBDAE; - --secondary-color: #ffc107; - --light-color: #ECF7F6; - } - <% when "bioportal" %> - :root{ - --primary-color: #234979; - --hover-color: #6B96B7; - --secondary-color: #ffc107; - --light-color: #F0F5F6; - } - - <% when "ontoportal" , "testportal" %> - :root{ - --primary-color: #5499a4; - --hover-color: #6B96B7; - --secondary-color: #ffc107; - --light-color: #F1F6FA; - } - <%# Here to add a new theme ... %> - <% end %> -<% end %> - - -// common variables -:root{ - --error-color: #EB4335; - --warning-color: #F2BE22; - --gray-color: #888888; - --success-color: #2DC54E; - --admin-color: #145FF4; - --container-max-width: 1248px; - --bg-info-light-color: rgba(59, 130, 246, 0.1); - --bg-danger-light-color: rgba(239, 68, 68, 0.1); - --bg-warning-light-color: rgba(234, 179, 8, 0.1); - --bg-success-light-color: rgba(34, 197, 94, 0.1); +<% themes = { + "agroportal" => { primary: "#3CB371", hover: "#41C67C", secondary: "#ffc107", light: "#F1F6FA" }, + "stageportal" => { primary: "#37AEA0", hover: "#3BBDAE", secondary: "#ffc107", light: "#ECF7F6" }, + "bioportal" => { primary: "#76A7CC", hover: "#6B96B7", secondary: "#ffc107", light: "#F0F5F6" }, + "ontoportal" => { primary: "#5499a4", hover: "#6B96B7", secondary: "#ffc107", light: "#F1F6FA" }, + "testportal" => { primary: "#5499a4", hover: "#6B96B7", secondary: "#ffc107", light: "#F1F6FA" } +} %> + +<% ui_theme = $UI_THEME.to_s.parameterize %> +<% selected_theme_key = themes.key?(ui_theme) ? ui_theme : "ontoportal" %> +<% selected_theme = themes[selected_theme_key] %> + +:root { + --primary-color: <%= selected_theme[:primary] %>; + --hover-color: <%= selected_theme[:hover] %>; + --secondary-color: <%= selected_theme[:secondary] %>; + --light-color: <%= selected_theme[:light] %>; + --error-color: #EB4335; + --warning-color: #F2BE22; + --gray-color: #888888; + --success-color: #2DC54E; + --admin-color: #145FF4; + --container-max-width: 1248px; + --bg-info-light-color: rgba(59, 130, 246, 0.1); + --bg-danger-light-color: rgba(239, 68, 68, 0.1); + --bg-warning-light-color: rgba(234, 179, 8, 0.1); + --bg-success-light-color: rgba(34, 197, 94, 0.1); } - - - - - From b5aa0da2dbf7ac47e6110cc279c0cc63f235cf2f Mon Sep 17 00:00:00 2001 From: mdorf Date: Wed, 13 Nov 2024 15:32:56 -0800 Subject: [PATCH 25/28] fixes for #345 - display issues with jump to search --- Gemfile.lock | 107 ++++++++++-------- .../container_splitter_controller.js | 9 +- .../controllers/simple_tree_controller.js | 9 +- 3 files changed, 70 insertions(+), 55 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7ec1141dfa..eb7956fe18 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,11 +102,12 @@ GEM autoprefixer-rails (>= 9.1.0) popper_js (>= 2.11.6, < 3) sassc-rails (>= 2.0.0) - brakeman (5.4.1) + brakeman (6.2.2) + racc bugsnag (6.27.1) concurrent-ruby (~> 1.0) builder (3.3.0) - capistrano (3.19.1) + capistrano (3.19.2) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -125,11 +126,11 @@ GEM sshkit (~> 1.3) capistrano-yarn (2.0.2) capistrano (~> 3.0) - capybara (3.39.2) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) @@ -144,11 +145,11 @@ GEM bigdecimal rexml crass (1.0.6) - css_parser (1.17.1) + css_parser (1.19.1) addressable csv (3.3.0) dalli (3.2.8) - date (3.3.4) + date (3.4.0) debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) @@ -159,25 +160,30 @@ GEM ed25519 (1.3.0) erubi (1.13.0) erubis (2.7.0) - excon (0.112.0) - execjs (2.9.1) - faraday (2.0.0) - ruby2_keywords (>= 0.0.4) - faraday-excon (2.1.0) - excon (>= 0.27.4) - faraday (~> 2.0) + excon (1.2.0) + execjs (2.10.0) + faraday (2.12.0) + faraday-net_http (>= 2.0, < 3.4) + json + logger + faraday-excon (2.3.0) + excon (>= 1.0.0) + faraday (>= 2.11.0, < 3) faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) faraday-multipart (1.0.4) multipart-post (~> 2) - ffi (1.16.3) + faraday-net_http (3.3.0) + net-http + ffi (1.17.0) + ffi (1.17.0-arm64-darwin) flag-icons-rails (3.4.6.1) sass-rails globalid (1.2.1) activesupport (>= 6.1) graphql (2.0.31) base64 - graphql-client (0.23.0) + graphql-client (0.24.0) activesupport (>= 3.0) graphql (>= 1.13.0) haml (5.2.2) @@ -188,9 +194,10 @@ GEM activesupport (>= 5.1) haml (>= 4.0.6) railties (>= 5.1) - hashdiff (1.1.1) + hashdiff (1.1.2) hashie (5.0.0) - highline (2.1.0) + highline (3.1.1) + reline html2haml (2.3.0) erubis (~> 2.7.0) haml (>= 4.0) @@ -236,7 +243,7 @@ GEM railties (>= 3.2.16) jsbundling-rails (1.3.1) railties (>= 6.0.0) - json (2.7.2) + json (2.8.1) json-jwt (1.16.7) activesupport (>= 4.2) aes_key_wrap @@ -261,7 +268,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.6.1) - loofah (2.22.0) + loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) lookbook (1.5.5) @@ -289,20 +296,20 @@ GEM mime-types (3.6.0) logger mime-types-data (~> 3.2015) - mime-types-data (3.2024.1001) + mime-types-data (3.2024.1105) mini_mime (1.1.5) minitest (5.25.1) - msgpack (1.7.3) + msgpack (1.7.5) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.4.1) mysql2 (0.5.6) - net-ftp (0.2.1) + net-ftp (0.3.8) net-protocol time - net-http (0.3.2) + net-http (0.5.0) uri - net-imap (0.4.17) + net-imap (0.4.18) date net-protocol net-pop (0.1.2) @@ -317,13 +324,13 @@ GEM net-protocol net-ssh (7.3.0) netrc (0.11.0) - newrelic_rpm (9.14.0) - nio4r (2.7.3) - nokogiri (1.15.6-aarch64-linux) + newrelic_rpm (9.15.0) + nio4r (2.7.4) + nokogiri (1.16.7-aarch64-linux) racc (~> 1.4) - nokogiri (1.15.6-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.6-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) @@ -332,7 +339,7 @@ GEM rack (>= 1.2, < 4) snaky_hash (~> 2.0) version_gem (~> 1.1) - oj (3.16.6) + oj (3.16.7) bigdecimal (>= 3.0) ostruct (>= 0.2) omniauth (2.1.2) @@ -361,18 +368,18 @@ GEM omniauth-rails_csrf_protection (1.0.2) actionpack (>= 4.2) omniauth (~> 2.0) - ostruct (0.6.0) + ostruct (0.6.1) parallel (1.26.3) - parser (3.3.5.0) + parser (3.3.6.0) ast (~> 2.4.1) racc popper_js (2.11.8) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - psych (5.1.2) + psych (5.2.0) stringio - public_suffix (5.1.1) + public_suffix (6.0.1) puma (5.6.9) nio4r (~> 2.0) racc (1.8.1) @@ -403,7 +410,7 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails-i18n (7.0.9) + rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) railties (7.0.8) @@ -424,16 +431,16 @@ GEM json redcarpet (3.6.0) regexp_parser (2.9.2) - reline (0.5.10) + reline (0.5.11) io-console (~> 0.5) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.3.8) - rouge (4.4.0) - rspec-core (3.13.1) + rexml (3.3.9) + rouge (4.5.1) + rspec-core (3.13.2) rspec-support (~> 3.13.0) rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) @@ -441,7 +448,7 @@ GEM rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (7.0.1) + rspec-rails (7.1.0) actionpack (>= 7.0) activesupport (>= 7.0) railties (>= 7.0) @@ -450,7 +457,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - rubocop (1.67.0) + rubocop (1.68.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -460,10 +467,9 @@ GEM rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.3) + rubocop-ast (1.36.1) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) ruby_dig (0.0.2) ruby_parser (3.21.1) racc (~> 1.5) @@ -480,11 +486,11 @@ GEM sprockets-rails tilt select2-rails (4.0.13) - selenium-webdriver (4.9.0) + selenium-webdriver (4.16.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - sexp_processor (4.17.2) + sexp_processor (4.17.3) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -512,7 +518,7 @@ GEM ostruct stimulus-rails (1.3.4) railties (>= 6.0.0) - stringio (3.1.1) + stringio (3.1.2) temple (0.10.3) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) @@ -520,16 +526,16 @@ GEM execjs (>= 0.3.0, < 3) thor (1.3.2) tilt (2.4.0) - time (0.4.0) + time (0.4.1) date - timeout (0.4.1) + timeout (0.4.2) turbo-rails (2.0.11) actionpack (>= 6.0.0) railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.6.0) - uri (0.13.1) + uri (1.0.1) version_gem (1.1.4) view_component (2.83.0) activesupport (>= 5.2.0, < 8.0) @@ -557,6 +563,7 @@ GEM PLATFORMS aarch64-linux arm64-darwin-22 + arm64-darwin-23 x86_64-linux x86_64-linux-musl @@ -636,4 +643,4 @@ DEPENDENCIES will_paginate (~> 3.0) BUNDLED WITH - 2.4.22 + 2.5.11 diff --git a/app/javascript/controllers/container_splitter_controller.js b/app/javascript/controllers/container_splitter_controller.js index a05ff88101..9f934d5aef 100644 --- a/app/javascript/controllers/container_splitter_controller.js +++ b/app/javascript/controllers/container_splitter_controller.js @@ -5,7 +5,11 @@ export default class extends Controller { static targets = ['container'] connect() { - this.element.style.display= 'flex' + this.element.style.display = 'flex'; + if (this.element.getAttribute('splitter-data-initial') == 0) { + return; + } + Split(this.containerTargets, { elementStyle: function (dimension, size, gutterSize) { return { @@ -21,6 +25,7 @@ export default class extends Controller { direction: "horizontal", sizes: [30, 70], cursor: "col-resize" - }) + }); + this.element.setAttribute('splitter-data-initial', 0); } } diff --git a/app/javascript/controllers/simple_tree_controller.js b/app/javascript/controllers/simple_tree_controller.js index d178b3bb34..cdebf57316 100644 --- a/app/javascript/controllers/simple_tree_controller.js +++ b/app/javascript/controllers/simple_tree_controller.js @@ -3,13 +3,16 @@ import {useSimpleTree} from "../mixins/useSimpleTree"; export default class extends Controller { connect() { + if (this.element.getAttribute('simple-tree-data-initial') == 0) { + return; + } this.simpleTreeCollection = useSimpleTree(this.element, this.#afterClick.bind(this), this.#afterAjaxError.bind(this), this.#beforeAjax.bind(this) - ) - - this.#onClickTooManyChildrenInit() + ); + this.#onClickTooManyChildrenInit(); + this.element.setAttribute('simple-tree-data-initial', 0); } #onClickTooManyChildrenInit(){ From a21da663c61e05017940cb4c7712edf80c3089b6 Mon Sep 17 00:00:00 2001 From: mdorf Date: Thu, 14 Nov 2024 12:30:21 -0800 Subject: [PATCH 26/28] fixed a tree term display issue with flat ontologies --- app/views/concepts/_show.html.haml | 2 +- app/views/ontologies/_treeview.html.haml | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/views/concepts/_show.html.haml b/app/views/concepts/_show.html.haml index d28aefd6cd..18b8920105 100644 --- a/app/views/concepts/_show.html.haml +++ b/app/views/concepts/_show.html.haml @@ -3,7 +3,7 @@ %div{:style => "padding: 100px 0; font-size: larger; font-weight: bold; text-align: center;"} Use the "Jump To" to find a class and display details, visualization, notes, and mappings - else - %div + %div.cls-info-container %ul.nav.nav-tabs.tabs %li#details_top.nav-item %button.nav-link.active.py-1{:href => "#details" , data:{'bs-toggle': 'tab', 'bs-target': '#details_content'}} Details diff --git a/app/views/ontologies/_treeview.html.haml b/app/views/ontologies/_treeview.html.haml index cc7b4cac71..b436f40eae 100644 --- a/app/views/ontologies/_treeview.html.haml +++ b/app/views/ontologies/_treeview.html.haml @@ -1,10 +1,9 @@ = turbo_frame_tag 'concepts_tree_view' do - - unless @ontology.flat? - #tree_wrapper.card.p-1 - %ul.simpleTree{data:{controller: 'simple-tree'}} - %li.root - %ul - = draw_tree(@root, @concept.id) + #tree_wrapper.p-1 + %ul.simpleTree{data:{controller: 'simple-tree'}} + %li.root + %ul + = draw_tree(@root, @concept.id) :javascript jQuery(document).ready(function () { From 82b8a40c2b2a15196808f18c7a22397308646b1b Mon Sep 17 00:00:00 2001 From: mdorf Date: Thu, 14 Nov 2024 12:54:01 -0800 Subject: [PATCH 27/28] fixed a visualization issue with term page --- app/views/concepts/_biomixer.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/concepts/_biomixer.html.erb b/app/views/concepts/_biomixer.html.erb index b75b51d91a..53fbff6a80 100644 --- a/app/views/concepts/_biomixer.html.erb +++ b/app/views/concepts/_biomixer.html.erb @@ -60,6 +60,6 @@ window.onmessage = function(e) {
-
From 550ef26be024048bed9be5ab5f1b8a98cd27c887 Mon Sep 17 00:00:00 2001 From: mdorf Date: Thu, 14 Nov 2024 13:05:38 -0800 Subject: [PATCH 28/28] re-implemented the jump_to fix in the new code --- .../controllers/ontoportal_autocomplete_controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/controllers/ontoportal_autocomplete_controller.js b/app/javascript/controllers/ontoportal_autocomplete_controller.js index d0bfb07ee3..22dcc33c20 100644 --- a/app/javascript/controllers/ontoportal_autocomplete_controller.js +++ b/app/javascript/controllers/ontoportal_autocomplete_controller.js @@ -72,13 +72,13 @@ export default class extends Controller { let extraParams = { objecttypes: this.objectTypesValue }; - if (this.#isNotEmpty(this.submissionLangValue)) { + if (this.#isMultiple(this.submissionLangValue)) { extraParams["lang"] = this.langValue } return extraParams } - #isNotEmpty(arr) { + #isMultiple(arr) { return Array.isArray(arr) && arr.length > 0; }