Skip to content

Commit

Permalink
Merge branch 'main' into APPS-1198_add-a-terms-of-use-reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jun 26, 2023
2 parents 8dfb265 + a409f12 commit 16056ae
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 27 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ gem 'mysql2', '~> 0.5'
gem 'pkg-config', '~> 1.1'
gem 'puma', '~> 5.5' # app server
gem 'rails', '~> 5.2'
gem 'rails_autolink'
gem 'rollbar' # Error reporting tool
gem 'rsolr', '>= 1.0'
gem 'sassc-rails', '>= 2.1.2' # SASS -> CSS compiler
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails_autolink (1.1.8)
actionview (> 3.1)
activesupport (> 3.1)
railties (> 3.1)
railties (5.2.4.5)
actionpack (= 5.2.4.5)
activesupport (= 5.2.4.5)
Expand Down Expand Up @@ -487,6 +491,7 @@ DEPENDENCIES
puma (~> 5.5)
rails (~> 5.2)
rails-controller-testing (>= 1.0.4)
rails_autolink
rollbar
rsolr (>= 1.0)
rspec-collection_matchers
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ class CatalogController < ApplicationController
config.add_show_field 'description_tesim', label: 'Description'
config.add_show_field 'caption_tesim', label: 'Caption'
config.add_show_field 'toc_tesim', label: 'Table of Contents'
config.add_show_field 'contents_note_tesim', label: 'Contents note'
config.add_show_field 'contents_note_tesim', label: 'Contents note', auto_link: true # make this field url aware
config.add_show_field 'contents_ssi', label: 'Contents'
config.add_show_field 'undertext_objects_ssim', label: 'Undertext Objects', break_options: {}
config.add_show_field 'undertext_objects_ssim', label: 'Undertext Objects', auto_link: true, break_options: {}
config.add_show_field 'provenance_tesim', label: 'Provenance'
config.add_show_field 'colophon_tesim', label: 'Colophon'
config.add_show_field 'note_tesim', label: 'Note'
Expand Down Expand Up @@ -252,8 +252,8 @@ class CatalogController < ApplicationController
config.add_show_field 'geographic_coordinates_ssim'

# HISTORY TAB
config.add_show_field 'related_tesim', label: 'Related Items', break_options: {}
config.add_show_field 'overtext_manuscript_ssm', label: 'Overtext manuscript', break_options: {}
config.add_show_field 'related_tesim', label: 'Related Items', break_options: {}, auto_link: true
config.add_show_field 'overtext_manuscript_ssm', label: 'Overtext manuscript', break_options: {}, auto_link: true

# SECONDARY
# Find This Item
Expand Down
29 changes: 29 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true
require 'rails_autolink'

module ApplicationHelper
include ERB::Util # provides html_escape

# Uses Rails auto_link to add links to fields
#
# @param field [String,Hash] string to format and escape, or a hash as per helper_method
# @option field [SolrDocument] :document
# @option field [String] :field name of the solr field
# @option field [Blacklight::Configuration::IndexField, Blacklight::Configuration::ShowField] :config
# @option field [Array] :value array of values for the field
# @param show_link [Boolean]
# @return [ActiveSupport::SafeBuffer]
def iconify_auto_link(field, show_link = true)
if field.is_a? Hash
options = field[:config].separator_options || {}
text = field[:value].to_sentence(options)
else
text = field
end
# this block is only executed when a link is inserted;
# if we pass text containing no links, it just returns text.
auto_link(html_escape(text)) do |value|
"<span class='fa fa-external-link'></span>#{('&nbsp;' + value) if show_link}"
end
end
end
20 changes: 20 additions & 0 deletions app/processors/auto_link.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true
# Joins values using configured value, linebreak, or delimiter
class AutoLink < Blacklight::Rendering::AbstractStep
include ActionView::Helpers::TextHelper

def render
if config.auto_link
linked_values = values.map do |value|
auto_link(html_escape(value), &:to_s)
end
next_step(linked_values)
else
next_step(values)
end
end

def html_escape(*args)
ERB::Util.html_escape(*args)
end
end
2 changes: 1 addition & 1 deletion app/processors/custom_join.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def render
next_step(values.map { |x| html_escape(x) })
else
joiner = config.break_options ? (config.join_with || '<br>'.html_safe) : (config.join_with || '&nbsp;|&nbsp;'.html_safe)
next_step(safe_join(values, joiner))
next_step(safe_join(values.map(&:html_safe), joiner))
end
end

Expand Down
11 changes: 0 additions & 11 deletions app/views/catalog/work_record--sinai/_content_metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,10 @@
<div class="primary-metadata_tab-box--sinai">
<%= render 'catalog/work_record--sinai/content_work_metadata', document: document %>
<% contents.each do |field_name, field| %>
<% if field_name == "undertext_objects_ssim" %>
<div class="metadata-block--sinai">
<span class="metadata-block_title--sinai">
<%= 'Undertext objects' %>
</span>
<span class="metadata-block_value--sinai">
<%= render_undertext_objects_markup %>
</span>
</div>
<% else %>
<div class="metadata-block--sinai">
<span class="metadata-block_title--sinai"> <%= (render_document_show_field_label document, field: field_name).tr(':', '') %></span>
<span class="metadata-block_value--sinai"><%= doc_presenter.field_value field %></span>
</div>
<% end %>
<% end %>
</div>
<% end %>
11 changes: 7 additions & 4 deletions config/initializers/blacklight.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# frozen_string_literal: true
ActiveSupport::Reloader.to_prepare do
Blacklight::Rendering::Pipeline.operations = [Blacklight::Rendering::HelperMethod,
Blacklight::Rendering::LinkToFacet,
Blacklight::Rendering::Microdata,
CustomJoin]
Blacklight::Rendering::Pipeline.operations = [
AutoLink,
Blacklight::Rendering::HelperMethod,
Blacklight::Rendering::LinkToFacet,
Blacklight::Rendering::Microdata,
CustomJoin
]
end
16 changes: 9 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
version: '3.6'
version: "3.6"

services:
sinai:
# image: uclalibrary/sinaimanuscripts:latest
build: .
command: 'sh start-sinai.sh'
stdin_open: true
tty: true
command: "sh start-sinai.sh"
depends_on:
- db
- solr
env_file:
- ./default.env
- ./docker.env
ports:
- '127.0.0.1:3004:3000'
- "127.0.0.1:3004:3000"
volumes:
- .:/sinai
- node_modules:/sinai/node_modules
Expand All @@ -25,19 +27,19 @@ services:
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- mysql_data:/var/lib/mysql
ports:
- '127.0.0.1:3306:3306'
- "127.0.0.1:3306:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"

solr:
image: uclalibrary/solr-ursus:7.4
ports:
- '127.0.0.1:8983:8983'
- "127.0.0.1:8983:8983"

solr_test:
image: uclalibrary/solr-ursus:7.4
ports:
- '127.0.0.1:8985:8983'
- "127.0.0.1:8985:8983"

volumes:
mysql_data:
Expand Down

0 comments on commit 16056ae

Please sign in to comment.