Skip to content

Commit

Permalink
add template info to each manifest.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Wood committed Jul 20, 2022
1 parent 408ab1a commit 9b0bfaf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
4 changes: 0 additions & 4 deletions lib/duplicateGraphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ module.exports = async function(config, original, slug) {

//load/create parent info
if (parent) {
console.log(parent)
manifest.parent.push(original)
} else {
manifest.parent = [original]
}
// console.log(config)
console.log(original)
// console.log(slug)

await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
console.log(`Duplicate of ${original} created as ${fullSlug} -- you got this!`);
Expand Down
35 changes: 32 additions & 3 deletions server/handlers/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@ var fs = require("fs").promises;
var path = require("path");
var readJSON = require("../../lib/readJSON");

var templateList = {

This comment has been minimized.

Copy link
@thomaswilburn

thomaswilburn Jul 20, 2022

Contributor

The original plan was for the rig to not be tightly coupled between the templates and the actual mechanism--the original rig kept templates with the Flask app itself, but this meant that non-NPR organizations who tweaked the look and feel of their templates had to reconcile this with any code changes for functionality. Putting these sheet IDs into the code of the rig will undo that work--maybe it should be changed in the actual manifests of the template repo instead?

This comment has been minimized.

Copy link
@DanielJWood

DanielJWood Jul 21, 2022

Contributor

Agreed. This was rolled back in the subsequent commit. I had created this list along with code to backfill existing the manifest.json files with the template type. I shouldn't have committed the list of IDs! Oops.

"1G5p4UIsKwUK303k4gLXhAmFnret0lg3w7qLm5S62Tsg":"ai2html_graphic",
"1nbpweBccoaBqxuyKSL6o0q_qkdponL0OWgJpbozQp58":"bar_chart",
"1km6lszUzHwbgg9eFe1qcsUHfQBIF48r1XnFc1nQcnog":"county_map",
"12PsbQ7uTHr_iFeJLgt7LSkU66BQUNX8_5wQrJuvjYFU":"stacked_grouped_column_chart",
"12e3cNKWd1E2IHcDGN72URkbp7Yjb_3TbJrAxIgpYCTI":"state_grid_map",
"1E0fEV2lnchh8l5fuTvOTR5GRuv4jVtOEI-unEOCPtd4":"portrait_pullquotes",
"1kekyEB3w293-8Ex2R3VdsQZTQmrfJwZ6sfWxS7OBDyA":"graphic",
"1pcLyLFhEpKMlNpp3UqWZ1XgW8ZaloVe_d04CGdNnEWc":"dot_chart",
"1a8F0oYWVC0BdEpG8Mbz2HKRkGIn0XQiGWTcVZMXeVdQ":"table",
"1kekyEB3w293-8Ex2R3VdsQZTQmrfJwZ6sfWxS7OBDyA":"d3_graphic",
"1wq0oi5HfgfYBdDs32-Qs77xmnI9VMXPUgRHA8lKIRmM":"annotated_line_chart",
"1QTLmFGjd2BCU3QQvvXb-8RN9YkztBFOaOeaZ40SEKjw":"block_histogram",
"1-wN8QJAaAE5zzIMcbfPPchPWAGFj6BnpZrU72Fp6cm4":"column_chart",
"1G5p4UIsKwUK303k4gLXhAmFnret0lg3w7qLm5S62Tsg":"ai2html_map",
"1DLHWPcJcGoKHRGBtATdBbZVIT0EuiAXG_SiQiDucazg":"stacked_bar_chart",
"1DLxMcQRpyp1rqGJTjC28jJH5Df1GYrJrJnBl2PW9-MU":"line_chart",
"19d-SxZs0z5fl7pETB427wp4DYzNwB5znkNZg6kF69j4":"grouped_bar_chart",
"1tCkiSX2QV2_LjXWW6sNe7s9MqREeDEYrIGQF8mb0OHw":"stacked_column_chart"
}

var getFolders = async function(dir) {
var listing = await fs.readdir(dir);
var matching = [];
Expand All @@ -22,11 +43,19 @@ var getFolders = async function(dir) {
var getMetadata = async function(data,dir) {
var metadata = {};
for (var i = 0; i < data.length; i++) {
var manifest = await readJSON(path.join(dir, data[i], "manifest.json"));
if (manifest.templateType) {
var manifestPath = path.join(dir, data[i], "manifest.json");
var manifest = await readJSON(manifestPath);
if (manifest.templateType && manifest.templateType != "test") {
var template = manifest.templateType;
}
else if (manifest.templateType == "test") {
var template = templateList[manifest.templateSheet];

manifest.templateType = template;
// update manifest with test
await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
} else {
var template = "";
template = "";
}

if (manifest.parent) {
Expand Down

0 comments on commit 9b0bfaf

Please sign in to comment.