Skip to content

Commit 25f7d56

Browse files
committed
added extra_target_templates parameter to webannotation() method
1 parent b0511ed commit 25f7d56

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/annotation.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,15 @@ impl PyAnnotation {
522522
namespaces
523523
}
524524
}
525+
if let Ok(Some(v)) = kwargs.get_item("extra_target_templates") {
526+
config.extra_target_templates = {
527+
let mut extra_target_templates = Vec::new();
528+
for template in v.extract::<Vec<String>>()? {
529+
extra_target_templates.push(template);
530+
}
531+
extra_target_templates
532+
}
533+
}
525534
}
526535
self.map(|annotation| {
527536
if auto_context {

stam.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,9 @@ class Annotation:
880880
881881
`context_namespaces`: `[(str,str)]`
882882
Automatically generate a JSON-LD context alias for all URIs in keys, maps URI prefixes to namespace prefixes
883+
884+
`extra_target_templates`: `[str]`
885+
Adds an extra target alongside the usual target with TextPositionSelector. This extra target can be used for provide a direct IRI/URI to fetch the exact textselection (if the backend system supports it). In the template, you should specify an IRI with the variables {resource} (which is the resource IRI), {begin}, and {end}, they will be substituted accordingly. A common value is: {resource}/{begin}/{end}
883886
"""
884887

885888
def test(self, operator: TextSelectionOperator, other: Annotation) -> bool:

0 commit comments

Comments
 (0)