Skip to content

Commit

Permalink
add variable in layout.ejs
Browse files Browse the repository at this point in the history
  • Loading branch information
phaneendraandukuri committed Feb 23, 2023
1 parent fa76d78 commit cb1bacb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
3 changes: 3 additions & 0 deletions app/server/handlers/render-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export async function renderLayout(res, params) {
get(params.store.getState(), ["qt", "config", "publisher-attributes", "placeholder_delay"])
);

const webengageLicenseCode = get(params.store.getState(), ["qt", "config", "webengage-config", "licenseCode"], "");

res.render(
"pages/layout",
Object.assign(
Expand Down Expand Up @@ -69,6 +71,7 @@ export async function renderLayout(res, params) {
placeholderDelay,
pageType,
enableBreakingNews: params.pageType !== "profile-page",
webengageLicenseCode,
},
params
)
Expand Down
21 changes: 12 additions & 9 deletions app/server/load-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getNavigationMenuArray } from "./data-loaders/menu-data";
import { loadCollectionPageData } from "./data-loaders/collection-page-data";
import { loadAuthorPageData } from "./data-loaders/author-page-data";
import { PAGE_TYPE } from "../isomorphic/constants";
import webengageConfig from "../../config/webengage-config";

const { ads } = require("@quintype/framework/server/static-configuration");

Expand All @@ -27,10 +28,10 @@ const WHITELIST_CONFIG_KEYS = [
"publisher-name",
"public-integrations",
"sketches-host",
"publisher-settings"
"publisher-settings",
];

const svgSpritePath = Array.from(getAssetFiles()).find(asset => asset.includes("sprite"));
const svgSpritePath = Array.from(getAssetFiles()).find((asset) => asset.includes("sprite"));

export function getPublisherAttributes(publisherYml = publisher) {
const publisherAttributes = get(publisherYml, ["publisher"], {});
Expand All @@ -42,15 +43,16 @@ export function loadErrorData(error, config) {
const errorComponents = { 404: "not-found" };
return Promise.resolve({
data: {
navigationMenu: getNavigationMenuArray(config.layout.menu, config.sections)
navigationMenu: getNavigationMenuArray(config.layout.menu, config.sections),
},
config: Object.assign(pick(config.asJson(), WHITELIST_CONFIG_KEYS), {
"publisher-attributes": publisherAttributes,
"webengage-config": webengageConfig,
"ads-config": ads,
svgSpritePath
svgSpritePath,
}),
pageType: errorComponents[error.httpStatusCode],
httpStatusCode: error.httpStatusCode || 500
httpStatusCode: error.httpStatusCode || 500,
});
}

Expand Down Expand Up @@ -89,22 +91,23 @@ export function loadData(pageType, params, config, client, { host, next, domainS
}
}

return _loadData().then(data => {
return _loadData().then((data) => {
return {
httpStatusCode: data.httpStatusCode || 200,
pageType: data.pageType || pageType,
data: Object.assign({}, data, {
navigationMenu: getNavigationMenuArray(config.layout.menu, config.sections),
timezone: publisherAttributes.timezone || null
timezone: publisherAttributes.timezone || null,
}),
config: Object.assign(pick(config.asJson(), WHITELIST_CONFIG_KEYS), {
"publisher-attributes": publisherAttributes,
"webengage-config": webengageConfig,
"image-cdn-format": "gumlet",
"ads-config": ads,
svgSpritePath,
domainSlug,
showPlaceholder: publisherAttributes.enable_placeholder
})
showPlaceholder: publisherAttributes.enable_placeholder,
}),
};
});
}
2 changes: 1 addition & 1 deletion views/pages/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<script id='_webengage_script_tag' type='text/javascript'>
var webengage; !function(w,e,b,n,g){function o(e,t){e[t[t.length-1]]=function(){r.__queue.push([t.join("."),arguments])}}var i,s,r=w[b],z=" ",l="init options track screen onReady".split(z),a="feedback survey notification".split(z),c="options render clear abort".split(z),p="Open Close Submit Complete View Click".split(z),u="identify login logout setAttribute".split(z);if(!r||!r.__v){for(w[b]=r={__queue:[],__v:"6.0",user:{}},i=0;i<l.length;i++)o(r,[l[i]]);for(i=0;i<a.length;i++){for(r[a[i]]={},s=0;s<c.length;s++)o(r[a[i]],[a[i],c[s]]);for(s=0;s<p.length;s++)o(r[a[i]],[a[i],"on"+p[s]])}for(i=0;i<u.length;i++)o(r.user,["user",u[i]]);setTimeout(function(){var f=e.createElement("script"),d=e.getElementById("_webengage_script_tag");f.type="text/javascript",f.async=!0,f.src=("https:"==e.location.protocol?"https://ssl.widgets.webengage.com":"http://cdn.widgets.webengage.com")+"/js/webengage-min-v-6.0.js",d.parentNode.insertBefore(f,d)})}}(window,document,"webengage");
webengage.init('~10a5cb515');
webengage.init("<%- webengageLicenseCode -%>");
webengage.user.setAttribute('user_type', 'malibu_user');
</script>
</head>
Expand Down

0 comments on commit cb1bacb

Please sign in to comment.