From 1e0a43e604f599849a6b7c73564d36f01daf4e7e Mon Sep 17 00:00:00 2001 From: Mike Lynch <mike@mikelynch.org> Date: Mon, 12 Aug 2019 16:48:14 +1000 Subject: [PATCH] Started a branch for my mods --- README.md | 12 ++++++------ make-ocfl-index.js | 19 ++++++++++++------- makefile | 2 -- package.json | 6 ++++-- ro-crate-deposit.js | 2 ++ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f431870..e91df6c 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 0fef97f..e41ad58 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 91c8d1c..db3cdcb 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 0abea9a..e60970c 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 1dd487b..a06284c 100644 --- a/ro-crate-deposit.js +++ b/ro-crate-deposit.js @@ -36,5 +36,7 @@ async function main() { } } } + + main(); -- GitLab