Collation Tool

plugins/cap-collation/cap-collation.php

Plugin Name: Capitularia Collation Tool Plugin URI: Description: Collates TEI files.

Version: 0.2.2 Author: Marcello Perathoner Author URI: License: GPLv2 or later Text Domain: cap-collation Domain Path: /languages

Capitularia Collation Tool plugin.

The Collation Tool plugin lets any member of the general public do collations of arbitrary sections from different manuscripts.

This plugin provides a shortcode that inserts a dashboard on the page. Within the dashboard the user can request collations of sections of manuscripts. The dashboard is implemented in javascript with Vue.js. The PHP code of this plugin basically only serves the Javascript code to the user.

The actual collation is done on the Capitularia API Server with a customized version of CollateX for Java.

A big Makefile, run by cron on the API server, uses XSLT and Saxon to extract the relevant sections from the TEI files and pre-processes them for collation. In the end all TEI tags are removed and only the normalized text is stored into the Postgres database. On an incoming collation request the API server reads the pre-processed texts from the database and sends them to CollateX.

See: collatex_server, collation overview.

constant NAME

‘Capitularia Collation Tool’

The name of the plugin.

constant DOMAIN

‘cap-collation’

The Text Domain of the plugin.

plugins/cap-collation/functions.php

Capitularia Collation Tool global functions.

ns(function_name)

Add current namespace

Parameters:
  • function_name (string) – The class or function name without namespace

Returns:

The name with namespace

Return type:

string

enqueue_scripts()

Enqueue the front page script and localize it.

The script is a webpacked Vue.js application containing its own css.

Return type:

void

on_shortcode(dummy_atts, dummy_content)

Replace the shortcode with the collation dashboard.

Insert a Vue.js component. Vue.js takes over from that and builds the collation dashboard.

Parameters:
  • dummy_atts (array) – (unused) The shortcode attributes

  • dummy_content (array) – (unused) The shortcode content (should be empty)

Returns:

The Vue.js component as HTML.

Return type:

string

plugins/collation/tools

File: plugins/cap-collation/src/js/tools.js

Contains utility functions for the collation applet.

plugins/collation/tools.LANG
cap-collation

The Wordpress Text Domain of the plugin.

plugins/collation/tools.bk_id

(string) The id of the “Obertext”.

plugins/collation/tools.cap_collation_algorithms

The collation algorithms we support. The Needleman-Wunsch-Gotoh algorithm is available only with our special patched version of CollateX.

plugins/collation/tools.Palette

A color palette.

plugins/collation/tools.insert_css_palette(css)

Insert a CSS color palette into the DOM making it active.

Arguments:
  • css (String()) – The color palette as string.

plugins/collation/tools.get_api_entrypoint()

Get the API entrypoint

Returns:

The root URL of the API server.

Return type:

string

plugins/collation/tools.api(url, data)

This calls the API on the API server

Arguments:
  • url (string()) – The endpoint relative to the API root.

  • data (Object()) – The data to send.

Returns:

Promise resolved when call completed.

Return type:

Promise

plugins/collation/tools.encodeRFC5987ValueChars(str)

Build a valid filename to save the config.

Arguments:
  • str (string()) – The string to encode.

Returns:

The encoded string.

Return type:

string

plugins/collation/tools.sort_key(s)

A key that sorts numbers right

Arguments:
  • s (string()) – Any string.

Returns:

A key derived from the string that sorts numbers right.

Return type:

string

plugins/collation/tools.build_witness_url(w)

Build an URL that represents one witness to be collated.

Arguments:
  • w (Object()) – The witness object

Returns:

The url

Return type:

string

plugins/collation/tools.fix_witness(w)

Calculate some attributes for a witness object: a human-readable title, i18n, sort key.

Arguments:
  • w (Object()) – The witness object to fix

Returns:

The fixed witness object

Return type:

Object

plugins/collation/tools.parse_locus_url(url)

Parse a locus url into a witness object similar to one returned by the data server. Currently used only to calculate the title length in the results table.

Arguments:
  • url (string()) – The witness url

Returns:

The witness object

Return type:

Object

plugins/collation/tools.unroll_witnesses(rolled)

Unroll collate struct Unrolls the witness list before sending it to the collation server.

Arguments:
  • rolled (Array()) – The collate struct

Returns:

The unrolled witness array Turns this: [ { “corresp”: “BK.40_4”, “witnesses”: [ “bk-textzeuge”, “vatikan-bav-chigi-f-iv-75” ] }, { “corresp”: “BK.137”, “witnesses”: [ “bk-textzeuge”, “kopenhagen-kb-1943-4”, “paris-bn-lat-2718” ] } ] into this: [ “BK.40_4/bk-textzeuge”, “BK.40_4/vatikan-bav-chigi-f-iv-75”, “BK.137/bk-textzeuge”, “BK.137/kopenhagen-kb-1943-4”, “BK.137/paris-bn-lat-2718”, ]

Return type:

Array