-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: APPS-2472-2473 Add autolink for url aware (#1129)
* add autolink so the contents_note and related_ito fields can be url aware * add autolink to Gemfile * comment out older related_to code
- Loading branch information
1 parent
a05f220
commit a017add
Showing
11 changed files
with
99 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>#{(' ' + value) if show_link}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters