Skip to content

Commit ad0ce87

Browse files
authored
Merge branch 'master' into tess-yml-style
2 parents 5a5f93c + ce261e3 commit ad0ce87

87 files changed

Lines changed: 6131 additions & 74399 deletions

File tree

Some content is hidden

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

Gemfile.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,16 @@ GEM
198198
eventbrite_sdk (3.6.0)
199199
rest-client (~> 2.0)
200200
execjs (2.8.1)
201-
faraday (2.13.1)
201+
faraday (2.14.1)
202202
faraday-net_http (>= 2.0, < 3.5)
203203
json
204204
logger
205205
faraday-follow_redirects (0.3.0)
206206
faraday (>= 1, < 3)
207207
faraday-multipart (1.1.0)
208208
multipart-post (~> 2.0)
209-
faraday-net_http (3.4.0)
210-
net-http (>= 0.5.0)
209+
faraday-net_http (3.4.2)
210+
net-http (~> 0.5)
211211
ffi (1.15.5)
212212
font-awesome-sass (4.7.0)
213213
sass (>= 3.2)
@@ -263,7 +263,7 @@ GEM
263263
jquery-turbolinks (2.1.0)
264264
railties (>= 3.1.0)
265265
turbolinks
266-
json (2.12.2)
266+
json (2.18.1)
267267
json-canonicalization (1.0.0)
268268
json-jwt (1.16.6)
269269
activesupport (>= 4.2)
@@ -381,8 +381,8 @@ GEM
381381
bigdecimal (>= 3.1, < 5)
382382
multipart-post (2.4.1)
383383
nested_form (0.3.2)
384-
net-http (0.6.0)
385-
uri
384+
net-http (0.9.1)
385+
uri (>= 0.11.1)
386386
net-http-persistent (4.0.6)
387387
connection_pool (~> 2.2, >= 2.2.4)
388388
net-imap (0.5.8)
@@ -396,7 +396,7 @@ GEM
396396
net-protocol
397397
netrc (0.11.0)
398398
nio4r (2.7.4)
399-
nokogiri (1.18.9)
399+
nokogiri (1.19.1)
400400
mini_portile2 (~> 2.8.2)
401401
racc (~> 1.4)
402402
numerizer (0.1.1)
@@ -461,7 +461,7 @@ GEM
461461
pundit (2.3.1)
462462
activesupport (>= 3.0.0)
463463
racc (1.8.1)
464-
rack (2.2.20)
464+
rack (2.2.22)
465465
rack-cors (2.0.2)
466466
rack (>= 2.0.0)
467467
rack-oauth2 (2.2.0)
@@ -780,7 +780,7 @@ GEM
780780
unf_ext (0.0.8.2)
781781
unicode-display_width (2.4.2)
782782
unicode-types (1.10.0)
783-
uri (1.0.4)
783+
uri (1.1.1)
784784
useragent (0.16.11)
785785
validate_email (0.1.6)
786786
activemodel (>= 3.0)

