Trainers bip scholar - #1373
Conversation
4164297 to
def10b7
Compare
def10b7 to
5dcabdb
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a server-rendered BIP!Scholar “researcher infographic” to trainer profile pages (keyed by the trainer’s ORCID), including styling and controller/view tests, to improve trainer recognition within TeSS.
Changes:
- Embed a new BIP!Scholar infographic partial in
trainers#showwhen an ORCID is present. - Add a helper to fetch/cache BIP!Scholar score data via HTTPS and render it safely via ERB.
- Add new SCSS styling, image asset, and controller/view tests for the embed behavior.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
test/controllers/trainers_controller_test.rb |
Adds tests asserting presence/absence of the embed and fallback behaviors. |
app/views/trainers/show.html.erb |
Renders the new infographic partial under the trainer ORCID section. |
app/views/common/_bip_scholar_infographics.html.erb |
New ERB-rendered widget: fallback message, stats badge link, compact mode support. |
app/helpers/bip_scholar_helper.rb |
New helper for fetching/caching BIP!Scholar API responses and formatting. |
app/assets/stylesheets/pages/bip-scholar.scss |
Adds widget-specific styling. |
app/assets/stylesheets/application.scss |
Imports the new BIP!Scholar stylesheet. |
app/assets/images/bip-minimal.svg |
Adds the BIP!Scholar logo used in the badge. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| module BipScholarHelper | ||
| require 'net/http' |
| return nil if orcid.blank? | ||
|
|
||
| # Cache in Redis for 24 hours to prevent blocking TeSS web threads | ||
| Rails.cache.fetch("bip_scholar_score_#{orcid}", expires_in: 24.hours) do |
| empty_mode = local_assigns.fetch(:empty_mode, 'default') # empty_mode hides BIP!Scholar widget if no ORCID on BIP!Scholar is found | ||
| %> | ||
|
|
||
| <div class="bip-scholar-embed" data-orcid="<%= orcid %>"> |
There was a problem hiding this comment.
Even without the hidden, we do not see blank div on the UI (even though it is present and not hidden in the HTML).
When adding the hidden, it doesn't change anything on the UI and we can still see it in the HTML as well but ok this is a safe hidden parameter, fair enough.
| <div class="bip-scholar-stat <%= 'bip-scholar-stat--group-sep' if stat[:sep] %>" title="<%= stat[:label] %>"> | ||
| <span class="bip-scholar-stat-value"> | ||
| <i class="fa fa-<%= stat[:icon] %> bip-scholar-stat-icon"></i> | ||
| <%= stat[:value] %> | ||
| </span> | ||
| <% unless is_compact %> | ||
| <span class="bip-scholar-stat-label"><%= stat[:label] %></span> | ||
| <% end %> | ||
| </div> |
There was a problem hiding this comment.
Ok to add class="sr-only" for accessibility as found in https://stackoverflow.com/a/19758620
| test 'should show bip-scholar embed in compact layout' do | ||
| BipScholarHelper.stub :fetch_score, nil do | ||
| # Simulates passing empty_mode: 'silent' in view partial render | ||
| html = @controller.render_to_string( | ||
| partial: 'common/bip_scholar_infographics', | ||
| locals: { orcid: @trainer.orcid, layout: 'compact', empty_mode: 'default' } | ||
| ) | ||
| doc = Nokogiri::HTML(html) | ||
|
|
||
| assert_equal 0, doc.css('a.bip-scholar-badge.bip-scholar-badge--compact').size | ||
| end | ||
| end |
| <% if data.nil? %> | ||
| <% unless empty_mode == 'silent' %> | ||
| <div class="bip-scholar-no-profile"> | ||
| <i class="fa fa-circle-info"></i> |
|
I have addressed copilot reviews |
Summary of changes
Motivation and context
As part of EVERSE WP5 'Training and Recognition', I am creating a link between BIP!Scholar and EVERSE Training. To allow more recognition for trainers, I am embedding a researcher infographic, first seen in APICURON (in your curator profile) and then provided by the BIP!Scholar team through: https://github.com/athenarc/bip-plugin/tree/main.
I chose to translate the widget in Ruby to avoid XSS. The
compactandempty_modeparameters are kept. Some icons may have changed due to FA icons version used in TeSS. The base implementation using the JS widget is still shown in the commit 69d22e4.Screenshots
If ORCID found AND in BIP!Scholar:
If ORCID found AND in BIP!Scholar +
layout: 'compact'inapp/views/trainers/show.html.erb:If ORCID not found OR not registered in BIP!Scholar:
If no ORCID OR not registered +
empty_mode: 'silent'inapp/views/trainers/show.html.erbChecklist