Commit 84f39937 authored by PTSEFTON's avatar PTSEFTON
Browse files

Fixed bug with recursion not calling the correct function

parent fd769ec2
......@@ -136,7 +136,6 @@ if (program.generateHtml) {
} else {
//TODO - there is a lot of repetition here, sort it out
var zipname;
dirs.forEach(function(dir) {
if (shell.test("-d", dir)) {
var c = new Collection();
......@@ -146,8 +145,10 @@ if (program.generateHtml) {
output_dir = path.join(process.cwd(), output_dir);
}
if (program.bag) {
output_dir = path.join(program.bag, path.basename(dir));
c.bag(output_dir);
console.log("OUTPUT", output_dir)
if (!path.isAbsolute(output_dir)) {
output_dir = path.join(process.cwd(), output_dir);
}
......@@ -193,9 +194,10 @@ if (program.generateHtml) {
}
}
var index_maker = new Index();
console.log("OUTPUT", output_dir)
index_maker.init(
path.join(output_dir, catalog_file_name),
path.join(output_dir),
output_dir,
multiple,
path.join(__dirname, "defaults/catalog_template.html")
);
......
......@@ -181,7 +181,7 @@ module.exports = function () {
? "<a href='" + this.zip_path + "'>Download a zip file</a>"
: "";
var catalog_actual_path = path.join(
path.dirname(this.out_dir),
this.out_dir,
defaults.catalog_json_file_name
);
var stats = fs.statSync(catalog_actual_path);
......@@ -329,6 +329,7 @@ module.exports = function () {
},
get_file_ref: function get_file_ref(dest_path, from_id) {
dest_path = this.helper.value_as_array(dest_path)[0]
if (this.multiple_files_dir && !this.first_page) {
var source_path = this.get_html_path(from_id);
return path.relative(path.dirname(source_path), dest_path);
......@@ -441,7 +442,6 @@ module.exports = function () {
dataset_to_html: function dataset_to_html(node) {
// Turns any item into an HTML table
var path = "pairtree" + node["@id"].replace(/(..)/g, "/$1");
var html = "";
var keys = new Set(Object.keys(node));
if (node["identifier"]) {
......@@ -456,10 +456,11 @@ module.exports = function () {
if (keys.has("encodingFormat")) {
keys.delete("fileFormat");
}
if (!this.first_page && node["@label"] && !node["name"]) {
html += node["@label"];
for (let key of Object.keys(node)) {
node[key] = this.helper.value_as_array(node[key])
for (let v of node[key]) {
if (
key != "@id" &&
......@@ -467,7 +468,7 @@ module.exports = function () {
v["@id"] &&
this.helper.item_by_id[v["@id"]]
) {
html += " | " + dataset_to_html(this.helper.item_by_id[v["@id"]]);
html += " | " + this.dataset_to_html(this.helper.item_by_id[v["@id"]]);
}
}
}
......@@ -602,6 +603,7 @@ module.exports = function () {
}
// TODO: Use loadjson or somesuch
// Shift loading into the calcyte script
if (!crate_data["@graph"]) {
crate_data = require(crate_data);
}
......
......@@ -121,18 +121,18 @@ module.exports = function() {
//console.log("Nesting, this is the name", this.name)
var nested_type = nest[2];
var nested_json = { "TYPE:": nested_type };
nested_json["name"] = data;
var parts = data.replace(/ *, +/, ",").split(",");
//console.log(parts)
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
var pair = part.match(/(.*?) *: *(.*)/);
// TURN INTO JSON {"@Type:Person, name='...' "}
// Pass BACK!
//var nested_property = new module.exports;
nested_json[lowercase_first(pair[1])] = pair[2];
}
nested_json[lowercase_first(pair[1]).trim()] = pair[2].trim();
}
if (!nested_json["name"]) {
nested_json["name"] = data;
}
//console.log("NESTING", nested_json)
this.nested_item_json.push(nested_json);
this.data = "";
......
<html>
<head>
<style>
table {
width: 90%;
text-align: left;
vertical-align: top;
margin-bottom: 2em;
}
td {
margin-right: 2em;
white-space: normal;
}
details {
margin-left: 2em;
}
.break {
word-break: break-all;
}
div.collection {
margin-left: +1em;
}
</style>
<script type="application/ld+json">
{
"@id": "https://dx.doi.org/10.1016/this_is_an_example_not_a_real_DOI",
"@type": [
"Dataset"
],
"contentLocation": [
{
"@id": "fb3faee3-aa8c-4c7a-8350-b5b9eebbcf57"
}
],
"path": [
"./"
],
"creator": [
{
"@id": "http://orcid.org/0000-0003-4953-0830"
},
{
"@id": "Keir Vaughan-Taylor"
},
{
"@id": "http://orcid.org/0000-0002-2038-7922"
},
{
"@id": "http://orcid.org/0000-0003-4953-9114"
}
],
"datePublished": [
"2017"
],
"description": [
"Sketchsheets and data from the Glop Pot cave survey"
],
"hasPart": [
{
"@id": "cp7glop.svx"
},
{
"@id": "cp7glop.ai"
},
{
"@id": "CATALOG"
},
{
"@id": "asf"
},
{
"@id": "datasheets"
},
{
"@id": "sketchsheets"
}
],
"identifier": [
"https://dx.doi.org/10.1016/this_is_an_example_not_a_real_DOI"
],
"name": [
"Glop Pot data"
],
"publisher": [
{
"@id": "https://suss.caves.org.au/"
}
]
}
</script>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta charset='utf-8'/>
</head>
<body>
<nav class="navbar navbar-inverse">
<ul class="nav navbar-nav" >
<li >
<a href="" class="active"><button type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-home"></span>&nbsp;Glop Pot data</button></a></li>
</ul>
</nav>
<div class="container">
<div class="jumbotron">
<h3>Glop Pot data</h3>
<h4></h4>
</div>
<p>A machine-readable version of this page, created at 2018-09-17T07:45:42.817Z is available <a href='CATALOG.json'>CATALOG.json</a></p>
<table class = 'table' id = 'https://dx.doi.org/10.1016/this_is_an_example_not_a_real_DOI'
><hr
><tr
><th style = 'white-space: nowrap; width: 1%;'
>@id</th
><td
><a href = 'https://dx.doi.org/10.1016/this_is_an_example_not_a_real_DOI' class = 'fa fa-external-link' title = 'Glop Pot data'
>https://dx.doi.org/10.1016/this_is_an_example_not_a_real_DOI</a
></td
></tr
><tr
><th
><span
>name<sup
><a href = 'http://schema.org/name' title = 'Definition of: name'
>?</a
></sup
></span
></th
><td
><b
>Glop Pot data</b
></td
></tr
><tr
><th
>@type</th
><td
><span
>Dataset<sup
><a href = 'http://schema.org/Dataset' title = 'Definition of: Dataset'
>?</a
></sup
></span
></td
></tr
><tr
><th
><span
>description<sup
><a href = 'http://schema.org/description' title = 'Definition of: description'
>?</a
></sup
></span
></th
><td
>Sketchsheets and data from the Glop Pot cave survey</td
></tr
><tr
><th
><span
>datePublished<sup
><a href = 'http://schema.org/datePublished' title = 'Definition of: datePublished'
>?</a
></sup
></span
></th
><td
>2017</td
></tr
><tr
><th
><span
>creator<sup
><a href = 'http://schema.org/creator' title = 'Definition of: creator'
>?</a
></sup
></span
></th
><td
><ul
><li
><a href = './CATALOG_files/http:__orcid.org_0000-0003-4953-0830.html'
>Mike Lake</a
></li
><li
><a href = './CATALOG_files/Keir Vaughan-Taylor.html'
>Keir Vaughan-Taylor</a
></li
><li
><a href = './CATALOG_files/http:__orcid.org_0000-0002-2038-7922.html'
>Andreas Klocker</a
></li
><li
><a href = './CATALOG_files/http:__orcid.org_0000-0003-4953-9114.html'
>Phil Maynard</a
></li
></ul
></td
></tr
><tr
><th
><span
>path<sup
><a href = 'http://schema.org/contentUrl' title = 'Definition of: path'
>?</a
></sup
></span
></th
><td
><a href = './'
>.</a
></td
></tr
><tr
><th
><span
>contentLocation<sup
><a href = 'http://schema.org/contentLocation' title = 'Definition of: contentLocation'
>?</a
></sup
></span
></th
><td
><a href = './CATALOG_files/fb3faee3-aa8c-4c7a-8350-b5b9eebbcf57.html'
>Glop Pot</a
></td
></tr
><tr
><th
><span
>hasPart<sup
><a href = 'http://schema.org/hasPart' title = 'Definition of: hasPart'
>?</a
></sup
></span
></th
><td
><ul
><li
><a href = './CATALOG_files/cp7glop.svx.html'
>cp7glop.svx</a
></li
><li
><a href = './CATALOG_files/cp7glop.ai.html'
>cp7glop.ai</a
></li
><li
><a href = './CATALOG_files/CATALOG.html'
>CATALOG</a
></li
><li
><a href = './CATALOG_files/asf.html'
>asf</a
></li
><li
><a href = './CATALOG_files/datasheets.html'
>CP7 Glop Pot, Cooleman Plains, Glop Pot data sheets </a
></li
><li
><a href = './CATALOG_files/sketchsheets.html'
>Sketch Sheets</a
></li
></ul
></td
></tr
><tr
><th
><span
>publisher<sup
><a href = 'http://schema.org/publisher' title = 'Definition of: publisher'
>?</a
></sup
></span
></th
><td
><a href = './CATALOG_files/https:__suss.caves.org.au_.html'
>Sydney University Speleological Society</a
></td
></tr
></table
>
<p>This file was created at 2018-09-17T07:45:42.827Z by
<a href='https://code.research.uts.edu.au/eresearch/calcytejs'>
Calcyte</a> which implements the <a href='https://github.com/UTS-eResearch/datacrate/blob/master/spec/0.3/data_crate_specification_v0.3.md'>
Draft DataCrate Packaging format</a>, version 0.3
</p>
</body>
</html>
This diff is collapsed.
<html>
<head>
<style>
table {
width: 90%;
text-align: left;
vertical-align: top;
margin-bottom: 2em;
}
td {
margin-right: 2em;
white-space: normal;
}
details {
margin-left: 2em;
}
.break {
word-break: break-all;
}
div.collection {
margin-left: +1em;
}
</style>
<script type="application/ld+json">
{
"@id": "https://dx.doi.org/10.5281/zenodo.1009240",
"@type": "Dataset",
"isOutputOf": "DataCrate",
"contact": {
"@id": "http://orcid.org/0000-0002-3545-944X"
},
"contentLocation": {
"@id": "http://www.geonames.org/8152662/catalina-park.html"
},
"path": "./",
"creator": {
"@id": "http://orcid.org/0000-0002-3545-944X"
},
"datePublished": "2017-06-29",
"description": "This is a simple dataset for demonstration purposes it contains just one image and a directory full of useless text files.",
"hasPart": [
{
"@id": "CATALOG"
},
{
"@id": "lots_of_little_files"
},
{
"@id": "pics"
}
],
"identifier": [
"dx.doi.org/10.5281/zenodo.1009240"
],
"keywords": "Dogs, Fences, The Gully",
"name": "Sample dataset for DataCrate v0.2",
"publisher": {
"@id": "http://uts.edu.au"
},
"relatedLink": {
"@id": "http://dx.doi.org/10.1000/123456"
},
"temporalCoverage": "2017",
"@reverse": {
"isPartOf": [
{
"@id": "lots_of_little_files"
},
{
"@id": "pics"
}
]
}
}
</script>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta charset='utf-8'/>
</head>
<body>
<nav class="navbar navbar-inverse">
<ul class="nav navbar-nav" >
<li >
<a href="" class="active"><button type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-home"></span>&nbsp;Sample dataset for DataCrate v0.2</button></a></li>
</ul>
</nav>
<div class="container">
<div class="jumbotron">
<h3>Sample dataset for DataCrate v0.2</h3>
<h4></h4>
</div>
<p>A machine-readable version of this page, created at 2018-01-17T06:35:14.000Z is available <a href='CATALOG.json'>CATALOG.json</a></p>
<table class = 'table' id = 'https://dx.doi.org/10.5281/zenodo.1009240'
><hr
><tr
><th style = 'white-space: nowrap; width: 1%;'
>@id</th
><td
><a href = 'https://dx.doi.org/10.5281/zenodo.1009240' class = 'fa fa-external-link' title = 'Sample dataset for DataCrate v0.2'
>https://dx.doi.org/10.5281/zenodo.1009240</a
></td
></tr
><tr
><th
><span
>name<sup
><a href = 'http://schema.org/name' title = 'Definition of: name'
>?</a
></sup
></span
></th
><td
><b
>Sample dataset for DataCrate v0.2</b
></td
></tr
><tr
><th
>@type</th
><td
><span
>Dataset<sup
><a href = 'http://schema.org/Dataset' title = 'Definition of: Dataset'
>?</a
></sup
></span
></td
></tr
><tr
><th
>Items referencing this:</th
><td
><table class = 'table'
><tr
><th style = 'white-space: nowrap; width: 1%;'
>Relationship</th
><th
>Referenced-by</th
></tr
><tr
><th
>isPartOf</th
><td
><ul
><li
><a href = 'CATALOG_files/pairtree_root/lo/ts/_o/f_/li/tt/le/_f/il/es/index.html'
>lots_of_little_files</a
></li
><li
><a href = 'CATALOG_files/pairtree_root/pi/cs/index.html'
>Pictures</a
></li
></ul
></td
></tr
></table
></td
></tr
><tr
><th
><span
>description<sup
><a href = 'http://schema.org/description' title = 'Definition of: description'
>?</a
></sup
></span
></th
><td