Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
eResearch
CalcyteJS
Commits
9d1a75eb
Commit
9d1a75eb
authored
Nov 19, 2019
by
PTSEFTON
Browse files
Added -p for partOf
parent
35a8f617
Changes
4
Hide whitespace changes
Inline
Side-by-side
calcyfy
View file @
9d1a75eb
...
...
@@ -44,17 +44,14 @@ program
.
action
(
function
(
directories
)
{
dirs
=
directories
;
})
.
option
(
"-b, --bag [bag-dir]"
,
"Create Bagit Bag(s) under [bag-dir])"
)
.
option
(
"-n, --no"
,
"No Citation - only applies ith --bag"
)
.
option
(
"-z, --zip"
,
"Create a zipped version of the bag - only applies with --bag"
)
.
option
(
"-b, --bag [bag-dir]"
,
"Create Bagit Bag(s) under [bag-dir])"
)
.
option
(
"-z --zip"
,
"Zip the bagged ro-crate (only works with --bag"
)
.
option
(
"-p --partOf [partOf]"
,
"This is part of another RO-Crate, supply the ro-crate-metadata.jsonld path."
)
.
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 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"
...
...
@@ -109,16 +106,17 @@ else {
})
}
async
function
generateHTML
(
metadata
_p
ath
)
{
async
function
generateHTML
(
metadata
P
ath
)
{
// Save an HTML file
console
.
log
(
"Generating html from: "
+
metadata
_p
ath
);
if
(
!
path
.
isAbsolute
(
metadata
_p
ath
))
{
metadata
_p
ath
=
path
.
join
(
process
.
cwd
(),
metadata
_p
ath
);
console
.
log
(
"Generating html from: "
+
metadata
P
ath
);
if
(
!
path
.
isAbsolute
(
metadata
P
ath
))
{
metadata
P
ath
=
path
.
join
(
process
.
cwd
(),
metadata
P
ath
);
}
var
dir
=
path
.
dirname
(
metadata
_p
ath
)
var
dir
=
path
.
dirname
(
metadata
P
ath
)
shell
.
rm
(
"-rf"
,
path
.
join
(
dir
,
"ro-crate-metadata_files"
));
var
crate
=
new
ROCrate
(
JSON
.
parse
(
fs
.
readFileSync
(
metadata_path
)));
var
root
=
crate
.
getRootDataset
();
var
crate
=
new
ROCrate
(
JSON
.
parse
(
fs
.
readFileSync
(
metadataPath
)));
await
crate
.
index
();
var
root
=
await
crate
.
getRootDataset
();
if
(
program
.
url
){
// Add dowload info
if
(
!
root
[
"distribution"
])
{
...
...
@@ -140,6 +138,29 @@ async function generateHTML(metadata_path) {
crate
=
new
roCrate
(
crate
.
getJson
());
}
if
(
program
.
partOf
)
{
var
parentCrate
=
new
ROCrate
(
JSON
.
parse
(
fs
.
readFileSync
(
program
.
partOf
)));
await
parentCrate
.
index
();
parentRoot
=
await
parentCrate
.
getRootDataset
();
console
.
log
(
"PARENT ROOT"
,
parentRoot
);
// Inherit metadata
if
(
!
root
.
datePublished
)
{
console
.
log
(
"Inherit"
)
root
.
datePublished
=
parentRoot
.
datePublished
;
}
if
(
!
root
.
name
)
{
root
.
name
=
"Part of: "
+
parentRoot
.
name
;
}
if
(
!
root
.
descripton
)
{
root
.
description
=
"This is a part of: "
+
parentRoot
.
name
;
}
if
(
!
root
.
isPartOf
&&
parentRoot
.
identifier
)
{
console
.
log
(
"So here we are"
)
root
.
isPartOf
=
parentRoot
.
identifier
;
}
console
.
log
(
"ROOT"
,
root
)
}
var
index_maker
=
new
Index
();
index_maker
.
init
(
...
...
@@ -150,9 +171,8 @@ async function generateHTML(metadata_path) {
fs
.
writeFileSync
(
path
.
join
(
dir
,
htmlFileName
),
await
index_maker
.
make_index_html
(
program
.
url
,
program
.
cratescript
));
if
(
program
.
bag
)
{
// Bag the HTML
// TODO - GET THIS WORKING
var
bagger
=
new
Bag
();
var
dest
=
path
.
join
(
program
.
bag
,
path
.
basename
(
dir
));
...
...
@@ -166,15 +186,14 @@ async function generateHTML(metadata_path) {
metadata_path
=
path
.
join
(
dir
,
metadata_file_name
);
const
index
=
await
fs
.
copyFile
(
path
.
join
(
__dirname
,
"defaults"
,
"index.html"
),
path
.
join
(
dest
,
"index.html"
));
bagger
.
update
();
}
if
(
program
.
zip
&&
program
.
bag
)
{
shell
.
cd
(
bagger
.
targetDir
);
var
zipname
=
path
.
join
(
"../"
,
path
.
basename
(
bagger
.
targetDir
)
+
".zip"
);
shell
.
rm
(
"-f"
,
zipname
);
shell
.
exec
(
"zip -r "
+
zipname
+
" "
+
"*"
);
if
(
program
.
zip
){
var
zipname
=
path
.
join
(
program
.
bag
,
path
.
basename
(
path
.
dirname
(
metadataPath
))
.
replace
(
" "
,
"_"
)
+
".zip"
);
console
.
log
(
'name'
,
zipname
)
shell
.
cd
(
dir
);
shell
.
rm
(
"-f"
,
`"${zipname}"`
);
shell
.
exec
(
"zip -r "
+
zipname
+
" "
+
"*"
);
}
}
...
...
lib/property.js
View file @
9d1a75eb
...
...
@@ -78,7 +78,7 @@ module.exports = function() {
this
.
nested_item_json
=
[];
if
(
this
.
name
===
"
ID
"
)
{
this
.
name
=
"
identifier
"
;
this
.
is_id
=
true
;
}
else
if
(
this
.
name
===
"
TYPE:
"
)
{
this
.
is_type
=
true
;
}
else
if
(
name
==
"
MIME:
"
)
{
...
...
@@ -95,7 +95,7 @@ module.exports = function() {
this
.
name
=
this
.
name
.
substring
(
5
);
this
.
is_json
=
true
;
}
//Assume what's left of header is a property, and hence starts with lowecase letter
//Assume what's left of header is a property, and hence starts with lowe
r
case letter
this
.
name
=
lowercase_first
(
this
.
name
);
var
nest
;
if
(
this
.
name
.
endsWith
(
"
*
"
))
{
...
...
@@ -124,9 +124,7 @@ module.exports = function() {
this
.
property_URI
=
get_RDF_for_column
(
this
.
name
);
if
(
this
.
property_URI
==
"
http://schema.org/identifier
"
)
{
this
.
is_id
=
true
;
}
if
(
this
.
property_URI
==
"
http://schema.org/name
"
)
{
this
.
is_name
=
true
;
...
...
test_data/sample/CATALOG_sample.xlsx
View file @
9d1a75eb
No preview for this file type
test_data/sample/pics/CATALOG_pics.xlsx
View file @
9d1a75eb
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment