From bf3ef13bde8526c59558552a2bb6bacee40f054c Mon Sep 17 00:00:00 2001 From: Mark Scannell Date: Mon, 11 Sep 2023 12:59:19 +0100 Subject: [PATCH] Enable easy creation of static index.html pages through tokens that can be used for the manifest.json and catalog.json data. This does not change the existing behaviour. --- Makefile | 2 +- src/app/services/project_service.js | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 09957e1f..5fd380f5 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ test: npm test dist: clean - DBT_DOCS_ENV=production webpack + NODE_OPTIONS=--openssl-legacy-provider DBT_DOCS_ENV=production webpack rm -rf dist/fonts dist/main.js dist/main.js.map submodule: diff --git a/src/app/services/project_service.js b/src/app/services/project_service.js index 3ec2620a..18e15c74 100644 --- a/src/app/services/project_service.js +++ b/src/app/services/project_service.js @@ -21,7 +21,14 @@ angular .module('dbt') .factory('project', ['$q', '$http', function($q, $http) { - var TARGET_PATH = ''; + // These tokens will pass-through any webpack process, and + // enable replacement of the strings for objects containing + // the data for the manifest and catalog (manifest.json and + // catalog.json). + var INLINE_FILES = { + 'manifest': 'MANIFEST.JSON INLINE DATA', + 'catalog': 'CATALOG.JSON INLINE DATA' + } var service = { project: {}, @@ -95,6 +102,16 @@ angular } function loadFile(label, path) { + + // If there is an INLINE_FILES that isn't a string (must be JSON data), + // use it directly. + if (label in INLINE_FILES && typeof INLINE_FILES[label] === "object") { + return { + label: label, + data: INLINE_FILES[label] + } + } + return $http({ method: 'GET', url: path @@ -118,8 +135,8 @@ angular service.loadProject = function() { var cache_bust = "?cb=" + (new Date()).getTime(); var promises = [ - loadFile('manifest', TARGET_PATH + "manifest.json" + cache_bust), - loadFile('catalog', TARGET_PATH + "catalog.json" + cache_bust), + loadFile('manifest', "manifest.json" + cache_bust), + loadFile('catalog', "catalog.json" + cache_bust), ] $q.all(promises).then(function(files) {