Skip to content

Commit

Permalink
link settings dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Cain committed Oct 4, 2023
1 parent 14da844 commit eb538aa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 45 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ AllCops:
- 'config/**/*'
- 'vendor/**/*'
- 'Vagrantfile'
- 'app/helpers/geoblacklight_helper.rb'

Style/Documentation:
Enabled: false
Expand Down
88 changes: 44 additions & 44 deletions app/helpers/geoblacklight_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module GeoblacklightHelper
module GeoblacklightHelper # rubocop:disable Metrics/ModuleLength
def document_available?
@document.public? || (@document.same_institution? && user_signed_in?)
end
Expand All @@ -10,17 +10,17 @@ def document_downloadable?
end

def iiif_jpg_url
@document.references.iiif.endpoint.sub! "info.json", "full/full/0/default.jpg"
@document.references.iiif.endpoint.sub! 'info.json', 'full/full/0/default.jpg'
end

def download_link_file(label, id, url)
link_to(
label,
url,
"contentUrl" => url,
'contentUrl' => url,
:data => {
download: "trigger",
download_type: "direct",
download: 'trigger',
download_type: 'direct',
download_id: id
}
)
Expand All @@ -31,9 +31,9 @@ def download_link_hgl(text, document)
text,
download_hgl_path(id: document),
data: {
blacklight_modal: "trigger",
download: "trigger",
download_type: "harvard-hgl",
blacklight_modal: 'trigger',
download: 'trigger',
download_type: 'harvard-hgl',
download_id: document.id
}
)
Expand All @@ -43,57 +43,56 @@ def download_link_hgl(text, document)
# @return [String]
def download_link_iiif
link_to(
download_text("JPG"),
download_text('JPG'),
iiif_jpg_url,
"contentUrl" => iiif_jpg_url,
'contentUrl' => iiif_jpg_url,
:data => {
download: "trigger"
download: 'trigger'
}
)
end

def download_link_generated(download_type, document)
link_to(export_format_label(download_type),
"",
data: {
download_path: download_path(document.id, type: download_type),
download: "trigger",
download_type: download_type,
download_id: document.id
}
)
'',
data: {
download_path: download_path(document.id, type: download_type),
download: 'trigger',
download_type:,
download_id: document.id
})
end

##
# Blacklight catalog controller helper method to truncate field value to 150 chars
# @param [SolrDocument] args
# @return [String]
def snippit(args)
truncate(Array(args[:value]).flatten.join(" "), length: 150)
truncate(Array(args[:value]).flatten.join(' '), length: 150)
end

##
# Returns an SVG icon or empty HTML span element
# @return [SVG or HTML tag]
def geoblacklight_icon(name, **args)
icon_name = name ? name.to_s.parameterize : "none"
icon_name = name ? name.to_s.parameterize : 'none'
begin
blacklight_icon(icon_name, **args)
rescue Blacklight::Exceptions::IconNotFound
tag.span class: "icon-missing geoblacklight-none"
tag.span class: 'icon-missing geoblacklight-none'
end
end

##
# Looks up properly formatted names for formats
#
def proper_case_format(format)
t("geoblacklight.formats.#{format.to_s.parameterize(separator: "_")}")
t("geoblacklight.formats.#{format.to_s.parameterize(separator: '_')}")
end

# Format labels are customized for exports - look up the appropriate key.
def export_format_label(format)
t("geoblacklight.download.export_#{format.to_s.parameterize(separator: "_")}_link")
t("geoblacklight.download.export_#{format.to_s.parameterize(separator: '_')}_link")
end

##
Expand All @@ -109,7 +108,7 @@ def formatted_name_reference(reference)
#
def download_text(format)
download_format = proper_case_format(format)
value = t("geoblacklight.download.download_link", download_format: download_format)
value = t('geoblacklight.download.download_link', download_format:)
value.html_safe
end

