Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
🐛 Move render_ocr_snippets method
Browse files Browse the repository at this point in the history
Ref #469 & notch8/iiif_print#254

* Update IiifPrint to use a branch that:
  - does not include derivative rodeo, which broke PDF splitting
  - moves render_ocr_snippets method to an appropriate helpers

* Remove render_ocr_snippets definition from application controller.
* Add iiif_print_helper to pull in behavior.
  • Loading branch information
LaRita Robinson committed Jun 30, 2023
1 parent 98ed18d commit dc26ae1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GIT

GIT
remote: https://github.com/scientist-softserv/iiif_print.git
revision: d44ea621b0751d11f054d4ae30b994ea5454c591
revision: 9f20467a6ff1f14872087f1e1dddda0f9fea91fd
branch: no-rodeo
specs:
iiif_print (1.0.0)
Expand Down
21 changes: 1 addition & 20 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class ApplicationController < ActionController::Base
include HykuHelper
include IiifPrintHelper
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception, prepend: true
Expand All @@ -20,7 +19,7 @@ class ApplicationController < ActionController::Base
include Hyrax::ThemedLayoutController
with_themed_layout '1_column'

helper_method :current_account, :admin_host?, :render_ocr_snippets
helper_method :current_account, :admin_host?
before_action :authenticate_if_needed
before_action :require_active_account!, if: :multitenant?
before_action :set_account_specific_connections!
Expand All @@ -33,24 +32,6 @@ class ApplicationController < ActionController::Base

protected

# remove this once we've backported to `IIIFPrintHelper` and update IIIF Print
def render_ocr_snippets(options = {})
snippets = options[:value]
# rubocop:disable Rails/OutputSafety
snippets_content = [ActionController::Base.helpers.content_tag('div',
"... #{snippets.first} ...".html_safe,
class: 'ocr_snippet first_snippet')]
# rubocop:enable Rails/OutputSafety
if snippets.length > 1
snippets_content << render(partial: 'catalog/snippets_more',
locals: { snippets: snippets.drop(1),
options: options })
end
# rubocop:disable Rails/OutputSafety
snippets_content.join("\n").html_safe
# rubocop:enable Rails/OutputSafety
end

def is_hidden
current_account.persisted? && !current_account.is_public?
end
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/iiif_print_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true
module IiifPrintHelper
include IiifPrint::IiifPrintHelperBehavior
end

0 comments on commit dc26ae1

Please sign in to comment.