serving files from _shared
This commit is contained in:
parent
4cd2de5df3
commit
5f2865b09a
|
@ -527,7 +527,7 @@
|
|||
"props": {
|
||||
"main": {
|
||||
"_component": "@budibase/standard-components/login",
|
||||
"logo": "/assets/budibase-logo.png",
|
||||
"logo": "/_shared/budibase-logo.png",
|
||||
"loginRedirect": "",
|
||||
"usernameLabel": "Username",
|
||||
"passwordLabel": "Password",
|
||||
|
@ -535,7 +535,7 @@
|
|||
},
|
||||
"unauthenticated": {
|
||||
"_component": "@budibase/standard-components/login",
|
||||
"logo": "/assets/budibase-logo.png",
|
||||
"logo": "/_shared/budibase-logo.png",
|
||||
"loginRedirect": "",
|
||||
"usernameLabel": "Username",
|
||||
"passwordLabel": "Password",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"description": "",
|
||||
"inherits": "@budibase/standard-components/login",
|
||||
"props": {
|
||||
"logo": "/assets/budibase-logo.png"
|
||||
"logo": "/_shared/budibase-logo.png"
|
||||
},
|
||||
"tags": [
|
||||
"login",
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,7 @@
|
|||
<meta name='viewport' content='width=device-width'>
|
||||
|
||||
<title>Budibase</title>
|
||||
<link rel='icon' type='image/png' href='/_master//assets/favicon.png'>
|
||||
<link rel='icon' type='image/png' href='/_master/_shared/favicon.png'>
|
||||
|
||||
|
||||
<script src='/_master/clientAppDefinition.js'></script>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,7 @@
|
|||
<meta name='viewport' content='width=device-width'>
|
||||
|
||||
<title>Budibase - Login</title>
|
||||
<link rel='icon' type='image/png' href='/_master//assets/favicon.png'>
|
||||
<link rel='icon' type='image/png' href='/_master/_shared/favicon.png'>
|
||||
|
||||
|
||||
<script src='/_master/clientAppDefinition.js'></script>
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
hello
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
window['##BUDIBASE_APPDEFINITION##'] = {"hierarchy":{"name":"root","type":"root","children":[{"name":"customer","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":1000,"values":null,"allowDeclaredValuesOnly":false},"label":"name","getInitialValue":"default","getUndefinedValue":"default"}],"children":[{"name":"invoiceyooo","type":"record","fields":[{"name":"amount","type":"number","typeOptions":{"minValue":99999999999,"maxValue":99999999999,"decimalPlaces":2},"label":"amount","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":2,"indexes":[],"allidsShardFactor":1,"collectionName":"invoices","isSingle":false}],"validationRules":[],"nodeId":1,"indexes":[],"allidsShardFactor":64,"collectionName":"customers","isSingle":false}],"pathMaps":[],"indexes":[],"nodeId":0},"componentLibraries":["./customComponents","./moreCustomComponents","@budibase/standard-components"],"appRootPath":"","props":{"_component":"some_component"}}
|
||||
window['##BUDIBASE_APPDEFINITION##'] = {"hierarchy":{"name":"root","type":"root","children":[{"name":"customer","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":1000,"values":null,"allowDeclaredValuesOnly":false},"label":"name","getInitialValue":"default","getUndefinedValue":"default"}],"children":[{"name":"invoiceyooo","type":"record","fields":[{"name":"amount","type":"number","typeOptions":{"minValue":99999999999,"maxValue":99999999999,"decimalPlaces":2},"label":"amount","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":2,"indexes":[],"allidsShardFactor":1,"collectionName":"invoices","isSingle":false}],"validationRules":[],"nodeId":1,"indexes":[],"allidsShardFactor":64,"collectionName":"customers","isSingle":false}],"pathMaps":[],"indexes":[],"nodeId":0},"componentLibraries":[{"importPath":"/lib/customComponents/index.js","libName":"./customComponents"},{"importPath":"/lib/moreCustomComponents/index.js","libName":"./moreCustomComponents"},{"importPath":"/lib/node_modules/@budibase/standard-components/dist/index.js","libName":"@budibase/standard-components"}],"appRootPath":"","props":{"_component":"some_component"}}
|
|
@ -5,17 +5,18 @@
|
|||
<meta name='viewport' content='width=device-width'>
|
||||
|
||||
<title>Budibase App</title>
|
||||
<link rel='icon' type='image/png' href='//assets/favicon.png'>
|
||||
<link rel='icon' type='image/png' href='//_shared/favicon.png'>
|
||||
|
||||
<link rel='stylesheet' href='https://css-r-us.com/myawesomestyles.css'>
|
||||
<link rel='stylesheet' href='///local.css'>
|
||||
|
||||
<script src='/clientAppDefinition.js'></script>
|
||||
<script src='/budibase-client.js'></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body id="app">
|
||||
<script src='/clientAppDefinition.js'></script>
|
||||
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
window['##BUDIBASE_APPDEFINITION##'] = {"hierarchy":{"name":"root","type":"root","children":[{"name":"customer","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":1000,"values":null,"allowDeclaredValuesOnly":false},"label":"name","getInitialValue":"default","getUndefinedValue":"default"}],"children":[{"name":"invoiceyooo","type":"record","fields":[{"name":"amount","type":"number","typeOptions":{"minValue":99999999999,"maxValue":99999999999,"decimalPlaces":2},"label":"amount","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":2,"indexes":[],"allidsShardFactor":1,"collectionName":"invoices","isSingle":false}],"validationRules":[],"nodeId":1,"indexes":[],"allidsShardFactor":64,"collectionName":"customers","isSingle":false}],"pathMaps":[],"indexes":[],"nodeId":0},"componentLibraries":["./customComponents","./moreCustomComponents","@budibase/standard-components"],"appRootPath":"","props":{"_component":"some_other_component"}}
|
||||
window['##BUDIBASE_APPDEFINITION##'] = {"hierarchy":{"name":"root","type":"root","children":[{"name":"customer","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":1000,"values":null,"allowDeclaredValuesOnly":false},"label":"name","getInitialValue":"default","getUndefinedValue":"default"}],"children":[{"name":"invoiceyooo","type":"record","fields":[{"name":"amount","type":"number","typeOptions":{"minValue":99999999999,"maxValue":99999999999,"decimalPlaces":2},"label":"amount","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":2,"indexes":[],"allidsShardFactor":1,"collectionName":"invoices","isSingle":false}],"validationRules":[],"nodeId":1,"indexes":[],"allidsShardFactor":64,"collectionName":"customers","isSingle":false}],"pathMaps":[],"indexes":[],"nodeId":0},"componentLibraries":[{"importPath":"/lib/customComponents/index.js","libName":"./customComponents"},{"importPath":"/lib/moreCustomComponents/index.js","libName":"./moreCustomComponents"},{"importPath":"/lib/node_modules/@budibase/standard-components/dist/index.js","libName":"@budibase/standard-components"}],"appRootPath":"","props":{"_component":"some_other_component"}}
|
|
@ -5,17 +5,18 @@
|
|||
<meta name='viewport' content='width=device-width'>
|
||||
|
||||
<title>Test App 1 - Login</title>
|
||||
<link rel='icon' type='image/png' href='//assets/favicon.png'>
|
||||
<link rel='icon' type='image/png' href='//_shared/favicon.png'>
|
||||
|
||||
<link rel='stylesheet' href='https://css-r-us.com/myawesomestyles.css'>
|
||||
<link rel='stylesheet' href='///local.css'>
|
||||
|
||||
<script src='/clientAppDefinition.js'></script>
|
||||
<script src='/budibase-client.js'></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body id="app">
|
||||
<script src='/clientAppDefinition.js'></script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -159,7 +159,7 @@
|
|||
"main": {},
|
||||
"unauthenticated": {
|
||||
"_component": "budibase-standard-components/login",
|
||||
"logo": "/assets/budibase-logo.png",
|
||||
"logo": "/_shared/budibase-logo.png",
|
||||
"loginRedirect": "",
|
||||
"usernameLabel": "Username",
|
||||
"passwordLabel": "Password",
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,7 @@
|
|||
<meta name='viewport' content='width=device-width'>
|
||||
|
||||
<title>Budibase App</title>
|
||||
<link rel='icon' type='image/png' href='/testApp2//assets/favicon.png'>
|
||||
<link rel='icon' type='image/png' href='/testApp2/_shared/favicon.png'>
|
||||
|
||||
|
||||
<script src='/testApp2/budibase-client.js'></script>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
window['##BUDIBASE_APPDEFINITION##'] = {"hierarchy":{"name":"root","type":"root","children":[{"name":"customer","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":1000,"values":null,"allowDeclaredValuesOnly":false},"label":"name","getInitialValue":"default","getUndefinedValue":"default"}],"children":[{"name":"invoiceyooo","type":"record","fields":[{"name":"amount","type":"number","typeOptions":{"minValue":99999999999,"maxValue":99999999999,"decimalPlaces":2},"label":"amount","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":2,"indexes":[],"allidsShardFactor":1,"collectionName":"invoices","isSingle":false}],"validationRules":[],"nodeId":1,"indexes":[{"name":"customer_invoices","type":"index","map":"return {...record};","filter":"","indexType":"ancestor","getShardName":"","getSortKey":"record.id","aggregateGroups":[],"allowedRecordNodeIds":[2],"nodeId":5}],"allidsShardFactor":64,"collectionName":"customers","isSingle":false}],"pathMaps":[],"indexes":[{"name":"Yeo index","type":"index","map":"return {...record};","filter":"","indexType":"ancestor","getShardName":"","getSortKey":"record.id","aggregateGroups":[],"allowedRecordNodeIds":[1],"nodeId":4},{"name":"everyones_invoices","type":"index","map":"return {...record};","filter":"","indexType":"ancestor","getShardName":"","getSortKey":"record.id","aggregateGroups":[],"allowedRecordNodeIds":[2],"nodeId":6}],"nodeId":0},"componentLibraries":["budibase-standard-components"],"appRootPath":"/testApp2","props":{"_component":"budibase-standard-components/login","logo":"/assets/budibase-logo.png","loginRedirect":"","usernameLabel":"Username","passwordLabel":"Password","loginButtonLabel":"Login"}}
|
||||
window['##BUDIBASE_APPDEFINITION##'] = {"hierarchy":{"name":"root","type":"root","children":[{"name":"customer","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":1000,"values":null,"allowDeclaredValuesOnly":false},"label":"name","getInitialValue":"default","getUndefinedValue":"default"}],"children":[{"name":"invoiceyooo","type":"record","fields":[{"name":"amount","type":"number","typeOptions":{"minValue":99999999999,"maxValue":99999999999,"decimalPlaces":2},"label":"amount","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":2,"indexes":[],"allidsShardFactor":1,"collectionName":"invoices","isSingle":false}],"validationRules":[],"nodeId":1,"indexes":[{"name":"customer_invoices","type":"index","map":"return {...record};","filter":"","indexType":"ancestor","getShardName":"","getSortKey":"record.id","aggregateGroups":[],"allowedRecordNodeIds":[2],"nodeId":5}],"allidsShardFactor":64,"collectionName":"customers","isSingle":false}],"pathMaps":[],"indexes":[{"name":"Yeo index","type":"index","map":"return {...record};","filter":"","indexType":"ancestor","getShardName":"","getSortKey":"record.id","aggregateGroups":[],"allowedRecordNodeIds":[1],"nodeId":4},{"name":"everyones_invoices","type":"index","map":"return {...record};","filter":"","indexType":"ancestor","getShardName":"","getSortKey":"record.id","aggregateGroups":[],"allowedRecordNodeIds":[2],"nodeId":6}],"nodeId":0},"componentLibraries":["budibase-standard-components"],"appRootPath":"/testApp2","props":{"_component":"budibase-standard-components/login","logo":"/_shared/budibase-logo.png","loginRedirect":"","usernameLabel":"Username","passwordLabel":"Password","loginButtonLabel":"Login"}}
|
|
@ -5,7 +5,7 @@
|
|||
<meta name='viewport' content='width=device-width'>
|
||||
|
||||
<title>Test App Two</title>
|
||||
<link rel='icon' type='image/png' href='/testApp2//assets/favicon.png'>
|
||||
<link rel='icon' type='image/png' href='/testApp2/_shared/favicon.png'>
|
||||
|
||||
|
||||
<script src='/testApp2/budibase-client.js'></script>
|
||||
|
|
|
@ -2,8 +2,8 @@ const {initialiseData, setupDatastore} = require("@budibase/core");
|
|||
const constructHierarchy = require("../utilities/constructHierarchy");
|
||||
const getDatabaseManager = require("../utilities/databaseManager");
|
||||
const {getApisForUser, getApisWithFullAccess} = require("../utilities/budibaseApi");
|
||||
const masterDbAppDefinition = require("../appPackages/master/appDefinition.json");
|
||||
const masterDbAccessLevels = require("../appPackages/master/access_levels.json");
|
||||
const masterDbAppDefinition = require("../appPackages/_master/appDefinition.json");
|
||||
const masterDbAccessLevels = require("../appPackages/_master/access_levels.json");
|
||||
const { masterAppPackage } = require("../utilities/createAppPackage");
|
||||
|
||||
module.exports = async (context, datastoreModule, username, password) => {
|
||||
|
|
|
@ -50,6 +50,7 @@ module.exports = (config, app) => {
|
|||
|
||||
ctx.instance = instance.instance;
|
||||
ctx.publicPath = instance.publicPath;
|
||||
ctx.sharedPath = instance.sharedPath;
|
||||
ctx.isAuthenticated = !!instance.instance;
|
||||
|
||||
await next();
|
||||
|
@ -210,7 +211,13 @@ module.exports = (config, app) => {
|
|||
|
||||
if(path.startsWith("/api/")) {
|
||||
await next();
|
||||
} else {
|
||||
} else if(path.startsWith("/_shared/")) {
|
||||
await send(
|
||||
ctx,
|
||||
path.replace(`/_shared/`, ""),
|
||||
{ root: ctx.sharedPath });
|
||||
}
|
||||
else {
|
||||
await send(ctx, path, { root: ctx.publicPath });
|
||||
}
|
||||
})
|
||||
|
@ -347,8 +354,8 @@ module.exports = (config, app) => {
|
|||
ctx.body
|
||||
);
|
||||
ctx.response.status = StatusCodes.OK;
|
||||
})
|
||||
.post("/:appname/api/actionsAndTriggers", async (ctx) => {
|
||||
});
|
||||
/*.post("/:appname/api/actionsAndTriggers", async (ctx) => {
|
||||
ctx.body = await ctx.instance.templateApi.saveApplicationHierarchy(
|
||||
ctx.body
|
||||
);
|
||||
|
@ -359,7 +366,7 @@ module.exports = (config, app) => {
|
|||
ctx.body
|
||||
);
|
||||
ctx.response.status = StatusCodes.OK;
|
||||
});
|
||||
})*/
|
||||
|
||||
const getRecordKey = (appname, wholePath) =>
|
||||
wholePath
|
||||
|
|
|
@ -4,7 +4,7 @@ const { readFile } = require("fs-extra");
|
|||
const { hierarchy } = require("@budibase/core");
|
||||
const { take } = require("lodash/fp");
|
||||
const masterAppDefinition = constructHierarchy(
|
||||
require("../appPackages/master/appDefinition.json"));
|
||||
require("../appPackages/_master/appDefinition.json"));
|
||||
const {getApisWithFullAccess} = require("../utilities/budibaseApi");
|
||||
const { createTarGzPackage } = require("../utilities/targzAppPackage");
|
||||
const { timeout } = require("./helpers");
|
||||
|
|
|
@ -3,7 +3,7 @@ const constructHierarchy = require("../utilities/constructHierarchy");
|
|||
const { readFile } = require("fs-extra");
|
||||
const {getRecordApi, getAuthApi} = require("@budibase/core");
|
||||
const masterAppDefinition = constructHierarchy(
|
||||
require("../appPackages/master/appDefinition.json"));
|
||||
require("../appPackages/_master/appDefinition.json"));
|
||||
const {getApisWithFullAccess} = require("../utilities/budibaseApi");
|
||||
const { createTarGzPackage } = require("../utilities/targzAppPackage");
|
||||
const { timeout } = require("./helpers");
|
||||
|
|
|
@ -45,4 +45,26 @@ module.exports = (app) => {
|
|||
|
||||
});
|
||||
|
||||
|
||||
it("should serve file from shared when authenticated", async () => {
|
||||
const response = await app.get("/testApp/_shared/shared_file.txt")
|
||||
.set("cookie", app.credentials.testAppUser1.cookie)
|
||||
.expect(statusCodes.OK);
|
||||
|
||||
const expectedFile = await readFile("appPackages/testApp/public/_shared/shared_file.txt", "utf8");
|
||||
|
||||
expect(response.text).toBe(expectedFile);
|
||||
|
||||
});
|
||||
|
||||
it("should serve file from shared when not authenticated", async () => {
|
||||
const response = await app.get("/testApp/_shared/shared_file.txt")
|
||||
.expect(statusCodes.OK);
|
||||
|
||||
const expectedFile = await readFile("appPackages/testApp/public/_shared/shared_file.txt", "utf8");
|
||||
|
||||
expect(response.text).toBe(expectedFile);
|
||||
|
||||
});
|
||||
|
||||
}
|
|
@ -100,7 +100,7 @@ module.exports = () => {
|
|||
testAppInfo: {
|
||||
name: "testApp"
|
||||
},
|
||||
destroy: () => server.destroy(),
|
||||
destroy: () => server && server.destroy(),
|
||||
masterAppPackage: masterAppPackage({ config }),
|
||||
testAppInstance1AppPackage: async (app) => applictionVersionPackage(
|
||||
await buildAppContext(config, true),
|
||||
|
|
|
@ -64,7 +64,7 @@ const buildIndexHtml = async (config, appname, appPath, pages, pageName) => {
|
|||
|
||||
const templateObj = {
|
||||
title: pages[pageName].index.title || "Budibase App",
|
||||
favicon: `${appRootPath}/${pages[pageName].index.favicon || "/assets/favicon.png"}`,
|
||||
favicon: `${appRootPath}/${pages[pageName].index.favicon || "/_shared/favicon.png"}`,
|
||||
stylesheets: (pages.stylesheets || []).map(stylesheetUrl),
|
||||
appRootPath
|
||||
}
|
||||
|
|
|
@ -56,7 +56,8 @@ module.exports.masterAppPackage = (context) => {
|
|||
: plugins,
|
||||
appPath: standardPackage.appPath,
|
||||
unauthenticatedUiPath: standardPackage.unauthenticatedUiPath,
|
||||
mainUiPath: standardPackage.mainUiPath
|
||||
mainUiPath: standardPackage.mainUiPath,
|
||||
sharedPath: standardPackage.sharedPath
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -67,7 +68,9 @@ const publicPaths = (appPath) => ({
|
|||
mainUiPath: resolve(join(
|
||||
__dirname, appPath, "public", "main")),
|
||||
unauthenticatedUiPath: resolve(join(
|
||||
__dirname, appPath, "public", "unauthenticated"))
|
||||
__dirname, appPath, "public", "unauthenticated")),
|
||||
sharedPath: resolve(join(
|
||||
__dirname, appPath, "public", "_shared"))
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -152,14 +152,16 @@ module.exports = async (context) => {
|
|||
masterDatastore,
|
||||
masterAppPackage(context),
|
||||
session),
|
||||
publicPath: masterPkg.mainUiPath
|
||||
publicPath: masterPkg.mainUiPath,
|
||||
sharedPath: masterPkg.sharedPath
|
||||
});
|
||||
|
||||
|
||||
} catch(_) {
|
||||
return ({
|
||||
instance: null,
|
||||
publicPath: masterPkg.unauthenticatedUiPath
|
||||
publicPath: masterPkg.unauthenticatedUiPath,
|
||||
sharedPath: masterPkg.sharedPath
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -183,15 +185,18 @@ module.exports = async (context) => {
|
|||
instanceDatastore,
|
||||
appPackage,
|
||||
session),
|
||||
publicPath: appPackage.mainUiPath
|
||||
publicPath: appPackage.mainUiPath,
|
||||
sharedPath: appPackage.sharedPath
|
||||
});
|
||||
|
||||
} catch(_) {
|
||||
const appPublicPaths = applictionVersionPublicPaths(
|
||||
app.name,
|
||||
app.defaultVersion.id);
|
||||
return ({
|
||||
instance:null,
|
||||
publicPath: applictionVersionPublicPaths(
|
||||
app.name,
|
||||
app.defaultVersion.id).unauthenticatedUiPath
|
||||
publicPath: appPublicPaths.unauthenticatedUiPath,
|
||||
sharedPath: appPublicPaths.sharedPath
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue