diff --git a/Gemfile b/Gemfile index fd3d45f4b..64968c1a5 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,7 @@ gem 'i18n' gem 'rails-i18n', '~> 7.0.0' gem 'iconv' gem 'multi_json' -gem 'mysql2', '0.5.3' +gem 'mysql2' gem 'oj' gem 'open_uri_redirections' gem 'pry' diff --git a/Gemfile.lock b/Gemfile.lock index f7c16a9bc..fa8c7a40a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,6 +90,7 @@ GEM ast (2.4.2) autoprefixer-rails (10.4.15.0) execjs (~> 2) + base64 (0.2.0) bcrypt_pbkdf (1.1.0) better_html (2.0.2) actionview (>= 6.0) @@ -100,7 +101,7 @@ GEM smart_properties bindata (2.4.15) bindex (0.8.1) - bootsnap (1.16.0) + bootsnap (1.17.0) msgpack (~> 1.2) bootstrap (4.2.1) autoprefixer-rails (>= 9.1.0) @@ -143,7 +144,7 @@ GEM cube-ruby (0.0.3) daemons (1.4.1) dalli (3.2.6) - date (3.3.3) + date (3.3.4) debug (1.8.0) irb (>= 1.5.0) reline (>= 0.3.1) @@ -174,7 +175,7 @@ GEM flamegraph (0.9.5) globalid (1.2.1) activesupport (>= 6.1) - graphql (2.1.3) + graphql (2.1.6) racc (~> 1.4) graphql-client (0.18.0) activesupport (>= 3.0) @@ -208,14 +209,15 @@ GEM rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) iconv (1.0.8) - importmap-rails (1.2.1) + importmap-rails (1.2.3) 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.6.0) - irb (1.8.3) + irb (1.9.0) rdoc reline (>= 0.3.8) iso-639 (0.3.6) @@ -273,18 +275,18 @@ GEM multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.3.0) - mysql2 (0.5.3) + mysql2 (0.5.5) net-ftp (0.2.0) net-protocol time - net-http (0.3.2) + net-http (0.4.0) uri - net-imap (0.4.1) + net-imap (0.4.4) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout net-scp (4.0.0) net-ssh (>= 2.6.5, < 8.0.0) @@ -292,7 +294,8 @@ GEM net-protocol net-ssh (7.2.0) netrc (0.11.0) - newrelic_rpm (9.5.0) + newrelic_rpm (9.6.0) + base64 nio4r (2.5.9) nokogiri (1.15.4-x86_64-darwin) racc (~> 1.4) @@ -390,7 +393,7 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) @@ -489,9 +492,9 @@ GEM rack (>= 1, < 3) thor (1.2.2) tilt (2.3.0) - time (0.2.2) + time (0.3.0) date - timeout (0.4.0) + timeout (0.4.1) turbo-rails (1.5.0) actionpack (>= 6.0.0) activejob (>= 6.0.0) @@ -505,7 +508,7 @@ GEM concurrent-ruby (~> 1.0) unf (0.1.4) unf_ext - unf_ext (0.0.8.2) + unf_ext (0.0.9) unicode-display_width (2.5.0) uri (0.12.2) version_gem (1.1.3) @@ -533,7 +536,6 @@ GEM zeitwerk (2.6.11) PLATFORMS - x86_64-darwin-21 x86_64-darwin-23 x86_64-linux x86_64-linux-musl @@ -573,7 +575,7 @@ DEPENDENCIES listen lookbook (~> 1.5.5) multi_json - mysql2 (= 0.5.3) + mysql2 net-ftp (~> 0.2.0) net-http newrelic_rpm diff --git a/README.md b/README.md index 33bdfb964..da0a39912 100644 --- a/README.md +++ b/README.md @@ -1,130 +1,15 @@ -bioportal_web_ui -================ - -A rails application for biological ontologies, see http://bioportal.bioontology.org/ - -## Todo - -### Finir les metadata (grosse prio) - -#### Grosses tâches - -* Faire en sorte de bien récupèrer quand on a des array de metadata (en ajoutant les champs) - * Faire une method générique (genre une class) qui permet de facilement distinguer les types de metadata (pas besoin d'ajouter les champs en dur dans le code) - -* Passer à bootstrap pour faire le joli layout? - * Dans un premier temps import bootstrap seulement dans le form? - * On pourrait faire des col pour ranger les metadata par "dates", "description", "links" dans des panels bootstrap - -* Meilleur affichage des metadata : - * Bouton pour les valeurs qui reviennent tout le temps - -#### Plein de petits todo - -* Permettre de filtrer les ontos en fct des metadata -Voir col P : https://docs.google.com/spreadsheets/d/1r1twxJvXdQXrkX0Ocis6YY08nlO5cGneCAQ5F7U_CoA/edit#gid=0 -Surtout dans les pages browse et welcome (voir les trucs en orange). Page Landscape plus tard - -Le but c'est d'avoir des résultats visibles - -* 3 blocks dans edit submission metadata - * Origin - * Toutes les prop qui ont la valeur S (colonne Q de docs.google Review of metadata prop) pour Simple - * Toutes les prop qui ont la valeur C (colonne Q de docs.google Review of metadata prop) pour Complete - - -**SEPARER License, onto hasSyntax, etc. Des meatdata de base de NCBO** - -**Change tout** -* Premier bloc avec les metadata pas du tout extraites (formats, contact, file upload...) -* 2eme bloc avec les metadata que le portal utilise: description, documentation... -* Expliquer que quand on ajoute un fichier les metadata sont updatés avec les metadata contenues dans le fichier (après le bloc des metadata non extraites)a - -X Add contact > même type de bouton que Add new Language - -Petit ? quand tu le survoles on dit qu'on extrait normalement cette metadata de l'onto à partir de: list des metadata mappings -Et on note "omv:description + rdfs:comment" quand on prend les valeurs de chaque propriété -Trouver comment montrer qu'on prend omv:naturalLanguage plusieurs fois si remplis plusieurs fois - -Rassembler toutes les dates ensembles (au lieu de simple et complete) dans un même table - -X Attention date picker par défaut marche pas sur firefox (utiliser date picker de jQuery, celui used par NCBO) - -Mettre des espaces : HASCONTRIBUTOR & cie - -Afficher dans l'interface graphique quelle metadata on remplis par défaut (on les met toutes au même endroit ?) - -TODO list : mettre un champ text plus gros ? (comme description) - -Le but est d'éviter d'avoir un gros listing indigeste de metadata - -Exemple : -Sous description ajouter bouton "voulez-vous ajouter un abstract?" -Sous release date "voulez-vous ajouter d'autre dates" -Sous contact "voulez-vous ajouter d'autres peoples" ? -Sous publisher "voulez-vous ajouter d'autre rôle d'institut etc" - -Depiction et logo à côté l'un de l'autre - -Generalizes, HASDISJUNCTIONSWITH, et toutes les metadata de relations entre onto: faire en sorte de pouvoir choisir des ontos dans BioPortal (pitit popip) - -Dans Default Properties sur le spreadsheet des metadata elles sont groupées - - -* Dans browse: permettre de trier dans l'ordre alphabétique -* Ajouter des petits drapeaux à côté des naturalLang (dans browse et dans la page de présentation des submissions) - -* IncludedInDataCatalog: faudrait avoir des boutons plutôt (voir avec logo, pour les catalogs connus comme ontobee) - -* Handling des metadata plus propre et - - -### Fermer les issues - - - -### Page Welcome - -https://github.com/sifrproject/bioportal_web_ui/issues/12 -https://github.com/agroportal/agroportal_web_ui/issues/59 - - -Dans links par exemple on peut mettre "need an ontology mapper: yamplusplus.lirmm.fr" - -Feed twitter: https://support.twitter.com/articles/20170071 -https://twitter.com/agrohackathon - - -## Resolve problems - -* Ca lag beaucoup sur des ontos avec beaucoup de submissions (comme TRANSMAT sur AgroPortal) - -* En particulier quand on ajoute une nouvelle submission - -* Add New submission bug parfois (avec uploadFile) : faire des tests, s'il faut ça fait un moment que ça plante sans qu'on s'en rende compte (on utilise beaucoup l'URL en ce moment) -```ruby -TypeError (no implicit conversion of Symbol into Integer): - app/controllers/submissions_controller.rb:28:in `[]' - app/controllers/submissions_controller.rb:28:in `create' - - -# Following line bugs -if @errors[:error][:uploadFilePath] && @errors[:error][:uploadFilePath].first[:options] -end +### Configuration +``` +cp .env.sample .env ``` -## How to - -### Add a facet filter for a metadata in browse - -In 3 files : -* app/views/ontologies/browse.html.erb -* public/browse/app.js -* app/controllers/ontologies_controller.rb - - -## Log to production.log +### Run dev +```bash +bin/ontoportal dev +``` -```ruby -Rails.logger.warn "Submission params: #{params[:submission]}" +### Run test with a local OntoPortal API +```bash +bin/ontoportal test ``` + diff --git a/bin/ontoportal b/bin/ontoportal new file mode 100755 index 000000000..963fd3ecf --- /dev/null +++ b/bin/ontoportal @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +docker compose run --rm rails bash -c "bundle check || bundle install" > /dev/null 2>&1 + +case "$1" in + "bundle") + echo "Run: $*" + docker compose run --rm -it rails bash -c "$*" + ;; + "dev") + echo "Starting development server..." + if [ ! -f ".env" ]; then + echo "the file .env was not found" + exit 0 + 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 + + echo "Run: bundle exec rails s -b 0.0.0.0" + docker compose run --rm -it --service-ports rails bash -c "bin/rails db:prepare && bundle exec rails s -b 0.0.0.0" + ;; + "test") + echo "Running API..." + bin/run_api + + echo "Running tests..." + echo "Run: API_URL=http://localhost:9393 bundle exec rails test -v $*" + docker compose run --rm -it test bash -c "RAILS_ENV=test bin/rails db:prepare && API_URL=http://localhost:9393 bundle exec rails test -v $*" + + echo "Stopping API..." + bin/stop_api + + ;; + *) + echo "Usage: $0 {dev|test|bundle}" + exit 1 + ;; +esac \ No newline at end of file diff --git a/config/bioportal_config_env.rb.sample b/config/bioportal_config_env.rb.sample index 0f747779c..b4f8a71c3 100644 --- a/config/bioportal_config_env.rb.sample +++ b/config/bioportal_config_env.rb.sample @@ -1,33 +1,17 @@ # coding: utf-8 -#local IP address lookup. This doesn't make connection to external hosts -require 'socket' -def local_ip - orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily - - UDPSocket.open do |s| - s.connect '8.8.8.8', 1 #google - s.addr.last - end -ensure - Socket.do_not_reverse_lookup = orig -end - -$LOCAL_IP = local_ip - # Organization info -$ORG = "NCBO" -$ORG_URL = "http://www.bioontology.org" +$ORG = ENV['ORG'] +$ORG_URL = ENV['ORG_URL'] # Site name (required) -$SITE = "BioPortal" -$SITE_URL = "localhost" +$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://localhost:3000" +$UI_URL = ENV['UI_URL'] # If you are running a PURL server to provide URLs for ontologies in your BioPortal instance, enable this option @@ -41,14 +25,24 @@ $PURL_PREFIX = "http://purl.bioontology.org/ontology" $ANNOTATOR_DISABLED = false # Unique string representing the UI's id for use with the BioPortal Core -$API_KEY = "" +$API_KEY = ENV['API_KEY'] # BioPortal API service address -$REST_URL = "http://example.org:8080/" +$REST_URL = ENV['API_URL'] # Annotator REST service address #$ANNOTATOR_URL = "http://services.stageportal.lirmm.fr/annotator" -$ANNOTATOR_URL = "#{$REST_URL}/annotator" +$ANNOTATOR_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'] + # Announcements sympa mailing list REQUEST address, EX: list-request@lists.example.org $ANNOUNCE_LIST_SERVICE ||= "SERVICE_EXAMPLE" @@ -97,7 +91,7 @@ $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 = ["MDRFRE", "WHO-ARTFRE", "MSHFRE", "CIM-10"] +$RESTRICTED_DOWNLOADS = [] # Ontolobridge endpoint url $ONTOLOBRIDGE_BASE_URL = "https://ontolobridge.ccs.miami.edu/api-test/requests" @@ -111,38 +105,21 @@ $NEW_TERM_REQUEST_ONTOLOGIES = [] # Legacy REST core service address (BioPortal v3.x and lower) $LEGACY_REST_URL = "http://example.org:8080/bioportal" -# 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 # Release version text (appears in footer of all pages, except 404 and 500 errors) -$RELEASE_VERSION = "4.24 (February 2016)" +$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 = "" +$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 -# Redis server to use for NCBO::Resolver -$REDIS_HOST = "" -$REDIS_PORT = 6379 - -# Cube metrics reporting -$ENABLE_CUBE = false -$CUBE_HOST = "localhost" -$CUBE_PORT = 1180 # Enable client request caching -$CLIENT_REQUEST_CACHING = false +$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 # Email settings ActionMailer::Base.smtp_settings = { @@ -153,13 +130,13 @@ 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 = "sifrportal-users@lirmm.fr" +$ANNOUNCE_LIST = ENV['SUPPORT_EMAIL'] # Email addresses used for sending notifications (errors, feedback, support) -$SUPPORT_EMAIL = "sifrportal-support@lirmm.fr" +$SUPPORT_EMAIL = ENV['SUPPORT_EMAIL'] # Email used to send notifications -$NOTIFICATION_EMAIL = "notifications@bioportal.lirmm.fr" +$NOTIFICATION_EMAIL = ENV['SUPPORT_EMAIL'] # reCAPTCHA # In order to use reCAPTCHA on the account creation and feedback submission pages: @@ -175,29 +152,11 @@ ENV['USE_RECAPTCHA'] = 'false' # Custom BioPortal logging require 'log' -$REMOTE_LOGGING = false - -## -# Flex Options -## - -# URL to pull Flex apps from -$FLEX_URL = "/flex" - -# Flex App API keys -$ANNOTATOR_FLEX_APIKEY = "" -$SEARCH_FLEX_APIKEY = "" -$RECOMMENDER_FLEX_APIKEY = "" -$FLEXOVIZ_APIKEY = "" # URL where BioMixer GWT app is located #$BIOMIXER_URL = "http://bioportal-integration.bio-mixer.appspot.com" -$BIOMIXER_URL = "http://#{$SITE_URL}/BioMixer" - -# Array with all the additional ontology metadata to display in the ontology details -$ADDITIONAL_ONTOLOGY_METADATA = ["naturalLanguage", "hasLicense", "notes", "modificationDate", "URI", "hasContributor", "hasCreator", "endorsedBy", "hasDomain", - "keyClasses", "keywords", "isOfType", "knowUsage", "designedForOntologyTask", "hasFormalityLevel", "usedImports", "usedKnowledgeRepresentationParadigm", - "usedOntologyEngineeringMethodology", "usedOntologyEngineeringTool"] +$BIOMIXER_URL = ENV['BIOMIXER_URL'] +$BIOMIXER_APIKEY = ENV['BIOMIXER_APIKEY'] ## # Custom Ontology Details @@ -215,35 +174,4 @@ $FRONT_NOTICE = '' # EX: $SITE_NOTICE = { :unique_key => 'Put your message here (can include <a href="/link">html</a> if you use single quotes).' } $SITE_NOTICE = { } -# Used in browse for facetted search to avoid having to call the API (for performance) -$FORMALITY_LEVELS = { - "http://w3id.org/nkos/nkostype#classification_schema" => "Classification scheme", - "http://w3id.org/nkos/nkostype#dictionary" => "Dictionary", - "http://w3id.org/nkos/nkostype#gazetteer" => "Gazetteer", - "http://w3id.org/nkos/nkostype#glossary" => "Glossary", - "http://w3id.org/nkos/nkostype#list" => "List", - "http://w3id.org/nkos/nkostype#name_authority_list" => "Name authority list", - "http://w3id.org/nkos/nkostype#ontology" => "Ontology", - "http://w3id.org/nkos/nkostype#semantic_network" => "Semantic network", - "http://w3id.org/nkos/nkostype#subject_heading_scheme" => "Subject heading scheme", - "http://w3id.org/nkos/nkostype#synonym_ring" => "Synonym ring", - "http://w3id.org/nkos/nkostype#taxonomy" => "Taxonomy", - "http://w3id.org/nkos/nkostype#terminology" => "Terminology", - "http://w3id.org/nkos/nkostype#thesaurus" => "Thesaurus" -} -$IS_OF_TYPE = { - "http://omv.ontoware.org/2005/05/ontology#ApplicationOntology" => "Application Ontology", - "http://omv.ontoware.org/2005/05/ontology#CoreOntology" => "Core Ontology", - "http://omv.ontoware.org/2005/05/ontology#DomainOntology" => "Domain Ontology", - "http://omv.ontoware.org/2005/05/ontology#TaskOntology" => "Task Ontology", - "http://omv.ontoware.org/2005/05/ontology#UpperLevelOntology" => "Upper Level Ontology", - "http://omv.ontoware.org/2005/05/ontology#Vocabulary" => "Vocabulary" -} -$NATURAL_LANGUAGES = { - "http://lexvo.org/id/iso639-3/eng" => "English", - "http://lexvo.org/id/iso639-3/fra" => "French", - "http://lexvo.org/id/iso639-3/spa" => "Spanish", - "http://lexvo.org/id/iso639-3/por" => "Portuguese", - "http://lexvo.org/id/iso639-3/ita" => "Italian", - "http://lexvo.org/id/iso639-3/deu" => "German" -} + diff --git a/docker-compose.yml b/docker-compose.yml index 38be0278f..e5c511191 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,52 +1,86 @@ x-app: &default-app + image: agroportal/ontoportal_web_ui build: - context: "." - target: "app" + context: . args: - - "UID=${UID:-1000}" - - "GID=${GID:-1000}" - - "RAILS_ENV=${RAILS_ENV:-production}" - - "NODE_ENV=${NODE_ENV:-production}" - depends_on: - - "db" - - "cache" - links: - - "db" - - "cache" + RUBY_VERSION: '2.7.8' + RAILS_ENV: 'development' env_file: - ".env" tty: true volumes: - - "${DOCKER_WEB_VOLUME}" - - bundle:/usr/local/bundle + - .:/app + - bundle:/usr/local/bundle - node:/node_modules + - rails_cache:/app/tmp/cache + - assets:/app/public/assets + - /var/run/docker.sock:/var/run/docker.sock + tmpfs: + - /tmp + - /app/tmp/pids services: db: - environment: - MYSQL_ROOT_PASSWORD: 'bp_user' - image: "mysql:latest" - profiles: ["db"] + image: "mysql:8.0" + networks: + - default + volumes: + - mysql-data:/var/lib/mysql ports: - "3306:3306" - volumes: - - db-v:/var/lib/mysql + environment: + MYSQL_ROOT_PASSWORD: root + cache: - deploy: - resources: - limits: - cpus: "${DOCKER_REDIS_CPUS:-0}" - memory: "${DOCKER_REDIS_MEMORY:-0}" - image: "memcached:1.6.17-bullseye" - profiles: ["cache"] + image: memcached:latest + restart: unless-stopped + command: [ "-m", "1024" ] + networks: + - default + ports: + - "11211:11211" + node: + <<: *default-app + command: "yarn build --watch" + tty: true + volumes: + - .:/app + - bundle:/usr/local/bundle + - node:/node_modules + - rails_cache:/app/tmp/cache + - assets:/app/public/assets + - /var/run/docker.sock:/var/run/docker.sock - web: + rails: <<: *default-app + depends_on: + - db + - cache + - node + links: + - db + - cache + environment: + BUNDLE_WITHOUT: '' + DB_HOST: db + CACHE_HOST: cache ports: - - "${DOCKER_WEB_PORT_FORWARD:-127.0.0.1:3000}:${PORT:-3000}" - profiles: ["web"] - command: "yarn build --watch" + - "3000:3000" + test: + <<: *default-app + depends_on: + - db + - cache + network_mode: 'host' + environment: + BUNDLE_WITHOUT: '' + DB_HOST: 127.0.0.1 + CACHE_HOST: 127.0.0.1 + + volumes: - db-v: + mysql-data: bundle: + rails_cache: + assets: node: