From 13bf57211f4378ca1ca45f7f0d662f911a9fd25f Mon Sep 17 00:00:00 2001 From: rgravitvl Date: Thu, 26 Oct 2023 19:01:23 +0530 Subject: [PATCH 01/52] Updated for product detail page --- scripts/scripts.js | 1 + templates/product/product.js | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 templates/product/product.js diff --git a/scripts/scripts.js b/scripts/scripts.js index 5da2bbe93..7322c3e30 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -22,6 +22,7 @@ const LCP_BLOCKS = ['breadcrumb']; // add your LCP blocks to the list const TEMPLATE_LIST = { blog: 'blog', news: 'blog', + 'product-family': 'product', }; /** diff --git a/templates/product/product.js b/templates/product/product.js new file mode 100644 index 000000000..2f34e0803 --- /dev/null +++ b/templates/product/product.js @@ -0,0 +1,38 @@ +function getCoveoApiPayload() { + const sku = window.location.pathname.split('/')?.slice(-1).at(0).split('.').at(0); + const paylod = { + context: { + host: 'stage.lifesciences.danaher.com', + internal: false + }, + q: `@familyid==${sku}`, + pipeline: 'Product Details', + } + return paylod; +} + +async function makeCoveoApiRequest(path, payload = {}) { + const accessToken = window.DanaherConfig !== undefined + ? window.DanaherConfig.familyProductKey + : 'xx2a2e7271-78c3-4e3b-bac3-2fcbab75323b'; + const organizationId = window.DanaherConfig !== undefined + ? window.DanaherConfig.searchOrg + : 'danahernonproduction1892f3fhz'; + const resp = await fetch(`https://${organizationId}.org.coveo.com${path}?organizationId=${organizationId}`, { + method: 'POST', + headers: { + authorization: `Bearer ${accessToken}`, + 'content-type': 'application/json', + }, + body: JSON.stringify(payload), + }); + const jsonData = await resp.json(); + return jsonData; + } + +export default async function buildAutoBlocks() { + const main = document.querySelector('main'); + makeCoveoApiRequest('/rest/search/v2', getCoveoApiPayload()).then((data) => { + console.log(data); + }) +} \ No newline at end of file From a49cfafc62b7bf50bf304ba11093cac7bf5c66dd Mon Sep 17 00:00:00 2001 From: wz914876 Date: Tue, 19 Dec 2023 19:15:04 +0530 Subject: [PATCH 02/52] initial commit --- blocks/header/header.js | 2 +- styles/styles.css | 16 ++++++++++++++++ styles/tailwind.css | 4 ++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/blocks/header/header.js b/blocks/header/header.js index 82f354b79..918b78c2c 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -642,7 +642,7 @@ function buildFlyoutMenus(headerBlock) { { class: 'inline-flex justify-between items-center mb-2' }, span({ class: 'text-left text-xl font-bold py-2 pl-1 text-gray-900 w-1/2' }, menuTitle), menuItemEl.querySelector(':scope > p > a') - ? a({ class: 'btn btn-info', href: menuItemEl.querySelector(':scope > p > a').href }, 'Explore All') : '', + ? a({ class: 'btn btn-info rounded-full', href: menuItemEl.querySelector(':scope > p > a').href }, 'Explore All') : '', ), linkList, ), diff --git a/styles/styles.css b/styles/styles.css index d3443c236..69483a24e 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -2169,6 +2169,22 @@ main .section.carousel-container { color: rgb(255 255 255 / var(--tw-text-opacity)); } +.btn-info { + --tw-border-opacity: 1; + border-color: rgb(59 199 229 / var(--tw-border-opacity)); + --tw-bg-opacity: 1; + background-color: rgb(59 199 229 / var(--tw-bg-opacity)); + --tw-text-opacity: 1; + color: rgb(255 255 255 / var(--tw-text-opacity)); +} + +.btn-info:hover { + --tw-border-opacity: 1; + border-color: rgb(1 139 157 / var(--tw-border-opacity)); + --tw-bg-opacity: 1; + background-color: rgb(1 139 157 / var(--tw-bg-opacity)); +} + .sticky-footer { position: fixed; bottom: 0.75rem; diff --git a/styles/tailwind.css b/styles/tailwind.css index 20ab1ebde..60dfe871f 100644 --- a/styles/tailwind.css +++ b/styles/tailwind.css @@ -166,6 +166,10 @@ @apply text-danaherpurple-500 bg-white border-2 border-danaherpurple-500 hover:text-white hover:bg-danaherpurple-500; } + .btn-info { + @apply text-white bg-lightblue-500 hover:bg-lightblue-600 border-lightblue-500 hover:border-lightblue-600; + } + .form-input, .form-select, .form-date { From 95b92fda06e20105f1960f544988f13e57dfa4a7 Mon Sep 17 00:00:00 2001 From: Markus Haack Date: Wed, 20 Dec 2023 13:43:46 +0100 Subject: [PATCH 03/52] feat: add support for folders and product metadata --- fstab.yaml | 6 ++++++ paths.yaml | 1 + 2 files changed, 7 insertions(+) diff --git a/fstab.yaml b/fstab.yaml index b2b9b9a4a..bb13db392 100644 --- a/fstab.yaml +++ b/fstab.yaml @@ -3,3 +3,9 @@ mountpoints: url: https://1050314-569danaherxwalk-stage.adobeioruntime.net/api/v1/web/convert/main/ type: markup suffix: ".html?wcmmode=disabled" + +folders: + /us/en/products/family/: /us/en/products/product-coveo + /us/en/products/sku/: /us/en/products/product-coveo + /us/en/products/bundles/: /us/en/products/product-coveo + \ No newline at end of file diff --git a/paths.yaml b/paths.yaml index ca1df4555..8db3067fa 100644 --- a/paths.yaml +++ b/paths.yaml @@ -5,6 +5,7 @@ mappings: - /content/dam/danaher/franklin/config.json:/.helix/config.json - /content/dam/danaher/franklin/headers.json:/.helix/headers.json - /content/dam/danaher/franklin/metadata.json:/metadata.json + - /content/dam/danaher/franklin/metadata-products.json:/metadata-products.json - /content/dam/danaher/franklin/redirects.json:/redirects.json includes: From 3e80abdd2a4a5cba0d46c058766aabcdc2d37457 Mon Sep 17 00:00:00 2001 From: rgravitvl Date: Wed, 20 Dec 2023 22:45:50 +0530 Subject: [PATCH 04/52] updated converter for product overview --- tools/importer/transformers/columns.js | 73 +++++++++++-------- .../transformers/fullLayoutSection.js | 2 +- tools/importer/transformers/index.js | 2 + tools/importer/transformers/productMenu.js | 5 ++ tools/importer/transformers/util.js | 22 +++++- 5 files changed, 70 insertions(+), 34 deletions(-) create mode 100644 tools/importer/transformers/productMenu.js diff --git a/tools/importer/transformers/columns.js b/tools/importer/transformers/columns.js index 590d15603..372538aca 100644 --- a/tools/importer/transformers/columns.js +++ b/tools/importer/transformers/columns.js @@ -1,8 +1,8 @@ import { - featureImage, imageText, getHeading, getAEMHeading, + featureImage, imageText, getHeading, + getAEMHeading, videoembed, getFutureSectionCard } from './util.js'; /* global WebImporter */ - const render = { featureimage: (item, row, document) => { const featureImages = (item.content) ? item.content.querySelectorAll('div.featureimage') : [item]; @@ -30,27 +30,59 @@ const render = { heading: (item, row, document) => { const heading = item.content ? item.content.querySelector('div.heading') : item; if (heading) { - const headingEL = getHeading(heading, document); - row.push(headingEL); + getHeading(heading, document); + row.push(heading); } }, 'heading-aem': (item, row, document) => { const aemHeading = (item.content) ? item.content.querySelector('div.heading-aem') : item; if (aemHeading) { - const aemHeadingEL = getAEMHeading(aemHeading, document); - row.push(aemHeadingEL); + getAEMHeading(aemHeading, document); + row.push(aemHeading); + } + }, + + 'featuresection-card': (item, row, document) => { + const featureSectionCardEl = (item.content) ? item.content.querySelector('div.featuresection-card') : item; + if (featureSectionCardEl) { + getFutureSectionCard(featureSectionCardEl, document) + row.push(featureSectionCardEl); } }, - script: (template, row) => { - const featureImageEl = template.content.querySelector('div.featureimage'); + script: (item, row) => { + const featureImageEl = item.content.querySelector('div.featureimage'); if (featureImageEl) { row.push(featureImageEl); } }, + + text: (item, row) => { + const text = item.content.querySelector('div.text'); + if (text) row.push(text); + }, + + video: (item, row, document) => { + const videoEl = item.content ? item.content.querySelector('div.video') : item; + videoembed(videoEl, document) + row.push(videoEl); + }, }; +const updateBlockName = (blockName, option) => { + const match = blockName.match(/Columns\s*\(\s*([^)]*)\s*\)/); + if (match) { + const contentInsideParentheses = match[1]; + const updatedString = `Columns (${contentInsideParentheses}, ${option})`; + blockName = updatedString; + } else { + const updatedString = `Columns (${option})`; + blockName = updatedString; + } + return blockName; +} + const createAllColumns = (allColumns, document, noOfColumn) => { allColumns.forEach((item) => { const columns = []; @@ -60,7 +92,7 @@ const createAllColumns = (allColumns, document, noOfColumn) => { else blockName = 'Columns (itemscenter)'; } else if (noOfColumn === 3) blockName = 'Columns (cols-3)'; else blockName = 'Columns'; - + const templates = item.querySelectorAll('template'); [...templates].forEach((template) => { if (template.content.children.length > 0) { @@ -69,28 +101,11 @@ const createAllColumns = (allColumns, document, noOfColumn) => { if (element.className === 'container responsivegrid') { const container = template.content.querySelector('div.cmp-container'); if (container) { - const match = blockName.match(/Columns\s*\(\s*([^)]*)\s*\)/); - if (match) { - const contentInsideParentheses = match[1]; - const updatedString = `Columns (${contentInsideParentheses}, ${container.id})`; - blockName = updatedString; - } else { - const updatedString = `Columns (${container.id})`; - blockName = updatedString; - } + blockName = updateBlockName(blockName, container.id); [...container.children].forEach((childItem) => { render[childItem.className](childItem, row, document); }); } - } else if (element.className === 'script') { - const featureImageElem = template.content.querySelector('div.featureimage'); - - if (featureImageElem) { - row.push(featureImageElem); - } - } else if (element.className === 'text') { - const text = template.content.querySelector('div.text'); - if (text) row.push(text); } else if (element.className !== 'articlecard') { render[element.className](template, row, document); } @@ -100,9 +115,9 @@ const createAllColumns = (allColumns, document, noOfColumn) => { }); const cells = [ [blockName], - [...columns], + columns, ]; - + if (columns.flat(1).length > 0) { const block = WebImporter.DOMUtils.createTable(cells, document); item.append(block); diff --git a/tools/importer/transformers/fullLayoutSection.js b/tools/importer/transformers/fullLayoutSection.js index c6a895eef..70ab19a97 100644 --- a/tools/importer/transformers/fullLayoutSection.js +++ b/tools/importer/transformers/fullLayoutSection.js @@ -10,7 +10,7 @@ const createFullLayoutSection = (main, document) => { const table = WebImporter.DOMUtils.createTable(cells, document); e.after(table); if ((arr.length === 1 || i < arr.length - 1) - && !e.parentNode.nextElementSibling.className.includes('carousel')) { + && !e.parentNode.nextElementSibling?.className.includes('carousel')) { table.after(document.createElement('hr')); } styleIndex += 1; diff --git a/tools/importer/transformers/index.js b/tools/importer/transformers/index.js index b8441d07b..afdadade7 100644 --- a/tools/importer/transformers/index.js +++ b/tools/importer/transformers/index.js @@ -37,6 +37,7 @@ import productCategoryList from './productCategoryList.js'; import opcoHomeArticlesList from './opcoHomeArticlesList.js'; import socialFeeds from './socialFeeds.js'; import postProcessSVGIcons from './postProcessSVGIcons.js'; +import productMenu from './productMenu.js'; // eslint-disable-next-line import/prefer-default-export export const transformers = [ @@ -74,6 +75,7 @@ export const transformers = [ productCategoryList, opcoHomeArticlesList, socialFeeds, + productMenu ]; export const xfTransformers = [ diff --git a/tools/importer/transformers/productMenu.js b/tools/importer/transformers/productMenu.js new file mode 100644 index 000000000..53ba2325c --- /dev/null +++ b/tools/importer/transformers/productMenu.js @@ -0,0 +1,5 @@ +const createProductMenu = (main, document) => { + const productMenu = main.querySelector('div.product-menu'); + console.log(productMenu.outerHTML); +}; +export default createProductMenu; diff --git a/tools/importer/transformers/util.js b/tools/importer/transformers/util.js index 5de6c1bd0..5c970ee2e 100644 --- a/tools/importer/transformers/util.js +++ b/tools/importer/transformers/util.js @@ -45,6 +45,22 @@ const cleanUpHTML = (html) => { return html; }; +export const getFutureSectionCard = (featureSectionCardDiv, document) => { + const featureSectionCardEL = featureSectionCardDiv?.querySelector('featuresection-card'); + const title = featureSectionCardEL?.getAttribute('title') + const description = featureSectionCardEL?.getAttribute('description') + const image = featureSectionCardEL?.getAttribute('card-image') + const titleDivEl = document.createElement('div'); + titleDivEl.textContent = title; + featureSectionCardDiv.append(titleDivEl) + const pEl = document.createElement('p'); + pEl.textContent = description; + featureSectionCardDiv.append(pEl) + const imgEl = document.createElement('img'); + imgEl.src = image; + featureSectionCardDiv.append(imgEl) +}; + export const mapTable = (table, document) => { let tHead = table.querySelector('thead'); if (!tHead) { @@ -64,15 +80,14 @@ export const getHeading = (heading, document) => { if (heading.nextElementSibling && [...heading.nextElementSibling.classList].includes('featureimage')) { const text = document.createElement('strong'); text.textContent = headingEL?.getAttribute('heading'); - headingEL.append(text); + heading.append(text); } else { const hTag = headingEL?.getAttribute('headingtag') ? headingEL?.getAttribute('headingtag') : 'h2'; const headEl = document.createElement(hTag); headEl.textContent = headingEL?.getAttribute('heading'); - headingEL.append(headEl); + heading.append(headEl); } } - return headingEL; }; export const getAEMHeading = (aemHeading, document) => { @@ -84,7 +99,6 @@ export const getAEMHeading = (aemHeading, document) => { } else { aemHeading.append(aemHeading.firstElementChild); } - return aemHeading; }; export const featureImage = (featureImg, document) => { From 6d73273be387429ed5e025141cde19d8028b574e Mon Sep 17 00:00:00 2001 From: rgravitvl Date: Thu, 21 Dec 2023 15:26:45 +0530 Subject: [PATCH 05/52] updated product converter --- .../test/fixtures/product-converted.html | 30 ++------ tools/importer/transformers/columns.js | 71 +------------------ tools/importer/transformers/product.js | 47 ++++++++---- tools/importer/transformers/productMenu.js | 2 +- tools/importer/transformers/util.js | 67 +++++++++++++++++ 5 files changed, 107 insertions(+), 110 deletions(-) diff --git a/tools/actions/convert/test/fixtures/product-converted.html b/tools/actions/convert/test/fixtures/product-converted.html index 640bb1fdc..0f079ce78 100644 --- a/tools/actions/convert/test/fixtures/product-converted.html +++ b/tools/actions/convert/test/fixtures/product-converted.html @@ -26,13 +26,9 @@