Collation Tool¶
PHP¶
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 the super collator library.
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 the super collator.
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 attributesdummy_content (
array
) – (unused) The shortcode content (should be empty)
- Returns:
The Vue.js component as HTML.
- Return type:
string
Javascript¶
plugins/cap-collation/src/js/front.js¶
Initializes the collation applet.
plugins/cap-collation/src/js/main.vue¶
- class plugins/cap-collation/main.Main()¶
The vue.js instance that manages the whole page.
plugins/cap-collation/src/js/results.vue¶
- class plugins/cap-collation/results.Results()¶
The vue.js instance that manages the collation output table.
plugins/cap-collation/src/js/selector.vue¶
- class plugins/cap-collation/selector.Selector()¶
The vue.js instance that manages the section selector(s).
plugins/cap-collation/src/js/tools.js¶
Utility functions for the collation applet.
- plugins/cap-collation/tools.DOMAIN¶
cap-collation
The Wordpress Text Domain of the plugin.
- plugins/cap-collation/tools.bk_id¶
(string) The id of the “Obertext”.
- plugins/cap-collation/tools.cap_collation_algorithms¶
The collation algorithms we support.
- plugins/cap-collation/tools.Palette¶
A color palette.
- plugins/cap-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/cap-collation/tools.api(endpoint, data)¶
This calls the API on the API server
- Arguments:
endpoint (
string()
) – The endpoint relative to the API root.data (
URLSearchParams()
) – The query to send.
- Returns:
Promise resolved when call completed.
- Return type:
Promise
- plugins/cap-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/cap-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/cap-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/cap-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/cap-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/cap-collation/tools.unroll_witnesses(rolled)¶
Unroll collate struct Unrolls the witness list before sending it to the collation server. Turns this: .. code-block:: json [ { “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: .. code-block: json [ “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”, ]
- Arguments:
rolled (
Array()
) – The collate struct
- Returns:
The unrolled witness array
- Return type:
Array