diff --git a/.env.sample b/.env.sample
index 9d4cb5a54..9e0d0a433 100644
--- a/.env.sample
+++ b/.env.sample
@@ -1,137 +1,43 @@
-# Default values are optimized for production to avoid having to configure
-# much in production.
-#
-# However it should be easy to get going in development too. If you see an
-# uncommented option that means it's either mandatory to set or it's being
-# overwritten in development to make your life easier.
+##################### UI configuration ####################
+RAILS_ENV=development
+SITE=Testportal
+ORG=LIRMM
+ORG_URL=http://www.lirmm.fr
-# Enable BuildKit by default:
-# https://docs.docker.com/develop/develop-images/build_enhancements
-export DOCKER_BUILDKIT=1
+UI_URL=http://localhost:3000
+API_URL=http://localhost:9393
+API_KEY=
-# Rather than use the directory name, let's control the name of the project.
-export COMPOSE_PROJECT_NAME=ontoportal-docker
+UI_THEME=ontoportal
-# In development we want all services to start but in production you don't
-# need the asset watchers to run since assets get built into the image.
-#
-# You can even choose not to run postgres and redis in prod if you plan to use
-# managed cloud services. Everything "just works", even optional depends_on!
-#export COMPOSE_PROFILES=postgres,redis,web,worker,cable
-export COMPOSE_PROFILES=db,cache,assets,web
+BIOMIXER_URL=
+BIOMIXER_APIKEY=
-# If you're running native Linux and your uid:gid isn't 1000:1000 you can set
-# these to match your values before you build your image. You can check what
-# your uid:gid is by running `id` from your terminal.
-#export UID=1000
-#export GID=1000
+ANNOTATOR_URL=
-# You can generate a more secure secret by running: ./run rails secret
-export SECRET_KEY_BASE=insecure_key_for_dev
+FAIRNESS_DISABLED=false
+FAIRNESS_URL=
-# Which environment is running? These should be "development" or "production".
-#export RAILS_ENV=production
-#export NODE_ENV=production
-export RAILS_ENV=development
-export NODE_ENV=development
+NCBO_ANNOTATORPLUS_ENABLED=false
+NCBO_ANNOTATOR_URL=
+NCBO_API_KEY=
-# The bind port for puma.
-#
-# Be warned that if you change this value you'll need to change 8000 in both
-# your Dockerfile and in a few spots in docker-compose.yml due to the nature of
-# how this value can be set (Docker Compose doesn't support nested ENV vars).
-#export PORT=8000
+SUPPORT_EMAIL=sifrportal-support@lirmm.fr
+RELEASE_VERSION="OntoPortal Appliance 3.0.1"
-# How many workers and threads should your app use? WEB_CONCURRENCY defaults
-# to the server's CPU count * 2. That is a good starting point. In development
-# it's a good idea to use 1 to avoid race conditions when debugging.
-#export WEB_CONCURRENCY=
-#export RAILS_MAX_THREADS=5
-#export WEB_CONCURRENCY=1
-#export RAILS_MAX_THREADS=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"
-# You'll always want to set POSTGRES_USER and POSTGRES_PASSWORD since the
-# postgres Docker image uses them for its default database user and password.
-export POSTGRES_USER=hello
-export POSTGRES_PASSWORD=password
-#export POSTGRES_DB=hello
-#export POSTGRES_HOST=postgres
-#export POSTGRES_PORT=5432
+## 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=stage
-# What's your full Redis connection URL? This will be used for caching, Sidekiq,
-# and Action Cable. You can always split them up later.
-#export REDIS_URL=redis://redis:6379/1
-# The bind port for puma but for Action Cable.
-#
-# Be warned that if you change this value you'll need to change 28080 in a few
-# spots in docker-compose.yml due to the nature of how this value can be set
-# (Docker Compose doesn't support nested ENV vars).
-#export CABLE_PORT=28080
-
-# The Action Cable address that will be accessible over HTTP. In production
-# you would typically have this reverse proxied to a sub-domain with nginx, in
-# which case you would set something like: ws://cable.example.com
-#
-# This is one case where it defaults to a development value because it's not
-# possible for me to know what domain name you'll be using.
-#export ACTION_CABLE_FRONTEND_URL=ws://localhost:28080
-
-# Comma separated list of RegExp origins to allow connections from for Action
-# Cable. The values will be converted into a proper RegExp, so omit the / /.
-#
-# Examples:
-# http:\/\/localhost*
-# http:\/\/example.*,https:\/\/example.*
-#export ACTION_CABLE_ALLOWED_REQUEST_ORIGINS=http:\/\/localhost*
-
-# If this is set then Rails will serve files from public/ in production. You
-# probably don't want this behavior unless you're testing prod mode locally,
-# because nginx would typically serve static files.
-#export RAILS_SERVE_STATIC_FILES=
-
-# Should Docker restart your containers if they go down in unexpected ways?
-#export DOCKER_RESTART_POLICY=unless-stopped
-export DOCKER_RESTART_POLICY=no
-
-# What health check test command do you want to run? In development, having it
-# curl your web server will result in a lot of log spam, so setting it to
-# /bin/true is an easy way to make the health check do basically nothing.
-#export DOCKER_WEB_HEALTHCHECK_TEST=curl localhost:8000/up
-export DOCKER_WEB_HEALTHCHECK_TEST=/bin/true
-
-# What ip:port should be published back to the Docker host for the app server?
-# If you're using Docker Toolbox or a custom VM you can't use 127.0.0.1. This
-# is being overwritten in dev to be compatible with more dev environments.
-#
-# If you have a port conflict because something else is using 8000 then you
-# can either stop that process or change 8000 to be something else.
-#
-# Use the default in production to avoid having puma directly accessible to
-# the internet since it'll very likely be behind nginx or a load balancer.
-#export DOCKER_WEB_PORT_FORWARD=127.0.0.1:8000
-export DOCKER_WEB_PORT_FORWARD=127.0.0.1:3000
-
-# This is the same as above except for Action Cable.
-#export DOCKER_CABLE_PORT_FORWARD=127.0.0.1:28080
-export DOCKER_CABLE_PORT_FORWARD=28080
-
-# What volume path should be used? In dev we want to volume mount everything
-# so that we can develop our code without rebuilding our Docker images.
-#export DOCKER_WEB_VOLUME=./public:/app/public
-
-
-export DOCKER_WEB_VOLUME=.:/app
-
-# What CPU and memory constraints will be added to your services? When left at
-# 0 they will happily use as much as needed.
-# export DOCKER_POSTGRES_CPUS=0
-# export DOCKER_POSTGRES_MEMORY=0
-# export DOCKER_REDIS_CPUS=0
-# export DOCKER_REDIS_MEMORY=0
-# export DOCKER_WEB_CPUS=0
-# export DOCKER_WEB_MEMORY=0
-# export DOCKER_WORKER_CPUS=0
-# export DOCKER_WORKER_MEMORY=0
-# export DOCKER_CABLE_CPUS=0
-# export DOCKER_CABLE_MEMORY=0
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
new file mode 100644
index 000000000..b4c725d6e
--- /dev/null
+++ b/.github/workflows/docker-image.yml
@@ -0,0 +1,47 @@
+name: Docker branch Images build
+
+on:
+ push:
+ branches:
+ - development
+ - stage
+ - test
+ release:
+ types: [ published ]
+
+jobs:
+ push_to_registry:
+ name: Push Docker branch image to Docker Hub
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out the repo
+ uses: actions/checkout@v3
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+
+ - name: Log in to Docker Hub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Extract metadata (tags, labels) for Docker
+ id: meta
+ uses: docker/metadata-action@v4
+ with:
+ images: agroportal/ontoportal_web_ui
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v4
+ with:
+ context: .
+ platforms: linux/amd64,linux/arm64
+ build-args: |
+ RUBY_VERSION=2.7
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
diff --git a/.github/workflows/tests-real-data.yml b/.github/workflows/tests-real-data.yml
new file mode 100644
index 000000000..d2b410d5b
--- /dev/null
+++ b/.github/workflows/tests-real-data.yml
@@ -0,0 +1,52 @@
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
+# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
+name: "Run remote API tests CI"
+
+on:
+ push:
+ pull_request_target:
+ types: [ opened, reopened ]
+env:
+ API_URL: ${{ secrets.API_URL }}
+ API_KEY: ${{ secrets.API_KEY }}
+ BIOMIXER_URL: ${{ secrets.BIOMIXER_URL }}
+ FAIRNESS_URL: ${{ secrets.FAIRNESS_URL }}
+ ANNOTATOR_URL: ${{ secrets.ANNOTATOR_URL }}
+ DB_HOST: 127.0.0.1
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ services:
+ mysql:
+ image: mysql:8.0
+ ports:
+ - "3306:3306"
+ env:
+ MYSQL_ROOT_PASSWORD: root
+ memcached:
+ image: memcached:1.6
+ ports:
+ - 11211:11211
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ # Add or replace dependency steps here
+ - name: Install Ruby and gems
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: 2.7.8
+ bundler-cache: true
+ # Add or replace database setup steps here
+ - name: set up config file
+ run: cp config/database.yml.sample config/database.yml
+ - name: Set up database schema
+ run: RAILS_ENV=test bin/rails db:setup
+ - name: Set up yarn
+ run: yarn install
+ # Add or replace test runners here
+ - name: Run tests
+ run: RAILS_ENV=test bin/rails test test/controllers/* -v
\ No newline at end of file
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index ec6dde7e7..9a3d8c966 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -4,28 +4,30 @@
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
-name: "Ruby on Rails CI"
+name: "Run local API tests CI"
on:
push:
pull_request_target:
types: [ opened, reopened ]
env:
- API_URL: ${{ secrets.API_URL }}
- API_KEY: ${{ secrets.API_KEY }}
+ API_URL: http://localhost:9393
+ REMOTE_API_KEY: 8b5b7825-538d-40e0-9e9e-5ab9274a9aeb
+ REMOTE_API_URL: https://data.bioontology.org
BIOMIXER_URL: ${{ secrets.BIOMIXER_URL }}
FAIRNESS_URL: ${{ secrets.FAIRNESS_URL }}
ANNOTATOR_URL: ${{ secrets.ANNOTATOR_URL }}
+ DB_HOST: 127.0.0.1
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
- image: mysql:latest
+ image: mysql:8.0
ports:
- "3306:3306"
env:
- MYSQL_ROOT_PASSWORD: 'bp_user'
+ MYSQL_ROOT_PASSWORD: root
memcached:
image: memcached:1.6
ports:
@@ -39,6 +41,10 @@ jobs:
with:
ruby-version: 2.7.8
bundler-cache: true
+
+ - name: Run OntoPortal API
+ run: bin/run_api -k ${{ env.REMOTE_API_KEY }} -r agroportal -t stage -s STY -u ${{ env.REMOTE_API_URL }}
+
# Add or replace database setup steps here
- name: set up config file
run: cp config/database.yml.sample config/database.yml
@@ -48,4 +54,4 @@ jobs:
run: yarn install
# Add or replace test runners here
- name: Run tests
- run: RAILS_ENV=test bin/rails test -v
\ No newline at end of file
+ run: RAILS_ENV=test bin/rails test -v
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 88f019fdb..25a479745 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,50 +1,50 @@
-FROM ruby:2.7.5-alpine AS app
-
+# 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
-ARG UID=1000
-ARG GID=1000
-
-RUN apk add --no-cache \
- build-base \
- libxml2-dev \
- libxslt-dev \
- mariadb-dev \
- git \
- nodejs \
- tzdata \
- yarn \
- less \
- && addgroup --gid ${GID} ruby \
- && adduser -u ${UID} -G ruby -D ruby \
- && chown ruby:ruby -R /app \
- && mkdir /node_modules \
- && chown ruby:ruby -R /node_modules /app
-
-USER ruby
-
-COPY --chown=ruby:ruby bin/ ./bin
-RUN chmod 0755 bin/*
-
+# Set production environment
ARG RAILS_ENV="production"
+ARG BUNDLE_WITHOUT="development test"
-ENV RAILS_ENV="${RAILS_ENV}" \
- NODE_ENV="${NODE_ENV}" \
- PATH="${PATH}:/home/ruby/.local/bin:/node_modules/.bin" \
- USER="ruby" \
- BUNDLE_PATH=/usr/local/bundle
-
-COPY --chown=ruby:ruby Gemfile* ./
-RUN bundle install --jobs "$(nproc)"
-RUN gem install rails
-
+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 --no-document && \
+ gem install -N bundler
+COPY Gemfile* .
+RUN bundle install
RUN echo "--modules-folder /node_modules" > .yarnrc
-COPY --chown=ruby:ruby package.json *yarn* ./
+COPY package.json *yarn* ./
RUN yarn install
+COPY . .
+
+# Precompile bootsnap code for faster boot times
+RUN bundle exec bootsnap precompile --gemfile app/ lib/
+
+ENV BINDING="0.0.0.0"
EXPOSE 3000
-CMD ["sh"]
\ No newline at end of file
+CMD ["bash"]
\ No newline at end of file
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 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.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/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/assets/stylesheets/theme-variables.scss.erb b/app/assets/stylesheets/theme-variables.scss.erb
index 9c467c8af..2e43abe68 100644
--- a/app/assets/stylesheets/theme-variables.scss.erb
+++ b/app/assets/stylesheets/theme-variables.scss.erb
@@ -1,5 +1,5 @@
<%# This file contains all the color themes of ontoportal alliance%>
-<% if (ui_theme = $UI_THEME.to_s.parameterize).present? && File.exists?(Rails.root.join('app', 'assets', 'stylesheets', 'themes', ui_theme))
+<% if (ui_theme = $UI_THEME.to_s.parameterize)
case ui_theme
when "agroportal" %>
:root{
@@ -27,24 +27,17 @@
--light-color: #F0F5F6;
--admin-color: #145FF4;
}
- <% when "testportal" %>
+
+ <% when "ontoportal" , "testportal" %>
:root{
- --primary-color: #3CB371;
- --hover-color: #41C67C;
+ --primary-color: #5499a4;
+ --hover-color: #6B96B7;
--secondary-color: #ffc107;
+ --light-color: #F0F5F6;
--admin-color: #145FF4;
--light-color: #F1F6FA;
--error-color: #EB4335;
}
-
- <% when "ontoportal" %>
- :root{
- --primary-color: #3CB371;
- --hover-color: #41C67C;
- --secondary-color: #ffc107;
- --light-color: #F0F5F6;
- --error-color: #EB4335;
- }
<%# Here to add a new theme ... %>
<% end %>
<% end %>
diff --git a/app/components/link_field_component.rb b/app/components/link_field_component.rb
index 211851b71..91640461f 100644
--- a/app/components/link_field_component.rb
+++ b/app/components/link_field_component.rb
@@ -10,7 +10,7 @@ def initialize(value:, raw: false)
def internal_link?
- @value.to_s.include?(URI.parse($REST_URL).hostname) || @value.to_s.include?($UI_HOSTNAME)
+ @value.to_s.include?(URI.parse($REST_URL).hostname) || @value.to_s.include?(URI.parse($UI_URL).hostname)
end
end
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 90af90d25..1731b7b08 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -9,7 +9,7 @@ class AdminController < ApplicationController
:$DEBUG_BEFORE, :$stdout, :$-0, :$-l, :$-I, :$DEBUG, :$',
:$gems_rake_task, :$_, :$CODERAY_DEBUG, :$-F, :$", :$0, :$=, :$FILENAME, :$?,
:$!, :$rdebug_in_irb, :$-K, :$TESTING, :$fileutils_rb_have_lchmod,
- :$EMAIL_EXCEPTIONS, :$binding, :$-v, :$>, :$SAFE, :$/,
+ :$binding, :$-v, :$>, :$SAFE, :$/,
:$fileutils_rb_have_lchown, :$-p, :$-W, :$:, :$__dbg_interface,
:$stderr, :$\, :$&, :$<, :$debug, :$;, :$~, :$-a,
:$DEBUG_RDOC, :$CGI_ENV, :$LOAD_PATH, :$-d, :$*, :$., :$-w, :$+,
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 1c3bc48a0..8273cfae2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -76,9 +76,6 @@ def detect_locale
$trial_license_initialized = false
- if !$EMAIL_EXCEPTIONS.nil? && $EMAIL_EXCEPTIONS == true
- include ExceptionNotifiable
- end
# See ActionController::RequestForgeryProtection for details
protect_from_forgery
@@ -128,10 +125,7 @@ def domain_ontology_set
Thread.current[:slice] = @subdomain_filter
end
- def anonymous_user
- user = DataAccess.getUser($ANONYMOUS_USER)
- user ||= User.new({"id" => 0})
- end
+
def ontology_not_found(ontology_acronym)
not_found("Ontology #{ontology_acronym} not found")
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 9c21ee7e6..443f76df5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -305,13 +305,6 @@ def error_message_alert
end
end
- def anonymous_user
- #
- # TODO: Fix and failures from removing 'DataAccess' call here.
- #
- #user = DataAccess.getUser($ANONYMOUS_USER)
- user ||= User.new({"id" => 0})
- end
def render_advanced_picker(custom_ontologies = nil, selected_ontologies = [], align_to_dom_id = nil)
selected_ontologies ||= []
diff --git a/bin/ontoportal b/bin/ontoportal
new file mode 100755
index 000000000..fde87be37
--- /dev/null
+++ b/bin/ontoportal
@@ -0,0 +1,157 @@
+#!/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."
+ 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..."
+
+ create_config_files
+ local reset_cache=false
+ local api_url=""
+ local api_key=""
+
+ # Check for command line arguments
+ while [[ "$#" -gt 0 ]]; do
+ case $1 in
+ --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
+
+ echo "Run: bundle exec rails s -b 0.0.0.0 -p 3000"
+ docker compose run --rm -it --service-ports rails bash -c "(bundle check || bundle install) && bin/rails db:prepare && bundle exec rails s -b 0.0.0.0 -p 3000"
+}
+
+# Function to handle the "test" option
+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 "(bundle check || bundle install) && RAILS_ENV=test bin/rails db:prepare && API_URL=http://localhost:9393 bundle exec rails test -v $*"
+
+ echo "Stopping API..."
+ bin/stop_api
+}
+
+# Function to handle the "run" option
+run() {
+ echo "Run: $*"
+ docker compose run --rm -it rails bash -c "$*"
+}
+
+# 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..c44c794ba
--- /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 https://github.com/syphax-bouazzouni/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 --no-provision"
+ echo "Run: $command"
+ eval "$command"
+)
+
diff --git a/bin/stop_api b/bin/stop_api
new file mode 100755
index 000000000..930fc24dd
--- /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 stop
+fi
+
diff --git a/config/bioportal_config_env.rb.sample b/config/bioportal_config_env.rb.sample
index 0f747779c..96624e79f 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,78 @@ $FRONT_NOTICE = ''
# EX: $SITE_NOTICE = { :unique_key => 'Put your message here (can include html 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"
+$HOME_PAGE_LOGOS = {
+ supported_by: [
+ {
+ 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'
+ }
+ ],
+ with_the_collaboration_of: [
+ {
+ 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'
+ }
+ ]
}
-$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"
+
+$FOOTER_LINKS = {
+ social: [
+ { logo: 'social/people.svg', link: 'https://github.com/orgs/agroportal/people' },
+ { logo: 'social/github.svg', link: 'https://github.com/agroportal' },
+ { logo: 'social/twitter.svg', link: 'https://twitter.com/lagroportal' }
+ ],
+ sections: {
+ products: {
+ ontoportal: 'https://ontoportal.org/',
+ release_notes: 'https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/release-notes-btKjZk5tU2',
+ api: 'https://data.agroportal.lirmm.fr/',
+ sparql: 'https://sparql.agroportal.lirmm.fr/test/'
+ },
+ support: {
+ contact_us: 'https://agroportal.lirmm.fr/feedback',
+ wiki: 'https://www.bioontology.org/wiki/',
+ documentation: 'https://ontoportal.github.io/documentation/'
+ },
+ agreements: {
+ terms: '',
+ privacy_policy: '',
+ cite_us: '',
+ acknowledgments: ''
+ },
+ about: {
+ about_us: 'https://github.com/agroportal/project-management',
+ projects: 'https://d2kab.mystrikingly.com/',
+ team: 'https://github.com/orgs/agroportal/people'
+ }
+ }
}
+
+$UI_THEME = ENV['UI_THEME'] || 'ontoportal'
diff --git a/config/database.yml.sample b/config/database.yml.sample
index 463e3ebea..6edf6ed31 100644
--- a/config/database.yml.sample
+++ b/config/database.yml.sample
@@ -13,8 +13,8 @@ default: &default
adapter: mysql2
encoding: utf8mb4
username: root
- password: bp_user
- host: 127.0.0.1
+ password: root
+ host: <%= ENV["DB_HOST"] %>
development:
<<: *default
diff --git a/config/environments/development.rb b/config/environments/development.rb
index b595b87cd..a7d82faf4 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -16,7 +16,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?
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
index af53788f9..c7c4027c3 100644
--- a/config/initializers/omniauth.rb
+++ b/config/initializers/omniauth.rb
@@ -1,5 +1,5 @@
Rails.application.config.middleware.use OmniAuth::Builder do
- $OMNIAUTH_PROVIDERS.each do |provider, config|
+ Array($OMNIAUTH_PROVIDERS).each do |provider, config|
provider config[:strategy] || provider, config[:client_id], config[:client_secret], client_options: {}.merge(config[:client_options].to_h)
end
end
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index 38be0278f..03a188dd3 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,52 +1,80 @@
x-app: &default-app
- build:
- context: "."
- target: "app"
- args:
- - "UID=${UID:-1000}"
- - "GID=${GID:-1000}"
- - "RAILS_ENV=${RAILS_ENV:-production}"
- - "NODE_ENV=${NODE_ENV:-production}"
- depends_on:
- - "db"
- - "cache"
- links:
- - "db"
- - "cache"
+ image: agroportal/ontoportal_web_ui:test
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
+ healthcheck:
+ test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
+ timeout: 5s
+ retries: 3
+
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"
- web:
+ rails:
<<: *default-app
+ depends_on:
+ db:
+ condition: service_healthy
+ cache:
+ condition: service_started
+ node:
+ condition: service_started
+ 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:
diff --git a/lib/log.rb b/lib/log.rb
index 00c815d60..edef5506f 100644
--- a/lib/log.rb
+++ b/lib/log.rb
@@ -12,13 +12,7 @@ class LOG
# :concept_id
# :concept_name
def self.add(level, message, request = nil, remote_params = nil)
- if request
- if !$REMOTE_LOGGING.nil? && $REMOTE_LOGGING
- remote(level, message, request, remote_params)
- end
- else
- local(level, message)
- end
+ local(level, message)
end
private
diff --git a/test/controllers/ontologies_controller_test.rb b/test/controllers/ontologies_controller_test.rb
index ed96305ca..c7fcdb06c 100644
--- a/test/controllers/ontologies_controller_test.rb
+++ b/test/controllers/ontologies_controller_test.rb
@@ -11,7 +11,7 @@ class OntologiesControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
- ONTOLOGIES.sample(5).flat_map { |ont| PAGES.map { |page| [ont, page] } }.each do |ont, page|
+ ONTOLOGIES.flat_map { |ont| PAGES.map { |page| [ont, page] } }.each do |ont, page|
test "should get page #{page} of #{ont.acronym} ontology" do
path = "#{ontologies_path}/#{ont.acronym}?p=#{page}"
get path