Skip to content

Commit

Permalink
Merge branch 'stage' into MWPW-127443-eliminate-bowser
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratko Zagorac committed Aug 21, 2023
2 parents e23d2c8 + 32eb19e commit 7404be9
Show file tree
Hide file tree
Showing 81 changed files with 4,045 additions and 204 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/test-milo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,32 @@ jobs:
curl -X POST 'https://dc.ci.corp.adobe.com/job/DC%20Release%20-%20Run%20Nala/buildWithParameters?token=${{ secrets.JNK_JOB_TOKEN }}&branch=main' \
-u '${{ secrets.JNK_USER }}:${{ secrets.JNK_API_TOKEN }}'
run-tests-gha:
name: Smoke Test
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts

- name: Install Playwright
run: npx playwright install --with-deps chromium

- name: Run the tests
run: xvfb-run -a npx run test/e2e/frictionless -t @smoke-converter

- name: Save test logs
uses: actions/upload-artifact@v3
with:
name: reports
path: reports/
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const localeMap = {
'gr_el': 'el-gr',
'ie': 'en-ie',
'il_en': 'en-il',
'il_he': 'he-il',
'it': 'it-it',
'lv': 'lv-lv',
'lt': 'lt-lt',
Expand Down
52 changes: 25 additions & 27 deletions acrobat/blocks/dc-converter-widget/dc-converter-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ const localeMap = {
'cy_en': 'en-cy',
'dk': 'da-dk',
'de': 'de-de',
'ee': 'en-ee',
'ee': 'et-ee',
'es': 'es-es',
'fr': 'fr-fr',
'gr_en': 'en-gr',
'gr_el': 'el-gr',
'ie': 'en-ie',
'il_en': 'en-il',
'il_he': 'he-il',
'it': 'it-it',
'lv': 'en-lv',
'lt': 'en-lt',
'lv': 'lv-lv',
'lt': 'lt-lt',
'lu_de': 'de-lu',
'lu_en': 'en-lu',
'lu_fr': 'fr-lu',
Expand All @@ -40,17 +41,17 @@ const localeMap = {
'pt': 'pt-pt',
'ro': 'ro-ro',
'ch_de': 'de-ch',
'si': 'si-si',
'si': 'sl-si',
'sk': 'sk-sk',
'ch_fr': 'fr-ch',
'fi': 'fi-fi',
'se': 'sv-se',
'ch_it': 'it-ch',
'tr': 'tr-tr',
'uk': 'en-uk',
'bg': 'en-bg',
'bg': 'bg-bg',
'ru': 'ru-ru',
'ua': 'ua-ua',
'ua': 'uk-ua',
'au': 'en-au',
'hk_en': 'en-hk',
'in': 'en-in',
Expand Down Expand Up @@ -117,7 +118,7 @@ let url = new URL(window.location.href);
let langFromPath = url.pathname.split('/')[1];
const pageLang = localeMap[langFromPath] || 'en-us';

export default function init(element) {
export default async function init(element) {
redirectLegacyBrowsers();
element.closest('main > div').dataset.section = 'widget';
const widget = element;
Expand Down Expand Up @@ -148,7 +149,7 @@ export default function init(element) {

if (window.location.hostname === 'www.adobe.com') {
WIDGET_ENV = `https://acrobat.adobe.com/dc-hosted/${DC_WIDGET_VERSION}/dc-app-launcher.js`;
DC_DOMAIN = 'https://acrobat.adobe.com';
DC_DOMAIN = 'https://www.adobe.com/dc';
ENV = 'prod';
}

Expand All @@ -158,7 +159,7 @@ export default function init(element) {
|| window.location.hostname === 'main--dc--adobecom.hlx.live'
|| window.location.hostname === 'www.stage.adobe.com') {
WIDGET_ENV = `https://stage.acrobat.adobe.com/dc-hosted/${STG_DC_WIDGET_VERSION}/dc-app-launcher.js`;
DC_DOMAIN = 'https://stage.acrobat.adobe.com';
DC_DOMAIN = 'https://www.stage.adobe.com/dc';
DC_GENERATE_CACHE_VERSION = STG_DC_GENERATE_CACHE_VERSION;
ENV = 'stage';
}
Expand Down Expand Up @@ -202,26 +203,23 @@ export default function init(element) {
const isReturningUser = window.localStorage.getItem('pdfnow.auth');
const isRedirection = /redirect_(?:conversion|files)=true/.test(window.location.search);
const preRenderDropZone = !isReturningUser && !isRedirection;
if (preRenderDropZone) {
(async () => {
// TODO: Make dynamic
const response = await fetch(DC_GENERATE_CACHE_URL || `${DC_DOMAIN}/dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${VERB}-${pageLang}.html`);
switch (response.status) {
case 200: {
const template = await response.text();
if (!("rendered" in widgetContainer.dataset)) {
widgetContainer.dataset.rendered = "true";
const doc = new DOMParser().parseFromString(template, 'text/html');
document.head.appendChild(doc.head.getElementsByTagName('Style')[0]);
widgetContainer.appendChild(doc.body.firstElementChild);
performance.mark("milo-insert-snippet");
}
break;
if (VERB === 'compress-pdf' || preRenderDropZone) {
const response = await fetch(DC_GENERATE_CACHE_URL || `${DC_DOMAIN}/dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${VERB}-${pageLang}.html`);
switch (response.status) {
case 200: {
const template = await response.text();
if (!("rendered" in widgetContainer.dataset)) {
widgetContainer.dataset.rendered = "true";
const doc = new DOMParser().parseFromString(template, 'text/html');
document.head.appendChild(doc.head.getElementsByTagName('Style')[0]);
widgetContainer.appendChild(doc.body.firstElementChild);
performance.mark("milo-insert-snippet");
}
default:
break;
break;
}
})();
default:
break;
}
}

window.addEventListener('IMS:Ready', async () => {
Expand Down
1 change: 0 additions & 1 deletion acrobat/blocks/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const blocks = [
'eventwrapper',
'personalization',
'verb-subfooters',
'promotion'
];

export default blocks;
Empty file.
26 changes: 0 additions & 26 deletions acrobat/blocks/promotion/promotion.js

This file was deleted.

5 changes: 5 additions & 0 deletions acrobat/scripts/contentSecurityPolicy/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ const imgSrc = [
'milo.adobe.com',
'p.typekit.net',
's.tgm.yahoo-net.jp',
's.yimg.jp',
'yjtag.yahoo.co.jp',
';',
];

Expand Down Expand Up @@ -222,6 +224,9 @@ const scriptSrc = [
'tag.demandbase.com',
'*.typekit.net',
'zn3n5vyia1vy8b4ly-adobe.siteintercept.qualtrics.com/',
's.yjtag.jp/tag.js',
's.yimg.jp',
'yjtag.yahoo.co.jp',
';',
];

Expand Down
5 changes: 5 additions & 0 deletions acrobat/scripts/contentSecurityPolicy/stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const imgSrc = [
'http://localhost:6456/',
'*.hlx.page',
'*.hlx.live',
's.yimg.jp',
'yjtag.yahoo.co.jp',
';',
];

Expand Down Expand Up @@ -238,6 +240,9 @@ const scriptSrc = [
'http://localhost:6456/',
'*.hlx.page',
'*.hlx.live',
's.tgm.yahoo-net.jp',
's.yimg.jp',
'yjtag.yahoo.co.jp',
';',
];

Expand Down
8 changes: 7 additions & 1 deletion acrobat/scripts/maps/localeMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const localeMap = {
'br': 'pt-BR',
'la': 'es-ES',
'mx': 'es-ES',
'be_nl': 'nl-NL'
'be_nl': 'nl-NL',
'bg': 'bg-BG',
'ee': 'et-EE',
'lt': 'lt-LT',
'lv': 'lv-LV',
'ua': 'uk-UA',
'si': 'sl-SI'
};
export default localeMap;
64 changes: 28 additions & 36 deletions acrobat/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const locales = {
cy_en: { ietf: 'en-CY', tk: 'pps7abe.css' },
dk: { ietf: 'da-DK', tk: 'aaz7dvd.css' },
de: { ietf: 'de-DE', tk: 'vin7zsi.css' },
ee: { ietf: 'en-EE', tk: 'aaz7dvd.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' },
Expand All @@ -111,7 +111,7 @@ const locales = {
ro: { ietf: 'en-RO', tk: 'aaz7dvd.css' },
sa_en: { ietf: 'en', tk: 'pps7abe.css' },
ch_de: { ietf: 'de-CH', tk: 'vin7zsi.css' },
si: { ietf: 'en-SI', tk: 'aaz7dvd.css' },
si: { ietf: 'sl-SI', tk: 'aaz7dvd.css' },
sk: { ietf: 'en-SK', tk: 'aaz7dvd.css' },
ch_fr: { ietf: 'fr-CH', tk: 'vrk5vyv.css' },
fi: { ietf: 'fi-FI', tk: 'aaz7dvd.css' },
Expand All @@ -122,9 +122,9 @@ const locales = {
uk: { ietf: 'en-GB', tk: 'pps7abe.css' },
at: { ietf: 'de-AT', tk: 'vin7zsi.css' },
cz: { ietf: 'cs-CZ', tk: 'aaz7dvd.css' },
bg: { ietf: 'en-BG', tk: 'aaz7dvd.css' },
bg: { ietf: 'bg-BG', tk: 'aaz7dvd.css' },
ru: { ietf: 'ru-RU', tk: 'aaz7dvd.css' },
ua: { ietf: 'en-UA', tk: 'aaz7dvd.css' },
ua: { ietf: 'uk-UA', tk: 'aaz7dvd.css' },
il_he: { ietf: 'he', tk: 'nwq1mna.css', dir: 'rtl' },
ae_ar: { ietf: 'ar', tk: 'nwq1mna.css', dir: 'rtl' },
mena_ar: { ietf: 'ar', tk: 'dis2dpj.css', dir: 'rtl' },
Expand Down Expand Up @@ -203,32 +203,31 @@ const { ietf } = getLocale(locales);

(async function loadPage() {
// Fast track the widget
(async () => {
const widgetBlock = document.querySelector('[class*="dc-converter-widget"]');
if (widgetBlock) {
const blockName = widgetBlock.classList.value;
widgetBlock.removeAttribute('class');
widgetBlock.id = 'dc-converter-widget';
const DC_WIDGET_VERSION = document.querySelector('meta[name="dc-widget-version"]')?.getAttribute('content');
const [,DC_GENERATE_CACHE_VERSION] = DC_WIDGET_VERSION.split('_');
const dcUrls = [
`https://acrobat.adobe.com/dc-hosted/${DC_WIDGET_VERSION}/dc-app-launcher.js`,
`https://acrobat.adobe.com/dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${window.location.pathname.split('/').pop().split('.')[0]}-${ietf.toLowerCase()}.html`
];
const widgetBlock = document.querySelector('[class*="dc-converter-widget"]');
if (widgetBlock) {
const blockName = widgetBlock.classList.value;
widgetBlock.removeAttribute('class');
widgetBlock.id = 'dc-converter-widget';
const DC_WIDGET_VERSION = document.querySelector('meta[name="dc-widget-version"]')?.getAttribute('content');
const DC_GENERATE_CACHE_VERSION = document.querySelector('meta[name="dc-generate-cache-version"]')?.getAttribute('content');
const dcUrls = [
`https://www.adobe.com/dc/dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${window.location.pathname.split('/').pop().split('.')[0]}-${ietf.toLowerCase()}.html`,
`https://acrobat.adobe.com/dc-hosted/${DC_WIDGET_VERSION}/dc-app-launcher.js`
];

dcUrls.forEach( url => {
const link = document.createElement('link');
link.setAttribute('rel', 'prefetch');
if(url.split('.').pop() === 'html') {link.setAttribute('as', 'fetch');}
if(url.split('.').pop() === 'js') {link.setAttribute('as', 'script');;}
link.setAttribute('href', url);
document.head.appendChild(link);
})
dcUrls.forEach( url => {
const link = document.createElement('link');
link.setAttribute('rel', 'prefetch');
if(url.split('.').pop() === 'html') {link.setAttribute('as', 'fetch');}
if(url.split('.').pop() === 'js') {link.setAttribute('as', 'script');;}
link.setAttribute('href', url);
link.setAttribute('crossorigin', '');
document.head.appendChild(link);
})

const { default: dcConverter } = await import(`../blocks/${blockName}/${blockName}.js`);
dcConverter(widgetBlock);
}
})();
const { default: dcConverter } = await import(`../blocks/${blockName}/${blockName}.js`);
await dcConverter(widgetBlock);
}

// Setup CSP
(async () => {
Expand All @@ -253,16 +252,9 @@ const { ietf } = getLocale(locales);
addLocale(ietf);
setConfig({ ...CONFIG, miloLibs });
loadLana({ clientId: 'dxdc' });
// get event back form dc web and then load area
// get event back form dc web and then load area
await loadArea(document, false);

// Promotion from metadata (for FedPub)
const promotionMetadata = getMetadata('promotion');
if (promotionMetadata && !document.querySelector('main .promotion')) {
const { promotionFromMetadata } = await import('../blocks/promotion/promotion.js');
promotionFromMetadata(promotionMetadata);
}

// Setup Logging
const { default: lanaLogging } = await import('./dcLana.js');
lanaLogging();
Expand Down
2 changes: 1 addition & 1 deletion acrobat/styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ div.how-to {
/* Full Screen Widget */
@media (max-width: 600px) {
.fsw > div > div {
height: calc(100vh - 100px);
min-height: calc(100vh - 100px) !important;
}
}

Expand Down
2 changes: 1 addition & 1 deletion head.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="preconnect" href="https://acrobat.adobe.com">
<link rel="preconnect" href="https://acrobat.adobe.com" crossorigin>
<script src="/acrobat/scripts/scripts.js" type="module"></script>
<style>body { display: none; }</style>
<link rel="icon" href="data:,">
Loading

0 comments on commit 7404be9

Please sign in to comment.