app/assets/javascripts/application.js

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ document.addEventListener("turbolinks:load", function(e) {
277277
LearningPaths.init();
278278

279279
$('.tess-expandable').each(function () {
280+
if (this.dataset.origHeight) {
281+
return;
282+
}
280283
var limit = this.dataset.heightLimit || 300;
281284

282285
if (this.clientHeight > limit) {
@@ -286,32 +289,11 @@ document.addEventListener("turbolinks:load", function(e) {
286289
this.dataset.origHeight = this.clientHeight;
287290
this.style.maxHeight = '' + limit + 'px';
288291
this.classList.add('tess-expandable-closed');
289-
var btn = $('<a href="#" class="tess-expandable-btn">Show more</a>');
292+
const btn = $('<a href="#" class="tess-expandable-btn">Show more</a>');
290293
btn.insertAfter($(this));
291294
}
292295
});
293296

294-
$(document).on('click', '.tess-expandable-btn', function (event) {
295-
event.preventDefault();
296-
var div = this.parentElement.querySelector('.tess-expandable');
297-
var maxHeight = parseInt(div.dataset.origHeight) + 80;
298-
var limit = parseInt(div.dataset.heightLimit || "300");
299-
300-
if (div.classList.contains('tess-expandable-closed')) {
301-
div.classList.add('tess-expandable-open');
302-
div.classList.remove('tess-expandable-closed');
303-
div.style.maxHeight = '' + maxHeight + 'px';
304-
this.innerHTML = 'Show less';
305-
} else {
306-
div.classList.remove('tess-expandable-open');
307-
div.classList.add('tess-expandable-closed');
308-
div.style.maxHeight = '' + limit + 'px';
309-
this.innerHTML = 'Show more';
310-
}
311-
312-
return false;
313-
});
314-
315297
$('.faq .question dt').click(function () {
316298
var button = $(this).find('.expand');
317299
var sign = button.text();
@@ -380,6 +362,36 @@ $(document).on('click', '[href="#activity_log"]', function () {
380362
return false;
381363
});
382364

365+
$(document).on('click', '.tess-expandable-btn', function (event) {
366+
event.preventDefault();
367+
let div = this.previousElementSibling;
368+
369+
if (!div || !div.classList.contains('tess-expandable')) {
370+
div = this.parentElement.querySelector('.tess-expandable');
371+
}
372+
373+
if (!div) {
374+
return false;
375+
}
376+
377+
const maxHeight = parseInt(div.dataset.origHeight) + 80;
378+
const limit = parseInt(div.dataset.heightLimit || "300");
379+
380+
if (div.classList.contains('tess-expandable-closed')) {
381+
div.classList.add('tess-expandable-open');
382+
div.classList.remove('tess-expandable-closed');
383+
div.style.maxHeight = '' + maxHeight + 'px';
384+
this.innerHTML = 'Show less';
385+
} else {
386+
div.classList.remove('tess-expandable-open');
387+
div.classList.add('tess-expandable-closed');
388+
div.style.maxHeight = '' + limit + 'px';
389+
this.innerHTML = 'Show more';
390+
}
391+
392+
return false;
393+
});
394+
383395
// sticky-navbar feature
384396
document.addEventListener('turbolinks:load', function () {
385397

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
var SourceFilters = {
2+
lastId: function () {
3+
var existing_list_item_ids = $(".source-filter-form").map(function (i, c) { return $(c).data("id-in-filter-list") });
4+
if (existing_list_item_ids.length == 0) return 0;
5+
return Math.max.apply(null, existing_list_item_ids) + 1;
6+
},
7+
8+
add: function () {
9+
var new_form = $($('#source-filter-template').clone().html().replace(/REPLACE_ME/g, SourceFilters.lastId()));
10+
new_form.appendTo('#source-filter-list');
11+
12+
return false; // Stop form being submitted
13+
},
14+
15+
addBlockFilter: function () {
16+
var new_form = $($('#source-filter-template').clone().html().replace(/REPLACE_ME/g, SourceFilters.lastId()).replace(/allow/, 'block'));
17+
new_form.appendTo('#source-block-list');
18+
19+
return false; // Stop form being submitted
20+
},
21+
22+
delete: function () {
23+
$(this).parents('.source-filter-form').fadeOut().find("input[name$='[_destroy]']").val("true");
24+
}
25+
};
26+
27+
document.addEventListener("turbolinks:load", function () {
28+
$('#source-filters')
29+
.on('click', '#add-source-filter-btn', SourceFilters.add)
30+
.on('click', '#add-source-filter-btn-label', SourceFilters.add)
31+
.on('click', '.delete-source-filter-btn', SourceFilters.delete);
32+
$('#source-block-filters')
33+
.on('click', '#add-source-block-filter-btn', SourceFilters.addBlockFilter)
34+
.on('click', '#add-source-block-filter-btn-label', SourceFilters.addBlockFilter)
35+
.on('click', '.delete-source-filter-btn', SourceFilters.delete);
36+
});

app/assets/stylesheets/application.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
@import "curators";
3131
@import "events";
3232
@import "external-resources";
33+
@import "sources";
3334
@import "footer";
3435
@import "forms";
3536
@import "headers";
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.source-filter-form {
2+
display: flex;
3+
gap: 1em;
4+
margin-bottom: 4px;
5+
6+
label {
7+
margin-right: 4px;
8+
}
9+
}

app/controllers/orcid_controller.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class OrcidController < ApplicationController
2+
before_action :orcid_auth_enabled
23
before_action :authenticate_user!
34
before_action :set_oauth_client, only: [:authenticate, :callback]
45

@@ -43,4 +44,10 @@ def set_oauth_client
4344
host: config[:host].presence || (Rails.env.production? ? 'orcid.org' : 'sandbox.orcid.org')
4445
)
4546
end
47+
48+
def orcid_auth_enabled
49+
unless TeSS::Config.orcid_authentication_enabled?
50+
raise ActionController::RoutingError.new('Feature not enabled')
51+
end
52+
end
4653
end

app/controllers/sources_controller.rb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class SourcesController < ApplicationController
2-
before_action :set_source, except: [:index, :new, :create, :check_exists]
3-
before_action :set_content_provider, except: [:index, :check_exists]
2+
before_action :set_source, except: %i[index new create check_exists]
3+
before_action :set_content_provider, except: %i[index check_exists]
44
before_action :set_breadcrumbs
55

66
include SearchableIndex
@@ -65,8 +65,8 @@ def check_exists
6565
end
6666
else
6767
respond_to do |format|
68-
format.html { render :nothing => true, :status => 200, :content_type => 'text/html' }
69-
format.json { render json: {}, :status => 200, :content_type => 'application/json' }
68+
format.html { render nothing: true, status: 200, content_type: 'text/html' }
69+
format.json { render json: {}, status: 200, content_type: 'application/json' }
7070
end
7171
end
7272
end
@@ -75,6 +75,7 @@ def check_exists
7575
# PATCH/PUT /sources/1.json
7676
def update
7777
authorize @source
78+
7879
respond_to do |format|
7980
if @source.update(source_params)
8081
@source.create_activity(:update, owner: current_user) if @source.log_update_activity?
@@ -94,8 +95,10 @@ def destroy
9495
@source.create_activity :destroy, owner: current_user
9596
@source.destroy
9697
respond_to do |format|
97-
format.html { redirect_to policy(Source).index? ? sources_path : content_provider_path(@content_provider),
98-
notice: 'Source was successfully deleted.' }
98+
format.html do
99+
redirect_to policy(Source).index? ? sources_path : content_provider_path(@content_provider),
100+
notice: 'Source was successfully deleted.'
101+
end
99102
format.json { head :no_content }
100103
end
101104
end
@@ -106,7 +109,7 @@ def test
106109
@source.test_job_id = job_id
107110

108111
respond_to do |format|
109-
format.json { render json: { id: job_id }}
112+
format.json { render json: { id: job_id } }
110113
end
111114
end
112115

@@ -150,11 +153,11 @@ def set_content_provider
150153

151154
# Never trust parameters from the scary internet, only allow the white list through.
152155
def source_params
153-
permitted = [:url, :method, :token, :default_language, :enabled]
156+
permitted = %i[url method token default_language enabled source_filters]
154157
permitted << :approval_status if policy(@source || Source).approve?
155158
permitted << :content_provider_id if policy(Source).index?
156159

157-
params.require(:source).permit(permitted)
160+
params.require(:source).permit(permitted, source_filters_attributes: %i[id mode property value _destroy])
158161
end
159162

160163
def set_breadcrumbs
@@ -164,7 +167,7 @@ def set_breadcrumbs
164167
add_breadcrumb 'Sources', content_provider_path(@content_provider, anchor: 'sources')
165168

166169
if params[:id]
167-
add_breadcrumb @source.title, content_provider_source_path(@content_provider, @source) if (@source && !@source.new_record?)
170+
add_breadcrumb @source.title, content_provider_source_path(@content_provider, @source) if @source && !@source.new_record?
168171
add_breadcrumb action_name.capitalize.humanize, request.path unless action_name == 'show'
169172
elsif action_name != 'index'
170173
add_breadcrumb action_name.capitalize.humanize, request.path
@@ -173,5 +176,4 @@ def set_breadcrumbs
173176
super
174177
end
175178
end
176-
177179
end

app/controllers/trainers_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ def index
2424
# GET /trainers/1.json
2525

2626
def show
27+
@bioschemas = @trainer.user.registrations.flat_map(&:to_bioschemas)
2728
respond_to do |format|
29+
format.html
2830
format.json
2931
format.json_api { render json: @trainer }
30-
format.html
3132
end
3233
end
3334

@@ -45,5 +46,4 @@ def trainer_params
4546
{ :expertise_technical => [] }, { :interest => [] }, { :activity => [] },
4647
{ :fields => [] }, { :social_media => [] })
4748
end
48-
49-
end
49+
end

app/controllers/users_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def invitees
3939
# GET /users/1
4040
# GET /users/1.json
4141
def show
42+
@bioschemas = @user.registrations.flat_map(&:to_bioschemas)
4243
respond_to do |format|
4344
format.html
4445
format.json

app/helpers/events_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
module EventsHelper
66
def events_info
77
I18n.t('info.events.description',
8-
link: link_to(I18n.t('info.events.link'),
9-
registering_resources_path(anchor: 'automatic')))
8+
link: I18n.t('info.events.link'),
9+
url: registering_resources_path(anchor: 'automatic'))
1010
end
1111

1212
def google_calendar_export_url(event)

0 commit comments

Comments
 (0)