diff --git a/README.md b/README.md index f431870ef8d1322931fd61459653642e4bcab588..e91df6c0c58bc476491dad14498d688755860e26 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,18 @@ TO fetch them: ### Add all the examples to an OCFL repository To make all the example from calcyte: -- `make all REPO_PATH=~/working/ocfl-demo/repo SRC_PATH=~/working/ocfl-test-data/src` +- `make all REPO_PATH=~/working/ocfl-demos/repo SRC_PATH=~/working/ocfl-demos/src` This will: - Generate RO-Crates for all the examples at `~/working/calcyte.js/test_data/` -- Create an OCFL repository at `~/working/ocfl-demo/repo` if it does not already exist +- Create an OCFL repository at `~/working/ocfl-demos/repo` if it does not already exist - Deposit all the example RO-Crates into the repository - Generate an index file +### To build the OCFL repository without running Calcyte + + make index REPO_PATH=~/working/ocfl-demos/repo SRC_PATH=~/working/ocfl-demos/src + ## TODO @@ -63,10 +67,6 @@ This will: ### Port legacy datasets from the UTS Research Data Repository -h - - - ### Run with data downloaded from Research Data Australia ### Add in sample data from Omeka (Farms to freeways and Dharmae) diff --git a/make-ocfl-index.js b/make-ocfl-index.js index 0fef97fddea91c0e2949e8b8ecbbaf8cb0f818a3..e41ad585b0e4919cd0639881e22dfb7520b8b81d 100644 --- a/make-ocfl-index.js +++ b/make-ocfl-index.js @@ -3,7 +3,7 @@ const path = require('path'); const fs = require('fs-extra'); const ocfl = require("ocfl"); -console.log(ocfl); +const hasha = require('hasha'); const OCFLRepository = require('ocfl').Repository; var argv = require('yargs').argv; var Utils = require("ro-crate").Utils @@ -11,11 +11,15 @@ var ROCrate = require('ro-crate').ROCrate; var utils = new Utils(); +const URL_HASH_ALGORITHM = 'md5'; + // This is an asynchronous library so you need to call using await, or use promises + + async function main() { - // OCFL repo - exsists? + // OCFL repo - exists? const repoPath = argv.repo ? argv.repo : "ocfl_demo"; // Make or open a database // Get or open an OCFL repo @@ -43,11 +47,12 @@ async function main() { var dataset = crate.getRootDataset() console.log(dataset['@id'], dataset['description'], p); var newItem = { - "@id": dataset["@id"], - name: utils.asArray(dataset.name)[0], - description: utils.asArray(dataset.description)[0], - datePublished: utils.asArray(dataset.name)[0], - path: object.path + "@id": dataset["@id"], + uri_id: hasha(dataset["@id"], { algorithm: URL_HASH_ALGORITHM }), + name: utils.asArray(dataset.name)[0], + description: utils.asArray(dataset.description)[0], + datePublished: utils.asArray(dataset.name)[0], + path: path.relative(repoPath, object.path) } index.push(newItem); diff --git a/makefile b/makefile index 91c8d1cea8e8e97d43d00483509471643f253b22..db3cdcb05ca93727fbe2c8fbe88502a702c523b4 100644 --- a/makefile +++ b/makefile @@ -30,5 +30,3 @@ pull: cd $(SRC_PATH) wget -r -np -nH --cut-dirs=3 https://data.research.uts.edu.au/examples/ro-crate/examples/src/ cd - - - diff --git a/package.json b/package.json index 0abea9a3a950f1946caefdae014cd72d189923d3..e60970c45f68b0f764ba1ded7a52dada0d19c09a 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,16 @@ }, "repository": { "type": "git", - "url": "TBA" + "url": "https://code.research.uts.edu.au/eresearch/ocfl-demos" }, "author": "UTS eResearch Staff", "license": "GPL-3.0", "dependencies": { "fs-extra": "^8.1.0", + "hasha": "^5.0.0", "ocfl": "^1.0.3", "ro-crate": "^1.0.1", - "yargs": "^13.3.0" + "yargs": "^13.3.0", + "solr-catalog": "^1.0.1" } } diff --git a/ro-crate-deposit.js b/ro-crate-deposit.js index 1dd487bccc515135fd4b8b16413e9c9028461457..a06284ceb4e72a0534b2851b95c4fe97f7baab90 100644 --- a/ro-crate-deposit.js +++ b/ro-crate-deposit.js @@ -36,5 +36,7 @@ async function main() { } } } + + main();