Skip to content

Add TapasXq::DeriveReaderService to generate reading interface XHTML #58

@candyhazlett

Description

@candyhazlett

Background

The tapas-xq endpoint POST /tapas-xq/derive-reader/:type transforms a TEI file into an XHTML snippet (a <div>) for display in the TAPAS reading interface. This is the core reader functionality and is not yet implemented in Rails.

Work required

app/services/tapas_xq/derive_reader_service.rb

Create with:

  • Constructor: view_package_type:, tei_content:, extra_params: {}, client: nil
  • #derive — POSTs to /derive-reader/#{view_package_type} with { file: tei_content }.merge(extra_params), returns the XHTML string

Error handling:

  • TapasXq::InvalidTeiError (422) — raised by client.rb when tapas-xq rejects the TEI file
  • TapasXq::InvalidResponseError — raised on 400 (unknown view package type); callers should validate the type against the ViewPackage table before calling
  • Other TapasXq::Error subclasses propagate normally

The extra_params argument supports view-package-specific parameters (each package may define additional form parameters in its configuration file).

Controller / job integration (to be designed)

The derive-reader call is stateless — tapas-xq does not store anything. It can be called:

  • On demand per request (acceptable for small files, but may be slow)
  • As a background job with result cached on CoreFile (e.g., a reader_xhtml column) and invalidated on TEI update

The integration point (controller action, background job, or caching strategy) is left to the implementer to decide based on performance requirements.

Dependencies

Tests

See spec/services/tapas_xq/derive_reader_service_spec.rb in the testing plan doc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions