Skip to content

Commit

Permalink
Merge pull request #495 from trln/Blacklight-8
Browse files Browse the repository at this point in the history
Blacklight 8
  • Loading branch information
lfarrell authored Jan 14, 2025
2 parents d92c640 + f1a9e11 commit 0949948
Show file tree
Hide file tree
Showing 110 changed files with 3,064 additions and 1,070 deletions.
Binary file added .DS_Store
Binary file not shown.
12 changes: 7 additions & 5 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ on:
jobs:
tests:
runs-on: ubuntu-latest
env:
ENGINE_CART_RAILS_OPTIONS: '--skip-javascript --skip-bundle'
strategy:
fail-fast: false
matrix:
ruby: ['3.0', '3.1', '3.2', '3.3']
name: Ruby ${{ matrix.ruby }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Install dependencies
run: bundle install

- name: Run rubocop
run: rake rubocop
run: rake rubocop

- name: Generate a Rails testing application
run: rake engine_cart:generate
Expand Down
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml
require: rubocop-rspec

AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 3.0
# TODO: review this later
NewCops: disable
Exclude:
Expand Down Expand Up @@ -116,3 +116,6 @@ Lint/MissingCopEnableDirective:

Lint/ConstantDefinitionInBlock:
Enabled: false

RSpec/IndexedLet:
Enabled: false
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG RUBY_VERSION=2.7.6
ARG RUBY_VERSION=3.1.6
FROM ruby:${RUBY_VERSION} AS app_bootstrap

RUN apt-get update && apt-get install -y nodejs vim less
Expand All @@ -18,15 +18,20 @@ FROM app_bootstrap AS runnable
COPY --from=builder /gems /gems
COPY ./bundler_config.rb .

# This line is a workaround that seems to be needed when using
# using ruby:3.1.x Docker images, to prevent this error:
# `check_for_activated_spec!': You have already activated error_highlight 0.3.0, but your Gemfile requires error_highlight 0.6.0 ...
RUN gem update error_highlight

RUN $(./bundler_config.rb path /gems)

WORKDIR /app

EXPOSE 3000

ENV ENGINE_CART_RAILS_OPTIONS="--skip-webpack-install --skip-javascript"
ENV ENGINE_CART_RAILS_OPTIONS="--skip-webpack-install --skip-javascript --skip-bundle"

ENV BOOTSTRAP_VERSION="~> 4.1"
ENV BOOTSTRAP_VERSION="~> 5.3"

# allows setting options for caching HTTP operations
# used in unit testing with 'vcr', a ruby framework for recording
Expand Down
22 changes: 11 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ gemspec
# engine_cart stanza: 2.5.0
# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__)))

if File.exist?(file)
begin
eval_gemfile file
Expand All @@ -28,23 +29,22 @@ if File.exist?(file)
else
Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"

# TRLN CUSTOMIZATION:
# We'll use the Rails --skip-javascript flag so when generated we
# won't get the default JS files in app/javascript. We are sticking
# with Sprockets for now; our JS is in app/assets/javascripts.
# We also run --skip-bundle to avoid running `bundle install` upon the
# initial creation of the Rails app. We'll run it later in our generator
# steps after customizing the Gemfile.
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--skip-javascript --skip-bundle'

if ENV['RAILS_VERSION']
if ENV['RAILS_VERSION'] == 'edge'
gem 'rails', github: 'rails/rails'
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks --skip-javascript'
else
gem 'rails', ENV['RAILS_VERSION']
end

case ENV['RAILS_VERSION']
when /^6.0/
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 4.0'
when /^5.[12]/
gem 'sass-rails', '~> 5.0'
gem 'sprockets', '~> 3.7'
gem 'thor', '~> 0.20'
end
end
end
# END ENGINE_CART BLOCK
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ gem 'trln_argon', git: 'https://github.com/trln/trln_argon'
3. Run the following:

$ bundle install
$ bundle exec rails generate blacklight:install --devise --skip-solr
$ bundle exec rails generate blacklight:install --devise --skip-solr --skip-javascript
$ bundle exec rails generate trln_argon:install
$ bundle exec rake db:migrate

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.5
3.0.0
10 changes: 7 additions & 3 deletions app/assets/javascripts/trln_argon/advanced_search_scope.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
Blacklight.onLoad(function() {
$(window).on('load', function(){

//remove default mast search to fix duplicate IDs
// remove default mast search to fix duplicate IDs
$(".blacklight-catalog-advanced_search #search-navbar").remove();
$(".blacklight-trln-advanced_search #search-navbar").remove();


// remove the skip link that leads to that mast search field
$(".blacklight-catalog-advanced_search #skip-link a[href='#search_field']").remove();
$(".blacklight-trln-advanced_search #skip-link a[href='#search_field']").remove();

// change adv search scope
$(".blacklight-trln-advanced_search").length > 0 ? $('#option_trln').attr('checked',true) : $('#option_catalog').attr('checked',true);

$("input[type='radio'][name='option']").change(function() {
var action = $(this).val();
$(".advanced").attr("action", "/" + action);
Expand Down
12 changes: 2 additions & 10 deletions app/assets/javascripts/trln_argon/advanced_search_select.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
Blacklight.onLoad(function() {
$('.advanced-search-facet-select').chosen({
allow_single_deselect: true,
no_results_text: 'No results matched'
no_results_text: 'No results matched',
width: '100%'
});

resizeChosen();
jQuery(window).on('resize', resizeChosen);
});

function resizeChosen() {
$(".chosen-container").each(function() {
$(this).attr('style', 'width: 100%');
});
}
2 changes: 1 addition & 1 deletion app/assets/javascripts/trln_argon/bookmark_share.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $(document).on('click', '#share_bookmarksLink', function( e ){


// create modal
$('#content').append('<div class="modal fade" id="bookmark-modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><h4 class="modal-title">' + shareBookmarksText + '</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div><div class="modal-body"><p class="form-text">' + shareBookmarksHelperText + '</p><div class="input-group"><input id="sharing-url-holder" type="text" class="form-control" data-autoselect="" value="' + bookmarkShareURL + '" aria-label="' + shareBookmarksText + '" readonly=""><span class="input-group-btn"><button id="copy-to-clipboard" class="btn btn-outline-secondary" type="button" data-toggle="tooltip" data-placement="bottom" title="Copy to clipboard"><i class="fa fa-clipboard" aria-hidden="true"></i></button></span></div></div><div class="modal-footer"><button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button></div></div></div></div>');
$('#content').append('<div class="modal fade" id="bookmark-modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><h4 class="modal-title">' + shareBookmarksText + '</h4><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div><div class="modal-body"><p class="form-text">' + shareBookmarksHelperText + '</p><div class="input-group"><input id="sharing-url-holder" type="text" class="form-control" data-autoselect="" value="' + bookmarkShareURL + '" aria-label="' + shareBookmarksText + '" readonly=""><span class="input-group-btn"><button id="copy-to-clipboard" class="btn btn-outline-secondary" type="button" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Copy to clipboard"><i class="fa fa-clipboard" aria-hidden="true"></i></button></span></div></div><div class="modal-footer"><button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Close</button></div></div></div></div>');

// open modal
$('#bookmark-modal').modal('show');
Expand Down
67 changes: 33 additions & 34 deletions app/assets/javascripts/trln_argon/enable_facet_checkbox.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
Blacklight.onLoad(function() {
Blacklight.onLoad(function () {
/**
* Ensures that checkbox-only facets (currently, access_type which is either
* online or not)
* (a) do not display a header and
* (b) automatically select/deselect based on whether the value of the checkbox
* (b) automatically select/deselect based on whether the value of the checkbox
* changes.
*/
$(window).on('load', function() {
$('#facet-panel-collapse .facet-checkbox-wrapper').each(
function(index, element) {
var wrapper = $(this);

// hide the header
wrapper.closest('div.card').find('.facet-field-heading').hide();

var fieldName = wrapper.data('facetField');
if ( !fieldName ) {
return;
}
var fieldValue = wrapper.data('checkboxField');
var field = wrapper.find(":checkbox");
var parameter = "f[" + fieldName + "][]";
var currentURL = new URL(window.location);
var currentParams = currentURL.searchParams;
if ( currentParams.has(parameter) ) {
field.attr("checked", "checked");
$(window).on('load', function () {
// Target the updated facet-checkbox list structure
$('#facet-panel-collapse .blacklight-facet-checkboxes li').each(function (index, element) {
var listItem = $(this);

// hide the header
listItem.closest('div.card').find('.facet-field-heading').hide();

var fieldName = "access_type_f";
var fieldValue = listItem.find('input').val();
var field = listItem.find(":checkbox");
var parameter = "f_inclusive[" + fieldName + "][]";

var currentURL = new URL(window.location);
var currentParams = currentURL.searchParams;

// Check the checkbox if it exists in the URL
if (currentParams.has(parameter) && currentParams.getAll(parameter).includes(fieldValue)) {
field.prop("checked", true);
} else {
field.prop("checked", false);
}

// Add change listener to reload the page when checkbox is checked/unchecked
field.on('change', function () {
if (field.is(':checked')) {
currentParams.append(parameter, fieldValue);
} else {
field.removeAttr("checked");
currentParams.delete(parameter);
}
field.on('change', () => {
if ( field.is(':checked')) {
currentParams.set(parameter, fieldValue);
currentURL.searchParams = currentParams;
window.location.searchParams = currentParams;
} else {
currentParams.delete(parameter);
currentURL.searchParams = currentParams;
}
console.log("sending to ", currentURL);
window.location.assign(currentURL.toString());
});
currentURL.search = currentParams.toString();
window.location.assign(currentURL.toString());
});
});
});
}); // END Blacklight.onLoad
21 changes: 12 additions & 9 deletions app/assets/javascripts/trln_argon/expand_contract.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// test if an element is in the viewport
$.fn.isInViewport = function() {
var elementTop = $(this).offset().top;
var elementBottom = elementTop + $(this).outerHeight();
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + $(window).height();
return elementBottom > viewportTop && elementTop < viewportBottom;
};

Blacklight.onLoad(function() {

/**
* Tests whether an element is vertically
* contained within the current viewport
**/
$.fn.isInViewport = function() {
var elementTop = $(this).offset().top;
var elementBottom = elementTop + $(this).outerHeight();
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + $(window).height();
return elementBottom > viewportTop && elementTop < viewportBottom;
};

$("#documents .hider, #holdings .hider").click(function(evt) {
evt.preventDefault();
var theAnchorID = $(this).attr('href');
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/trln_argon/location_facet.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Blacklight.onLoad(function() {
facetLocationWrapper.find('ul.facet-hierarchy > .twiddle-open > ul > li').slice( parseInt(locationFacetLimit) ).hide();

// add 'more' and 'less' button at end
facetLocationWrapper.find('ul.facet-hierarchy > .twiddle-open > ul').append( "<li role='treeitem' class='location-more-toggle-wrapper'><a class='more_locations_link'>more <span class='sr-only'>Locations</span> »</a><a class='less_locations_link' style='display: none;'>less <span class='sr-only'>Locations</span> »</a></li>" );
facetLocationWrapper.find('ul.facet-hierarchy > .twiddle-open > ul').append( "<li role='treeitem' class='location-more-toggle-wrapper'><a class='more_locations_link'>more <span class='visually-hidden'>Locations</span> »</a><a class='less_locations_link' style='display: none;'>less <span class='visually-hidden'>Locations</span> »</a></li>" );

// click 'more' to show all
facetLocationWrapper.find('.more_locations_link').click(function() {
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/trln_argon/results_count_for_toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Blacklight.onLoad(function() {
}
}

fetch_and_display_toggle_count($('.blacklight-catalog-index #trln-toggle .toggle-trln label'));
fetch_and_display_toggle_count($('.blacklight-trln-index #trln-toggle .toggle-local label'));
fetch_and_display_toggle_count($('.blacklight-catalog-index #trln-toggle .toggle-trln .toggle-label'));
fetch_and_display_toggle_count($('.blacklight-trln-index #trln-toggle .toggle-local .toggle-label'));
});
2 changes: 1 addition & 1 deletion app/assets/javascripts/trln_argon/trln_argon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//= require trln_argon/progressive_links.js
//= require trln_argon/physical_media_facet.js
//= require bootstrap
//= require chosen-jquery
//= require chosen.jquery.js
//= require blacklight/hierarchy/hierarchy.js
//= require trln_argon/location_facet.js
//= require trln_argon/advanced_search_select.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ h2.query-criteria-heading label {
width: 100%;
}

@include media-breakpoint-down(xs) {
@include media-breakpoint-down(sm) {
.submit-buttons {
margin-top: 15px;
text-align: left;
Expand All @@ -53,8 +53,6 @@ h2.query-criteria-heading label {
}

.sorting {
display: inline-flex;

label {
margin-right: 8px;
font-weight: 700;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/trln_argon/trln_argon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
@import 'trln_argon/trln_argon_variables_defaults';

/* trln_argon dependences: blacklight_advanced_search, blacklight_range_limit, etc. */
/* trln_argon dependences: bootstrap, blacklight, plugins, etc. */
@import 'trln_argon/trln_argon_dependencies';

/* additional trln_argon stylesheets */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

@import 'bootstrap';

@import 'blacklight/blacklight';

@import 'blacklight_advanced_search';

@import 'blacklight/hierarchy/hierarchy';
Expand Down
Loading

0 comments on commit 0949948

Please sign in to comment.