Skip to content

Commit 767c39d

Browse files
committed
webanno: added {resource_iri} variable for extra targets, and {resource} now yields only the ID
1 parent 43de5cd commit 767c39d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/api/webanno.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ pub struct WebAnnoConfig {
154154

155155
/// Adds an extra targets alongside the usual target with TextPositionSelector. This can
156156
/// be used for provide a direct URL to fetch the exact textselection (if the backend system supports it).
157-
/// In the template, you should use the variables {resource} (which is the resource IRI), {begin}, and {end} , they will be substituted accordingly.
158-
/// A common value is {resource}/{begin}/{end} .
157+
/// In the template, you should use the variables {resource_iri} (which is the resource IRI) or {resource} (which is the ID), {begin}, and {end} , they will be substituted accordingly.
158+
/// A common value is {resource_iri}/{begin}/{end} or https://example.com/{resource}/{begin}/{end}.
159159
pub extra_target_templates: Vec<String>,
160160

161161
/// Do not output @context (useful if already done at an earlier stage)
@@ -517,12 +517,14 @@ fn output_selector(
517517
for extra_target_template in config.extra_target_templates.iter() {
518518
let mut template = extra_target_template.clone();
519519
template = template.replace(
520-
"{resource}",
520+
"{resource_iri}",
521521
&into_iri(
522522
resource.id().expect("resource must have ID"),
523523
&config.default_resource_iri,
524524
),
525525
);
526+
template = template
527+
.replace("{resource}", resource.id().expect("resource must have ID"));
526528
template = template.replace("{begin}", &format!("{}", textselection.begin()));
527529
template = template.replace("{end}", &format!("{}", textselection.end()));
528530
if !ann_out.is_empty() {

0 commit comments

Comments
 (0)