From c2228994522d6e4b462c76b5ef164a21fac4168c Mon Sep 17 00:00:00 2001 From: Syphax Date: Thu, 10 Oct 2024 09:51:00 +0200 Subject: [PATCH 1/4] align bioportal and agroportal configuration files --- .dockerignore | 25 + .env.sample | 43 + .gitignore | 26 +- Dockerfile | 53 + Gemfile | 185 +- Gemfile.lock | 503 +- Procfile.dev | 2 +- README | 182 - README.rdoc | 261 - app/controllers/application_controller.rb | 11 +- app/helpers/application_helper.rb | 2 +- bin/dev | 2 +- bin/ontoportal | 213 + bin/run_api | 69 + bin/setup | 5 +- bin/stop_api | 13 + config/application.rb | 23 +- config/bioportal_config_env.rb.sample | 312 +- config/credentials.yml.enc | 1 + config/database.yml.sample | 5 +- config/environment.rb | 16 +- config/environments/appliance.rb | 3 +- config/environments/development.rb | 31 +- config/environments/production.rb | 23 +- config/environments/staging.rb | 7 +- config/environments/test.rb | 13 +- config/i18n-tasks.yml | 8 + config/initializers/assets.rb | 4 +- config/initializers/cube_reporter.rb | 43 - config/initializers/graphql_client.rb | 32 +- config/initializers/miniprofiler.rb | 2 - .../new_framework_defaults_7_0.rb | 122 +- config/initializers/omniauth.rb | 5 + config/newrelic.yml | 51 + config/robots/appliance.txt | 21 +- config/settings.yml | 2 + db/schema.rb | 10 +- docker-compose.yml | 122 + lib/resolver/acronym_from_virtual.rb | 535 -- lib/resolver/virtual_from_acronym.rb | 533 -- lib/resolver/virtual_from_version.rb | 7144 ----------------- lib/tasks/generate_component_previews.rake | 34 + package.json | 28 +- yarn.lock | 1396 +++- 44 files changed, 2784 insertions(+), 9337 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.sample create mode 100644 Dockerfile delete mode 100644 README delete mode 100644 README.rdoc create mode 100755 bin/ontoportal create mode 100755 bin/run_api create mode 100755 bin/stop_api create mode 100644 config/credentials.yml.enc create mode 100644 config/i18n-tasks.yml delete mode 100644 config/initializers/cube_reporter.rb delete mode 100644 config/initializers/miniprofiler.rb create mode 100644 config/initializers/omniauth.rb create mode 100644 config/newrelic.yml create mode 100644 docker-compose.yml delete mode 100644 lib/resolver/acronym_from_virtual.rb delete mode 100644 lib/resolver/virtual_from_acronym.rb delete mode 100644 lib/resolver/virtual_from_version.rb create mode 100644 lib/tasks/generate_component_previews.rake diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..8cdea307d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +.git/ +log/* +!log/.keep +app/assets/builds/* +!app/assets/builds/.keep +node_modules/ +public/assets/ +storage/* +!storage/.keep +tmp/* +!tmp/.keep + +.bundle +.byebug_history +.dockerignore +.env* +!.env.example +config/master.key +docker-compose.override.yml +yarn-error.log +yarn-debug.log* +.yarn-integrity + +config/credentials/* +config/credentials.yml.enc \ No newline at end of file diff --git a/.env.sample b/.env.sample new file mode 100644 index 000000000..94f4a336b --- /dev/null +++ b/.env.sample @@ -0,0 +1,43 @@ +##################### UI configuration #################### +RAILS_ENV=development +SITE=Testportal +ORG=LIRMM +ORG_URL=http://www.lirmm.fr + +UI_URL=http://localhost:3000 +API_URL=http://localhost:9393 +API_KEY= + +UI_THEME=ontoportal + +BIOMIXER_URL= +BIOMIXER_APIKEY= + +ANNOTATOR_URL= + +FAIRNESS_DISABLED=false +FAIRNESS_URL= + +NCBO_ANNOTATORPLUS_ENABLED=false +NCBO_ANNOTATOR_URL= +NCBO_API_KEY= + +SUPPORT_EMAIL=sifrportal-support@lirmm.fr +RELEASE_VERSION="OntoPortal Appliance 3.0.1" + +ANALYTICS_ID= +USE_RECAPTCHA=false +#################### Buidling the API for running tests #################### +## An ontology that will be imported in the starting of the API server +STARTER_ONTOLOGY=STY +## API key of a remote API used to download the starter ontology +OP_API_KEY=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb +## API url of the remote API used to download the starter ontology +OP_API_URL="https://data.bioontology.org" + +## Image repositroy from which the ontoportal api will be built +API_IMAGE_REPOSITORY=agroportal +## Image tag/version from which the ontoportal api will be built +API_IMAGE_TAG=master + + diff --git a/.gitignore b/.gitignore index ab0ea98b5..32214c3fa 100644 --- a/.gitignore +++ b/.gitignore @@ -17,8 +17,9 @@ rerun.txt pickle-email-*.html config/bioportal_config*.rb config/database.yml -config/secrets.yml config/deploy/* +config/locales/en.rb +config/secrets.yml **.DS_Store /public/**/cache/** /public/umls/* @@ -28,23 +29,28 @@ nohup.out # Ignore editor files .idea *.swp +.rbenv-gemsets .tags .tags_sorted_by_file -config/newrelic.yml - node_modules - -# Ignore keys for decrypting credentials -/config/credentials/development.key -/config/credentials/test.key -/config/credentials/staging.key -/config/credentials/production.key -/config/credentials/appliance.key +.env +config/site_config.rb +docker-sync.yml +.docker-sync/daemon.log +.docker-sync/daemon.pid /app/assets/builds/* !/app/assets/builds/.keep /node_modules + +# Encryption keys +/config/master.key +/config/credentials/development.key +/config/credentials/test.key +/config/credentials/staging.key +/config/credentials/production.key +/config/credentials/appliance.key \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..2eb0ea3ba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# 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 +WORKDIR /app + +# Set production environment +ARG RAILS_ENV="production" +ARG BUNDLE_WITHOUT="development test" + +ENV RAILS_LOG_TO_STDOUT="1" \ + RAILS_SERVE_STATIC_FILES="true" \ + RAILS_ENV="${RAILS_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 . . + +RUN bundle install +RUN yarn install && yarn build + + + +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 + +ENV BINDING="0.0.0.0" +EXPOSE 3000 + +CMD ["bash"] \ No newline at end of file diff --git a/Gemfile b/Gemfile index c423cef31..f6f404787 100644 --- a/Gemfile +++ b/Gemfile @@ -2,93 +2,135 @@ source 'https://rubygems.org' +# Main Rails gem # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '7.0.8' +gem 'rails', '7.0.3' -# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] -gem 'sprockets-rails', require: 'sprockets/railtie' +# JavaScript bundling for Rails +gem 'jsbundling-rails' -# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails] -gem 'jsbundling-rails', '~> 1.3' +# Chart.js integration for Rails +gem 'chart-js-rails' -# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] -gem 'turbo-rails' +gem 'select2-rails' -# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] -gem 'stimulus-rails' +# SassC as a replacement for sass-rails +gem 'sassc-rails' # sass-rails replacement + +# Terser JavaScript minifier as a replacement for Uglifier +gem 'terser' # uglifier replacement + +# Bootstrap front-end framework +gem 'bootstrap', '~> 5.2.3' + +# jQuery integration for Rails +gem 'jquery-rails' + +# jQuery UI integration for Rails +gem 'jquery-ui-rails' -# Build JSON APIs with ease [https://github.com/rails/jbuilder] -# gem 'jbuilder' +# The original asset pipeline for Rails +# [https://github.com/rails/sprockets-rails] +gem 'sprockets-rails' -# Use Redis for Action Cable -gem 'redis', '~> 4.0' +# Use the Puma web server +# [https://github.com/puma/puma] +gem 'puma', '~> 5.0' -# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] -# gem 'kredis' +# Use JavaScript with ESM import maps +# [https://github.com/rails/importmap-rails] +gem 'importmap-rails' -# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" +# Hotwire's SPA-like page accelerator +# [https://turbo.hotwired.dev] +gem 'turbo-rails' -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +# Hotwire's modest JavaScript framework +# [https://stimulus.hotwired.dev] +gem 'stimulus-rails' + +# Debugging tool +# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem 'pry' +gem 'pry' + +# Time zone info for Windows platforms gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', require: false -# Use Sass to process CSS -gem 'sassc-rails' - -gem 'bootstrap', '~> 5.2.3' -gem 'chart-js-rails' -gem 'jquery-rails' -gem 'jquery-ui-rails' -gem 'select2-rails' - -gem 'base64', '0.1.0' -gem 'cube-ruby', require: 'cube' +# Memcached client for Ruby gem 'dalli' -gem 'flamegraph' -# Version 2.1 breaks graphql-client. See: https://github.com/github/graphql-client/issues/310. -gem 'graphql', '~> 2.0.27' + +# GraphQL client for Ruby gem 'graphql-client' + +# Haml template engine for Ruby on Rails gem 'haml', '~> 5.1' + +# Internationalization (i18n) gem 'i18n' -gem 'iso-639', '~> 0.3.6' +gem 'rails-i18n', '~> 7.0.0' + +# MySQL database adapter +gem 'mysql2' + +# JSON parsing libraries gem 'multi_json' -gem 'mysql2', '0.5.5' gem 'oj' -gem 'ontologies_api_client', github: 'ncbo/ontologies_api_ruby_client', tag: 'v2.4.0' -gem 'open_uri_redirections' -gem 'pry' -gem 'psych', '< 4' -gem 'rack-mini-profiler' -gem 'rails_autolink' -gem 'rdoc' + +# Google reCAPTCHA integration gem 'recaptcha', '~> 5.9.0' + +# Simple HTTP and REST client for Ruby gem 'rest-client' -gem 'rexml', '~> 3' -gem 'stackprof', require: false -# pinning strscan to v 3.0.1 to deal with deployment issue. Remove line below when issue is fixed -gem 'strscan', '3.0.1' +# View components framework for Rails +gem 'lookbook', '~> 1.5.5' +gem 'view_component', '~> 2.72' -gem 'terser' -gem 'thin' +# Pagination library for Rails gem 'will_paginate', '~> 3.0' -gem 'net-ftp' gem 'flag-icons-rails', '~> 3.4' gem 'inline_svg' -group :staging, :production do - # Application monitoring +# Render SVG files in Rails views +gem 'inline_svg' + +# ISO language codes and flags +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: 'development' + +# 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' + +# Multi-Provider Authentication +gem 'omniauth' +gem 'omniauth-rails_csrf_protection' +gem 'omniauth-github' +gem 'omniauth-google-oauth2' +gem 'omniauth-keycloak' +gem 'omniauth-orcid' + +group :staging, :production, :appliance do + # Application performance monitoring gem 'newrelic_rpm' - # Logs in json format, useful for shipping logs to logstash + + # 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 - # Capistrano deployment + # Capistrano Deployment gem 'bcrypt_pbkdf', '>= 1.0', '< 2.0', require: false # https://github.com/miloserdow/capistrano-deploy/issues/42 gem 'capistrano', '~> 3.17', require: false gem 'capistrano-bundler', require: false @@ -98,22 +140,47 @@ group :development do gem 'capistrano-rbenv', require: false gem 'capistrano-yarn', require: false gem 'ed25519', '>= 1.2', '< 2.0', require: false # https://github.com/miloserdow/capistrano-deploy/issues/42 - gem 'html2haml' - gem 'listen' # Static code analysis gem 'brakeman', require: false gem 'rubocop', require: false - # gem 'i18n-debug' -end + # Haml support for Rails + gem 'haml-rails' + gem 'html2haml' -group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + # Debugging tools gem 'debug', platforms: %i[mri mingw x64_mingw] - gem 'rspec-rails' + + # Use console on exceptions pages + # [https://github.com/rails/web-console] + gem 'web-console' + + # Internationalization tasks + # gem 'i18n-debug' + gem 'i18n-tasks' + gem 'i18n-tasks-csv', '~> 1.1' + gem 'deepl-rb' + + # Email preview in the browser + gem 'letter_opener_web', '~> 2.0' end group :test do + # System testing + # [https://guides.rubyonrails.org/testing.html#system-testing] gem 'capybara' + + # WebDriver for system testing + gem 'selenium-webdriver' + + # Code coverage generation + gem 'simplecov', require: false + gem 'simplecov-cobertura' # for codecov.io + + # Mock HTTP requests in tests + gem 'webmock' + + # Testing framework for Rails + gem 'rspec-rails' end diff --git a/Gemfile.lock b/Gemfile.lock index 4103dea80..a25e96c4e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,109 +1,112 @@ GIT - remote: https://github.com/ncbo/ontologies_api_ruby_client.git - revision: f589b13dfbbc133ea67cbae1a8f92b41ea85c14b - tag: v2.4.0 + remote: https://github.com/ontoportal-lirmm/ontologies_api_ruby_client.git + revision: abea6c217c0ee93bcfd80c47c2af52747365d491 + branch: development specs: - ontologies_api_client (2.4.0) - activesupport (= 7.0.8) - addressable (~> 2.8) + ontologies_api_client (2.2.0) + activesupport excon faraday - faraday-excon + faraday-excon (~> 2.0.0) faraday-multipart lz4-ruby multi_json oj + spawnling (= 2.1.5) GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.0.3) + actionpack (= 7.0.3) + activesupport (= 7.0.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + actionmailbox (7.0.3) + actionpack (= 7.0.3) + activejob (= 7.0.3) + activerecord (= 7.0.3) + activestorage (= 7.0.3) + activesupport (= 7.0.3) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.0.3) + actionpack (= 7.0.3) + actionview (= 7.0.3) + activejob (= 7.0.3) + activesupport (= 7.0.3) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) - rack (~> 2.0, >= 2.2.4) + actionpack (7.0.3) + actionview (= 7.0.3) + activesupport (= 7.0.3) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + actiontext (7.0.3) + actionpack (= 7.0.3) + activerecord (= 7.0.3) + activestorage (= 7.0.3) + activesupport (= 7.0.3) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.0.3) + activesupport (= 7.0.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8) - activesupport (= 7.0.8) + activejob (7.0.3) + activesupport (= 7.0.3) globalid (>= 0.3.6) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.0.3) + activesupport (= 7.0.3) + activerecord (7.0.3) + activemodel (= 7.0.3) + activesupport (= 7.0.3) + activestorage (7.0.3) + actionpack (= 7.0.3) + activejob (= 7.0.3) + activerecord (= 7.0.3) + activesupport (= 7.0.3) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.0.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) - airbrussh (1.5.3) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + aes_key_wrap (1.1.0) + airbrussh (1.5.2) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) autoprefixer-rails (10.4.19.0) execjs (~> 2) - base64 (0.1.0) + base64 (0.2.0) bcrypt_pbkdf (1.1.1) - bcrypt_pbkdf (1.1.1-arm64-darwin) bcrypt_pbkdf (1.1.1-x86_64-darwin) bigdecimal (3.1.8) - bootsnap (1.18.4) + bindata (2.5.0) + bindex (0.8.1) + bootsnap (1.18.3) msgpack (~> 1.2) bootstrap (5.2.3) autoprefixer-rails (>= 9.1.0) popper_js (>= 2.11.6, < 3) sassc-rails (>= 2.0.0) - brakeman (6.2.1) - racc + brakeman (5.4.1) + bugsnag (6.27.0) + concurrent-ruby (~> 1.0) builder (3.3.0) - capistrano (3.19.1) + capistrano (3.18.1) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -122,77 +125,105 @@ GEM sshkit (~> 1.3) capistrano-yarn (2.0.2) capistrano (~> 3.0) - capybara (3.40.0) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.11) + nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) chart-js-rails (0.1.7) railties (> 3.1) + childprocess (5.0.0) coderay (1.1.3) - concurrent-ruby (1.3.4) + concurrent-ruby (1.3.3) + crack (1.0.0) + bigdecimal + rexml crass (1.0.6) - cube-ruby (0.0.3) - daemons (1.4.1) + css_parser (1.17.1) + addressable dalli (3.2.8) date (3.3.4) debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) + deepl-rb (2.5.3) diff-lcs (1.5.1) + docile (1.4.0) domain_name (0.6.20240107) ed25519 (1.3.0) erubi (1.13.0) erubis (2.7.0) - eventmachine (1.2.7) - excon (0.111.0) + excon (0.110.0) execjs (2.9.1) - faraday (2.12.0) - faraday-net_http (>= 2.0, < 3.4) - json - logger - faraday-excon (2.2.0) - excon (>= 0.109.0) - faraday (>= 2.11.0, < 3) + faraday (2.0.1) + faraday-net_http (~> 2.0) + ruby2_keywords (>= 0.0.4) + faraday-excon (2.0.0) + excon (>= 0.27.4) + faraday (~> 2.0.0.alpha.pre.2) + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (3.3.0) - net-http - ffi (1.17.0) - ffi (1.17.0-arm64-darwin) - ffi (1.17.0-x86_64-darwin) + faraday-net_http (2.1.0) + ffi (1.16.3) flag-icons-rails (3.4.6.1) sass-rails - flamegraph (0.9.5) globalid (1.2.1) activesupport (>= 6.1) - graphql (2.0.31) + graphql (2.3.5) base64 - graphql-client (0.23.0) + graphql-client (0.22.0) activesupport (>= 3.0) graphql (>= 1.13.0) haml (5.2.2) temple (>= 0.8.0) tilt + haml-rails (2.1.0) + actionpack (>= 5.1) + activesupport (>= 5.1) + haml (>= 4.0.6) + railties (>= 5.1) + hashdiff (1.1.0) + hashie (5.0.0) + highline (2.1.0) html2haml (2.3.0) erubis (~> 2.7.0) haml (>= 4.0) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) + htmlbeautifier (1.4.3) + htmlentities (4.3.4) http-accept (1.7.0) - http-cookie (1.0.7) + http-cookie (1.0.6) domain_name (~> 0.5) - i18n (1.14.6) + i18n (1.14.5) concurrent-ruby (~> 1.0) - inline_svg (1.10.0) + i18n-tasks (0.9.37) + activesupport (>= 4.0.2) + ast (>= 2.1.0) + erubi + highline (>= 2.0.0) + i18n + parser (>= 2.2.3.0) + rails-i18n + rainbow (>= 2.2.2, < 4.0) + terminal-table (>= 1.5.1) + i18n-tasks-csv (1.1) + i18n-tasks (~> 0.9) + importmap-rails (2.0.1) + actionpack (>= 6.0.0) + activesupport (>= 6.0.0) + railties (>= 6.0.0) + inline_svg (1.9.0) activesupport (>= 3.0) nokogiri (>= 1.6) io-console (0.7.2) - irb (1.14.0) + irb (1.13.1) rdoc (>= 4.0.0) reline (>= 0.4.2) iso-639 (0.3.6) @@ -202,17 +233,48 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (7.0.0) railties (>= 3.2.16) - jsbundling-rails (1.3.1) + jsbundling-rails (1.3.0) railties (>= 6.0.0) json (2.7.2) + json-jwt (1.16.6) + activesupport (>= 4.2) + aes_key_wrap + base64 + bindata + faraday (~> 2.0) + faraday-follow_redirects + jwt (2.8.1) + base64 language_server-protocol (3.17.0.3) + launchy (3.0.1) + addressable (~> 2.8) + childprocess (~> 5.0) + letter_opener (1.10.0) + launchy (>= 2.2, < 4) + letter_opener_web (2.0.0) + actionmailer (>= 5.2) + letter_opener (~> 1.7) + railties (>= 5.2) + rexml listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) + lookbook (1.5.5) + actioncable + activemodel + css_parser + htmlbeautifier (~> 1.3) + htmlentities (~> 4.3.4) + listen (~> 3.0) + railties (>= 5.0) + redcarpet (~> 3.5) + rouge (>= 3.26, < 5.0) + view_component (> 2.0, < 4) + yard (~> 0.9.25) + zeitwerk (~> 2.5) lz4-ruby (0.3.3) mail (2.8.1) mini_mime (>= 0.1.1) @@ -224,19 +286,21 @@ GEM method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2024.0903) + mime-types-data (3.2024.0604) mini_mime (1.1.5) - minitest (5.25.1) + minitest (5.23.1) msgpack (1.7.2) multi_json (1.15.0) + multi_xml (0.6.0) multipart-post (2.4.1) - mysql2 (0.5.5) - net-ftp (0.3.7) + mutex_m (0.2.0) + mysql2 (0.5.6) + net-ftp (0.2.1) net-protocol time - net-http (0.4.1) + net-http (0.3.2) uri - net-imap (0.4.16) + net-imap (0.4.12) date net-protocol net-pop (0.1.2) @@ -251,49 +315,81 @@ GEM net-protocol net-ssh (7.2.3) netrc (0.11.0) - newrelic_rpm (9.13.0) + newrelic_rpm (9.10.2) nio4r (2.7.3) - nokogiri (1.16.7-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.7-x86_64-darwin) + nokogiri (1.15.6-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) + nokogiri (1.15.6-x86_64-linux) racc (~> 1.4) - oj (3.16.6) + oauth2 (2.0.9) + faraday (>= 0.17.3, < 3.0) + jwt (>= 1.0, < 3.0) + multi_xml (~> 0.5) + rack (>= 1.2, < 4) + snaky_hash (~> 2.0) + version_gem (~> 1.1) + oj (3.16.4) bigdecimal (>= 3.0) - ostruct (>= 0.2) - open_uri_redirections (0.2.1) - ostruct (0.6.0) - parallel (1.26.3) - parser (3.3.5.0) + omniauth (2.1.2) + hashie (>= 3.4.6) + rack (>= 2.2.3) + rack-protection + omniauth-github (2.0.1) + omniauth (~> 2.0) + omniauth-oauth2 (~> 1.8) + omniauth-google-oauth2 (1.1.2) + jwt (>= 2.0) + oauth2 (~> 2.0) + omniauth (~> 2.0) + omniauth-oauth2 (~> 1.8) + omniauth-keycloak (1.5.2) + faraday + json-jwt (> 1.13.0) + omniauth (>= 2.0) + omniauth-oauth2 (>= 1.7, < 1.9) + omniauth-oauth2 (1.8.0) + oauth2 (>= 1.4, < 3) + omniauth (~> 2.0) + omniauth-orcid (2.1.1) + omniauth-oauth2 (~> 1.3) + ruby_dig (~> 0.0.2) + omniauth-rails_csrf_protection (1.0.2) + actionpack (>= 4.2) + omniauth (~> 2.0) + parallel (1.25.1) + parser (3.3.3.0) ast (~> 2.4.1) racc popper_js (2.11.8) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - psych (3.3.4) - public_suffix (6.0.1) - racc (1.8.1) + psych (5.1.2) + stringio + public_suffix (5.0.5) + puma (5.6.8) + nio4r (~> 2.0) + racc (1.8.0) rack (2.2.9) - rack-mini-profiler (3.3.1) - rack (>= 1.2.0) + rack-protection (3.2.0) + base64 (>= 0.1.0) + rack (~> 2.2, >= 2.2.4) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails (7.0.3) + actioncable (= 7.0.3) + actionmailbox (= 7.0.3) + actionmailer (= 7.0.3) + actionpack (= 7.0.3) + actiontext (= 7.0.3) + actionview (= 7.0.3) + activejob (= 7.0.3) + activemodel (= 7.0.3) + activerecord (= 7.0.3) + activestorage (= 7.0.3) + activesupport (= 7.0.3) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.0.3) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -301,13 +397,12 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails_autolink (1.1.8) - actionview (> 3.1) - activesupport (> 3.1) - railties (> 3.1) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + rails-i18n (7.0.9) + i18n (>= 0.7, < 2) + railties (>= 6.0.0, < 8) + railties (7.0.3) + actionpack (= 7.0.3) + activesupport (= 7.0.3) method_source rake (>= 12.2) thor (~> 1.0) @@ -317,52 +412,59 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rdoc (6.3.4.1) + rdoc (6.7.0) + psych (>= 4.0.0) recaptcha (5.9.0) json - redis (4.8.1) + redcarpet (3.6.0) regexp_parser (2.9.2) - reline (0.5.10) + reline (0.5.9) 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.7) - rspec-core (3.13.1) + rexml (3.3.0) + strscan + rouge (4.3.0) + rspec-core (3.13.0) rspec-support (~> 3.13.0) - rspec-expectations (3.13.3) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (7.0.1) - actionpack (>= 7.0) - activesupport (>= 7.0) - railties (>= 7.0) + rspec-rails (6.1.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) rspec-core (~> 3.13) rspec-expectations (~> 3.13) rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - rubocop (1.66.1) + rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rubocop-ast (>= 1.32.2, < 2.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.3) + rubocop-ast (1.31.3) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) - ruby_parser (3.21.1) + ruby2_keywords (0.0.5) + ruby_dig (0.0.2) + ruby_parser (3.21.0) racc (~> 1.5) sexp_processor (~> 4.16) + rubyzip (2.3.2) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) sassc (2.4.0) @@ -374,63 +476,95 @@ GEM sprockets-rails tilt select2-rails (4.0.13) - sexp_processor (4.17.2) + selenium-webdriver (4.9.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + sexp_processor (4.17.1) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-cobertura (2.1.0) + rexml + simplecov (~> 0.19) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + 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) - sprockets-rails (3.5.2) + sprockets-rails (3.5.1) actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) - sshkit (1.23.1) + sshkit (1.22.2) base64 + mutex_m net-scp (>= 1.1.2) net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) - ostruct - stackprof (0.2.26) - stimulus-rails (1.3.4) + stimulus-rails (1.3.3) railties (>= 6.0.0) - strscan (3.0.1) + stringio (3.1.1) + strscan (3.1.0) temple (0.10.3) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) terser (1.2.3) execjs (>= 0.3.0, < 3) - thin (1.8.2) - daemons (~> 1.0, >= 1.0.9) - eventmachine (~> 1.0, >= 1.0.4) - rack (>= 1, < 3) - thor (1.3.2) - tilt (2.4.0) - time (0.4.0) + thor (1.3.1) + tilt (2.3.0) + time (0.3.0) date timeout (0.4.1) - turbo-rails (2.0.9) + turbo-rails (2.0.5) actionpack (>= 6.0.0) + activejob (>= 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) + unicode-display_width (2.5.0) + uri (0.13.0) + version_gem (1.1.4) + view_component (2.83.0) + activesupport (>= 5.2.0, < 8.0) + concurrent-ruby (~> 1.0) + method_source (~> 1.0) + web-console (4.2.1) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) + bindex (>= 0.4.0) + railties (>= 6.0.0) + webmock (3.23.1) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.18) + yard (0.9.36) + zeitwerk (2.6.15) PLATFORMS - arm64-darwin-22 - arm64-darwin-23 - x86_64-darwin-21 + x86_64-darwin-23 + x86_64-linux x86_64-linux + x86_64-linux-musl DEPENDENCIES - base64 (= 0.1.0) bcrypt_pbkdf (>= 1.0, < 2.0) bootsnap bootstrap (~> 5.2.3) brakeman + bugsnag (~> 6.26) capistrano (~> 3.17) capistrano-bundler capistrano-locally @@ -440,53 +574,62 @@ DEPENDENCIES capistrano-yarn capybara chart-js-rails - cube-ruby dalli debug + deepl-rb ed25519 (>= 1.2, < 2.0) + ffi (~> 1.16.3) flag-icons-rails (~> 3.4) - flamegraph - graphql (~> 2.0.27) graphql-client haml (~> 5.1) + haml-rails html2haml i18n + i18n-tasks + i18n-tasks-csv (~> 1.1) + importmap-rails inline_svg iso-639 (~> 0.3.6) jquery-rails jquery-ui-rails - jsbundling-rails (~> 1.3) - listen + jsbundling-rails + letter_opener_web (~> 2.0) + lookbook (~> 1.5.5) multi_json - mysql2 (= 0.5.5) - net-ftp + mysql2 + net-ftp (~> 0.2.0) + net-http (~> 0.3.2) newrelic_rpm oj + omniauth + omniauth-github + omniauth-google-oauth2 + omniauth-keycloak + omniauth-orcid + omniauth-rails_csrf_protection ontologies_api_client! - open_uri_redirections pry - psych (< 4) - rack-mini-profiler - rails (= 7.0.8) - rails_autolink - rdoc + puma (~> 5.0) + rails (= 7.0.3) + rails-i18n (~> 7.0.0) recaptcha (~> 5.9.0) - redis (~> 4.0) rest-client - rexml (~> 3) rspec-rails rubocop sassc-rails select2-rails + selenium-webdriver + simplecov + simplecov-cobertura sprockets-rails - stackprof stimulus-rails - strscan (= 3.0.1) terser - thin turbo-rails tzinfo-data + view_component (~> 2.72) + web-console + webmock will_paginate (~> 3.0) BUNDLED WITH - 2.5.11 + 2.3.23 diff --git a/Procfile.dev b/Procfile.dev index b19ff761b..03c54b1d7 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,2 +1,2 @@ -web: env RUBY_DEBUG_OPEN=true bin/rails server +web: bin/rails server -p 3000 js: yarn build --watch diff --git a/README b/README deleted file mode 100644 index 0d6affddc..000000000 --- a/README +++ /dev/null @@ -1,182 +0,0 @@ -== Welcome to Rails - -Rails is a web-application and persistence framework that includes everything -needed to create database-backed web-applications according to the -Model-View-Control pattern of separation. This pattern splits the view (also -called the presentation) into "dumb" templates that are primarily responsible -for inserting pre-built data in between HTML tags. The model contains the -"smart" domain objects (such as Account, Product, Person, Post) that holds all -the business logic and knows how to persist themselves to a database. The -controller handles the incoming requests (such as Save New Account, Update -Product, Show Post) by manipulating the model and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting started - -1. At the command prompt, start a new rails application using the rails command - and your application name. Ex: rails myapp - (If you've downloaded rails in a complete tgz or zip, this step is already done) -2. Change directory into myapp and start the web server: script/server (run with --help for options) -3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!" -4. Follow the guidelines to start developing your application - - -== Web Servers - -By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise -Rails will use the WEBrick, the webserver that ships with Ruby. When you run script/server, -Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures -that you can always get up and running quickly. - -Mongrel is a Ruby-based webserver with a C-component (which requires compilation) that is -suitable for development and deployment of Rails applications. If you have Ruby Gems installed, -getting up and running with mongrel is as easy as: gem install mongrel. -More info at: http://mongrel.rubyforge.org - -If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than -Mongrel and WEBrick and also suited for production use, but requires additional -installation and currently only works well on OS X/Unix (Windows users are encouraged -to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from -http://www.lighttpd.net. - -And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby -web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not -for production. - -But of course its also possible to run Rails on any platform that supports FCGI. -Apache, LiteSpeed, IIS are just a few. For more information on FCGI, -please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI - - -== Debugging Rails - -Have "tail -f" commands running on the server.log and development.log. Rails will -automatically display debugging and runtime information to these files. Debugging -info will also be shown in the browser on requests from 127.0.0.1. - - -== Breakpoints - -Breakpoint support is available through the script/breakpointer client. This -means that you can break out of execution at any point in the code, investigate -and change the model, AND then resume execution! Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find(:all) - breakpoint "Breaking out from the list" - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the breakpointer window. Here you can do things like: - -Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint' - - >> @posts.inspect - => "[#nil, \"body\"=>nil, \"id\"=>\"1\"}>, - #\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" - >> @posts.first.title = "hello from a breakpoint" - => "hello from a breakpoint" - -...and even better is that you can examine how your runtime objects actually work: - - >> f = @posts.first - => #nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you press CTRL-D - - -== Console - -You can interact with the domain model by starting the console through script/console. -Here you'll have all parts of the application configured, just like it is when the -application is running. You can inspect domain models, change values, and save to the -database. Starting the script without arguments will launch it in the development environment. -Passing an argument will specify a different environment, like script/console production. - -To reload your controllers and models after launching the console run reload! - -To reload your controllers and models after launching the console run reload! - - - -== Description of contents - -app - Holds all the code that's specific to this particular application. - -app/controllers - Holds controllers that should be named like weblogs_controller.rb for - automated URL mapping. All controllers should descend from ApplicationController - which itself descends from ActionController::Base. - -app/models - Holds models that should be named like post.rb. - Most models will descend from ActiveRecord::Base. - -app/views - Holds the template files for the view that should be named like - weblogs/index.rhtml for the WeblogsController#index action. All views use eRuby - syntax. - -app/views/layouts - Holds the template files for layouts to be used with views. This models the common - header/footer method of wrapping views. In your views, define a layout using the - layout :default and create a file named default.rhtml. Inside default.rhtml, - call <% yield %> to render the view using this layout. - -app/helpers - Holds view helpers that should be named like weblogs_helper.rb. These are generated - for you automatically when using script/generate for controllers. Helpers can be used to - wrap functionality for your views into methods. - -config - Configuration files for the Rails environment, the routing map, the database, and other dependencies. - -components - Self-contained mini-applications that can bundle together controllers, models, and views. - -db - Contains the database schema in schema.rb. db/migrate contains all - the sequence of Migrations for your schema. - -doc - This directory is where your application documentation will be stored when generated - using rake doc:app - -lib - Application specific libraries. Basically, any kind of custom code that doesn't - belong under controllers, models, or helpers. This directory is in the load path. - -public - The directory available for the web server. Contains subdirectories for images, stylesheets, - and javascripts. Also contains the dispatchers and the default HTML files. This should be - set as the DOCUMENT_ROOT of your web server. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. When using the script/generate scripts, template - test files will be generated for you and placed in this directory. - -vendor - External libraries that the application depends on. Also includes the plugins subdirectory. - This directory is in the load path. diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index 3e1c15c81..000000000 --- a/README.rdoc +++ /dev/null @@ -1,261 +0,0 @@ -== Welcome to Rails - -Rails is a web-application framework that includes everything needed to create -database-backed web applications according to the Model-View-Control pattern. - -This pattern splits the view (also called the presentation) into "dumb" -templates that are primarily responsible for inserting pre-built data in between -HTML tags. The model contains the "smart" domain objects (such as Account, -Product, Person, Post) that holds all the business logic and knows how to -persist themselves to a database. The controller handles the incoming requests -(such as Save New Account, Update Product, Show Post) by manipulating the model -and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting Started - -1. At the command prompt, create a new Rails application: - rails new myapp (where myapp is the application name) - -2. Change directory to myapp and start the web server: - cd myapp; rails server (run with --help for options) - -3. Go to http://localhost:3000/ and you'll see: - "Welcome aboard: You're riding Ruby on Rails!" - -4. Follow the guidelines to start developing your application. You can find -the following resources handy: - -* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html -* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ - - -== Debugging Rails - -Sometimes your application goes wrong. Fortunately there are a lot of tools that -will help you debug it and get it back on the rails. - -First area to check is the application log files. Have "tail -f" commands -running on the server.log and development.log. Rails will automatically display -debugging and runtime information to these files. Debugging info will also be -shown in the browser on requests from 127.0.0.1. - -You can also log your own messages directly into the log file from your code -using the Ruby logger class from inside your controllers. Example: - - class WeblogController < ActionController::Base - def destroy - @weblog = Weblog.find(params[:id]) - @weblog.destroy - logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") - end - end - -The result will be a message in your log file along the lines of: - - Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! - -More information on how to use the logger is at http://www.ruby-doc.org/core/ - -Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are -several books available online as well: - -* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) -* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) - -These two books will bring you up to speed on the Ruby language and also on -programming in general. - - -== Debugger - -Debugger support is available through the debugger command when you start your -Mongrel or WEBrick server with --debugger. This means that you can break out of -execution at any point in the code, investigate and change the model, and then, -resume execution! You need to install ruby-debug to run the server in debugging -mode. With gems, use sudo gem install ruby-debug. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.all - debugger - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the server window. Here you can do things like: - - >> @posts.inspect - => "[#nil, "body"=>nil, "id"=>"1"}>, - #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" - >> @posts.first.title = "hello from a debugger" - => "hello from a debugger" - -...and even better, you can examine how your runtime objects actually work: - - >> f = @posts.first - => #nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you can enter "cont". - - -== Console - -The console is a Ruby shell, which allows you to interact with your -application's domain model. Here you'll have all parts of the application -configured, just like it is when the application is running. You can inspect -domain models, change values, and save to the database. Starting the script -without arguments will launch it in the development environment. - -To start the console, run rails console from the application -directory. - -Options: - -* Passing the -s, --sandbox argument will rollback any modifications - made to the database. -* Passing an environment name as an argument will load the corresponding - environment. Example: rails console production. - -To reload your controllers and models after launching the console run -reload! - -More information about irb can be found at: -link:http://www.rubycentral.org/pickaxe/irb.html - - -== dbconsole - -You can go to the command line of your database directly through rails -dbconsole. You would be connected to the database with the credentials -defined in database.yml. Starting the script without arguments will connect you -to the development database. Passing an argument will connect you to a different -database, like rails dbconsole production. Currently works for MySQL, -PostgreSQL and SQLite 3. - -== Description of Contents - -The default directory structure of a generated Ruby on Rails application: - - |-- app - | |-- assets - | | |-- images - | | |-- javascripts - | | `-- stylesheets - | |-- controllers - | |-- helpers - | |-- mailers - | |-- models - | `-- views - | `-- layouts - |-- config - | |-- environments - | |-- initializers - | `-- locales - |-- db - |-- doc - |-- lib - | |-- assets - | `-- tasks - |-- log - |-- public - |-- script - |-- test - | |-- fixtures - | |-- functional - | |-- integration - | |-- performance - | `-- unit - |-- tmp - | `-- cache - | `-- assets - `-- vendor - |-- assets - | |-- javascripts - | `-- stylesheets - `-- plugins - -app - Holds all the code that's specific to this particular application. - -app/assets - Contains subdirectories for images, stylesheets, and JavaScript files. - -app/controllers - Holds controllers that should be named like weblogs_controller.rb for - automated URL mapping. All controllers should descend from - ApplicationController which itself descends from ActionController::Base. - -app/models - Holds models that should be named like post.rb. Models descend from - ActiveRecord::Base by default. - -app/views - Holds the template files for the view that should be named like - weblogs/index.html.erb for the WeblogsController#index action. All views use - eRuby syntax by default. - -app/views/layouts - Holds the template files for layouts to be used with views. This models the - common header/footer method of wrapping views. In your views, define a layout - using the layout :default and create a file named default.html.erb. - Inside default.html.erb, call <% yield %> to render the view using this - layout. - -app/helpers - Holds view helpers that should be named like weblogs_helper.rb. These are - generated for you automatically when using generators for controllers. - Helpers can be used to wrap functionality for your views into methods. - -config - Configuration files for the Rails environment, the routing map, the database, - and other dependencies. - -db - Contains the database schema in schema.rb. db/migrate contains all the - sequence of Migrations for your schema. - -doc - This directory is where your application documentation will be stored when - generated using rake doc:app - -lib - Application specific libraries. Basically, any kind of custom code that - doesn't belong under controllers, models, or helpers. This directory is in - the load path. - -public - The directory available for the web server. Also contains the dispatchers and the - default HTML files. This should be set as the DOCUMENT_ROOT of your web - server. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. When using the rails generate - command, template test files will be generated for you and placed in this - directory. - -vendor - External libraries that the application depends on. Also includes the plugins - subdirectory. If the app has frozen rails, those gems also go here, under - vendor/rails/. This directory is in the load path. diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 06cd2e302..7e1b0acbe 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -39,7 +39,7 @@ class ApplicationController < ActionController::Base # See ActionController::RequestForgeryProtection for details protect_from_forgery - before_action :set_global_thread_values, :domain_ontology_set, :authorize_miniprofiler, :clean_empty_strings_from_params_arrays, :init_trial_license + before_action :set_global_thread_values, :domain_ontology_set, :clean_empty_strings_from_params_arrays, :init_trial_license def set_global_thread_values Thread.current[:session] = session @@ -271,14 +271,7 @@ def params_string_for_redirect(params, options = {}) params_array.empty? ? "" : "#{prefix}#{params_array.join('&')}" end - # rack-mini-profiler authorization - def authorize_miniprofiler - if params[:enable_profiler] && params[:enable_profiler].eql?("true") && session[:user] && session[:user].admin? - Rack::MiniProfiler.authorize_request - else - Rack::MiniProfiler.deauthorize_request - end - end + # Verifies if user is logged in def authorize_and_redirect diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 12ec47cfe..9d1d87a7d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -285,7 +285,7 @@ def get_link_for_cls_ajax(cls_id, ont_acronym, target = nil) data_ont = " data-ont='#{ont_acronym}' " "#{cls_id}" else - auto_link(cls_id, :all, target: '_blank') + content_tag(:div, cls_id) end end diff --git a/bin/dev b/bin/dev index eda330c72..a4e05fa14 100755 --- a/bin/dev +++ b/bin/dev @@ -1,6 +1,6 @@ #!/usr/bin/env sh -if gem list --no-installed --exact --silent foreman; then +if ! gem list foreman -i --silent; then echo "Installing foreman..." gem install foreman fi diff --git a/bin/ontoportal b/bin/ontoportal new file mode 100755 index 000000000..3fa5d2939 --- /dev/null +++ b/bin/ontoportal @@ -0,0 +1,213 @@ +#!/usr/bin/env bash + +# Function to display script usage information +show_help() { + echo "Usage: $0 {dev|test|run|help} [--reset-cache] [--api-url API_URL] [--api-key API_KEY]" + echo " dev : Start the Ontoportal Web UI development server." + echo " Example: $0 dev --api-url http://localhost:9393 --api-key my_api_key" + echo " Use --reset-cache to remove volumes: $0 dev --reset-cache" + echo " test : Run tests. Specify either a test file:line_number or empty for 'all'." + echo " Example: $0 test test/integration/login_flows_test.rb:22 " + echo " run : Run a command in the Ontoportal Web UI Docker container." + echo " help : Show this help message." + echo + echo "Description:" + echo " This script provides convenient commands for managing an Ontoportal Web UI" + echo " application using Docker Compose. It includes options for starting the development server," + echo " running tests, and executing commands within the Ontoportal Web UI Docker container." + echo + echo "Goals:" + echo " - Simplify common tasks related to Ontoportal Web UI development using Docker." + echo " - Provide a consistent and easy-to-use interface for common actions." +} +# Function to update or create the .env file with API_URL and API_KEY +update_env_file() { + local api_url="$1" + local api_key="$2" + + # Update the .env file with the provided values + file_content=$(<.env) + + # Make changes to the variable + while IFS= read -r line; do + if [[ "$line" == "API_URL="* ]]; then + echo "API_URL=$api_url" + elif [[ "$line" == "API_KEY="* ]]; then + echo "API_KEY=$api_key" + else + echo "$line" + fi + done <<< "$file_content" > .env +} + +# Function to create configuration files if they don't exist +create_config_files() { + if [ ! -f ".env" ]; then + echo "Creating .env file from env.sample" + cp .env.sample .env + fi + + if [ ! -f "config/bioportal_config_development.rb" ]; then + echo "Creating config/bioportal_config_development.rb file from config/bioportal_config_env.rb.sample" + cp config/bioportal_config_env.rb.sample config/bioportal_config_development.rb + fi + + if [ ! -f "config/database.yml" ]; then + echo "Creating config/database.yml file from config/database.yml.sample" + cp config/database.yml.sample config/database.yml + fi +} + +# Function to handle the "dev" option +dev() { + echo "Starting Ontoportal Web UI development server..." + + + local reset_cache=false + local api_client_path="" + local api_url="" + local api_key="" + + # Check for command line arguments + while [[ "$#" -gt 0 ]]; do + case $1 in + --api-client-path) + api_client_path="$2" + shift 2 + ;; + --reset-cache) + reset_cache=true + shift + ;; + --api-url) + api_url="$2" + shift 2 + ;; + --api-key) + api_key="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" + show_help + exit 1 + ;; + esac + done + + + + # Check if arguments are provided + if [ -n "$api_url" ] && [ -n "$api_key" ]; then + # If arguments are provided, update the .env file + update_env_file "$api_url" "$api_key" + else + # If no arguments, fetch values from the .env file + source .env + api_url="$API_URL" + api_key="$API_KEY" + fi + + if [ -z "$api_url" ] || [ -z "$api_key" ]; then + echo "Error: Missing required arguments. Please provide both --api-url and --api-key or update them in your .env" + exit 1 + fi + + # Check if --reset-cache is present and execute docker compose down --volumes + if [ "$reset_cache" = true ]; then + echo "Resetting cache. Running: docker compose down --volumes" + docker compose down --volumes + fi + + local docker_run_cmd="docker compose run --rm -it" + local bash_cmd="" + # Conditionally add bind mounts only if the paths are not empty + for path_var in "api_client_path:ontologies_api_ruby_client" ; do + IFS=':' read -r path value <<< "$path_var" + + if [ -n "${!path}" ]; then + host_path="$(realpath "$(dirname "${!path}")")/$value" + echo "Run: bundle config local.$value ${!path}" + container_path="/app/tmp/$value" + docker_run_cmd+=" -v $host_path:$container_path" + bash_cmd+="(bundle config local.ontologies_api_client $container_path) &&" + else + bash_cmd+=" (bundle config unset local.ontologies_api_client) &&" + fi + done + bash_cmd+=" (bundle check || bundle install) && bin/rails secret && EDITOR='nano' bin/rails credentials:edit && bin/rails db:prepare && bundle exec rails s -b 0.0.0.0 -p 3000" + docker_run_cmd+=" --service-ports dev bash -c \"$bash_cmd\"" + echo "$docker_run_cmd" + echo "Run: bundle exec rails s -b 0.0.0.0 -p 3000" + eval "$docker_run_cmd" +} + +# Function to handle the "test" option +test() { + + + local api_url="" + local api_key="" + local test_options="" + + # Check for command line arguments + while [ "$#" -gt 0 ]; do + case "$1" in + --api-url) + shift + api_url="$1" + ;; + *) + + if [ -z "$test_options" ]; then + test_options="$1" + else + + test_options="$test_options $1" + fi + ;; + esac + shift + done + + if [ -z "$api_url" ]; then + api_url=http://localhost:9393 + echo "Running API..." + bin/run_api + fi + + echo "Running tests..." + echo "Run: API_URL=$api_url bundle exec rails test -v $test_options" + + docker compose run --rm -it test bash -c "bundle config unset local.ontologies_api_client && (bundle check || bundle install) && RAILS_ENV=test bin/rails db:prepare && API_URL=$api_url bundle exec rails test -v $test_options" + + # echo "Stopping API..." + # bin/stop_api +} + +# Function to handle the "run" option +run() { + echo "Run: $*" + docker compose run --rm -it dev bash -c "$*" +} + +create_config_files +# Main script logic +case "$1" in + "run") + run "${@:2}" + ;; + "dev") + dev "${@:2}" + ;; + "test") + test "${@:2}" + ;; + "help") + show_help + ;; + *) + show_help + exit 1 + ;; +esac diff --git a/bin/run_api b/bin/run_api new file mode 100755 index 000000000..5d1634b2f --- /dev/null +++ b/bin/run_api @@ -0,0 +1,69 @@ +#!/bin/bash +display_help() { + echo "Usage: $0 [options]" + echo "Options:" + echo " -f Remove tmp/ontoportal_docker" + echo " -k API_KEY API key" + echo " -r REPOSITORY Image repository" + echo " -t TAG Image tag" + echo " -s ONTOLOGY Starter ontology" + echo " -u URL Remote API URL" + echo " -h Display this help message" + exit 0 +} + + +env_file_path="$(realpath "$(dirname "$0")")/../.env" + +# Read and parse the .env file +if [ -f "$env_file_path" ]; then + while IFS='=' read -r key value; do + [[ "$key" =~ ^\s*# ]] && continue # Skip commented lines + [[ "$value" ]] || continue # Skip lines without values + export "$key"="$value" + done < "$env_file_path" +fi + + +while getopts ":k:r:t:s:u:fh" opt; do + case $opt in + k) api_key="$OPTARG" ;; + r) image_repository="$OPTARG" ;; + t) image_tag="$OPTARG" ;; + s) starter_ontology="$OPTARG" ;; + u) remote_api_url="$OPTARG" ;; + f) rm -fr tmp/ontoportal_docker ;; + h) display_help ;; + \?) echo "Invalid option: -$OPTARG" >&2; exit 1 ;; + :) echo "Option -$OPTARG requires an argument." >&2; exit 1 ;; + esac +done + + + +if [ ! -d "tmp/ontoportal_docker" ]; then + git clone --depth=1 -b main https://github.com/ontoportal-lirmm/ontoportal_docker.git tmp/ontoportal_docker +fi + +# If an option is not provided, check and use the corresponding value from the environment variables +api_key="${api_key:-$OP_API_KEY}" +image_repository="${image_repository:-$API_IMAGE_REPOSITORY}" +image_tag="${image_tag:-$API_IMAGE_TAG}" +starter_ontology="${starter_ontology:-$STARTER_ONTOLOGY}" +remote_api_url="${remote_api_url:-$OP_API_URL}" + +if curl -sSf http://localhost:9393 > /dev/null 2>&1; then + echo "API is already running in http://localhost:9393" + exit 0 +fi + +# Check if the Docker Compose service exists +docker compose ls -a --filter "name=ontoportal_docker" | grep -q "ontoportal_docker" && no_provision=true || no_provision=false +( + cd tmp/ontoportal_docker || exit 1 + command="./run -k $api_key -r $image_repository -t $image_tag -s $starter_ontology -u $remote_api_url" + [ "$no_provision" = true ] && command="$command" + echo "Run: $command" + eval "$command" +) + diff --git a/bin/setup b/bin/setup index 3bf0c5297..ec47b79b3 100755 --- a/bin/setup +++ b/bin/setup @@ -2,7 +2,7 @@ require "fileutils" # path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") @@ -17,9 +17,6 @@ FileUtils.chdir APP_ROOT do system! "gem install bundler --conservative" system("bundle check") || system!("bundle install") - # Install JavaScript dependencies - system! 'bin/yarn' - # puts "\n== Copying sample files ==" # unless File.exist?("config/database.yml") # FileUtils.cp "config/database.yml.sample", "config/database.yml" diff --git a/bin/stop_api b/bin/stop_api new file mode 100755 index 000000000..31308b172 --- /dev/null +++ b/bin/stop_api @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Check if the directory exists +if [ -d "tmp/ontoportal_docker" ]; then + # Check if the container is running + if docker ps --filter "name=ontoportal_docker-api" --format "{{.Names}}" | grep -q "ontoportal_docker-api"; then + container_names=$(docker ps --filter "name=ontoportal_docker-api" --format "{{.Names}}") + docker stop "$container_names" + fi + + cd "tmp/ontoportal_docker" && docker compose down --volumes +fi + diff --git a/config/application.rb b/config/application.rb index 65e56ea9c..77aa0796f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,13 +9,12 @@ module BioportalWebUi class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.1 - config.active_support.cache_format_version = 6.1 - config.active_support.disable_to_s_conversion = true - config.active_record.yaml_column_permitted_classes = [ - ActionController::Parameters, - HashWithIndifferentAccess - ] + config.load_defaults 7.0 + + # permitted locales available for the application + config.i18n.available_locales = [:en, :fr, :it, :de] + config.i18n.default_locale = :en + # Configuration for the application, engines, and railties goes here. # @@ -27,9 +26,17 @@ class Application < Rails::Application config.exceptions_app = self.routes - config.settings = config_for :settings + config.autoload_paths += %W[#{config.root}/app/lib/kgcl] + + config.settings = config_for :settings # Initialize configuration for KGCL change request functionality. config.change_request = config_for :change_request + + config.generators.template_engine = :haml + config.generators.test_framework = nil + + # Set the default layout to app/views/layouts/component_preview.html.erb + config.view_component.default_preview_layout = "component_preview" end end diff --git a/config/bioportal_config_env.rb.sample b/config/bioportal_config_env.rb.sample index 8ccef8e12..277b97201 100644 --- a/config/bioportal_config_env.rb.sample +++ b/config/bioportal_config_env.rb.sample @@ -1,82 +1,136 @@ -# coding: utf-8 - # Organization info -$ORG = "NCBO" -$ORG_URL = "http://www.bioontology.org" +$ORG = ENV['ORG'] +$ORG_URL = ENV['ORG_URL'] # Site name (required) -$SITE = "BioPortal" +$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 = "http://bioportal.bioontology.org" +$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' -# Unique string representing the UI's id for use with the BioPortal API -$API_KEY = "" +# 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 = "http://example.org:8080/" +$REST_URL = ENV['API_URL'] -# Ontolobridge endpoint url -$ONTOLOBRIDGE_BASE_URL = "https://ontolobridge.ccs.miami.edu/api-test/requests" +# 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" +$ONTOLOBRIDGE_AUTHENTICATION_TOKEN = 'Token Uq2pae73ktMtmgjUgtnhEOuHxr9sZeuK' # Ontologies for which to enable the new term request (Ontolobridge) tab $NEW_TERM_REQUEST_ONTOLOGIES = [] -# Max number of children to return when rendering a tree view -$MAX_CHILDREN = 2500 - -# Max number of children that it's possible to display (more than this is either too slow or not helpful to users) -$MAX_POSSIBLE_DISPLAY = 10000 +# 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 = "" +$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 = "" - -# 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 - -# Cube metrics reporting -$ENABLE_CUBE = false -$CUBE_HOST = "localhost" -$CUBE_PORT = 1180 +$ANALYTICS_ID = ENV['ANALYTICS_ID'] # Enable client request caching $CLIENT_REQUEST_CACHING = true -# Enable debugging of API Ruby client -$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 = [] - -# If you don't use Airbrake you can have exceptions emailed to the $ERROR_EMAIL address by setting this to 'true' -$EMAIL_EXCEPTIONS = 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 + 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 = "bioportal-test-request@lists.stanford.edu" - +$ANNOUNCE_LIST = ENV['SUPPORT_EMAIL'] # Email addresses used for sending notifications (errors, feedback, support) -$SUPPORT_EMAIL = "recipient@example.org" -$ADMIN_EMAIL = "recipient@example.org" -$ERROR_EMAIL = "recipient@example.org" +$SUPPORT_EMAIL = ENV['SUPPORT_EMAIL'] +# Email used to send notifications +$NOTIFICATION_EMAIL = ENV['SUPPORT_EMAIL'] + -# Settings for date formatting -CalendarDateSelect.format = :american # reCAPTCHA # In order to use reCAPTCHA on the account creation and feedback submission pages: @@ -89,32 +143,172 @@ CalendarDateSelect.format = :american # # 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://biomixer.bioontology.org' +# $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 = { 1000 => { "Additional Detail" => "Text to be shown in the right-hand column." } } +# $ADDITIONAL_ONTOLOGY_DETAILS = { "STY" => { "Additional Detail" => "Text to be shown in the right-hand column." } } ## $ADDITIONAL_ONTOLOGY_DETAILS = {} -################################# -## AUTO-GENERATED DO NOT MODIFY -################################# +# 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" + } + } +} + + -# Full string for site, EX: "NCBO BioPortal" -$ORG_SITE = ($ORG.nil? || $ORG.empty?) ? $SITE : "#{$ORG} #{$SITE}" +$UI_THEME = ENV['UI_THEME'] || 'ontoportal' +$HOSTNAME = ENV['API_URL'] -# Email address to mail when exceptions are raised -ExceptionNotifier.exception_recipients = [$ERROR_EMAIL] +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/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 000000000..a96b8c065 --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +0NEifnx5oHgE25IXOvUl+r2KJUh+4aPosj5xLB0hqXf7j1bT+60mgdOgU3emx5+PfU9GagfFR7Tb3dT4QbefFrnGujWqesRpYGCvKsiB1TnudiGL+jiOlb212yU5d0WqsnWNZ/0B8/oXmiv00pUMeMyMXchr9C5qJw4n0/+CGEz1NSC09SYO75mPGpizlriYLgh/d77rsMkD87XCA+fO1h27mra7jSGNe3y57r7z+sr1IMBwuWfjN3bGDhyx1SGwhMmlT5Fx4TOP/mYeNVS1EhmPdRQ5ZBSfNgLhXMPy22kX+vPtBPmSfTE7QkMNN2nTzO6V7WCSpQ3OzIZ2Uovuy6BT9jD95IiqcR5s8ZRXulqHX45fZ/ChNWdcZWh66LG7rTSsg84qqQqnim+fQf2SPJEQuyH9zpSpbMSH--Rk1H/tk4KRtT+LhV--iLJN0olR3i0IT5r29QC5Bg== \ No newline at end of file diff --git a/config/database.yml.sample b/config/database.yml.sample index 76884a865..6edf6ed31 100644 --- a/config/database.yml.sample +++ b/config/database.yml.sample @@ -12,10 +12,9 @@ default: &default adapter: mysql2 encoding: utf8mb4 - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root - password: - host: localhost + password: root + host: <%= ENV["DB_HOST"] %> development: <<: *default diff --git a/config/environment.rb b/config/environment.rb index cac531577..0c158d03b 100755 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,19 @@ # Load the Rails application. -require_relative "application" +require_relative 'application' + + +# Remove this after migrating to Rails 7.1 (https://github.com/rails/rails/issues/32947#issuecomment-1356391185) +class Rails::Application + def secret_key_base + if Rails.env.development? || Rails.env.test? || ENV["SECRET_KEY_BASE_DUMMY"] + secrets.secret_key_base ||= generate_development_secret + else + validate_secret_key_base( + ENV["SECRET_KEY_BASE"] || credentials.secret_key_base || secrets.secret_key_base + ) + end + end +end # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/appliance.rb b/config/environments/appliance.rb index dcf7bbadb..ec5f5e79f 100644 --- a/config/environments/appliance.rb +++ b/config/environments/appliance.rb @@ -80,13 +80,14 @@ # Use a different cache store in the appliance. config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211", { :namespace => 'bioportal_web_ui', :expires_in => 1.day } + # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Add custom data attributes to sanitize allowed list config.action_view.sanitized_allowed_attributes = ['id', 'class', 'style', 'data-cls', 'data-ont'] - + config.view_component.show_previews = true # TODO: Fix this? # enable json logging format. Useful for logstash # require 'rackstash' diff --git a/config/environments/development.rb b/config/environments/development.rb index 95f60f9b5..7e0593176 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -2,12 +2,21 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - + config.assets.debug = true # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false + config.action_mailer.delivery_method = :letter_opener_web + + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_deliveries = true + config.action_mailer.default_url_options = { host: '0.0.0:3000' } # Adjust the host/port as needed + + config.action_mailer_letter_opener_location = Rails.root.join('tmp', 'my_mails') + # Do not eager load code on boot. config.eager_load = false @@ -16,7 +25,9 @@ # Enable server timing config.server_timing = true - + + # Allow all hosts in development + config.hosts = nil # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join("tmp/caching-dev.txt").exist? @@ -56,22 +67,20 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = true - # Suppress logger output for asset requests. config.assets.quiet = true # memcache setup - config.cache_store = ActiveSupport::Cache::MemCacheStore.new('localhost', namespace: 'BioPortal') + config.cache_store = ActiveSupport::Cache::MemCacheStore.new('cache:11211', namespace: 'BioPortal') # Silence cache output config.cache_store.logger = Logger.new("/dev/null") if config.cache_store.respond_to?(:logger) # Add custom data attributes to sanitize allowed list config.action_view.sanitized_allowed_attributes = ['id', 'class', 'style', 'data-cls', 'data-ont'] + config.view_component.generate.sidecar = true + + config.file_watcher = ActiveSupport::FileUpdateChecker # Include BioPortal-specific configuration options require Rails.root.join('config', "bioportal_config_#{Rails.env}.rb") @@ -82,10 +91,6 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - # Use an evented file watcher to asynchronously detect changes in source code, - # routes, locales, etc. This feature depends on the listen gem. - config.file_watcher = ActiveSupport::EventedFileUpdateChecker - # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true -end +end \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index 89c5c8c7f..1e89497c1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,4 +1,4 @@ -require "active_support/core_ext/integer/time" +require 'active_support/core_ext/integer/time' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -18,7 +18,7 @@ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). - config.require_master_key = true + config.require_master_key = ENV['REQUIRE_MASTER_KEY'].present? # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. @@ -53,10 +53,10 @@ # Include generic and useful information about system operation, but avoid logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = :warn + config.log_level = :info # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -75,8 +75,8 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify + # Don't log any deprecations. + config.active_support.report_deprecations = false # Log disallowed deprecations. config.active_support.disallowed_deprecation = :log @@ -95,15 +95,18 @@ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") # Include the BioPortal-specific configuration options - require Rails.root.join('config', "bioportal_config_#{Rails.env}.rb") + if File.exist?(Rails.root.join('config', "bioportal_config_#{Rails.env}.rb")) + require Rails.root.join('config', "bioportal_config_#{Rails.env}.rb") + end # Use a different cache store in production. - config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211", { namespace: 'bioportal_web_ui', expires_in: 1.day } + config.cache_store = :mem_cache_store, ENV['MEMCACHE_SERVERS'] || 'localhost:11211', + { namespace: 'bioportal_web_ui', expires_in: 1.day } # Add custom data attributes to sanitize allowed list - config.action_view.sanitized_allowed_attributes = ['id', 'class', 'style', 'data-cls', 'data-ont'] + config.action_view.sanitized_allowed_attributes = %w[id class style data-cls data-ont] - if ENV["RAILS_LOG_TO_STDOUT"].present? + if ENV['RAILS_LOG_TO_STDOUT'].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) diff --git a/config/environments/staging.rb b/config/environments/staging.rb index a52909fae..c24addeaf 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -87,9 +87,6 @@ # Add custom data attributes to sanitize allowed list config.action_view.sanitized_allowed_attributes = ['id', 'class', 'style', 'data-cls', 'data-ont'] - # TODO: Fix this? - # enable json logging format. Useful for logstash - # require 'rackstash' - # config.rackstash.enabled = true - # config.rackstash.tags = ['ruby', 'rails2'] + # Include BioPortal-specific configuration options + require Rails.root.join('config', "bioportal_config_staging.rb") end diff --git a/config/environments/test.rb b/config/environments/test.rb index b31dce4a2..d35b8d0f7 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,6 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true + +require 'active_support/core_ext/integer/time' # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -14,7 +16,7 @@ # Eager loading loads your whole application. When running a single test locally, # this probably isn't necessary. It's a good idea to do in a continuous integration # system, or in some way before deploying your code. - config.eager_load = ENV["CI"].present? + config.eager_load = ENV['CI'].present? # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true @@ -25,7 +27,7 @@ # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - config.cache_store = :null_store + config.cache_store = ActiveSupport::Cache::MemCacheStore.new('localhost:11211', namespace: 'BioPortal') # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false @@ -53,10 +55,7 @@ config.active_support.disallowed_deprecation_warnings = [] # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true + # config.action_view.raise_on_missing_translations = true # Include the BioPortal-specific configuration options require Rails.root.join('config', "bioportal_config_#{Rails.env}.rb") diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml new file mode 100644 index 000000000..6495aad7c --- /dev/null +++ b/config/i18n-tasks.yml @@ -0,0 +1,8 @@ +# config/i18n-tasks.yml +<% require 'i18n-tasks-csv' %> + +csv: + export: + - "tmp/i18n-export/main.csv" + import: + - tmp/i18n-export/main.csv \ No newline at end of file diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 4b828e80c..15e020265 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,11 +1,9 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path. -# Rails.application.config.assets.paths << Emoji.images_path -# Add Yarn node_modules folder to the asset load path. Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. diff --git a/config/initializers/cube_reporter.rb b/config/initializers/cube_reporter.rb deleted file mode 100644 index 136f509dd..000000000 --- a/config/initializers/cube_reporter.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'cube' - -## -# This enables collection of request statistics for anaylsis via cube. -# A cube server is required. See http://square.github.io/cube/ for more info. -module Rack - class CubeReporter - - def initialize(app = nil, options = {}) - host = options[:cube_host] || "localhost" - port = options[:cube_port] || 1180 - @app = app - @cube = ::Cube::Client.new(host, port) - end - - def call(env) - start = Time.now - data = @app.call(env) - finish = Time.now - user = env["rack.session"] ? env["rack.session"][:user] : nil - apikey = user.apikey if user - username = user.username if user - req_data = { - duration_ms: ((finish - start)*1000).ceil, - path: env["REQUEST_PATH"], - status: data[0], - user: { - apikey: apikey, - username: username, - ip: env["REMOTE_ADDR"], - user_agent: env["HTTP_USER_AGENT"] - } - } - @cube.send "ui_request", DateTime.now, req_data - data - end - - end -end - -if global_variables.include?(:$ENABLE_CUBE) && $ENABLE_CUBE == true - Rails.configuration.middleware.use(::Rack::CubeReporter, {cube_host: $CUBE_HOST, cube_port: $CUBE_PORT}) -end \ No newline at end of file diff --git a/config/initializers/graphql_client.rb b/config/initializers/graphql_client.rb index 69a909bb9..9cf786411 100644 --- a/config/initializers/graphql_client.rb +++ b/config/initializers/graphql_client.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true - -require 'graphql/client' -require 'graphql/client/http' - -module GitHub - HTTPAdapter = GraphQL::Client::HTTP.new('https://api.github.com/graphql') do - def headers(_context) - { 'Authorization': "Bearer #{Rails.application.credentials[:kgcl][:github_access_token]}" } - end - end - - Client = GraphQL::Client.new( - schema: File.join(Rails.root, 'data', 'schema.json').to_s, - execute: HTTPAdapter - ) -end +# Disable as no used in ontoportal-lirmm branch and causing problems with docker image build +# require 'graphql/client' +# require 'graphql/client/http' +# +# module GitHub +# HTTPAdapter = GraphQL::Client::HTTP.new('https://api.github.com/graphql') do +# def headers(_context) +# { 'Authorization': "Bearer #{Rails.application.credentials.dig(:kgcl, :github_access_token)}" } +# end +# end +# +# Client = GraphQL::Client.new( +# schema: File.join(Rails.root, 'data', 'schema.json').to_s, +# execute: HTTPAdapter +# ) +# end diff --git a/config/initializers/miniprofiler.rb b/config/initializers/miniprofiler.rb deleted file mode 100644 index 05194cebb..000000000 --- a/config/initializers/miniprofiler.rb +++ /dev/null @@ -1,2 +0,0 @@ -Rack::MiniProfiler.config.authorization_mode = :allow_authorized -Rack::MiniProfiler.config.position = 'right' diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb index cf925f131..a579326e2 100644 --- a/config/initializers/new_framework_defaults_7_0.rb +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -11,10 +11,10 @@ # `button_to` view helper will render `