Skip to content

Hide search input in the Paged Field Formatter / Internet Archive Book reader if no OCR #118

@DiegoPino

Description

@DiegoPino

What is this?

Now that we have OCR we want to avoid confusing users and leading them to think they can "search" if no Solr Document with OCR exists.

How to do this?

  1. Find out if a certain ADO (Node bearing a strawberryfield) had already strawberryfield_flavor_datasource search api sources documents generated and those can be found.
      {
        "id":"5qc1nk-default_solr_index-strawberryfield_flavor_datasource/4:1:en:6ba944b8-8518-415e-abd2-4af808a457c7:ocr",
        "sm_context_tags":["search_api_X2f_index_X3a_default_solr_index",
          "search_api_solr_X2f_site_hash_X3a_5qc1nk",
          "drupal_X2f_langcode_X3a_und"],
          "tm_X3b_und_fulltext_with_original_ocr":["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ocr><p xml:id=\"sequence_1\" wh=\"2550 3300\"><b><l><w x=\".118 .095 .085 .014\">Sheppard</w><w x=\".209 .095 .052 .011\">Helen</w><w x=\".267 .095 .104 .01\">...."],
        "ss_search_api_language":"und",
        "ss_title_2":"Helen Sheppard Oral History Interview (Excerpt)",
        "sort_X3b_en_processor_id":"F.L\u0000",
        "timestamp":"2021-01-13T17:14:44Z",
        "site":"http://localhost:8001/",
        "ss_parent_id":"4",
        "ss_sequence_id":"1",   
        "boost_document":1.0,
        "ss_search_api_id":"strawberryfield_flavor_datasource/4:1:en:6ba944b8-8518-415e-abd2-4af808a457c7:ocr",
        "ss_processor_id":"ocr",
        "its_uid_2":0,
        "_version_":1688792554279010304,
        "ss_checksum":"2feffd1c3f381a542db82931982dd834",
        "ss_search_api_datasource":"strawberryfield_flavor_datasource"
}
  1. Call this new method from here https://github.com/esmero/format_strawberryfield/blob/1.0.0-RC1/src/Plugin/Field/FieldFormatter/StrawberryPagedFormatter.php#L322
    If result == FALSE add a Drupal Setting entry/flag that allows us..(continued..)

  2. ... In the JS to disable the search box https://github.com/esmero/format_strawberryfield/blob/1.0.0-RC1/js/iiif-iabookreader_strawberry.js#L37, somewhere there. There are IABOOK reader specific arguments that can be used to disable functionality (that should all the code that is needed on the JS)

  3. Make sure we have the right caching context so the FALSE does not get cached forever and the next time a user comes back and the documents are already there the search box is showed

@pcambra this one is for you! Feel free to ask/comment and reach out to me any time.

Metadata

Metadata

Assignees

Labels

Field FormatterThe thing that glues the pieces and adds glitterJavascriptFavourite language of a PHP developerenhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions