Commit d5761a89 authored by PTSEFTON's avatar PTSEFTON
Browse files

fixed paths in File Data Entities

parent 8d1b7740
......@@ -36,38 +36,43 @@ This version of Calcyte targets the [R0-Crate Spec, v0.2](https://github.com/UTS
npm link
## Get set up for development use
RO-Crate
## Usage / instructions
Calcyfy creates RO-Crates whith and HTML entry-point. This relies on
Get a web server running on local host:
```
```
### Usage
Calcyfy creates RO-Crates with an HTML entry-point in r
Usage:
```
> ./calcyfy
Usage: calcyfy [options] <directories...>
> ./calcyfy
Usage: calcyfy [options] <directories...>
Generates DataCrate HTML for ro-crate-metadata.jsonld files. Pass a list of directories. To create Spreadsheet files for entring metadata use -d or -r.
Generates [RO-Crate] HTML for ro-crate-metadata.jsonld files. Pass a list of directories. To create Spreadsheet files for entering metadata use -d or -r.
Options:
-V, --version output the version number
-b, --bag [bag-dir] Create Bagit Bag(s) under [bag-dir])
-n, --no No Citation - only applies ith --bag
-z, --zip Create a zipped version of the bag - only applies with --bag
-d, --depth [depth] Maximum depth to recurse into directories
-r, --recurse Recurse into directories looking for ro-crate-metadata_.xslx files
-s, --save Save ro-crate-metadata after trimming it (and adding missing context if necessary).
-h, --htmlscript [htmlscript] HTML render script
-u, --url [distro] Distribution URL
-h, --help output usage information
-V, --version output the version number
-b, --bag [bag-dir] Create Bagit Bag(s) under [bag-dir])
-n, --no No Citation - only applies ith --bag
-z, --zip Create a zipped version of the bag - only applies with --bag
-d, --depth [depth] Maximum depth to recurse into directories
-r, --recurse Recurse into directories looking for CATALOG_.xslx files
-c, --cratescript [cratesript] URL of "crate.js" rendering script from the ro-crate-js library
-u, --url [distro] Distribution URL
-h, --help output usage information
```
To run Calcyte on a group of directories pass it a list of directories
......@@ -83,13 +88,13 @@ One directory:
```
calcyfy -r test_data/sample/
calcyfy test_data/Glop_Pot -r -h http://localhost:8080/compiled
calcyfy test_data/Glop_Pot -r -c /
```
This will:
- Traverse the entire Glop_Pot directory, and generate or update CATALOG_name.xlsx files.
- Create or update the `test_data/Glop_Pot/`ro-crate-metadata.jsonld`` file
- Create a *RO-Crate Website* with entry-point `test_data/Glop_Pot/CATALOG.html`
- Create a *[RO-Crate] Website* with entry-point `test_data/Glop_Pot/ro-crate-metadata.html`
All the sample directories:
......
......@@ -52,7 +52,9 @@ program
)
.option("-d, --depth [depth]", "Maximum depth to recurse into directories looking for or creating CATALOG_.xlsx file")
.option("-r, --recurse", "Recurse into directories looking for or creating CATALOG_.xslx files")
.option("-c, --cratescript [cratesript]", "URL of Crate-script directtory")
.option("-c, --cratescript [cratesript]", "URL of Crate-script directory")
.option("-m, --maxfiles [maxfiles]", `Maximum number of files to itemise per directory (default is ${defaults.max_files_in_dir})`)
.option(
"-u, --url [distro]",
"Distribution URL"
......@@ -65,6 +67,9 @@ if (program.recurse) {
if (program.depth) {
depth = program.depth;
}
if (program.maxfiles) {
defaults.max_files_in_dir = program.maxfiles;
}
if (!program.rawArgs.length || !dirs) program.help();
// TODO: Refactor this by if statement - there is a lot of repetition
......
......@@ -369,6 +369,9 @@ module.exports = function() {
this.file_info_by_filename[f.filename.replace(/.*\//, "")] = f;
}
}
else {
console.log(`WARNING: Max ${defaults.max_files_in_dir} files exceeded (${items.length}) in ${dir}\n HINT: Re-run \n ${process.argv.join(" ")} -m ${items.length + 1}`)
}
//console.log(dir, metadatas[0]);
metadata_path = path.join(dir, metadatas[0]);
//console.log("Opening spreadsheet", metadata_path)
......@@ -433,11 +436,9 @@ module.exports = function() {
);
for (var item of extra_context) {
if (item["Key"] && item["Value"]) {
context[item["Key"]] = item["Value"]
if (item["SameAs"]) {
this.same_as.push({"@id": item["Value"], "sameAs": item["SameAs"]})
}
}
}
......@@ -466,7 +467,7 @@ module.exports = function() {
//console.log("making new child:", this.depth, this.max_depth, subdirs[i]);
child.read(
path.join(dir, subdirs[i]),
path.join(this.rel_path, subdirs[i]),
path.join(this.rel_path, subdirs[i] + "/"),
this,
this.max_depth
);
......
......@@ -23,7 +23,7 @@ const datacite_file_name = "datacite.xml";
const metadata_json_file_name = `${ro_crate_name}.jsonld`;
const html_file_name = "ro-crate-preview.html";
const max_depth = "10"; // Number of dirs to recurse into
const max_files_in_dir = "30"; // Don't list files in a directory if there are more than this
const max_files_in_dir = "20"; // Don't list files in a directory if there are more than this
const ignore_file_regex = new RegExp(
`(^~)|(^\\.)|(${datacite_file_name})|^${html_file_name}$|^${metadata_json_file_name}$`
);
......@@ -38,7 +38,7 @@ const ROCrate_profile_file = "defaults/profile-datacrate-v" + ROCrate_version +
const path = require("path")
const DEFAULTS = path.join(__dirname, '../defaults');
const defaults_dir = DEFAULTS;
const context = "https://raw.githubusercontent.com/ResearchObject/ro-crate/master/docs/0.2-DRAFT/context.json";
const context = "https://raw.githubusercontent.com/ResearchObject/ro-crate/master/docs/0.3-DRAFT/context.json";
const default_context = context;
const metadata_template = path.join(DEFAULTS, 'metadata_template.html');
const render_script = "https://code.research.uts.edu.au/eresearch/CalcyteJS/raw/feature/or-crate/lib/render.js";
......
......@@ -48,21 +48,6 @@ module.exports = function() {
return links_to;
}
function make_link(string, collection, el) {
//console.log("Linking", string);
var link_id = links_to_id(string, collection);
if (link_id && link_id.match(/^https?:\/\//i)) {
el.ele("a", string).att("href", link_id);
string = "<a href='" + link_id + "'>" + string + "</a>";
} else if (link_id) {
el.ele("a", string).att("href", "#" + link_id);
string = "<a href='#" + link_id + "'>" + string + "</a>";
} else {
el.ele("span", string);
}
return string;
}
return {
metadata: this.metadata,
......@@ -121,12 +106,7 @@ module.exports = function() {
}
frag["@type"] = this.types;
var ident = helper.value_as_array(this.id)
for (let id of ident){
if (id && id.match(/(https?:\/\/)(dx\.)?(doi.org\/10\.)/i)) {
helper.push_value(frag, "identifier", id.replace(/https?:\/\//i, ""))
}
}
this.json_ld_fragment = frag;
//console.log(frag);
return frag;
......@@ -145,27 +125,31 @@ module.exports = function() {
property.parse(key, value);
//this.colum_names.push(k);
//console.log("Fresh property", property.name, value);
if (property.is_file) {
//console.log("FILE ", this.collection.path, value);
this.id = path.join(this.collection.rel_path, value);
this.types.push("File");
//var pr = new metadata_property_name();
//pr.parse("path", this.id);
//this.properties[pr.name] = pr;
this.is_file = value;
} else if (property.is_id) {
//console.log("Got an ID", value);
this.id = value;
if (Array.isArray(value)) {
value = value[0];
}
if (value.endsWith("/" ) || value.startsWith(".") || value.match(/^(https?:\/\/|mailto:.*@|_b:)/i)) {
this.id = value;
}
else {
this.id = "#" + value;
}
} else if (property.is_name) {
this.name = value;
} else if (property.is_type) {
this.types = property.data;
this.types = this.types.concat(property.data);
}
// Add to lookup table
if (!this.id) {
this.id = uuidv4();
this.id = "#" + uuidv4();
}
//console.log(this.name)
if (this.name) {
......
......@@ -98,7 +98,6 @@ module.exports = function() {
//Assume what's left of header is a property, and hence starts with lowecase letter
this.name = lowercase_first(this.name);
var nest;
if (this.name.endsWith("*")) {
this.name = this.name.slice(0, -1);
this.is_repeating = true;
......@@ -127,7 +126,6 @@ module.exports = function() {
if (this.property_URI == "http://schema.org/identifier") {
this.is_id = true;
}
if (this.property_URI == "http://schema.org/name") {
......
......@@ -31,7 +31,7 @@
"json": "^9.0.6",
"jsonld": "^1.6.2",
"node-json2html": "^1.1.1",
"ro-crate": "^1.2.11",
"ro-crate": "^1.2.12",
"sha1": "^1.1.1",
"shelljs": "^0.8.1",
"tmp": "0.0.33",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment