From ec4cf973704296f5ab5074e0329b51b3358f6388 Mon Sep 17 00:00:00 2001 From: Ruchika Sinha <69535463+Ruchika4@users.noreply.github.com> Date: Mon, 24 Apr 2023 13:53:00 -0700 Subject: [PATCH] Sync main branch with stage (#30) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * WPS-21878 MWPW-127801 Changing git scrips and css lib folder name to creativecloud * MWPW-127801 Changing eslint folders to creativecloud * Update codeql.yml * Update run-tests.yaml * move icons to /creativecloud/img/icons * fix preview issue for promotions page * Update article-promotion.js * fix preview issue for promotions page * Update article-promotion.js * Update article-promotion.js * Update article-promotion.js * Adding more CC locales * Update scripts.js * Update article-promotion.js * Update scripts.js * Update codeql.yml * Update run-tests.yaml * Update scripts.js * Update scripts.js * Update scripts.js * Update scripts.js * Return if promotion block exists withour data-attribute * Update scripts.js * Update scripts.js * Update contentRoot (#33) * Re-adding content root --------- Co-authored-by: mathuria Co-authored-by: Solène Duprat Co-authored-by: Ruchika Sinha --- .github/workflows/codeql.yml | 4 +- .github/workflows/run-tests.yaml | 2 + 404.html | 2 +- cc/scripts/scripts.js | 75 --------- .../blocks/promotion/promotion.css | 0 .../blocks/promotion/promotion.js | 1 + .../features/article-promotion.js | 0 .../img/favicons/favicon-180.png | Bin .../img/favicons/favicon-192.png | Bin .../img/favicons/favicon-512.png | Bin .../img/favicons/favicon.ico | Bin .../img/favicons/favicon.svg | 0 .../img/favicons/favicon.webmanifest | 0 creativecloud/img/icons/3d-assets.svg | 27 +++ creativecloud/img/icons/designer.svg | 25 +++ creativecloud/img/icons/modeler.svg | 30 ++++ creativecloud/img/icons/painter.svg | 44 +++++ creativecloud/img/icons/sampler.svg | 44 +++++ creativecloud/img/icons/stager.svg | 63 +++++++ {cc => creativecloud}/scripts/fallback.js | 0 creativecloud/scripts/scripts.js | 154 ++++++++++++++++++ {cc => creativecloud}/scripts/utils.js | 0 {cc => creativecloud}/styles/styles.css | 0 head.html | 4 +- package.json | 2 +- test/blocks/promotion/promotion.test.js | 2 +- test/features/article-promotion.test.js | 2 +- 27 files changed, 398 insertions(+), 83 deletions(-) delete mode 100644 cc/scripts/scripts.js rename {cc => creativecloud}/blocks/promotion/promotion.css (100%) rename {cc => creativecloud}/blocks/promotion/promotion.js (93%) rename {cc => creativecloud}/features/article-promotion.js (100%) rename {cc => creativecloud}/img/favicons/favicon-180.png (100%) rename {cc => creativecloud}/img/favicons/favicon-192.png (100%) rename {cc => creativecloud}/img/favicons/favicon-512.png (100%) rename {cc => creativecloud}/img/favicons/favicon.ico (100%) rename {cc => creativecloud}/img/favicons/favicon.svg (100%) rename {cc => creativecloud}/img/favicons/favicon.webmanifest (100%) create mode 100644 creativecloud/img/icons/3d-assets.svg create mode 100644 creativecloud/img/icons/designer.svg create mode 100644 creativecloud/img/icons/modeler.svg create mode 100644 creativecloud/img/icons/painter.svg create mode 100644 creativecloud/img/icons/sampler.svg create mode 100644 creativecloud/img/icons/stager.svg rename {cc => creativecloud}/scripts/fallback.js (100%) create mode 100644 creativecloud/scripts/scripts.js rename {cc => creativecloud}/scripts/utils.js (100%) rename {cc => creativecloud}/styles/styles.css (100%) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 09f76d712..9aac6cf51 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,10 +13,10 @@ name: "CodeQL" on: push: - branches: [ "main" ] + branches: [ "stage", "main" ] pull_request: # The branches below must be a subset of the branches above - branches: [ "main" ] + branches: [ "stage", "main" ] schedule: # Scheduled to run at 06:18 every Friday - cron: '18 6 * * 5' diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 2f31d74f4..1f6257c01 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -2,10 +2,12 @@ name: Unit Tests and Linting on: push: branches: + - stage - main pull_request: types: [opened, synchronize, reopened, edited] branches: + - stage - main jobs: run-tests: diff --git a/404.html b/404.html index 991601b8c..e3ce8e1d8 100644 --- a/404.html +++ b/404.html @@ -5,7 +5,7 @@ 404 - + diff --git a/cc/scripts/scripts.js b/cc/scripts/scripts.js deleted file mode 100644 index 16d5509c3..000000000 --- a/cc/scripts/scripts.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2023 Adobe. All rights reserved. - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -import { setLibs } from './utils.js'; - -// Add project-wide style path here. -const STYLES = '/cc/styles/styles.css'; - -// Use '/libs' if your live site maps '/libs' to milo's origin. -const LIBS = 'https://milo.adobe.com/libs'; - -// Add any config options. -const CONFIG = { - codeRoot: '/cc', - contentRoot: '/creativecloud', - imsClientId: 'ccmilo', - locales: { - '': { ietf: 'en-US', tk: 'hah7vzn.css' }, - de: { ietf: 'de-DE', tk: 'hah7vzn.css' }, - kr: { ietf: 'ko-KR', tk: 'zfo3ouc' }, - th_th: { ietf: 'th–TH', tk: 'zfo3ouc' }, - }, - geoRouting: 'on', - prodDomains: ['www.adobe.com'], -}; - -// Load LCP image immediately -(async function loadLCPImage() { - const lcpImg = document.querySelector('img'); - lcpImg?.removeAttribute('loading'); -}()); - -async function loadArticlePromo(getMetadata) { - const promoEl = document.querySelector('main .promotion'); - const promoMeta = getMetadata('promotion'); - if (!(promoEl) && !(promoMeta)) return; - const { default: decoratePromo } = await import('../features/article-promotion.js'); - decoratePromo(promoMeta); -} - -/* - * ------------------------------------------------------------ - * Edit below at your own risk - * ------------------------------------------------------------ - */ - -const miloLibs = setLibs(LIBS); - -(function loadStyles() { - const paths = [`${miloLibs}/styles/styles.css`]; - if (STYLES) { paths.push(STYLES); } - paths.forEach((path) => { - const link = document.createElement('link'); - link.setAttribute('rel', 'stylesheet'); - link.setAttribute('href', path); - document.head.appendChild(link); - }); -}()); - -(async function loadPage() { - const { getMetadata, loadArea, loadDelayed, setConfig } = await import(`${miloLibs}/utils/utils.js`); - await loadArticlePromo(getMetadata); - setConfig({ ...CONFIG, miloLibs }); - await loadArea(); - loadDelayed(); -}()); diff --git a/cc/blocks/promotion/promotion.css b/creativecloud/blocks/promotion/promotion.css similarity index 100% rename from cc/blocks/promotion/promotion.css rename to creativecloud/blocks/promotion/promotion.css diff --git a/cc/blocks/promotion/promotion.js b/creativecloud/blocks/promotion/promotion.js similarity index 93% rename from cc/blocks/promotion/promotion.js rename to creativecloud/blocks/promotion/promotion.js index 057c64e5d..211d3dd0c 100644 --- a/cc/blocks/promotion/promotion.js +++ b/creativecloud/blocks/promotion/promotion.js @@ -1,5 +1,6 @@ export default async function init(el, promotionPath = '/creativecloud/promotions/hub') { const promotionName = el.getAttribute('data-promotion'); + if (!promotionName) return; const response = await window.fetch(`${promotionPath}/${promotionName}.plain.html`); if (!response.ok) return; const promotionContent = await response.text(); diff --git a/cc/features/article-promotion.js b/creativecloud/features/article-promotion.js similarity index 100% rename from cc/features/article-promotion.js rename to creativecloud/features/article-promotion.js diff --git a/cc/img/favicons/favicon-180.png b/creativecloud/img/favicons/favicon-180.png similarity index 100% rename from cc/img/favicons/favicon-180.png rename to creativecloud/img/favicons/favicon-180.png diff --git a/cc/img/favicons/favicon-192.png b/creativecloud/img/favicons/favicon-192.png similarity index 100% rename from cc/img/favicons/favicon-192.png rename to creativecloud/img/favicons/favicon-192.png diff --git a/cc/img/favicons/favicon-512.png b/creativecloud/img/favicons/favicon-512.png similarity index 100% rename from cc/img/favicons/favicon-512.png rename to creativecloud/img/favicons/favicon-512.png diff --git a/cc/img/favicons/favicon.ico b/creativecloud/img/favicons/favicon.ico similarity index 100% rename from cc/img/favicons/favicon.ico rename to creativecloud/img/favicons/favicon.ico diff --git a/cc/img/favicons/favicon.svg b/creativecloud/img/favicons/favicon.svg similarity index 100% rename from cc/img/favicons/favicon.svg rename to creativecloud/img/favicons/favicon.svg diff --git a/cc/img/favicons/favicon.webmanifest b/creativecloud/img/favicons/favicon.webmanifest similarity index 100% rename from cc/img/favicons/favicon.webmanifest rename to creativecloud/img/favicons/favicon.webmanifest diff --git a/creativecloud/img/icons/3d-assets.svg b/creativecloud/img/icons/3d-assets.svg new file mode 100644 index 000000000..e091f2a95 --- /dev/null +++ b/creativecloud/img/icons/3d-assets.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + diff --git a/creativecloud/img/icons/designer.svg b/creativecloud/img/icons/designer.svg new file mode 100644 index 000000000..b82e38d1f --- /dev/null +++ b/creativecloud/img/icons/designer.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/creativecloud/img/icons/modeler.svg b/creativecloud/img/icons/modeler.svg new file mode 100644 index 000000000..16ae93cfe --- /dev/null +++ b/creativecloud/img/icons/modeler.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/creativecloud/img/icons/painter.svg b/creativecloud/img/icons/painter.svg new file mode 100644 index 000000000..5defd09e2 --- /dev/null +++ b/creativecloud/img/icons/painter.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/creativecloud/img/icons/sampler.svg b/creativecloud/img/icons/sampler.svg new file mode 100644 index 000000000..56da3551e --- /dev/null +++ b/creativecloud/img/icons/sampler.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/creativecloud/img/icons/stager.svg b/creativecloud/img/icons/stager.svg new file mode 100644 index 000000000..dc6fe78b2 --- /dev/null +++ b/creativecloud/img/icons/stager.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/cc/scripts/fallback.js b/creativecloud/scripts/fallback.js similarity index 100% rename from cc/scripts/fallback.js rename to creativecloud/scripts/fallback.js diff --git a/creativecloud/scripts/scripts.js b/creativecloud/scripts/scripts.js new file mode 100644 index 000000000..38c3d8ad8 --- /dev/null +++ b/creativecloud/scripts/scripts.js @@ -0,0 +1,154 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import { setLibs } from './utils.js'; + +// Add project-wide style path here. +const STYLES = '/creativecloud/styles/styles.css'; + +// Use '/libs' if your live site maps '/libs' to milo's origin. +const LIBS = 'https://milo.adobe.com/libs'; + +const locales = { + // Americas + ar: { ietf: 'es-AR', tk: 'oln4yqj.css' }, + br: { ietf: 'pt-BR', tk: 'inq1xob.css' }, + ca: { ietf: 'en-CA', tk: 'pps7abe.css' }, + ca_fr: { ietf: 'fr-CA', tk: 'vrk5vyv.css' }, + cl: { ietf: 'es-CL', tk: 'oln4yqj.css' }, + co: { ietf: 'es-CO', tk: 'oln4yqj.css' }, + la: { ietf: 'es-LA', tk: 'oln4yqj.css' }, + mx: { ietf: 'es-MX', tk: 'oln4yqj.css' }, + pe: { ietf: 'es-PE', tk: 'oln4yqj.css' }, + '': { ietf: 'en-US', tk: 'hah7vzn.css' }, + // EMEA + africa: { ietf: 'en', tk: 'pps7abe.css' }, + be_fr: { ietf: 'fr-BE', tk: 'vrk5vyv.css' }, + be_en: { ietf: 'en-BE', tk: 'pps7abe.css' }, + be_nl: { ietf: 'nl-BE', tk: 'cya6bri.css' }, + cy_en: { ietf: 'en-CY', tk: 'pps7abe.css' }, + dk: { ietf: 'da-DK', tk: 'aaz7dvd.css' }, + de: { ietf: 'de-DE', tk: 'vin7zsi.css' }, + ee: { ietf: 'et-EE', tk: 'aaz7dvd.css' }, + es: { ietf: 'es-ES', tk: 'oln4yqj.css' }, + fr: { ietf: 'fr-FR', tk: 'vrk5vyv.css' }, + gr_en: { ietf: 'en-GR', tk: 'pps7abe.css' }, + ie: { ietf: 'en-GB', tk: 'pps7abe.css' }, + il_en: { ietf: 'en-IL', tk: 'pps7abe.css' }, + it: { ietf: 'it-IT', tk: 'bbf5pok.css' }, + lv: { ietf: 'lv-LV', tk: 'aaz7dvd.css' }, + lt: { ietf: 'lt-LT', tk: 'aaz7dvd.css' }, + lu_de: { ietf: 'de-LU', tk: 'vin7zsi.css' }, + lu_en: { ietf: 'en-LU', tk: 'pps7abe.css' }, + lu_fr: { ietf: 'fr-LU', tk: 'vrk5vyv.css' }, + hu: { ietf: 'hu-HU', tk: 'aaz7dvd.css' }, + mt: { ietf: 'en-MT', tk: 'pps7abe.css' }, + mena_en: { ietf: 'en', tk: 'pps7abe.css' }, + nl: { ietf: 'nl-NL', tk: 'cya6bri.css' }, + no: { ietf: 'no-NO', tk: 'aaz7dvd.css' }, + pl: { ietf: 'pl-PL', tk: 'aaz7dvd.css' }, + pt: { ietf: 'pt-PT', tk: 'inq1xob.css' }, + ro: { ietf: 'ro-RO', tk: 'aaz7dvd.css' }, + sa_en: { ietf: 'en', tk: 'pps7abe.css' }, + ch_de: { ietf: 'de-CH', tk: 'vin7zsi.css' }, + si: { ietf: 'sl-SI', tk: 'aaz7dvd.css' }, + sk: { ietf: 'sk-SK', tk: 'aaz7dvd.css' }, + ch_fr: { ietf: 'fr-CH', tk: 'vrk5vyv.css' }, + fi: { ietf: 'fi-FI', tk: 'aaz7dvd.css' }, + se: { ietf: 'sv-SE', tk: 'fpk1pcd.css' }, + ch_it: { ietf: 'it-CH', tk: 'bbf5pok.css' }, + tr: { ietf: 'tr-TR', tk: 'aaz7dvd.css' }, + ae_en: { ietf: 'en', tk: 'pps7abe.css' }, + uk: { ietf: 'en-GB', tk: 'pps7abe.css' }, + at: { ietf: 'de-AT', tk: 'vin7zsi.css' }, + cz: { ietf: 'cs-CZ', tk: 'aaz7dvd.css' }, + bg: { ietf: 'bg-BG', tk: 'aaz7dvd.css' }, + ru: { ietf: 'ru-RU', tk: 'aaz7dvd.css' }, + ua: { ietf: 'uk-UA', tk: 'aaz7dvd.css' }, + il_he: { ietf: 'he', tk: 'nwq1mna.css' }, + ae_ar: { ietf: 'ar', tk: 'nwq1mna.css' }, + mena_ar: { ietf: 'ar', tk: 'dis2dpj.css' }, + sa_ar: { ietf: 'ar', tk: 'nwq1mna.css' }, + // Asia Pacific + au: { ietf: 'en-AU', tk: 'pps7abe.css' }, + hk_en: { ietf: 'en-HK', tk: 'pps7abe.css' }, + in: { ietf: 'en-GB', tk: 'pps7abe.css' }, + id_id: { ietf: 'id', tk: 'czc0mun.css' }, + id_en: { ietf: 'en', tk: 'pps7abe.css' }, + my_ms: { ietf: 'ms', tk: 'sxj4tvo.css' }, + my_en: { ietf: 'en-GB', tk: 'pps7abe.css' }, + nz: { ietf: 'en-GB', tk: 'pps7abe.css' }, + ph_en: { ietf: 'en', tk: 'pps7abe.css' }, + ph_fil: { ietf: 'fil-PH', tk: 'ict8rmp.css' }, + sg: { ietf: 'en-SG', tk: 'pps7abe.css' }, + th_en: { ietf: 'en', tk: 'pps7abe.css' }, + in_hi: { ietf: 'hi', tk: 'aaa8deh.css' }, + th_th: { ietf: 'th', tk: 'aaz7dvd.css' }, + cn: { ietf: 'zh-CN', tk: 'puu3xkp' }, + hk_zh: { ietf: 'zh-HK', tk: 'jay0ecd' }, + tw: { ietf: 'zh-TW', tk: 'jay0ecd' }, + jp: { ietf: 'ja-JP', tk: 'dvg6awq' }, + kr: { ietf: 'ko-KR', tk: 'qjs5sfm' }, + // Langstore Support. + langstore: { ietf: 'en-US', tk: 'hah7vzn.css' }, +}; + +// Add any config options. +const CONFIG = { + contentRoot: '/creativecloud', + codeRoot: '/creativecloud', + imsClientId: 'ccmilo', + locales, + geoRouting: 'on', + prodDomains: ['www.adobe.com'], +}; + +// Load LCP image immediately +(async function loadLCPImage() { + const lcpImg = document.querySelector('img'); + lcpImg?.removeAttribute('loading'); +}()); + +async function loadArticlePromo(getMetadata) { + const promoEl = document.querySelector('main .promotion'); + const promoMeta = getMetadata('promotion'); + if (promoEl || !(promoMeta)) return; + const { default: decoratePromo } = await import('../features/article-promotion.js'); + decoratePromo(promoMeta); +} + +/* + * ------------------------------------------------------------ + * Edit below at your own risk + * ------------------------------------------------------------ + */ + +const miloLibs = setLibs(LIBS); + +(function loadStyles() { + const paths = [`${miloLibs}/styles/styles.css`]; + if (STYLES) { paths.push(STYLES); } + paths.forEach((path) => { + const link = document.createElement('link'); + link.setAttribute('rel', 'stylesheet'); + link.setAttribute('href', path); + document.head.appendChild(link); + }); +}()); + +(async function loadPage() { + const { getMetadata, loadArea, loadDelayed, setConfig } = await import(`${miloLibs}/utils/utils.js`); + await loadArticlePromo(getMetadata); + setConfig({ ...CONFIG, miloLibs }); + await loadArea(); + loadDelayed(); +}()); diff --git a/cc/scripts/utils.js b/creativecloud/scripts/utils.js similarity index 100% rename from cc/scripts/utils.js rename to creativecloud/scripts/utils.js diff --git a/cc/styles/styles.css b/creativecloud/styles/styles.css similarity index 100% rename from cc/styles/styles.css rename to creativecloud/styles/styles.css diff --git a/head.html b/head.html index 6f4670cd4..a58418337 100644 --- a/head.html +++ b/head.html @@ -1,5 +1,5 @@ - - + + diff --git a/package.json b/package.json index 7cec33c33..026ba5ae5 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "test:watch": "npm test -- --watch", "lint": "npm run lint:js && npm run lint:css", "lint:js": "eslint .", - "lint:css": "stylelint 'cc/blocks/**/*.css' 'cc/styles/*.css'" + "lint:css": "stylelint 'creativecloud/blocks/**/*.css' 'creativecloud/styles/*.css'" }, "repository": { "type": "git", diff --git a/test/blocks/promotion/promotion.test.js b/test/blocks/promotion/promotion.test.js index a76b3ed38..c15c8d3e6 100644 --- a/test/blocks/promotion/promotion.test.js +++ b/test/blocks/promotion/promotion.test.js @@ -6,7 +6,7 @@ document.body.innerHTML = await readFile({ path: './mocks/body.html' }); describe('promotion', () => { before(async () => { const el = document.querySelector('.promotion'); - const { default: init } = await import('../../../cc/blocks/promotion/promotion.js'); + const { default: init } = await import('../../../creativecloud/blocks/promotion/promotion.js'); await init(el, '/test/blocks/promotion/mocks'); }); diff --git a/test/features/article-promotion.test.js b/test/features/article-promotion.test.js index 7ce71d9fa..9658e9353 100644 --- a/test/features/article-promotion.test.js +++ b/test/features/article-promotion.test.js @@ -7,7 +7,7 @@ document.body.innerHTML = await readFile({ path: './mocks/body.html' }); describe('short form article promotion when metadata is set', () => { before(async () => { const metaEl = document.querySelector('head meta[name="promotion"]'); - const { default: init } = await import('../../cc/features/article-promotion.js'); + const { default: init } = await import('../../creativecloud/features/article-promotion.js'); init(metaEl.content); });