Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Milo] BulkPublisher BETA Preview content should point to stage #3554

Merged
merged 8 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions tools/send-to-caas/bulk-publish-to-caas.beta.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const showSuccessTable = (successArr) => {
tableBody.innerHTML += `<tr>
<td>${++index}</td>
<td class="ok">OK</td>
<td><a href="${pageUrl}" title="View page">${pageUrl}</a></td>
<td><a href="${pageUrl}" target="_blank" title="View page">${pageUrl}</a></td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good usability improvement for the UI. Could add rel=noopener noreferrer so the new tab can't access window.opener

<td class="entityid"><a target="_blank" href="${chimeraEndpoint}${response}" title="View Card JSON">${response}</a></td>
</tr>`;
});
Expand All @@ -147,7 +147,7 @@ const showErrorTable = (errorArr) => {
tableBody.innerHTML += `<tr>
<td>${index}</td>
<td class="error">Failed</td>
<td><a href="${pageUrl}">${pageUrl}</a></td>
<td><a href="${pageUrl}" target="_blank">${pageUrl}</a></td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good usability improvement for the UI. Could add rel=noopener noreferrer so the new tab can't access window.opener

<td>${message}</td>
</tr>`;
});
Expand All @@ -170,6 +170,7 @@ const processData = async (data, accessToken) => {
repo,
useHtml,
usePreview,
previewHost,
publishToFloodgate,
} = getConfig();

Expand All @@ -182,7 +183,7 @@ const processData = async (data, accessToken) => {
let domain = `https://${host}`;

if (usePreview) {
domain = `https://stage--${repo}--${owner}.hlx.page`;
domain = `https://${previewHost}`;
} else if (publishToFloodgate !== 'default') {
domain = `https://main--${repo}--${owner}.hlx.live`;
}
Expand All @@ -192,17 +193,14 @@ const processData = async (data, accessToken) => {

try {
const rawUrl = page.Path || page.path || page.url || page.URL || page.Url || page;

const { pathname } = new URL(rawUrl);
const pathnameNoHtml = pathname.replace('.html', '');
const pageUrl = usePreview ? `${domain}${pathnameNoHtml}` : `${domain}${pathname}`;
const prodUrl = `${host}${pathnameNoHtml}${useHtml ? '.html' : ''}`;
const pageUrl = `${domain}${pathname}`;

index += 1;
statusModal.setContent(`Publishing ${index} of ${data.length}:<br>${pageUrl}`);

if (pageUrl === 'stop') break; // debug, stop on empty line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good cleanup reviewing developmental/test code.


const { dom, error, lastModified } = await getPageDom(pageUrl, now);
if (error) {
errorArr.push([pageUrl, error]);
Expand Down Expand Up @@ -283,7 +281,7 @@ const bulkPublish = async () => {
const loadFromLS = () => {
BODY.classList = '';
const ls = localStorage.getItem(LS_KEY);
if (!ls || !ls.includes('presetSelector')) return;
if (!ls || !ls.includes('presetSelector') || !ls.includes('previewHost')) return;
try {
setConfig(JSON.parse(ls));
const config = getConfig();
Expand Down Expand Up @@ -386,6 +384,7 @@ presetSelector.addEventListener('change', () => {
} else {
config.contentType = selectedPreset.contentType;
}
config.previewHost = selectedPreset.previewHost || 'www.stage.adobe.com';

setConfig(config);
window.localStorage.setItem(LS_KEY, JSON.stringify(getConfig()));
Expand Down Expand Up @@ -487,9 +486,15 @@ helpButtons.forEach((btn) => {

case 'use-preview':
showAlert(`<p><b>Use Preview Content</b>
<p>When this option is checked, the tool will publish content from:
<p><tt>https://stage--{repo}--{owner}.hlx.<b>page</b></tt>
<p>This can be useful for testing before publishing to production.</p>`);
<p>When this option is checked, the tool will publish CaaS Metadata content from the stage environments:</p>
<p>For example:<br>
<tt> - https://www.stage.adobe.com</tt><br>
<tt> - https://business.stage.adobe.com</tt><br>
<tt> - https://blog.stage.adobe.com</tt><br>
<tt> - https://milo.stage.adobe.com</tt><br>
<tt> - https://news.stage.adobe.com</tt>
</p>
<p>This can be useful for testing before publishing content to production.</p>`);
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion tools/send-to-caas/bulkpublisher.beta.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h4>Advanced Options</h4>
</div>
<div id="use-preview-cb" class="field checkbox">
<input type="checkbox" id="usePreview" name="usePreview" />
<label for="usePreview">Use Preview Content (*.page)<span class="help use-preview" title="Help about this functionality">(?)</span></label>
<label for="usePreview">Use Preview Content (*.stage.*)<span class="help use-preview" title="Help about this functionality">(?)</span></label>
Copy link
Contributor

@sanrai sanrai Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good as it clarifies that the preview environment is from a stage domain.

</div>
<!--
<div class="field">
Expand Down
Loading