Expand All @@ -126,13 +125,13 @@ def show_help_text?(feature, key)
def render_help_text_entry(feature, key)
if I18n.exists?("geoblacklight.help_text.#{feature}.#{key}", locale)
help_text = I18n.t("geoblacklight.help_text.#{feature}.#{key}")
tag.h3 class: "help-text viewer_protocol h6" do
tag.a data: {toggle: "popover", title: help_text[:title], content: help_text[:content]} do
tag.h3 class: 'help-text viewer_protocol h6' do
tag.a data: { toggle: 'popover', title: help_text[:title], content: help_text[:content] } do
help_text[:title]
end
end
else
tag.span class: "help-text translation-missing"
tag.span class: 'help-text translation-missing'
end
end

Expand All @@ -156,16 +155,16 @@ def show_attribute_table?
# get_field_values method
# @param [Hash] args from get_field_values
def render_value_as_truncate_abstract(args)
tag.div class: "truncate-abstract" do
Array(args[:value]).flatten.join(" ")
tag.div class: 'truncate-abstract' do
Array(args[:value]).flatten.join(' ')
end
end

##
# Selects the basemap used for map displays
# @return [String]
def geoblacklight_basemap
blacklight_config.basemap_provider || "positron"
blacklight_config.basemap_provider || 'positron'
end

##
Expand All @@ -175,10 +174,10 @@ def geoblacklight_basemap
def render_web_services(reference)
render(
partial: "web_services_#{reference.type}",
locals: {reference: reference}
locals: { reference: }
)
rescue ActionView::MissingTemplate
render partial: "web_services_default", locals: {reference: reference}
render partial: 'web_services_default', locals: { reference: }
end

##
Expand All @@ -194,13 +193,13 @@ def leaflet_options
# @param [Geoblacklight::Metadata::Base] metadata the metadata object
# @return [String]
def render_transformed_metadata(metadata)
render partial: "catalog/metadata/content", locals: {content: metadata.transform.html_safe}
rescue Geoblacklight::MetadataTransformer::TransformError => transform_err
Geoblacklight.logger.warn transform_err.message
render partial: "catalog/metadata/markup", locals: {content: metadata.to_xml}
rescue => err
Geoblacklight.logger.warn err.message
render partial: "catalog/metadata/missing"
render partial: 'catalog/metadata/content', locals: { content: metadata.transform.html_safe }
rescue Geoblacklight::MetadataTransformer::TransformError => e
Geoblacklight.logger.warn e.message
render partial: 'catalog/metadata/markup', locals: { content: metadata.to_xml }
rescue StandardError => e
Geoblacklight.logger.warn e.message
render partial: 'catalog/metadata/missing'
end

##
Expand All @@ -217,6 +216,7 @@ def first_metadata?(document, metadata)
# @param [Hash] document, field_name
def render_references_url(args)
return unless args[:document]&.references&.url

link_to(
args[:document].references.url.endpoint,
args[:document].references.url.endpoint
Expand All @@ -228,17 +228,17 @@ def relations_icon(document, icon)
icon_name = document[Settings.FIELDS.GEOM_TYPE] if Settings.USE_GEOM_FOR_RELATIONS_ICON
icon_name = icon if icon_name.blank?
icon_options = {}
icon_options = {classes: "svg_tooltip"} if Settings.USE_GEOM_FOR_RELATIONS_ICON
icon_options = { classes: 'svg_tooltip' } if Settings.USE_GEOM_FOR_RELATIONS_ICON
geoblacklight_icon(icon_name, **icon_options)
end

## Returns the data-map attribute value used as the JS map selector
def results_js_map_selector(controller_name)
case controller_name
when "bookmarks"
"bookmarks"
when 'bookmarks'
'bookmarks'
else
"index"
'index'
end
end
end
2 changes: 1 addition & 1 deletion config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# Linked files and directories (e.g., for database.yml, storage folders)
# append :linked_files, 'config/database.yml', 'config/master.key'
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system'
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system', 'config/settings'
append :linked_files, 'config/master.key', 'config/credentials.yml.enc'

# Passenger settings
Expand Down

0 comments on commit eb538aa

Please sign in to comment.