Skip to content

Commit

Permalink
make cadenza url configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jkissel committed Nov 6, 2023
1 parent 105d3e5 commit b071477
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"start:reformat": "onchange \"src/**/*\" -- prettier {{changed}} --write",
"test": "cross-env NODE_OPTIONS=--unhandled-rejections=warn jest",
"deploy:docs": "gh-pages --dist apidoc",
"sandbox": "http-server -a localhost -c-1 -d false --proxy http://localhost:8000 --proxy-options.headers.Origin http://localhost:8000 -o /sandbox.html"
"sandbox": "node ./sandbox.cjs"
},
"devDependencies": {
"@types/jest": "29.5.3",
Expand Down
7 changes: 7 additions & 0 deletions sandbox.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { execSync } = require('child_process');
const { URL } = require('url');

const DEFAULT_CADENZA_URL = 'http://localhost:8080/cadenza';
const cadenzaUrl = new URL((process.argv[2] === '--cadenza-url' && process.argv[3]) || process.env.CADENZA_URL || DEFAULT_CADENZA_URL);

execSync(`npx http-server -a localhost -c-1 -d false --proxy ${cadenzaUrl.origin} --proxy-options.headers.Origin ${cadenzaUrl.origin} -o /sandbox.html${cadenzaUrl.pathname !== '/' ? `?contextPath=${cadenzaUrl.pathname}` : ''}`, { stdio: 'inherit' });
3 changes: 2 additions & 1 deletion sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
history.replaceState(null, '', url);
};

const cadenzaClient = cadenza(location.origin + '/trunk', { iframe: 'iframe', debug: true });
const contextPath = new URLSearchParams(location.search).get('contextPath') ?? '';
const cadenzaClient = cadenza(location.origin + contextPath, { iframe: 'iframe', debug: true });
const actionHandlers = {
show ({ embeddingTargetId, hideMainHeaderAndFooter, hideWorkbookToolBar, jasperReportAsPdf, highlightGlobalId, operationMode, disabledUiFeatures }) {
cadenzaClient.show(embeddingTargetId, {
Expand Down

0 comments on commit b071477

Please sign in to comment.