Skip to contents

Writes the Milestones Project data to a folder of plain-text YAML files: one file per milestone, plus shared files for authors, references and the controlled vocabularies (aspects, subjects, keywords). The files are meant to be the editable, version-controlled source of the data. read_milestones_yaml() reads them back into the package's tables.

Usage

export_milestones_yaml(dir, overwrite = FALSE, quiet = FALSE)

Arguments

dir

Folder to write into. It is created if needed.

overwrite

Logical. If FALSE (the default), stop if dir already contains milestone files.

quiet

Logical. If TRUE, don't report what was written.

Value

The paths of the files written, invisibly.

Details

The layout is:

<dir>/
  milestones/<slug>.yaml   one per milestone, e.g. 1786Playfair.yaml (characters other
                           than letters, digits, `_`, `.`, `-` are dropped from the name)
  authors.yaml             all authors, keyed by "Family, Given"
  references.yaml          all references, keyed by BibTeX key
  vocabulary.yaml          aspect, subject and keyword names, with their ids

Within a milestone file, authors, references, keywords, aspects and subjects are given by name or key, not by integer id. Database ids (mid, aid, rid) are kept as id: fields so the tables can be rebuilt exactly. New items can leave them out.

Some cleaning is applied on export:

  • Text fields have \r\n converted to \n and trailing white space removed. Values that are then empty become missing and are omitted.

  • Author family names come from the cleaned lnames column (no HTML entities).

  • Duplicate rows in the link tables are dropped, as are links to authors not in the author table (in the database, aid 1 is "Unknown"). A milestone without authors: has unknown author(s).

  • A duplicated bibtexkey gets the suffix -<rid> to make the key unique, and the original value is kept in a bibtexkey field.

  • add_date and modified_date (m/d/yy in the database) are written as ISO dates. The MySQL "zero date" 0000-00-00 is treated as missing.

  • Image URLs under http://datavis.ca/milestones/uploads/images/ are written as a file: path relative to that folder.

Examples

if (FALSE) { # \dontrun{
dir <- file.path(tempdir(), "milestones-yaml")
export_milestones_yaml(dir)
list.files(dir, recursive = TRUE)[1:5]
cat(readLines(file.path(dir, "milestones", "1786Playfair.yaml")), sep = "\n")
} # }