Skip to content

Commit e8daa18

Browse files
authored
Merge branch 'master' into rails-7.2.3
2 parents 57b875f + 14b27a6 commit e8daa18

File tree

78 files changed

+2135
-73988
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2135
-73988
lines changed

.github/workflows/deployment-checks.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ jobs:
4848
cp config/secrets.github.yml config/secrets.yml
4949
cp config/ingestion.example.yml config/ingestion.yml
5050
bundle exec rake db:setup
51-
- run: bundle exec rake assets:precompile
52-
name: Run asset compilation
53-
- run: bundle exec whenever --update-crontab --set environment="$ENV"
54-
name: Run whenever update
51+
- name: Set up Node
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: '20.x'
55+
cache: 'yarn'
56+
- name: Install JS dependencies
57+
run: yarn install --frozen-lockfile --non-interactive
58+
- name: Run asset compilation
59+
run: bundle exec rake assets:precompile
60+
- name: Run whenever update
61+
run: bundle exec whenever --update-crontab --set environment="$ENV"

.github/workflows/test.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,12 @@ jobs:
5353
cp config/secrets.github.yml config/secrets.yml
5454
cp config/ingestion.example.yml config/ingestion.yml
5555
bundle exec rake db:test:prepare
56-
- run: bundle exec rails test
57-
name: Run tests
56+
- name: Set up Node
57+
uses: actions/setup-node@v4
58+
with:
59+
node-version: '20.x'
60+
cache: 'yarn'
61+
- name: Install JS dependencies
62+
run: yarn install --frozen-lockfile --non-interactive
63+
- name: Run tests
64+
run: bundle exec rails test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ config/ontologies/*.cache
4040

4141
tess.crontab
4242

43-
app-secrets*
43+
app-secrets*
44+
node_modules/

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ WORKDIR /code
88

99
# install dependencies
1010
RUN apt-get update \
11-
&& apt-get install build-essential curl file git gnupg2 imagemagick libpq-dev libyaml-dev nodejs -y \
11+
&& apt-get install build-essential curl file git gnupg2 imagemagick libpq-dev libyaml-dev nodejs npm -y \
1212
&& apt-get clean
1313

14+
# install yarn to manage JS dependencies
15+
RUN npm install --global [email protected]
1416

1517
# install supercronic - a cron alternative
1618
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64 \
@@ -41,6 +43,12 @@ COPY Gemfile Gemfile.lock ./
4143
# install gems
4244
RUN bundle check || bundle install
4345

46+
# copy package file
47+
COPY package.json yarn.lock ./
48+
49+
# install js dependencies
50+
RUN yarn install --frozen-lockfile --non-interactive
51+
4452
# copy code
4553
COPY . .
4654

Gemfile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ gem 'rails', '7.2.3'
66

77
gem 'active_model_serializers'
88
gem 'activerecord-session_store'
9+
gem 'addressable'
910
gem 'ahoy_matey'
1011
gem 'auto_strip_attributes'
1112
gem 'bootsnap', require: false
@@ -73,15 +74,6 @@ gem 'validate_url'
7374
gem 'whenever', require: false # Work around https://github.com/javan/whenever/issues/831
7475
gem 'will_paginate'
7576

76-
source 'https://rails-assets.org' do
77-
gem 'rails-assets-clipboard', '~> 1.5.12'
78-
gem 'rails-assets-devbridge-autocomplete', '~> 1.4.9'
79-
gem 'rails-assets-eonasdan-bootstrap-datetimepicker', '~> 4.17.42'
80-
gem 'rails-assets-markdown-it', '~> 7.0.1'
81-
gem 'rails-assets-moment', '~> 2.30.1'
82-
gem 'rails-assets-select2', '~> 4.0.8'
83-
end
84-
8577
group :development, :test do
8678
gem 'byebug'
8779
gem 'pry-byebug'

Gemfile.lock

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,6 @@ GIT
66
tess_rdf_extractors (1.1.0)
77
linkeddata (~> 3.2.0)
88

9-
GEM
10-
remote: https://rails-assets.org/
11-
specs:
12-
rails-assets-clipboard (1.5.16)
13-
rails-assets-devbridge-autocomplete (1.4.9)
14-
rails-assets-jquery (>= 1.7)
15-
rails-assets-eonasdan-bootstrap-datetimepicker (4.17.49)
16-
rails-assets-jquery (>= 1.8.3)
17-
rails-assets-moment (>= 2.10.5)
18-
rails-assets-jquery (3.7.0)
19-
rails-assets-markdown-it (7.0.1)
20-
rails-assets-moment (2.30.1)
21-
rails-assets-select2 (4.0.8)
22-
239
GEM
2410
remote: https://rubygems.org/
2511
specs:
@@ -831,6 +817,7 @@ PLATFORMS
831817
DEPENDENCIES
832818
active_model_serializers
833819
activerecord-session_store
820+
addressable
834821
ahoy_matey
835822
auto_strip_attributes
836823
better_errors
@@ -877,12 +864,6 @@ DEPENDENCIES
877864
pundit
878865
rack-cors
879866
rails (= 7.2.3)
880-
rails-assets-clipboard (~> 1.5.12)!
881-
rails-assets-devbridge-autocomplete (~> 1.4.9)!
882-
rails-assets-eonasdan-bootstrap-datetimepicker (~> 4.17.42)!
883-
rails-assets-markdown-it (~> 7.0.1)!
884-
rails-assets-moment (~> 2.30.1)!
885-
rails-assets-select2 (~> 4.0.8)!
886867
rails-controller-testing
887868
rails-i18n
888869
rails_admin

app/assets/javascripts/application.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
//= require markdown-it
2727
//= require URI
2828
//= require moment
29-
//= require eonasdan-bootstrap-datetimepicker
30-
//= require devbridge-autocomplete
29+
//= require bootstrap-datetimepicker
30+
//= require jquery.autocomplete
3131
//= require clipboard
3232
//= require ardc_vocab_widget_v2
3333
//= require select2

app/assets/stylesheets/application.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
// Vendor
4848
@import "cytoscape-panzoom";
4949
@import "jquery.simplecolorpicker";
50-
@import "eonasdan-bootstrap-datetimepicker";
50+
@import "bootstrap-datetimepicker";
5151
@import "ardc_vocab_widget_v2";
5252
@import "jquery.qtip.min";
5353
@import "select2";

app/controllers/callbacks_controller.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# The controller for callback actions
22
class CallbacksController < Devise::OmniauthCallbacksController
3+
include SpaceRedirect
34

45
Devise.omniauth_configs.each do |provider, config|
56
define_method(provider) do
@@ -11,6 +12,9 @@ class CallbacksController < Devise::OmniauthCallbacksController
1112

1213
def handle_callback(provider, config)
1314
@user = User.from_omniauth(request.env["omniauth.auth"])
15+
if request.env['omniauth.params'] && request.env['omniauth.params']['space_id']
16+
space = Space.find_by_id(request.env['omniauth.params']['space_id'])
17+
end
1418

1519
if @user.new_record?
1620
# new user
@@ -27,14 +31,15 @@ def handle_callback(provider, config)
2731

2832
sign_in @user
2933
flash[:notice] = "#{I18n.t('devise.registrations.signed_up')} Please ensure your profile is correct."
30-
redirect_to edit_user_path(@user)
34+
redirect_to_space(edit_user_path(@user), space)
3135
rescue Exception => e
3236
flash[:notice] = "Login failed: #{e.message.to_s}"
33-
redirect_to new_user_session_path
37+
redirect_to_space(new_user_session_path, space)
3438
end
3539
else
36-
sign_in_and_redirect @user
40+
scope = Devise::Mapping.find_scope!(@user)
41+
sign_in(scope, resource, {})
42+
redirect_to_space(after_sign_in_path_for(@user), space)
3743
end
3844
end
39-
4045
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module SpaceRedirect
2+
extend ActiveSupport::Concern
3+
4+
private
5+
6+
def redirect_to_space(path, space)
7+
if space&.is_subdomain?
8+
port_part = ''
9+
port_part = ":#{request.port}" if (request.protocol == "http://" && request.port != 80) ||
10+
(request.protocol == "https://" && request.port != 443)
11+
redirect_to URI.join("#{request.protocol}#{space.host}#{port_part}", path).to_s, allow_other_host: true
12+
else
13+
redirect_to path
14+
end
15+
end
16+
end

0 commit comments

Comments
 (0)