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
c3e589b5
Commit
c3e589b5
authored
Jul 10, 2019
by
PTSEFTON
Browse files
Tidying up HTML generation
parent
f57948c3
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
calcyfy
View file @
c3e589b5
...
...
@@ -26,7 +26,7 @@ const path = require("path");
const
shell
=
require
(
"shelljs"
);
const
program
=
require
(
"commander"
);
const
defaults
=
require
(
"./lib/defaults.js"
);
const
html
_f
ile
_n
ame
=
defaults
.
html_file_name
;
const
html
F
ile
N
ame
=
defaults
.
html_file_name
;
const
metadata_file_name
=
defaults
.
metadata_json_file_name
;
const
JSON_helper
=
require
(
"./lib/jsonldhelper.js"
)
const
fs
=
require
(
"fs"
)
...
...
@@ -168,7 +168,7 @@ async function generateHTML(metadata_path) {
path
.
join
(
__dirname
,
"defaults/metadata_template.html"
)
);
fs
.
writeFileSync
(
path
.
join
(
dir
,
defaults
.
html
_f
ile
_n
ame
),
fs
.
writeFileSync
(
path
.
join
(
dir
,
html
F
ile
N
ame
),
await
index_maker
.
make_index_html
(
program
.
url
,
program
.
htmlscript
));
...
...
compiled/crate.js
View file @
c3e589b5
This diff is collapsed.
Click to expand it.
defaults/metadata_template.html
View file @
c3e589b5
...
...
@@ -39,20 +39,20 @@ table.table {
<body>
<nav
class=
"navbar
navbar-inverse
"
>
<nav
class=
"navbar"
>
<ul
class=
"nav navbar-nav"
>
<li
><a
href=
"#"
><span
class=
"glyphicon glyphicon-home
"
></span></a></li>
<li
><a
href=
"#"
><span
class=
"glyphicon glyphicon-home
dataset_name"
>
<
%
-
dataset_name
%
></span></a></li>
</ul>
</nav>
<div
class=
"container"
>
<div
class=
"jumbotron"
>
<h4
class=
"citation"
><
%
-
citation
%
></h3>
<h3
class=
"name"
>
NAME - TODO
</h4>
<h3
class=
"
item_
name"
>
<
%
-
item_name
%
>
</h4>
<h4><
%
-
zip_link
%
></h4>
<a
href=
"./ro-crate-metadata.jsonld"
>
Download all the metadata for
this Dastaset
in JSON-LD format
</a>
<a
href=
"./ro-crate-metadata.jsonld"
>
Download all the metadata for
<span
class=
'name'
><
%
-
dataset_name
%
></span>
in JSON-LD format
</a>
</div>
...
...
lib/index_html.js
View file @
c3e589b5
...
...
@@ -16,7 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const
defaults
=
require
(
"
./defaults
"
);
const
Preview
=
require
(
"
./ro-crate-preview
"
)
const
Preview
=
require
(
"
./ro-crate-preview
-wrapper
"
)
var
ejs
=
require
(
"
ejs
"
);
const
fs
=
require
(
"
fs-extra
"
);
//context = require("../defaults/context.json");
...
...
@@ -41,6 +41,7 @@ module.exports = function () {
make_index_html
:
async
function
make_index_html
(
zip_path
,
render_script
)
{
var
body_el
=
""
;
var
name
=
this
.
helper
.
root_node
.
name
;
if
(
!
render_script
)
{
render_script
=
defaults
.
render_script
;
}
...
...
@@ -48,13 +49,17 @@ module.exports = function () {
zip_path
=
`<a href='
${
zip_path
}
'>Download this Dataset</a>`
;
}
const
preview
=
new
Preview
(
json
);
const
summary
=
await
preview
.
summarizeDataset
()
const
summary
=
await
preview
.
summarizeDataset
();
var
date
=
new
Date
();
var
timestamp
=
date
.
getTime
();
return
this
.
template
({
html
:
summary
.
html
(),
dataset_name
:
name
,
item_name
:
name
,
citation
:
this
.
text_citation
,
zip_link
:
zip_path
,
up_link
:
""
,
time_stamp
:
"
time
"
,
time_stamp
:
time
stamp
,
ROCrate_version
:
defaults
.
ROCrate_version
,
spec_id
:
defaults
.
DataCrate_Specification_Identifier
,
json_ld
:
JSON
.
stringify
(
this
.
helper
.
json_ld
,
null
,
2
),
...
...
lib/jsonldhelper.js
View file @
c3e589b5
...
...
@@ -83,8 +83,6 @@ class jsonldHelper {
if
(
!
this
.
json_ld
[
"
@context
"
])
{
this
.
json_ld
[
"
@context
"
]
=
defaults
.
default_context
;
}
console
.
log
(
"
CONTEXT
"
,
this
.
json_ld
[
"
@context
"
])
this
.
graph
=
this
.
json_ld
[
"
@graph
"
];
for
(
let
i
=
0
;
i
<
this
.
graph
.
length
;
i
++
)
{
var
item
=
this
.
graph
[
i
];
...
...
lib/ro-crate-preview.js
View file @
c3e589b5
...
...
@@ -55,7 +55,6 @@ class Preview {
async
display
(
id
)
{
const
datasetDisplay
=
await
this
.
renderMetadataForItem
(
id
);
$
(
"
div#summary
"
).
html
(
datasetDisplay
);
}
...
...
@@ -89,6 +88,7 @@ class Preview {
}
makeDataCite
()
{
// EXPERIMENTAL
// Simple framing exercise but not using JSON-lD Framing
// Make something that DataCite's Bolognese tool can parse
var
newJson
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
root
));
//COPY
...
...
@@ -120,7 +120,7 @@ class Preview {
return
;
}
var
name
=
item
.
name
?
item
.
name
:
id
;
//
$("
h3.
name").html(name);
$
(
"
.item_
name
"
).
html
(
this
.
helper
.
value_as_array
(
item
[
"
@type
"
]).
join
(
"
,
"
)
+
"
:
"
).
append
(
name
);
var
metaTable
=
$
(
"
<table class='table metadata'><tbody></table>
"
).
attr
(
"
id
"
,
id
);
var
meta
=
metaTable
.
find
(
"
tbody
"
);
for
(
let
prop
of
this
.
sortKeys
(
Object
.
keys
(
item
)))
{
...
...
@@ -144,7 +144,7 @@ class Preview {
return
metaTable
;
}
// Add labels to properties that link back to (mostly)
// Add labels to properties that link back to
definitions
(mostly)
async
addGloss
()
{
var
data
;
var
request
=
new
XMLHttpRequest
();
...
...
test_data/sample/CATALOG_sample.xlsx
View file @
c3e589b5
No preview for this file type
test_data/sample/pics/CATALOG_pics.xlsx
View file @
c3e589b5
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