Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable easy creation of static index.html pages #465

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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