diff --git a/.gitignore b/.gitignore index eaa496d6f..e5eb8ea5b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,8 @@ node_modules /config/credentials/test.key /config/credentials/staging.key /config/credentials/production.key + +/app/assets/builds/* +!/app/assets/builds/.keep + +/node_modules diff --git a/Gemfile b/Gemfile index b14475d22..710616a59 100644 --- a/Gemfile +++ b/Gemfile @@ -3,13 +3,40 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '6.1.7.3' +gem 'rails', '7.0.8' -gem 'sass-rails', '~> 5.0' -gem 'terser' -# See https://github.com/rails/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby -# gem 'duktape' +# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] +gem 'sprockets-rails', require: 'sprockets/railtie' + +# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails] +gem 'jsbundling-rails', '~> 1.3' + +# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] +gem 'turbo-rails' + +# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] +gem 'stimulus-rails' + +# Build JSON APIs with ease [https://github.com/rails/jbuilder] +# gem 'jbuilder' + +# Use Redis for Action Cable +gem 'redis', '~> 4.0' + +# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] +# gem 'kredis' + +# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] +# gem "bcrypt", "~> 3.1.7" + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +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' @@ -17,15 +44,6 @@ gem 'jquery-rails' gem 'jquery-ui-rails' gem 'select2-rails' -# To use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - -# To use Jbuilder templates for JSON -# gem 'jbuilder' - -# To use debugger -# gem 'debugger' - gem 'base64', '0.1.0' gem 'cube-ruby', require: 'cube' gem 'dalli' @@ -36,9 +54,11 @@ gem 'graphql-client' gem 'haml', '~> 5.1' gem 'i18n' gem 'iconv' +gem 'iso-639', '~> 0.3.6' gem 'multi_json' gem 'mysql2', '0.5.5' gem 'oj' +gem 'ontologies_api_client', github: 'ncbo/ontologies_api_ruby_client', tag: 'v2.2.5' gem 'open_uri_redirections' gem 'pry' gem 'psych', '< 4' @@ -49,39 +69,42 @@ gem 'recaptcha', '~> 5.9.0' gem 'rest-client' gem 'rexml', '~> 3' gem 'stackprof', require: false +gem 'terser' gem 'thin' gem 'will_paginate', '~> 3.0' -gem 'ontologies_api_client', github: 'ncbo/ontologies_api_ruby_client', tag: 'v2.2.4' - group :staging, :production do - # application monitoring + # Application monitoring gem 'newrelic_rpm' - # logs in json format, useful for shipping logs to logstash + # 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 - gem 'capistrano-rbenv', require: false gem 'capistrano-locally', require: false gem 'capistrano-passenger', require: false gem 'capistrano-rails', '~> 1.4', require: false + 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 + + # Static code analysis gem 'brakeman', require: false gem 'rubocop', require: false + # gem 'i18n-debug' end -group :test, :development do +group :development, :test do + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem 'debug', platforms: %i[mri mingw x64_mingw] gem 'rspec-rails' end diff --git a/Gemfile.lock b/Gemfile.lock index b6c78f6e0..e8efaa91b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,10 @@ GIT remote: https://github.com/ncbo/ontologies_api_ruby_client.git - revision: 7331b8372056ea0cf2a33cc0f86fcf6877712bef - tag: v2.2.4 + revision: 115cf36f54f73eb10c503147f54bb6f6672d3d99 + tag: v2.2.5 specs: - ontologies_api_client (2.2.4) - activesupport (= 6.1.7.3) + ontologies_api_client (2.2.5) + activesupport (= 7.0.8) addressable (~> 2.8) excon faraday @@ -18,74 +18,82 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.3) - actionpack (= 6.1.7.3) - activesupport (= 6.1.7.3) + actioncable (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.3) - actionpack (= 6.1.7.3) - activejob (= 6.1.7.3) - activerecord (= 6.1.7.3) - activestorage (= 6.1.7.3) - activesupport (= 6.1.7.3) + actionmailbox (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) mail (>= 2.7.1) - actionmailer (6.1.7.3) - actionpack (= 6.1.7.3) - actionview (= 6.1.7.3) - activejob (= 6.1.7.3) - activesupport (= 6.1.7.3) + 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) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.3) - actionview (= 6.1.7.3) - activesupport (= 6.1.7.3) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.3) - actionpack (= 6.1.7.3) - activerecord (= 6.1.7.3) - activestorage (= 6.1.7.3) - activesupport (= 6.1.7.3) + actiontext (7.0.8) + actionpack (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.3) - activesupport (= 6.1.7.3) + actionview (7.0.8) + activesupport (= 7.0.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.3) - activesupport (= 6.1.7.3) + activejob (7.0.8) + activesupport (= 7.0.8) globalid (>= 0.3.6) - activemodel (6.1.7.3) - activesupport (= 6.1.7.3) - activerecord (6.1.7.3) - activemodel (= 6.1.7.3) - activesupport (= 6.1.7.3) - activestorage (6.1.7.3) - actionpack (= 6.1.7.3) - activejob (= 6.1.7.3) - activerecord (= 6.1.7.3) - activesupport (= 6.1.7.3) + 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) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.3) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) airbrussh (1.5.0) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) - autoprefixer-rails (10.4.15.0) + autoprefixer-rails (10.4.16.0) execjs (~> 2) base64 (0.1.0) bcrypt_pbkdf (1.1.0) + bootsnap (1.17.1) + msgpack (~> 1.2) bootstrap (5.2.3) autoprefixer-rails (>= 9.1.0) popper_js (>= 2.11.6, < 3) @@ -123,21 +131,24 @@ GEM chart-js-rails (0.1.7) railties (> 3.1) coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) crass (1.0.6) cube-ruby (0.0.3) daemons (1.4.1) dalli (3.2.6) date (3.3.4) + debug (1.9.1) + irb (~> 1.10) + reline (>= 0.3.8) diff-lcs (1.5.0) domain_name (0.6.20231109) ed25519 (1.3.0) erubi (1.12.0) erubis (2.7.0) eventmachine (1.2.7) - excon (0.104.0) + excon (0.108.0) execjs (2.9.1) - faraday (2.7.11) + faraday (2.7.12) base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) @@ -169,13 +180,20 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) iconv (1.0.8) + io-console (0.7.2) + irb (1.12.0) + rdoc + reline (>= 0.4.2) + iso-639 (0.3.6) jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (2.6.3) + jsbundling-rails (1.3.0) + railties (>= 6.0.0) + json (2.7.2) language_server-protocol (3.17.0.3) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) @@ -196,11 +214,12 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2023.1003) mini_mime (1.1.5) - minitest (5.20.0) + minitest (5.21.2) + msgpack (1.7.2) multi_json (1.15.0) multipart-post (2.3.0) mysql2 (0.5.5) - net-imap (0.4.5) + net-imap (0.4.7) date net-protocol net-pop (0.1.2) @@ -215,13 +234,17 @@ GEM netrc (0.11.0) newrelic_rpm (9.6.0) base64 - nio4r (2.6.0) - nokogiri (1.15.5-x86_64-darwin) + nio4r (2.6.1) + nokogiri (1.16.0-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.0-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.0-x86_64-linux) racc (~> 1.4) oj (3.16.1) open_uri_redirections (0.2.1) - parallel (1.23.0) - parser (3.2.2.4) + parallel (1.24.0) + parser (3.3.0.5) ast (~> 2.4.1) racc popper_js (2.11.8) @@ -236,21 +259,20 @@ GEM rack (>= 1.2.0) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.3) - actioncable (= 6.1.7.3) - actionmailbox (= 6.1.7.3) - actionmailer (= 6.1.7.3) - actionpack (= 6.1.7.3) - actiontext (= 6.1.7.3) - actionview (= 6.1.7.3) - activejob (= 6.1.7.3) - activemodel (= 6.1.7.3) - activerecord (= 6.1.7.3) - activestorage (= 6.1.7.3) - activesupport (= 6.1.7.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) bundler (>= 1.15.0) - railties (= 6.1.7.3) - sprockets-rails (>= 2.0.0) + railties (= 7.0.8) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -262,21 +284,25 @@ GEM actionview (> 3.1) activesupport (> 3.1) railties (> 3.1) - railties (6.1.7.3) - actionpack (= 6.1.7.3) - activesupport (= 6.1.7.3) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rdoc (6.3.3) + rdoc (6.3.4.1) recaptcha (5.9.0) json - regexp_parser (2.8.2) + redis (4.8.1) + regexp_parser (2.9.0) + reline (0.5.0) + io-console (~> 0.5) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) @@ -291,7 +317,7 @@ GEM rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-rails (6.0.3) + rspec-rails (6.1.0) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) @@ -300,34 +326,23 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) rspec-support (3.12.1) - rubocop (1.57.2) + rubocop (1.63.3) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.4) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) ruby_parser (3.20.3) sexp_processor (~> 4.16) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.1.0) - railties (>= 5.2.0) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) @@ -339,9 +354,9 @@ GEM select2-rails (4.0.13) sexp_processor (4.17.0) spawnling (2.1.5) - sprockets (3.7.2) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) + rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) @@ -350,8 +365,10 @@ GEM net-scp (>= 1.1.2) net-ssh (>= 2.8.0) stackprof (0.2.25) + stimulus-rails (1.3.3) + railties (>= 6.0.0) temple (0.10.3) - terser (1.1.19) + terser (1.1.20) execjs (>= 0.3.0, < 3) thin (1.8.2) daemons (~> 1.0, >= 1.0.9) @@ -360,6 +377,10 @@ GEM thor (1.3.0) tilt (2.3.0) timeout (0.4.1) + turbo-rails (1.5.0) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) @@ -379,6 +400,7 @@ PLATFORMS DEPENDENCIES base64 (= 0.1.0) bcrypt_pbkdf (>= 1.0, < 2.0) + bootsnap bootstrap (~> 5.2.3) brakeman capistrano (~> 3.17) @@ -392,6 +414,7 @@ DEPENDENCIES chart-js-rails cube-ruby dalli + debug ed25519 (>= 1.2, < 2.0) flamegraph graphql (~> 2.0.27) @@ -400,8 +423,10 @@ DEPENDENCIES html2haml i18n iconv + iso-639 (~> 0.3.6) jquery-rails jquery-ui-rails + jsbundling-rails (~> 1.3) listen multi_json mysql2 (= 0.5.5) @@ -412,19 +437,24 @@ DEPENDENCIES pry psych (< 4) rack-mini-profiler - rails (= 6.1.7.3) + rails (= 7.0.8) rails_autolink rdoc recaptcha (~> 5.9.0) + redis (~> 4.0) rest-client rexml (~> 3) rspec-rails rubocop - sass-rails (~> 5.0) + sassc-rails select2-rails + sprockets-rails stackprof + stimulus-rails terser thin + turbo-rails + tzinfo-data will_paginate (~> 3.0) BUNDLED WITH diff --git a/Procfile.dev b/Procfile.dev new file mode 100644 index 000000000..b19ff761b --- /dev/null +++ b/Procfile.dev @@ -0,0 +1,2 @@ +web: env RUBY_DEBUG_OPEN=true bin/rails server +js: yarn build --watch diff --git a/app/assets/builds/.keep b/app/assets/builds/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 000000000..2c35fb2c3 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,7 @@ +//= link_tree ../images +//= link_tree ../builds +//= link application.js +//= link bp_annotator.js +//= link bp_annotatorplus.js +//= link vendor.js +//= link_directory ../stylesheets .css diff --git a/app/assets/javascripts/bp_admin.js b/app/assets/javascripts/bp_admin.js index 8b55a88b3..852605747 100644 --- a/app/assets/javascripts/bp_admin.js +++ b/app/assets/javascripts/bp_admin.js @@ -892,7 +892,7 @@ function populateUserRows(data) { let actions = [ 'Detail' , 'Delete', - 'Login as', + 'Login as', ] let row = [firstname, lastname, username, email , roles , id , created , actions.join('|')]; @@ -1018,7 +1018,7 @@ DeleteUsers.prototype._ajaxCall = function (username) { let notices = []; jQuery.ajax({ method: 'DELETE', - url: 'accounts/'+username, + url: `accounts/${encodeURIComponent(username)}`, data: [], dataType: "json", success: (data, msg) => { diff --git a/app/assets/javascripts/submissions.js.erb b/app/assets/javascripts/submissions.js.erb index 7dd111f65..7fad689ab 100644 --- a/app/assets/javascripts/submissions.js.erb +++ b/app/assets/javascripts/submissions.js.erb @@ -43,6 +43,11 @@ jQuery(document).ready(function(){ jQuery("#contacts").on("click", ".add-contact", addContact); jQuery("#contacts").on("click", ".remove-contact", removeContact); + jQuery("#submission_naturalLanguage").select2({ + dropdownParent: jQuery(".submissions form"), + include_hidden: false, + }); + jQuery("#ontology_submission_form").validate({ highlight: function(element) { $(element).closest('.form-group').addClass('has-error'); diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index b8ec4390c..875e3138e 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,20 +1,22 @@ -class NotesController < ApplicationController +# frozen_string_literal: true +class NotesController < ApplicationController layout 'ontology' def show id = clean_note_id(params[:id]) @note = LinkedData::Client::Models::Note.get(id, include_threads: true) - @ontology = (@notes.explore.relatedOntology || []).first + @note_decorator = NoteDecorator.new(@note, view_context) + @ontology = (@note.explore.relatedOntology || []).first if request.xhr? - render :partial => 'thread' + render partial: 'thread' return end respond_to do |format| - format.html { render :template => 'notes/show' } + format.html { render template: 'notes/show' } end end @@ -32,12 +34,12 @@ def virtual_show elsif concept_id @notes = @ontology.explore.single_class(concept_id).explore.notes @note_link = "/notes/virtual/#{@ontology.ontologyId}/?noteid=" - render :partial => 'list', :layout => 'ontology' + render partial: 'list', layout: 'ontology' return else @notes = @ontology.explore.notes @note_link = "/notes/virtual/#{@ontology.ontologyId}/?noteid=" - render :partial => 'list', :layout => 'ontology' + render partial: 'list', layout: 'ontology' return end @@ -52,14 +54,14 @@ def virtual_show end def create - if params[:type].eql?("reply") + if params[:type].eql?('reply') note = LinkedData::Client::Models::Reply.new(values: note_params) - elsif params[:type].eql?("ontology") + elsif params[:type].eql?('ontology') params[:relatedOntology] = [params.delete(:parent)] note = LinkedData::Client::Models::Note.new(values: note_params) - elsif params[:type].eql?("class") + elsif params[:type].eql?('class') params[:relatedClass] = [params.delete(:parent)] - params[:relatedOntology] = params[:relatedClass].map {|c| c["ontology"]} + params[:relatedOntology] = params[:relatedClass].map { |c| c['ontology'] } note = LinkedData::Client::Models::Note.new(values: note_params) else note = LinkedData::Client::Models::Note.new(values: note_params) @@ -68,17 +70,17 @@ def create new_note = note.save if new_note.errors - render :json => new_note.errors, :status => 500 + render json: new_note.errors, status: 500 return end unless new_note.nil? - render :json => new_note.to_hash.to_json + render json: new_note.to_hash.to_json end end def destroy - note_ids = params[:noteids].kind_of?(String) ? params[:noteids].split(",") : params[:noteids] + note_ids = params[:noteids].kind_of?(String) ? params[:noteids].split(',') : params[:noteids] ontology = DataAccess.getOntology(params[:ontologyid]) @@ -87,7 +89,7 @@ def destroy note_ids.each do |note_id| begin result = DataAccess.deleteNote(note_id, ontology.ontologyId, params[:concept_id]) - raise Exception if !result.nil? && result["errorCode"] + raise Exception if !result.nil? && result['errorCode'] rescue Exception => e errors << note_id next @@ -95,27 +97,27 @@ def destroy successes << note_id end - render :json => { :success => successes, :error => errors } + render json: { success: successes, error: errors } end def archive ontology = DataAccess.getLatestOntology(params[:ontology_virtual_id]) unless ontology.admin?(session[:user]) - render :json => nil.to_json, :status => 500 + render json: nil.to_json, status: 500 return end @archive = DataAccess.archiveNote(params) unless @archive.nil? - render :json => @archive.to_json + render json: @archive.to_json end end def show_concept_list - params[:p] = "classes" - params[:t] = "notes" + params[:p] = 'classes' + params[:t] = 'notes' redirect_new_api end @@ -134,5 +136,4 @@ def clean_note_id(id) id = id.match(/\Ahttp:\/\w/) ? id.sub('http:/', 'http://') : id CGI.unescape(id) end - end diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 59c1866ad..042c3e436 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -21,6 +21,7 @@ def new def create # Make the contacts an array params[:submission][:contact] = params[:submission][:contact].values + params[:submission][:naturalLanguage].compact_blank! @submission = LinkedData::Client::Models::OntologySubmission.new(values: submission_params) @ontology = LinkedData::Client::Models::Ontology.get(params[:submission][:ontology]) @@ -53,8 +54,8 @@ def edit def update # Make the contacts an array params[:submission][:contact] = params[:submission][:contact].values - params[:submission][:contact].delete_if { |c| c[:name].empty? || c[:email].empty? } + params[:submission][:naturalLanguage].compact_blank! @ontology = LinkedData::Client::Models::Ontology.get(params[:submission][:ontology]) submissions = @ontology.explore.submissions @@ -80,7 +81,7 @@ def submission_params :synonymProperty, :definitionProperty, :authorProperty, :obsoleteProperty, :obsoleteParent, :version, :status, :released, :isRemote, :pullLocation, :filePath, { contact: [:name, :email] }, :homepage, :documentation, - :publication) + :publication, naturalLanguage: []) p.to_h end end diff --git a/app/helpers/submissions_helper.rb b/app/helpers/submissions_helper.rb index e26758930..147da1030 100644 --- a/app/helpers/submissions_helper.rb +++ b/app/helpers/submissions_helper.rb @@ -14,4 +14,17 @@ def acronym_from_submission_muted(submission) def acronym_from_params_muted tag.small "for #{params[:ontology_id]}", class: 'text-muted' end + + def natural_language_selector(submission) + language_codes = ISO_639::ISO_639_1.map do |code| + # Get the alpha-2 code and English name + code.slice(2, 2).reverse + end + language_codes.sort! { |a, b| a.first.downcase <=> b.first.downcase } + + selected = submission.naturalLanguage + select(:submission, :naturalLanguage, options_for_select(language_codes, selected), + { include_blank: true }, + { multiple: true, class: 'form-select', 'aria-describedby': 'languageHelpBlock' }) + end end diff --git a/app/javascript/application-esbuild.js b/app/javascript/application-esbuild.js new file mode 100644 index 000000000..b8b490239 --- /dev/null +++ b/app/javascript/application-esbuild.js @@ -0,0 +1,5 @@ +// Entry point for the build script in your package.json +import '@hotwired/turbo-rails' +import './controllers' + +Turbo.session.drive = false \ No newline at end of file diff --git a/app/javascript/controllers/application.js b/app/javascript/controllers/application.js new file mode 100644 index 000000000..1213e85c7 --- /dev/null +++ b/app/javascript/controllers/application.js @@ -0,0 +1,9 @@ +import { Application } from "@hotwired/stimulus" + +const application = Application.start() + +// Configure Stimulus development experience +application.debug = false +window.Stimulus = application + +export { application } diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js new file mode 100644 index 000000000..373c3edc2 --- /dev/null +++ b/app/javascript/controllers/index.js @@ -0,0 +1,5 @@ +// This file is auto-generated by ./bin/rails stimulus:manifest:update +// Run that command whenever you add a new controller or create them with +// ./bin/rails generate stimulus controllerName + +import { application } from "./application" diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index a58be5537..a800a46e7 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -26,6 +26,7 @@ <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application-esbuild", "data-turbo-track": "reload", type: "module" %> <%= javascript_include_tag "vendor" %> <%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min.js" %> <%= javascript_include_tag "//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js" %> diff --git a/app/views/layouts/angular.html.erb b/app/views/layouts/angular.html.erb index 95a78f6c1..2b1704a71 100644 --- a/app/views/layouts/angular.html.erb +++ b/app/views/layouts/angular.html.erb @@ -33,6 +33,7 @@ <%= stylesheet_link_tag "application" %> + <%=javascript_include_tag "application-esbuild", "data-turbo-track": "reload", type: "module" %> <%=javascript_include_tag "vendor"%> <%=javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min.js"%> <%=javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"%> diff --git a/app/views/layouts/appliance.html.haml b/app/views/layouts/appliance.html.haml index 2ca01d6da..fc6511aaa 100644 --- a/app/views/layouts/appliance.html.haml +++ b/app/views/layouts/appliance.html.haml @@ -14,6 +14,7 @@ = stylesheet_link_tag "https://use.fontawesome.com/releases/v5.2.0/css/all.css", integrity: "sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ", crossorigin: "anonymous" = stylesheet_link_tag "application", media: "all" + = javascript_include_tag "application-esbuild", "data-turbo-track": "reload", type: "module" = javascript_include_tag "vendor" = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min.js" = javascript_include_tag "//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js" diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e721eb1e8..64ae08bb0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -3,6 +3,7 @@ BioportalWebUi <%= stylesheet_link_tag "application", :media => "all" %> + <%= javascript_include_tag "application-esbuild", "data-turbo-track": "reload", type: "module" %> <%= javascript_include_tag "application"%> <%= csrf_meta_tags %> diff --git a/app/views/submissions/_form.html.haml b/app/views/submissions/_form.html.haml index 957695656..0b342c880 100644 --- a/app/views/submissions/_form.html.haml +++ b/app/views/submissions/_form.html.haml @@ -125,6 +125,14 @@ %div.col-sm-10 = text_field(:submission, :version, value: @submission.version, class: 'form-control') +-# Natural language +%div.row.mb-3 + %label{class: 'col-sm-2 col-form-label'} Language + %div.col-sm-10 + = natural_language_selector(@submission) + %div{id: 'languageHelpBlock', class: 'form-text'} + Enter the language of the content of the ontology, i.e., English, French, etc. + -# Status %div.row.mb-3 %label{class: 'col-sm-2 col-form-label', for: "submission_status"} diff --git a/bin/dev b/bin/dev new file mode 100755 index 000000000..eda330c72 --- /dev/null +++ b/bin/dev @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +if gem list --no-installed --exact --silent foreman; then + echo "Installing foreman..." + gem install foreman +fi + +# Default to port 3000 if not specified +export PORT="${PORT:-3000}" + +exec foreman start -f Procfile.dev "$@" diff --git a/bin/rails b/bin/rails index 6fb4e4051..efc037749 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../config/application', __dir__) +APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/bin/setup b/bin/setup index 90700ac4f..3bf0c5297 100755 --- a/bin/setup +++ b/bin/setup @@ -13,24 +13,24 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') + puts "== Installing dependencies ==" + 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' + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" - system! 'bin/rails db:prepare' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/config/application.rb b/config/application.rb index 9f34dbe9b..65e56ea9c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -10,6 +10,8 @@ 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 diff --git a/config/boot.rb b/config/boot.rb index d69bd27dc..988a5ddc4 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/cable.yml b/config/cable.yml index 487866035..f41190b83 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -1,5 +1,6 @@ development: - adapter: async + adapter: redis + url: redis://localhost:6379/1 test: adapter: test diff --git a/config/environments/development.rb b/config/environments/development.rb index c1e4dd4f8..95f60f9b5 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -14,15 +14,18 @@ # Show full error reports. config.consider_all_requests_local = true + # Enable server timing + config.server_timing = true + # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join('tmp', 'caching-dev.txt').exist? + if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.to_i}" + "Cache-Control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false diff --git a/config/environments/production.rb b/config/environments/production.rb index 922888bd3..89c5c8c7f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -34,19 +34,19 @@ config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = 'http://assets.example.com' + # config.asset_host = "http://assets.example.com" # Specifies the header that your server uses for sending files. config.action_dispatch.x_sendfile_header = 'X-Sendfile' unless config.public_file_server.enabled # for Apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local # Mount Action Cable outside main process or domain. # config.action_cable.mount_path = nil - # config.action_cable.url = 'wss://example.com/cable' - # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true @@ -84,16 +84,19 @@ # Tell Active Support which deprecation messages to disallow. config.active_support.disallowed_deprecation_warnings = [] + # Don't log any deprecations. + # config.active_support.report_deprecations = false + # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + # 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") - + # 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 } @@ -108,25 +111,4 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - - # Inserts middleware to perform automatic connection switching. - # The `database_selector` hash is used to pass options to the DatabaseSelector - # middleware. The `delay` is used to determine how long to wait after a write - # to send a subsequent read to the primary. - # - # The `database_resolver` class is used by the middleware to determine which - # database is appropriate to use based on the time delay. - # - # The `database_resolver_context` class is used by the middleware to set - # timestamps for the last write to the primary. The resolver uses the context - # class timestamps to determine how long to wait before reading from the - # replica. - # - # By default Rails will store a last write timestamp in the session. The - # DatabaseSelector middleware is designed as such you can define your own - # strategy for connection switching and pass that into the middleware through - # these configuration options. - # config.active_record.database_selector = { delay: 2.seconds } - # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver - # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end diff --git a/config/environments/test.rb b/config/environments/test.rb index 47ff0776b..b31dce4a2 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,12 +8,13 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Turn false under Spring and add config.action_view.cache_template_loading = true. config.cache_classes = true - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. - config.eager_load = false + # 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? # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index ed7c2ad1c..4b828e80c 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -12,4 +12,3 @@ # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) -Rails.application.config.assets.precompile += %w( *.png *.jpg *.jpeg *.gif bp_annotator.js bp_annotatorplus.js vendor.js ) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 35d0f26fc..54f47cf15 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,30 +1,25 @@ # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header -# Rails.application.config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # If you are using webpack-dev-server then specify webpack-dev-server host -# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? - -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap and inline scripts +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true # end - -# If you are using UJS then enable automatic nonce generation -# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } - -# Set the nonce only to specific directives -# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) - -# Report CSP violations to a specified URI -# For further information see the following documentation: -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/cookie_rotator.rb b/config/initializers/cookie_rotator.rb new file mode 100644 index 000000000..abc1f7ffc --- /dev/null +++ b/config/initializers/cookie_rotator.rb @@ -0,0 +1,19 @@ +Rails.application.config.after_initialize do + Rails.application.config.action_dispatch.cookies_rotations.tap do |cookies| + authenticated_encrypted_cookie_salt = Rails.application.config.action_dispatch.authenticated_encrypted_cookie_salt + signed_cookie_salt = Rails.application.config.action_dispatch.signed_cookie_salt + + secret_key_base = Rails.application.secret_key_base + + key_generator = ActiveSupport::KeyGenerator.new( + secret_key_base, iterations: 1000, hash_digest_class: OpenSSL::Digest::SHA1 + ) + key_len = ActiveSupport::MessageEncryptor.key_len + + old_encrypted_secret = key_generator.generate_key(authenticated_encrypted_cookie_salt, key_len) + old_signed_secret = key_generator.generate_key(signed_cookie_salt) + + cookies.rotate :encrypted, old_encrypted_secret + cookies.rotate :signed, old_signed_secret + end +end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4b34a0366..adc6568ce 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,6 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. +# Configure parameters to be filtered from the log file. Use this to limit dissemination of +# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported +# notations and behaviors. Rails.application.config.filter_parameters += [ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index ac033bf9d..3860f659e 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,13 @@ # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' +# inflect.acronym "RESTful" # end diff --git a/config/initializers/new_framework_defaults_6_0.rb b/config/initializers/new_framework_defaults_6_0.rb deleted file mode 100644 index 8c069c5f4..000000000 --- a/config/initializers/new_framework_defaults_6_0.rb +++ /dev/null @@ -1,45 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.0 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Don't force requests from old versions of IE to be UTF-8 encoded. -Rails.application.config.action_view.default_enforce_utf8 = false - -# Embed purpose and expiry metadata inside signed and encrypted -# cookies for increased security. -# -# This option is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.0. -# Rails.application.config.action_dispatch.use_cookies_with_metadata = true - -# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification. -Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false - -# Return false instead of self when enqueuing is aborted from a callback. -Rails.application.config.active_job.return_false_on_aborted_enqueue = true - -# Send Active Storage analysis and purge jobs to dedicated queues. -Rails.application.config.active_storage.queues.analysis = :active_storage_analysis -Rails.application.config.active_storage.queues.purge = :active_storage_purge - -# When assigning to a collection of attachments declared via `has_many_attached`, replace existing -# attachments instead of appending. Use #attach to add new attachments without replacing existing ones. -Rails.application.config.active_storage.replace_on_assign_to_many = true - -# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail. -# -# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob), -# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions. -# If you send mail in the background, job workers need to have a copy of -# MailDeliveryJob to ensure all delivery jobs are processed properly. -# Make sure your entire app is migrated and stable on 6.0 before using this setting. -# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" - -# Enable the same cache key to be reused when the object being cached of type -# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count) -# of the relation's cache key into the cache version to support recycling cache key. -Rails.application.config.active_record.collection_cache_versioning = true diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb deleted file mode 100644 index 9526b835a..000000000 --- a/config/initializers/new_framework_defaults_6_1.rb +++ /dev/null @@ -1,67 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.1 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Support for inversing belongs_to -> has_many Active Record associations. -# Rails.application.config.active_record.has_many_inversing = true - -# Track Active Storage variants in the database. -# Rails.application.config.active_storage.track_variants = true - -# Apply random variation to the delay when retrying failed jobs. -# Rails.application.config.active_job.retry_jitter = 0.15 - -# Stop executing `after_enqueue`/`after_perform` callbacks if -# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. -# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true - -# Specify cookies SameSite protection level: either :none, :lax, or :strict. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax - -# Generate CSRF tokens that are encoded in URL-safe Base64. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_controller.urlsafe_csrf_tokens = true - -# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an -# UTC offset or a UTC time. -# ActiveSupport.utc_to_local_returns_utc_offset_times = true - -# Change the default HTTP status code to `308` when redirecting non-GET/HEAD -# requests to HTTPS in `ActionDispatch::SSL` middleware. -# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 - -# Use new connection handling API. For most applications this won't have any -# effect. For applications using multiple databases, this new API provides -# support for granular connection swapping. -# Rails.application.config.active_record.legacy_connection_handling = false - -# Make `form_with` generate non-remote forms by default. -# Rails.application.config.action_view.form_with_generates_remote_forms = false - -# Set the default queue name for the analysis job to the queue adapter default. -# Rails.application.config.active_storage.queues.analysis = nil - -# Set the default queue name for the purge job to the queue adapter default. -# Rails.application.config.active_storage.queues.purge = nil - -# Set the default queue name for the incineration job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.incineration = nil - -# Set the default queue name for the routing job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.routing = nil - -# Set the default queue name for the mail deliver job to the queue adapter default. -# Rails.application.config.action_mailer.deliver_later_queue_name = nil - -# Generate a `Link` header that gives a hint to modern browsers about -# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. -# Rails.application.config.action_view.preload_links_header = true diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb new file mode 100644 index 000000000..cf925f131 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,143 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.0 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.0`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +# `button_to` view helper will render `