Commit c3e589b5 authored by PTSEFTON's avatar PTSEFTON
Browse files

Tidying up HTML generation

parent f57948c3
......@@ -26,7 +26,7 @@ const path = require("path");
const shell = require("shelljs");
const program = require("commander");
const defaults = require("./lib/defaults.js");
const html_file_name = defaults.html_file_name;
const htmlFileName = 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_file_name),
fs.writeFileSync(path.join(dir, htmlFileName),
await index_maker.make_index_html(program.url, program.htmlscript));
......
This diff is collapsed.
......@@ -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">&nbsp;<%- 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>
......
......@@ -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");
......@@ -38,9 +38,10 @@ module.exports = function () {
this.helper.add_back_links();
// A container for our page
},
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: timestamp,
ROCrate_version: defaults.ROCrate_version,
spec_id: defaults.DataCrate_Specification_Identifier,
json_ld: JSON.stringify(this.helper.json_ld, null, 2),
......
......@@ -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];
......
......@@ -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();
......
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