Skip to content

Commit

Permalink
Enable easy creation of static index.html pages (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
mescanne authored Oct 13, 2023
1 parent b8b0dc1 commit 7a901c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 20 additions & 3 deletions src/app/services/project_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 7a901c1

Please sign in to comment.