[develop | DONE | ADDED] server.ts add custom css when generating the community css
This commit is contained in:
parent
d15c3bd565
commit
75714b8b27
10
server.ts
10
server.ts
|
@ -26,7 +26,7 @@ var bodyParser = require('body-parser')
|
||||||
|
|
||||||
var jsonParser = bodyParser.json()
|
var jsonParser = bodyParser.json()
|
||||||
|
|
||||||
function buildCss(portal: string, suffix = null, variables: {} = null) {
|
function buildCss(portal: string, suffix = null, variables: {} = null, customCss = "") {
|
||||||
let lessFile = 'community.less'
|
let lessFile = 'community.less'
|
||||||
if (portal === 'connect') {
|
if (portal === 'connect') {
|
||||||
lessFile = 'connect.less'
|
lessFile = 'connect.less'
|
||||||
|
@ -48,7 +48,7 @@ function buildCss(portal: string, suffix = null, variables: {} = null) {
|
||||||
rewriteUrls: 'all',
|
rewriteUrls: 'all',
|
||||||
modifyVars: modifyVars
|
modifyVars: modifyVars
|
||||||
};
|
};
|
||||||
less.render(input, options, function (error, result) {
|
less.render(customCss + input , options, function (error, result) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,7 +80,7 @@ function buildAll(res: Response = null) {
|
||||||
if (response.data && Array.isArray(response.data) && response.data.length > 0) {
|
if (response.data && Array.isArray(response.data) && response.data.length > 0) {
|
||||||
response.data.forEach((layout: Layout) => {
|
response.data.forEach((layout: Layout) => {
|
||||||
let variables = Layout.getVariables(CustomizationOptions.checkForObsoleteVersion(layout.layoutOptions, layout.portalPid));
|
let variables = Layout.getVariables(CustomizationOptions.checkForObsoleteVersion(layout.layoutOptions, layout.portalPid));
|
||||||
buildCss(layout.portalPid, layout.date ? layout.date : null, variables);
|
buildCss(layout.portalPid, layout.date ? layout.date : null, variables, layout.layoutOptions.identity.customCss);
|
||||||
});
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
res.status(200).send({
|
res.status(200).send({
|
||||||
|
@ -191,7 +191,7 @@ export function app() {
|
||||||
|
|
||||||
server.post('/build-css/:id/:suffix', jsonParser,(req, res) => {
|
server.post('/build-css/:id/:suffix', jsonParser,(req, res) => {
|
||||||
let variables = Layout.getVariables(CustomizationOptions.checkForObsoleteVersion(req.body, req.params.id));
|
let variables = Layout.getVariables(CustomizationOptions.checkForObsoleteVersion(req.body, req.params.id));
|
||||||
buildCss(req.params.id , req.params.suffix, variables);
|
buildCss(req.params.id , req.params.suffix, variables, req.body.layoutOptions.identity.customCss);
|
||||||
res.status(200).send({
|
res.status(200).send({
|
||||||
code: 200,
|
code: 200,
|
||||||
message: 'CSS build for ' + req.params.id + ' layout was successful'
|
message: 'CSS build for ' + req.params.id + ' layout was successful'
|
||||||
|
@ -200,7 +200,7 @@ export function app() {
|
||||||
|
|
||||||
server.post('/build-css/preview/:id/:suffix', jsonParser, (req, res) => {
|
server.post('/build-css/preview/:id/:suffix', jsonParser, (req, res) => {
|
||||||
let variables = Layout.getVariables(CustomizationOptions.checkForObsoleteVersion(req.body, req.params.id));
|
let variables = Layout.getVariables(CustomizationOptions.checkForObsoleteVersion(req.body, req.params.id));
|
||||||
buildCss(req.params.id, req.params.suffix, variables);
|
buildCss(req.params.id, req.params.suffix, variables, req.body.identity.customCss);
|
||||||
res.status(200).send({code: 200, message: 'CSS build for ' + req.params.id + ' layout was successful'});
|
res.status(200).send({code: 200, message: 'CSS build for ' + req.params.id + ' layout was successful'});
|
||||||
});
|
});
|
||||||
server.get('/health-check', async (_req, res, _next) => {
|
server.get('/health-check', async (_req, res, _next) => {
|
||||||
|
|
Loading…
Reference in New Issue