@kba/anno-queries

0.0.4 • Public • Published

anno-queries

Search and create fragments of Web Annotations

This module exposes classes for resources used as target or body of a Web Annotation.

DEMO

API

AnnoQuery

Common base class of all resource classes.

new AnnoQuery(_defaultkeys=[])

  • @param Array _defaultkeys Default path to the sub-object in question. Normally shoul d be either ['body'] or [target].

first(anno, ...keys)

Find the first resource in anno which matches this query. Descend by keys or fall back to this._defaultkeys.

all(anno, ...keys)

Find the first resource in anno which matches this query. Descend by keys or fall back to this._defaultkeys.

textualHtmlBody

Find/Create bodies with included HTML content, as used in a standard text annotation.

Example

{
  "type": "TextualBody",
  "format": "text/html",
  "value": "<p>Some text</p>"
}

simpleTagBody

Find/Create simple tag bodies. A simple tag body is a TextualBody with a purpose of tagging and a value.

Example

{
  "type": "TextualBody",
  "purpose": "tagging",
  {
     "@context": {
         "i10nValue": { "@id": "value", "@container": "@language" }
     },
     "en": "pineapple",
     "de": "ananas"
  }
}

semanticTagBody

Find/Create semantic tag bodies. A semantic tag body is a web resource (must have an id) with the sole purpose of classifying.

Example

{
  "id": "http://vocab/fruit17",
  "purpose": "classifying"
}

relationLinkBody

Find/Create qualified links to other web resources A semantic tag body is a web resource (must have an id) that is related to the target of the annotation by the relation in its 'predicate'. Always has a purpose of 'linking'.

Example

{
  "id": "http://example.org/work1",
  "purpose": "linking",
  "predicate": "http://purl.org/dcterms/partOf",
}

svgSelectorResource

Find/create SVG selector resources. An SVG selector is a selector of type SvgSelector with a value that holds the SVG inline.

Example

{
  "type": "SvgSelector",
  "value": "<svg>...</svg>"
}

mediaFragmentResource

A mediaFragmentResource is a resource with a selector of type FragmentSelector that conformsTo the Media Fragment Specs.

emptyAnnotation

An empty annotation is an object that has either no body or no target.

targetId

Guess the URL of the thing that is to be annotated

Readme

Keywords

none

Package Sidebar

Install

npm i @kba/anno-queries

Weekly Downloads

7

Version

0.0.4

License

ISC

Last publish

Collaborators

  • kba