Skip to contents

Renders a Betwixt candidate dataset as an interactive, standalone HTML review. The type argument selects between a web-based review using HTTP(S) resources and a local review using files stored alongside the generated HTML document.

Both formats preserve the original candidate values alongside editable review values. The generated HTML includes the original filename and creation timestamp as artefact provenance. Timestamps are recorded in ISO 8601 UTC format at one-second precision.

A review belongs to a project, has a filename stem, and has a non-negative sequence number. Sequence 0 represents the initial candidate review. Subsequent review states may use sequence 1, 2, and so on. Saving a draft or finalising a review does not itself change the sequence.

The project identifier identifies the larger knowledge-production project, while the table identifier identifies a table across successive review states. The filename stem independently determines the saved HTML filename.

Usage

render_local_html_review(
  candidate,
  cols = NULL,
  subheadings = NULL,
  title = "Betwixt Review",
  description = "Please review the following claims.",
  filename_stem = "betwixt-review",
  reviewer_name = "",
  reviewer_iri = "",
  table_id = "",
  project_id = "",
  sequence = 0L,
  row_comment = FALSE,
  review_comment = FALSE,
  path = NULL
)

render_review(candidate, ..., type = "web_html")

render_web_html_review(
  candidate,
  cols = NULL,
  subheadings = NULL,
  title = "Betwixt Review",
  description = "Please review the following claims.",
  filename_stem = "betwixt-review",
  reviewer_name = "",
  reviewer_iri = "",
  table_id = "",
  project_id = "",
  sequence = 0L,
  row_comment = FALSE,
  review_comment = FALSE,
  path = NULL
)

Arguments

candidate

A Betwixt candidate dataset.

cols

Optional named character vector containing presentation labels for candidate and context columns.

subheadings

Optional named character vector containing presentation subheadings for candidate columns.

title

Character string used as the review title.

description

Character string containing review instructions.

filename_stem

Base name for saved review files. Sequences greater than 0 append the sequence number.

reviewer_name

Initial reviewer name.

reviewer_iri

IRI identifying the reviewer, such as an ORCID, ISNI, or Wikidata URI.

table_id

Identifier of the table across successive review states.

project_id

Identifier of the larger knowledge-production project.

sequence

Single non-negative integer identifying the review sequence. Defaults to 0, representing the initial candidate review.

row_comment

Logical. Add an optional comment field to each review row. Defaults to FALSE.

review_comment

Logical. Add an optional comment field for the review as a whole. Defaults to FALSE.

path

Output directory for the generated HTML. For "web_html", NULL returns the HTML without writing a file. For "local_html", an existing directory is required to resolve local resource references.

...

Arguments passed to the selected review renderer.

type

Review format: "web_html" (default) or "local_html".

Value

A character string containing the rendered HTML, returned invisibly when written to path.

Details

The "web_html" renderer accepts HTTP(S) references in input_url and input_media_url. These references are validated syntactically without checking network availability.

The "local_html" renderer uses local resource paths, including relative references such as media/photo.jpg. Resources must already exist and be readable. Relative paths are resolved against the review output directory. The local renderer does not copy resources automatically.

Both formats embed the review CSS and JavaScript in the HTML document. Local reviews can therefore be moved together with their referenced resources without changing the relative paths.

Examples

# Create a local review using photographs bundled with Betwixt.
data(delini)

review_path <- tempfile("delini-review-")
dir.create(file.path(review_path, "media"), recursive = TRUE)

# Resolve packaged images and copy them into the review directory.
source_media <- sub(
  "^.*?/images/delini/",
  "media/delini/",
  delini$input_media_url
)
source_files <- system.file(source_media, package = "betwixt")
stopifnot(all(nzchar(source_files)))

file.copy(source_files, file.path(review_path, "media"))
#> [1] TRUE TRUE TRUE TRUE TRUE

# Use relative references in the candidate dataset.
candidate <- create_candidate_dataset(
  subject = delini$subject,
  input_media_url = file.path("media", basename(source_files)),
  input_label = delini$input_label,
  input_description = delini$input_description,
  label = delini$label,
  description = delini$description,
  subject_range = delini$subject_range,
  subject_definition = delini$subject_definition
)
#> Warning: Unknown or uninitialised column: `input_label`.

render_local_html_review(
  candidate,
  title = "Deliņi Farmstead Review",
  filename_stem = "delini-review",
  path = review_path
)
#> Review rendered: C:\Users\DANIEL~1\AppData\Local\Temp\RtmpIp3aeR\delini-review-51405a312229/delini-review.html
# Review using externally hosted photographs.
data(delini)

candidates <- create_candidate_dataset(
  input_media_url = delini$input_media_url,
  input_description = delini$input_description,
  label = delini$label,
  description = delini$description,
  subject = delini$subject,
  subject_range = delini$subject_range,
  subject_definition = delini$subject_definition
)

review_html <- render_web_html_review(
  candidates,
  title = "Deliņi Farmstead Review"
)