Tree.

manifest(tree)

Returns a new map-based tree where the same keys as the original, but with the values mapped to their hash value.

Example #

A tiny site contains the following files:

// site1.ori
{
  about: {
    index.html: "About page"
  }
  index.html: "Home page"
}

The manifest for this site shows the hash values for every resource in the tree:

$ ori Tree.manifest site1.ori
about:
  index.html: 1cc8d7c45a53d7c63a44a424f708c07b9062169a
index.html: 9521dba25709a79ede4a34b50471419774c41099

Each of the hex strings characterizes the current content of the corresponding resource. If you were to change any of the resource definitions, the affected hash values would change.

Suppose you copy the site and change the text of just about.html:

// site2.ori
{
  about: {
    index.html: "About page 2"
  }
  index.html: "Home page"
}

Now when you get the manifest for the updated site…

$ ori Tree.manifest site2.ori
about:
  index.html: 9079f42e508fe40be7e8531340200e9b5a706db3
index.html: 9521dba25709a79ede4a34b50471419774c41099

the hash value for about.html has changed. The hash value for index.html remains the same as before, because index.html didn’t change.

In this way, a manifest for a site (or a folder of files, etc.) is a way of very concisely reflecting the state of all the content.

Comparing manifests #

You can compare two manifests to see if they reflect exactly the same content. The Tree.changes builtin exists for precisely that purpose. Give the function two sites, and it will compare manifests to determine any changes between them:

$ ori changes site1.ori, site2.ori
about:
  index.html: changed

The Tree.applyChanges function compares manifests in this way to determine what values have changed and therefore need to be applied to a target tree. That process is one of the ways Dev.publish may use to publish a site to a network host.