Skip to content

Commit

Permalink
Merge branch 'main' of github.com:scientist-softserv/palni-palci
Browse files Browse the repository at this point in the history
  • Loading branch information
labradford committed Jun 14, 2023
2 parents dea52a8 + 3511c59 commit 4857db4
Show file tree
Hide file tree
Showing 35 changed files with 230 additions and 111 deletions.
5 changes: 1 addition & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CAPYBARA_SERVER=web
CHROME_HOSTNAME=chrome
CHROME_HOSTNAME=seleniarm-hub
DB_ADAPTER=postgresql
DB_HOST=db
DB_NAME=hyku
Expand Down Expand Up @@ -46,6 +46,3 @@ HYKU_MULTITENANT=true
# Comment this line if the Groups with Roles feature is disabled and to
# allow registered users to create curation concerns (Works, Collections, and FileSets)
HYKU_RESTRICT_CREATE_AND_DESTROY_PERMISSIONS=true

# Refer to the README for how to configure analytics
HYRAX_ANALYTICS=false
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,4 @@ gem 'pronto-rubocop', require: false

gem "order_already", "~> 0.3.1"
gem "redcarpet"
gem 'blacklight_range_limit'
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ GEM
blacklight_oai_provider (6.1.1)
blacklight (~> 6.0)
oai (~> 1.0)
blacklight_range_limit (7.0.1)
blacklight
jquery-rails
rails (>= 3.0)
tether-rails
bolognese (1.9.17)
activesupport (>= 4.2.5)
benchmark_methods (~> 0.7)
Expand Down Expand Up @@ -1253,6 +1258,7 @@ DEPENDENCIES
aws-sdk-sqs
blacklight (~> 6.7)
blacklight_oai_provider (~> 6.1, >= 6.1.1)
blacklight_range_limit
bolognese (>= 1.9.10)
bootstrap-datepicker-rails
bulkrax (~> 4.3.0)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ The full spec suite can be run in docker locally. There are several ways to do t
docker-compose exec web rake
```

#### Docker with an M1 chip
- You may run into issues with Selenium with an M1 chip. If so, use the override file provided called `docker-compose-override.yml`
- To see selenium grid running in the browser and check that selenium is connected properly, visit `localhost:4444`
- To see selenium tests running in the browser, you will need a VNC. Macs have a built in VNC app called Screen Sharing.
- Spotlight search: open Screen Sharing app
- enter the following address to watch your tests: vnc://localhost:6900
- if prompted for a password, the default is "secret"
- you should now be able to see selenium tests run in the browser.

### With out Docker

Please note that this is unused by most contributors at this point and will likely become unsupported in a future release of Hyku unless someone in the community steps up to maintain it.
Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@
//= require flot_graph
//= require statistics_tab_manager
//= require blacklight_gallery/default


// For blacklight_range_limit built-in JS, if you don't want it you don't need
// this:
//= require 'blacklight_range_limit'

7 changes: 6 additions & 1 deletion app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
*= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
*= require bootstrap-datepicker
*= require_self
*/
*
* Used by blacklight_range_limit
*= require 'blacklight_range_limit'
*
*/
16 changes: 16 additions & 0 deletions app/assets/stylesheets/hyku.scss
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,14 @@ span.constraint-value p, .facet-values p {
margin-top: 3em;
}

.mt-2 {
margin-top: 0.5em;
}

.mb-2 {
margin-bottom: .5em;
}

.hyc-banner {
padding: 15px;
.hyc-bugs .hyc-created-by, .hyc-bugs .hyc-last-updated, .hyc-title {
Expand All @@ -628,3 +636,11 @@ span.constraint-value p, .facet-values p {
position: relative;
}
}

// date range limit - blacklight_range_limit gem
form.range_limit.range_date_ssi {
line-height: 1.4;
input.range_begin, input.range_end {
width: auto;
}
}
4 changes: 4 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class CatalogController < ApplicationController
include BlacklightRangeLimit::ControllerOverride
include Hydra::Catalog
include Hydra::Controller::ControllerBehavior
include BlacklightOaiProvider::Controller
Expand Down Expand Up @@ -65,6 +66,7 @@ def self.modified_field
config.add_facet_field 'based_near_label_sim', limit: 5
config.add_facet_field 'publisher_sim', limit: 5
config.add_facet_field 'file_format_sim', limit: 5
config.add_facet_field 'date_ssi', label: 'Date Created', range: { num_segments: 10, assumed_boundaries: [1100, Time.zone.now.year + 2], segments: false, slider_js: false, maxlength: 4 }
config.add_facet_field 'member_of_collections_ssim', limit: 5, label: 'Collections'

# Have BL send all facet field names to Solr, which has been the default
Expand Down Expand Up @@ -369,6 +371,8 @@ def self.modified_field
config.add_sort_field "score desc, #{uploaded_field} desc", label: "relevance"
config.add_sort_field "title_ssi asc", label: "title (A-Z)"
config.add_sort_field "title_ssi desc", label: "title (Z-A)"
config.add_sort_field "date_ssi desc", label: "date created \u25BC"
config.add_sort_field "date_ssi asc", label: "date created \u25B2"
config.add_sort_field "#{uploaded_field} desc", label: "date uploaded \u25BC"
config.add_sort_field "#{uploaded_field} asc", label: "date uploaded \u25B2"
config.add_sort_field "#{modified_field} desc", label: "date modified \u25BC"
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/search_history_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class SearchHistoryController < ApplicationController
include Blacklight::SearchHistory

helper BlacklightRangeLimit::ViewHelperOverride
helper RangeLimitHelper
end
14 changes: 13 additions & 1 deletion app/indexers/app_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,19 @@ class AppIndexer < Hyrax::WorkIndexer
def generate_solr_document
super.tap do |solr_doc|
solr_doc['title_ssi'] = SortTitle.new(object.title.first).alphabetical
solr_doc["account_cname_tesim"] = Site.instance&.account&.cname
solr_doc['bulkrax_identifier_tesim'] = object.bulkrax_identifier
solr_doc['account_cname_tesim'] = Site.instance&.account&.cname
add_date(solr_doc)
end
end

def add_date(solr_doc)
# The allowed date formats are either YYYY, YYYY-MM, or YYYY-MM-DD
# the date must be formatted as a 4 digit year in order to be sorted.
valid_date_formats = /\A(\d{4})(?:-\d{2}(?:-\d{2})?)?\z/
date_string = solr_doc['date_created_tesim']&.first
year = date_string&.match(valid_date_formats)&.captures&.first
solr_doc['date_tesi'] = year if year
solr_doc['date_ssi'] = year if year
end
end
12 changes: 1 addition & 11 deletions app/indexers/etd_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,10 @@

# Generated via
# `rails generate hyrax:work Etd`
class EtdIndexer < Hyrax::WorkIndexer
# This indexes the default metadata. You can remove it if you want to
# provide your own metadata and indexing.
include Hyrax::IndexesBasicMetadata

# Fetch remote labels for based_near. You can remove this if you don't want
# this behavior
include Hyrax::IndexesLinkedMetadata

class EtdIndexer < AppIndexer
# Uncomment this block if you want to add custom indexing behavior:
def generate_solr_document
super.tap do |solr_doc|
solr_doc['bulkrax_identifier_tesim'] = object.bulkrax_identifier
solr_doc['title_ssi'] = SortTitle.new(object.title.first).alphabetical
solr_doc['admin_note_tesim'] = object.admin_note
end
end
Expand Down
12 changes: 1 addition & 11 deletions app/indexers/oer_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,10 @@

# Generated via
# `rails generate hyrax:work Oer`
class OerIndexer < Hyrax::WorkIndexer
# This indexes the default metadata. You can remove it if you want to
# provide your own metadata and indexing.
include Hyrax::IndexesBasicMetadata

# Fetch remote labels for based_near. You can remove this if you don't want
# this behavior
include Hyrax::IndexesLinkedMetadata

class OerIndexer < AppIndexer
# Uncomment this block if you want to add custom indexing behavior:
def generate_solr_document
super.tap do |solr_doc|
solr_doc['bulkrax_identifier_tesim'] = object.bulkrax_identifier
solr_doc['title_ssi'] = SortTitle.new(object.title.first).alphabetical
solr_doc['admin_note_tesim'] = object.admin_note
end
end
Expand Down
18 changes: 0 additions & 18 deletions app/models/concerns/account_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,24 +193,6 @@ def reload_library_config

def reload_analytics
# rubocop:disable Style/RedundantSelf
# fall back to the default values if they aren't set in the tenant
unless self.google_analytics_id.present? &&
self.google_oauth_app_name.present? &&
self.google_oauth_app_version.present? &&
(self.google_oauth_private_key_value.present? || self.google_oauth_private_key_path.present?) &&
self.google_oauth_private_key_secret.present? &&
self.google_oauth_client_email.present?

config = Hyrax::Analytics::Config.load_from_yaml
self.google_analytics_id = self.google_analytics_id.presence || config.analytics_id
self.google_oauth_app_name = self.google_oauth_app_name.presence || config.app_name
self.google_oauth_app_version = self.google_oauth_app_version.presence || config.app_version
self.google_oauth_private_key_value = self.google_oauth_private_key_value.presence || config.privkey_value
self.google_oauth_private_key_path = self.google_oauth_private_key_path.presence || config.privkey_path
self.google_oauth_private_key_secret = self.google_oauth_private_key_secret.presence || config.privkey_secret
self.google_oauth_client_email = self.google_oauth_client_email.presence || config.client_email
end

# require the analytics to be set per tenant
Hyrax::Analytics.config.analytics_id = self.google_analytics_id
Hyrax::Analytics.config.app_name = self.google_oauth_app_name
Expand Down
4 changes: 4 additions & 0 deletions app/models/etd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class Etd < ActiveFedora::Base
index.as :stored_searchable
end

property :date, predicate: ::RDF::URI("https://hykucommons.org/terms/date"), multiple: false do |index|
index.as :stored_searchable, :facetable
end

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
include ::Hyrax::BasicMetadata
Expand Down
4 changes: 4 additions & 0 deletions app/models/generic_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class GenericWork < ActiveFedora::Base
index.as :stored_searchable
end

property :date, predicate: ::RDF::URI("https://hykucommons.org/terms/date"), multiple: false do |index|
index.as :stored_searchable, :facetable
end

include ::Hyrax::BasicMetadata
# This line must be kept below all others that set up properties,
# including `include ::Hyrax::BasicMetadata`. All properties must
Expand Down
4 changes: 4 additions & 0 deletions app/models/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class Image < ActiveFedora::Base
index.as :stored_searchable
end

property :date, predicate: ::RDF::URI("https://hykucommons.org/terms/date"), multiple: false do |index|
index.as :stored_searchable, :facetable
end

# This must come after the properties because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
include ::Hyrax::BasicMetadata
Expand Down
4 changes: 4 additions & 0 deletions app/models/oer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class Oer < ActiveFedora::Base
index.as :stored_searchable
end

property :date, predicate: ::RDF::URI("https://hykucommons.org/terms/date"), multiple: false do |index|
index.as :stored_searchable, :facetable
end

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
include ::Hyrax::BasicMetadata
Expand Down
2 changes: 2 additions & 0 deletions app/models/search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class SearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior
include BlacklightRangeLimit::RangeLimitBuilder

include Hydra::AccessControlsEnforcement
include Hyrax::SearchFilters
end
4 changes: 2 additions & 2 deletions app/presenters/hyku/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Hyku
class WorkShowPresenter < Hyrax::WorkShowPresenter
Hyrax::MemberPresenterFactory.file_presenter_class = Hyrax::FileSetPresenter

delegate :title_or_label, :extent, :additional_information, :source, :bibliographic_citation, :admin_note, to: :solr_document
delegate :title_or_label, :extent, :additional_information, :source, :bibliographic_citation, :admin_note, :date, to: :solr_document

# OVERRIDE Hyrax v2.9.0 here to make featured collections work
delegate :collection_presenters, to: :member_presenter_factory
Expand Down Expand Up @@ -39,7 +39,7 @@ def page_title
"#{title.first} | ID: #{id} | #{I18n.t('hyrax.product_name')}"
else
"#{human_readable_type} | #{title.first} | ID: #{id} | #{I18n.t('hyrax.product_name')}"
end
end
end
end

Expand Down
100 changes: 100 additions & 0 deletions app/views/blacklight_range_limit/_range_limit_panel.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<%- # requires solr_config local passed in
field_config = range_config(field_name)
label = facet_field_label(field_name)

input_label_range_begin = field_config[:input_label_range_begin] || t("blacklight.range_limit.range_begin", field_label: label)
input_label_range_end = field_config[:input_label_range_end] || t("blacklight.range_limit.range_end", field_label: label)
maxlength = field_config[:maxlength]
-%>

<div class="limit_content range_limit">
<% if has_selected_range_limit?(field_name) %>
<ul class="current list-unstyled facet-values">
<li class="selected">
<span class="facet-label">
<span class="selected"><%= range_display(field_name) %></span>
<%= link_to remove_range_param(field_name), :class=>"remove", :title => t('blacklight.range_limit.remove_limit') do %>
<span class="glyphicon glyphicon-remove"></span>
<span class="sr-only">[<%= t('blacklight.range_limit.remove_limit') %>]</span>
<% end %>
</span>
<span class="selected facet-count"><%= number_with_delimiter(@response.total) %></span>
</li>
</ul>

<% end %>
<% unless selected_missing_for_range_limit?(field_name) %>
<%= form_tag search_action_path, :method => :get, class: [BlacklightRangeLimit.classes[:form], "range_#{field_name}"].join(' ') do %>
<%= render_hash_as_hidden_fields(search_state.params_for_search.except(:page)) %>

<!-- we need to include a dummy search_field parameter if none exists,
to trick blacklight into displaying actual search results instead
of home page. Not a great solution, but easiest for now. -->
<% unless params.has_key?(:search_field) %>
<%= hidden_field_tag("search_field", "dummy_range") %>
<% end %>

<div class="range_input_wrapper mt-2">
<div class="year-input">Between year:</div>
<%= render_range_input(field_name, :begin, input_label_range_begin, maxlength) %>
</div>

<div class="range_input_wrapper mt-2">
<div class="year-input">and year:</div>
<%= render_range_input(field_name, :end, input_label_range_end, maxlength) %>
</div>
<div class="range_input_wrapper mt-2 mb-2">
<%= submit_tag t('blacklight.range_limit.submit_limit'), class: BlacklightRangeLimit.classes[:submit] %>
</div>
<% end %>
<% end %>

<!-- no results profile if missing is selected -->
<% unless selected_missing_for_range_limit?(field_name) %>
<!-- you can hide this if you want, but it has to be on page if you want
JS slider and calculated facets to show up, JS sniffs it. -->
<div class="profile">
<% if stats_for_field?(field_name) %>
<!-- No stats information found for field in search response -->
<% end %>
<% if (min = range_results_endpoint(field_name, :min)) &&
(max = range_results_endpoint(field_name, :max)) %>
<p class="range subsection <%= "slider_js" unless field_config[:slider_js] == false %>">
Current results range from <span class="min"><%= range_results_endpoint(field_name, :min) %></span> to <span class="max"><%= range_results_endpoint(field_name, :max) %></span>
</p>

<% if field_config[:segments] != false %>
<div class="distribution subsection <%= 'chart_js' unless field_config[:chart_js] == false %>">
<!-- if we already fetched segments from solr, display them
here. Otherwise, display a link to fetch them, which JS
will AJAX fetch. -->
<% if solr_range_queries_to_a(field_name).length > 0 %>
<%= render(:partial => "blacklight_range_limit/range_segments", :locals => {:solr_field => field_name}) %>
<% else %>
<%= link_to('View distribution', main_app.url_for(search_state.to_h.merge(action: 'range_limit', range_field: field_name, range_start: min, range_end: max)), :class => "load_distribution") %>
<% end %>
</div>
<% end %>
<% end %>
<% if (stats = stats_for_field(field_name)) && stats["missing"] > 0 %>
<ul class="missing list-unstyled facet-values subsection">
<li>
<span class="facet-label">
<%= link_to BlacklightRangeLimit.labels[:missing], add_range_missing(field_name) %>
</span>
<span class="facet-count">
<%= number_with_delimiter(stats["missing"]) %>
</span>
</li>
</ul>
<% end %>
</div>
<% end %>
</div>
Loading

0 comments on commit 4857db4

Please sign in to comment.