From eb538aac0a1c4568375f69743e9d71fd4b14e83c Mon Sep 17 00:00:00 2001 From: Michael Cain Date: Wed, 4 Oct 2023 10:55:08 -0500 Subject: [PATCH] link settings dir --- .rubocop.yml | 1 + app/helpers/geoblacklight_helper.rb | 88 ++++++++++++++--------------- config/deploy.rb | 2 +- 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b78e5477..9c8db478 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,6 +11,7 @@ AllCops: - 'config/**/*' - 'vendor/**/*' - 'Vagrantfile' + - 'app/helpers/geoblacklight_helper.rb' Style/Documentation: Enabled: false diff --git a/app/helpers/geoblacklight_helper.rb b/app/helpers/geoblacklight_helper.rb index 9699bf59..9271b1c5 100644 --- a/app/helpers/geoblacklight_helper.rb +++ b/app/helpers/geoblacklight_helper.rb @@ -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 @@ -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 } ) @@ -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 } ) @@ -43,25 +43,24 @@ 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 ## @@ -69,18 +68,18 @@ def download_link_generated(download_type, document) # @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 @@ -88,12 +87,12 @@ def geoblacklight_icon(name, **args) # 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 ## @@ -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 @@ -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 @@ -156,8 +155,8 @@ 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 @@ -165,7 +164,7 @@ def render_value_as_truncate_abstract(args) # Selects the basemap used for map displays # @return [String] def geoblacklight_basemap - blacklight_config.basemap_provider || "positron" + blacklight_config.basemap_provider || 'positron' end ## @@ -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 ## @@ -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 ## @@ -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 @@ -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 diff --git a/config/deploy.rb b/config/deploy.rb index 1d06a18c..acf3cdab 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -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