-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add template info to each manifest.json
- Loading branch information
Daniel Wood
committed
Jul 20, 2022
1 parent
408ab1a
commit 9b0bfaf
Showing
2 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
DanielJWood
Contributor
|
||
"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 = []; | ||
|
@@ -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) { | ||
|
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?