domma-cms 1.69.2 → 1.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/admin/js/lib/wordpress-import-arrange.js +1 -1
- package/admin/js/templates/docs/usage-tools.html +11 -0
- package/admin/js/templates/wordpress-import.html +25 -3
- package/admin/js/views/wordpress-import.js +10 -10
- package/docs/DommaFeatures.md +3 -1
- package/package.json +1 -1
- package/server/routes/api/wordpress-import.js +60 -3
- package/server/services/wpImport/crawl.js +12 -3
- package/server/services/wpImport/custom.js +1 -0
- package/server/services/wpImport/index.js +24 -4
- package/server/services/wpImport/plan.js +82 -5
- package/server/services/wpImport/redirects.js +436 -0
- package/server/services/wpImport/wxr.js +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.70.0] - 2026-11-16
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Import a site brings across the old site's own redirects.** The redirects set up on the old site itself (a page that moved years ago, a campaign address) are added to SEO › Redirects with the import, each with its own code (301, 302, 307, 308, or 410 for gone) and leading to where the import puts the page it pointed at, so none goes through a second redirect.
|
|
8
|
+
- **Found without asking:** every address WordPress kept when a page, post or product was renamed (`_wp_old_slug`), the Safe Redirect Manager plugin's rules (they are in the export), and any redirect met while reading a live site (Wix or any other).
|
|
9
|
+
- **Given as a list** (a new "The old site's redirects" option in the preview: upload a file or paste): Squarespace's URL mappings (`/old -> /new 301`), the Redirection plugin's CSV or JSON export, Yoast's and Rank Math's CSV, a sheet with the old and new address in two columns (Wix, Shopify), or an `.htaccess` file (`Redirect`, `RedirectMatch`, `RedirectPermanent`, `RedirectTemp`, `RewriteRule` with an `R` flag).
|
|
10
|
+
- A rule that depends on a pattern this site's redirects cannot express, or on who is visiting, is listed in the preview with the reason and not guessed at. None is added over an address a page, the Blog or the Shop here uses, and the import's own redirects win for the same address. Running the import again updates them in place.
|
|
11
|
+
- API: `POST` and `DELETE /api/import/wordpress/staged/:id/redirects`.
|
|
12
|
+
|
|
3
13
|
## [1.69.2] - 2026-11-16
|
|
4
14
|
|
|
5
15
|
### Security
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const KIND_LABEL={page:"Page",post:"Post",product:"Product",custom:"Custom item",collection:"Collection",media:"Media",menu:"Menu",category:"Category",widgets:"Widget area"},KIND_PLURAL={page:"Pages",post:"Posts",product:"Products",custom:"Custom items",collection:"Collections",media:"Media",menu:"Menus",category:"Categories",widgets:"Widgets"},KIND_ICON={page:"file-text",post:"edit-3",product:"shopping-bag",custom:"box",collection:"database",media:"image",menu:"menu",category:"tag",widgets:"layout"},PLACE_TEXT={add:"Goes in the footer, after what is there now",there:"Already in the footer",off:"Not put in the footer (you chose this)",removed:"Not put back in the footer - it was taken out here since the last import",full:"Not put in the footer - it already has 8 blocks; make room in Site Settings \u203A Footer"},TYPE_AS={collection:{text:"Collection",tone:"ok"},pages:{text:"Pages",tone:"info"},skip:{text:"Skipped",tone:"muted"}},PRODUCT_TYPE_LABEL={simple:"Simple",variable:"With options",grouped:"Grouped",external:"External"},ACTION={create:{text:"New",tone:"ok"},rename:{text:"New, renamed",tone:"warn"},update:{text:"Update",tone:"info"},keep:{text:"Left as is",tone:"muted"},skip:{text:"Skipped",tone:"muted"}},RESULT={created:{text:"Made",tone:"ok"},updated:{text:"Updated",tone:"info"},kept:{text:"Left as is",tone:"muted"},skipped:{text:"Skipped",tone:"muted"},failed:{text:"Failed",tone:"bad"}},PLAN_FILTERS=[{id:"all",label:"All"},{id:"new",label:"New"},{id:"update",label:"Updates"},{id:"renamed",label:"Renamed"},{id:"keep",label:"Left as is"},{id:"skip",label:"Skipped"},{id:"rebuild",label:"Needs rebuilding"}],REPORT_FILTERS=[{id:"all",label:"All"},{id:"created",label:"Made"},{id:"updated",label:"Updated"},{id:"kept",label:"Left as is"},{id:"skipped",label:"Skipped"},{id:"failed",label:"Failed"},{id:"rebuild",label:"Needs rebuilding"}];const g=e=>!!(e.builder||e.needs||e.shortcodes?.length),w=e=>[e.builder?`Built with ${e.builder}`:"",e.needs||"",...(e.shortcodes||[]).map(t=>`[${t}]`)].filter(Boolean).join(" ");export function planMatches(e,t){switch(t){case"new":return e.action==="create"||e.action==="rename";case"update":return e.action==="update";case"renamed":return e.action==="rename"||!!e.replaces;case"keep":return e.action==="keep";case"skip":return e.action==="skip";case"rebuild":return g(e);default:return!0}}export function reportMatches(e,t){return t==="rebuild"?g(e):t==="all"||!t||e.result===t}export function counts(e,t,o,s=""){const a=e.filter(i=>!s||i.kind===s);return Object.fromEntries(t.map(i=>[i.id,a.filter(n=>o(n,i.id)).length]))}export function kindTabs(e){const t=["page","post","product","custom","collection","media","menu","category","widgets"],o={};for(const s of e)o[s.kind]=(o[s.kind]||0)+1;return[{id:"",label:"Everything",count:e.length},...t.filter(s=>o[s]).map(s=>({id:s,label:KIND_PLURAL[s],count:o[s]}))]}export function planRow(e){const t=ACTION[e.action]||ACTION.skip;let o=e.target?e.kind==="menu"?`Menu "${e.target}"`:e.kind==="collection"?`Collection "${e.target}"`:e.kind==="widgets"?`Block "${e.target}"`:e.target:"";e.kind==="widgets"&&e.place&&e.action!=="skip"&&(o=`${o}${o?" \xB7 ":""}${PLACE_TEXT[e.place]||""}`),e.kind==="custom"&&e.as==="collection"&&e.collection&&e.action!=="skip"&&(o=`In the collection "${e.collection}"${e.listAt?`, listed at ${e.listAt}`:""}`);const s=[e.kind==="custom"&&e.postType?`${KIND_LABEL.custom} (${e.postType})`:KIND_LABEL[e.kind]||e.kind];return e.listFor&&s.push("list page"),e.status&&(e.kind==="page"||e.kind==="post"||e.kind==="custom")&&s.push(e.status),e.kind==="collection"&&e.fields&&s.push(`${e.fields} fields`),e.kind==="product"&&(e.productType&&s.push(PRODUCT_TYPE_LABEL[e.productType]||e.productType),e.variants&&s.push(`${e.variants} option${e.variants===1?"":"s"}`),e.action!=="skip"&&e.status&&s.push(e.status==="active"?"on sale":"draft")),e.comments&&s.push(`${e.comments} comment${e.comments===1?"":"s"}`),e.count&&s.push(e.kind==="widgets"?`${e.count} widget${e.count===1?"":"s"}`:`${e.count} item${e.count===1?"":"s"}`),e.kind==="widgets"&&e.widgetTypes?.length&&s.push(e.widgetTypes.join(", ")),{key:e.key,kind:e.kind,icon:KIND_ICON[e.kind]||"file",title:e.title||"(untitled)",pill:e.replaces?"Replaces a page":t.text,pillClass:`is-${e.replaces?"warn":t.tone}`,where:o,meta:s.join(" \xB7 "),reason:e.reason||"",rebuild:w(e),chosen:!!e.choice}}export function reportRow(e){const t=RESULT[e.result]||RESULT.skipped;return{key:e.key,kind:e.kind,icon:KIND_ICON[e.kind]||"file",title:e.title||"(untitled)",pill:t.text,pillClass:`is-${t.tone}`,where:e.target||"",meta:[KIND_LABEL[e.kind]||e.kind,e.format==="html"?"kept as HTML":"",e.kind==="widgets"&&e.placed?"added to the footer":""].filter(Boolean).join(" \xB7 "),reason:[e.reason,...e.notes||[]].filter(Boolean).join(" "),rebuild:w(e)}}export function choiceItems(e,t){const o=[];return t&&o.push({id:"reset",label:"Undo my choice",icon:"rotate-ccw"}),t!=="skip"&&e.action!=="skip"&&e.action!=="keep"&&o.push({id:"skip",label:"Skip this",icon:"x-circle"}),t!=="overwrite"&&e.action==="keep"&&o.push({id:"overwrite",label:"Overwrite my changes here",icon:"refresh-cw"}),t!=="overwrite"&&e.action==="rename"&&(e.kind==="page"||e.kind==="post")&&e.wanted&&e.kind==="page"&&o.push({id:"overwrite",label:`Replace the page at ${e.wanted}`,icon:"refresh-cw"}),t!=="import"&&e.action==="skip"&&/Deleted (on this site|from the Blog|from the Shop|from the collection)/.test(e.reason||"")&&o.push({id:"import",label:"Import again",icon:"download"}),o}export function applyChoice(e,t,o){const s={...e||{}};return!o||o==="reset"?delete s[t]:s[t]=o,s}export function defaultOptions(e=!1){return{posts:e?"blog":"pages",media:"download",comments:!0,menus:!0,redirects:!0,drafts:!0,products:!0,types:{},listPages:{},choices:{},users:{},userRole:"",invite:!1,footer:{},home:!0,postsPage:0,latestPosts:!1,homeReplace:null}}export function cleanOptions(e={},t=!1){const o=defaultOptions(t),s=(a,i,n)=>i.includes(a)?a:n;return{posts:s(e.posts,t?["blog","pages","skip"]:["pages","skip"],o.posts),media:s(e.media,["download","zip","skip"],o.media),comments:e.comments!==!1,menus:e.menus!==!1,redirects:e.redirects!==!1,drafts:e.drafts!==!1,products:e.products!==!1,types:Object.fromEntries(Object.entries(e.types||{}).filter(([a,i])=>b.test(a)&&(i==="pages"||i==="skip"))),listPages:Object.fromEntries(Object.entries(e.listPages||{}).filter(([a,i])=>b.test(a)&&i===!1)),choices:Object.fromEntries(Object.entries(e.choices||{}).filter(([a,i])=>typeof a=="string"&&["skip","overwrite","import"].includes(i))),users:Object.fromEntries(Object.entries(e.users||{}).filter(([a,i])=>x.test(a)&&(i==="create"||i==="skip"))),userRole:typeof e.userRole=="string"&&y.test(e.userRole)?e.userRole:"",invite:e.invite===!0,footer:Object.fromEntries(Object.entries(e.footer||{}).filter(([a,i])=>k.test(a)&&i===!1)),home:e.home!==!1,postsPage:Number.isInteger(e.postsPage)&&e.postsPage>0?e.postsPage:0,latestPosts:e.latestPosts===!0,homeReplace:typeof e.homeReplace=="boolean"?e.homeReplace:null}}const k=/^[A-Za-z0-9_-]{1,100}$/;export function withFooterChoice(e,t,o){const s={...e.footer||{}};return o?delete s[t]:s[t]=!1,{...e,footer:s}}export function optionsSnapshot(e){const t=cleanOptions(e,!0),o=Object.keys(t.choices).sort().map(l=>`${l}=${t.choices[l]}`).join(","),s=Object.keys(t.types).sort().map(l=>`${l}=${t.types[l]}`).join(","),a=Object.keys(t.listPages).sort().join(","),i=Object.keys(t.users).sort().map(l=>`${l}=${t.users[l]}`).join(","),n=Object.keys(t.footer).sort().join(",");return[t.posts,t.media,t.comments,t.menus,t.redirects,t.drafts,t.products,o,s,a,i,t.userRole,t.invite,n,t.home,t.postsPage,t.latestPosts,t.homeReplace].join("|")}const b=/^[a-z0-9_-]{1,40}$/;export function withTypeChoice(e,t,o){const s={...e.types||{}};return o==="pages"||o==="skip"?s[t]=o:delete s[t],{...e,types:s}}export function withListPage(e,t,o){const s={...e.listPages||{}};return o?delete s[t]:s[t]=!1,{...e,listPages:s}}export const isDirty=(e,t)=>optionsSnapshot(e)!==optionsSnapshot(defaultOptions(t)),draftKey=e=>e?`wordpress-import.draft.${e}`:"";export function liveDrafts(e,t,o){if(!e||typeof e!="object"||!e.items||typeof e.items!="object")return{items:{},pruned:!1};if(e.owner&&o&&e.owner!==o)return{items:{},pruned:!1};const s={};let a=!1;for(const[i,n]of Object.entries(e.items))t.includes(i)&&n?.options&&n.was===i?s[i]=n:a=!0;return{items:s,pruned:a}}export function withDraft(e,t,o,s){const a={...e&&e.owner===t&&e.items||{}};return s?a[o]=s:delete a[o],{owner:t,items:a}}export function draftQuestion({when:e="",file:t=""}={}){return{title:"Choices you left last time",text:`You changed the import options${t?` for ${t}`:""}${e?` (${e})`:""} and left before running it. Throw away those choices and start from the defaults?`,confirmText:"Throw away",cancelText:"Keep them"}}export function progressText(e){if(!e)return"";const t=e.total?` \xB7 ${e.done} of ${e.total}`:"";return`${e.phase||"Working"}${t}${e.current?` \xB7 ${String(e.current).slice(0,80)}`:""}`}export const progressPercent=e=>e?.total?Math.min(100,Math.round(e.done/e.total*100)):0;export function planTiles(e){const t=e?.summary?.counts||{},o=s=>t[s]?t[s].total-t[s].skip:0;return[{id:"page",label:"Pages",value:o("page"),of:t.page?.total||0},{id:"post",label:"Posts",value:o("post"),of:t.post?.total||0},...t.product?[{id:"product",label:"Products",value:o("product"),of:t.product.total}]:[],...t.custom?[{id:"custom",label:"Custom items",value:o("custom"),of:t.custom.total}]:[],{id:"media",label:"Media",value:o("media"),of:t.media?.total||0},{id:"menu",label:"Menus",value:o("menu"),of:t.menu?.total||0},...e?.people?.rows?.length?[{id:"people",label:"New accounts",value:e.people.counts?.create||0,of:0}]:[],...t.widgets?[{id:"widgets",label:"Widget areas",value:o("widgets"),of:t.widgets.total}]:[],{id:"comments",label:"Comments",value:e?.summary?.comments||0,of:0},{id:"redirects",label:"Redirects",value:e?.summary?.redirects||0,of:0}].map(s=>({...s,sub:s.of&&s.of!==s.value?`of ${s.of}`:""}))}const x=/^author:(\d{1,12}|login-[\w.-]{1,60})$/,y=/^[a-z0-9][a-z0-9_-]{0,59}$/i;export const PERSON={create:{text:"New account",tone:"ok"},match:{text:"Matched",tone:"info"},linked:{text:"Linked before",tone:"info"},same:{text:"Same email",tone:"muted"},skip:{text:"No account",tone:"muted"}};export function creditText(e={}){const t=(o,s,a)=>e[o]?`${e[o]} ${e[o]===1?s:a}`:"";return[t("post","post","posts"),t("page","page","pages"),t("product","product","products"),t("custom","item","items")].filter(Boolean).join(", ")||"nothing in this import"}export function personRow(e){const t=PERSON[e.action]||PERSON.skip,o=e.problem==="email";return{key:e.key,name:e.name||"Author",meta:[e.email||(o?"no usable email":""),creditText(e.items)].filter(Boolean).join(" \xB7 "),reason:e.reason||"",pill:o?"No email":t.text,pillClass:`is-${o?"warn":t.tone}${e.choice?" is-chosen":""}`,choosable:!!e.choosable,segCreate:e.action==="create"?"is-on":"",segSkip:e.action==="skip"?"is-on":""}}export function chooseAllPeople(e,t){const o={};for(const s of e?.rows||[])s.choosable&&(o[s.key]=t);return o}export function choosePerson(e,t,o){const s={...e||{}},a=t.total?"create":"skip";return!o||o==="reset"||o===a?delete s[t.key]:s[t.key]=o,s}export function personMenuItems(e){const t=[];return e.choosable&&e.action!=="create"&&t.push({id:"create",label:"Make a new account",icon:"user-plus"}),e.choosable&&e.action!=="skip"&&t.push({id:"skip",label:"Do not make an account",icon:"user-x"}),e.choice&&t.push({id:"reset",label:"Undo my choice",icon:"rotate-ccw"}),e.email&&e.problem!=="email"&&t.push({id:"copy",label:"Copy the email address",icon:"copy"}),t.length||t.push({id:"none",label:"Nothing to choose for them",icon:"info",disabled:!0}),t}export function peopleSummary(e){const t=e?.counts||{};if(!e?.rows?.length)return{text:"This export names no authors.",tone:"info"};const o=[];t.create&&o.push(`${t.create} new account${t.create===1?"":"s"}`),t.match+t.linked&&o.push(`${t.match+t.linked} matched to ${t.match+t.linked===1?"a user":"users"} here`),t.skip&&o.push(`${t.skip} without an account`);let s=`${e.rows.length} author${e.rows.length===1?"":"s"}: ${o.join(", ")||"nothing to do"}.`;return t.create&&(s+=" New accounts have no password - nobody can sign in to one until a password is set."),!e.canCreate&&e.why&&(s+=` ${e.why}`),{text:s,tone:t.problems||!e.canCreate?"warn":"info"}}export function inviteNote(e){return e?.canCreate?e.mailReady?e.counts?.create?"Sent once the import has finished: an invitation saying an account has been made for them, with a link to set their password that works for 7 days.":"Nobody new to email.":"No mail server is set up (Settings \u203A Email), so this cannot be sent. After the import, use Users \u203A \u22EE \u203A Copy a reset link instead.":""}export function reportPersonRow(e){const t={created:{text:"Account made",tone:"ok"},matched:{text:"Matched",tone:"info"},linked:{text:"Linked before",tone:"info"},same:{text:"Same email",tone:"muted"},skipped:{text:"No account",tone:"muted"},failed:{text:"Failed",tone:"bad"}},o=t[e.result]||t.skipped,s=[creditText(e.items)];return e.result==="created"&&s.push(e.invited?"invited by email":e.inviteFailed?"the invitation was not sent":"no password set yet"),{key:e.key,name:e.name||"Author",meta:s.join(" \xB7 "),reason:e.reason||"",pill:o.text,pillClass:`is-${o.tone}`,userId:e.userId||""}}export function historyRow(e,t=o=>o){const o=e.summary||{},s=Object.values(o.kinds||{}).reduce((n,l)=>n+(l.created||0),0),a=Object.values(o.kinds||{}).reduce((n,l)=>n+(l.updated||0),0),i=[];return s&&i.push(`${s} made`),o.people?.created&&i.push(`${o.people.created} account${o.people.created===1?"":"s"}`),a&&i.push(`${a} updated`),o.redirects?.created&&i.push(`${o.redirects.created} redirect${o.redirects.created===1?"":"s"}`),o.rebuild&&i.push(`${o.rebuild} to rebuild`),o.failed&&i.push(`${o.failed} failed`),e.status==="failed"&&i.splice(0,i.length,"Stopped before the end - run it again to finish"),{id:e.id,title:e.siteTitle||e.source||"WordPress site",meta:[t(e.at),e.by,e.file].filter(Boolean).join(" \xB7 "),summary:i.join(", ")||"Nothing changed",pill:e.status==="failed"?"Stopped":e.status==="partial"?"Some failed":"Done",pillClass:e.status==="failed"||e.status==="partial"?"is-bad":"is-ok"}}export function stagedRow(e,t=o=>o){const o=e.counts||{},s=[o.page&&`${o.page} pages`,o.post&&`${o.post} posts`,o.product&&`${o.product} products`,o.attachment&&`${o.attachment} media`,e.widgets&&`${e.widgets.widgets} widget${e.widgets.widgets===1?"":"s"}`].filter(Boolean);return{id:e.id,title:e.siteTitle||e.fileName||"WordPress export",meta:[e.fileName,t(e.at),s.join(", ")].filter(Boolean).join(" \xB7 "),pill:e.uploads?"Uploads zip added":e.widgets?"Widgets added":e.source==="crawl"?"Read from the live site":e.platformName&&e.platformName!=="WordPress"?`${e.platformName} export`:"Waiting",pillClass:e.uploads||e.widgets?"is-ok":"is-muted"}}export function productSummary(e){const t=e?.summary?.products;if(!t?.total)return null;const o=t.shop||e.shop||{},s=e.options?.products!==!1,a=Object.entries(t.types||{}).map(([r,h])=>`${h} ${(PRODUCT_TYPE_LABEL[r]||r).toLowerCase()}`).join(", "),i=e.summary.counts?.product||{},n=[{label:"In the export",value:`${t.total}${a?` (${a})`:""}`}];o.available&&s&&(n.push({label:"On sale in the Shop",value:String(t.onSale||0)}),n.push({label:"As drafts",value:String(t.drafts||0)}),i.keep&&n.push({label:"Left as is",value:String(i.keep)}),n.push({label:"Skipped",value:String(i.skip||0)})),t.rebuild&&n.push({label:"Need rebuilding",value:String(t.rebuild)});let l,f="info";return o.available?s?l=`Products go to the Shop at ${o.basePath||"/shop"}.`:l='Products are not being imported - switch on "WooCommerce products" above to bring them in.':(l=o.reason||"Switch on the Shop to bring these in.",f="warn"),{note:l,tone:f,rows:n,notes:Array.isArray(t.notes)?t.notes:[]}}const u=(e,t,o=`${t}s`)=>`${e} ${e===1?t:o}`;export function customTypeRows(e){return(e?.summary?.customTypes||[]).map(t=>{const o=TYPE_AS[t.as]?t.as:"collection",s=TYPE_AS[o],a=t.rewrite?`was at /${t.rewrite}/\u2026`:"its old addresses are not in the export";let i;if(o==="skip")i="Nothing - left out.";else if(o==="pages")i=`${u(t.importing||0,"page")} under ${t.prefix}${t.drafts?` (${t.drafts} as draft${t.drafts===1?"":"s"})`:""}.`;else{const n=t.collection||{},l=n.action==="skip"?`The collection "${n.slug}" was deleted here - choose Import again on it below.`:`${n.action==="update"?"The collection":"A new collection"} "${n.slug}" with ${u(t.fields?.length||0,"field")}: ${u(t.importing||0,"entry","entries")}${t.drafts?` (${t.drafts} draft${t.drafts===1?"":"s"}, not shown on the site)`:""}.`,f=t.listPage?t.listAt?` A list page at ${t.listAt}${t.listAction==="keep"?" (edited here - left as it is)":""}; the old addresses lead there.`:"":" No list page - the old addresses are not redirected.";i=`${l}${f}`}return{type:t.type,label:t.label||t.type,meta:[u(t.count||0,"item"),`"${t.type}"`,a].join(" \xB7 "),samples:(t.samples||[]).length?`For example: ${t.samples.join(", ")}`:"",creates:i,pill:s.text,pillClass:`is-${s.tone}`,as:o,listOn:o==="collection"&&t.listPage!==!1,canList:o==="collection",listLabel:`List page at ${t.prefix||`/${t.type}`}`,segCollection:o==="collection"?"is-on":"",segPages:o==="pages"?"is-on":"",segSkip:o==="skip"?"is-on":""}})}export function internalTypeRows(e){return(e?.summary?.internalTypes||[]).map(t=>({type:t.type,text:`${t.type} (${t.count}) - ${t.reason}`}))}export function typeMenuItems(e){if(!e)return[];const t=[];return e.as!=="collection"&&t.push({id:"collection",label:"Import as a collection",icon:"database"}),e.as!=="pages"&&t.push({id:"pages",label:"Import as pages",icon:"file-text"}),e.as!=="skip"&&t.push({id:"skip",label:"Leave this type out",icon:"x-circle"}),e.as==="collection"&&t.push(e.listOn?{id:"nolist",label:"No list page",icon:"eye-off"}:{id:"list",label:"Make a list page",icon:"list"}),t.push({id:"show",label:"Show its items",icon:"filter"}),t}export function widgetAreaRows(e){return(e?.summary?.widgets?.areas||[]).map(t=>{const o=ACTION[t.action]||ACTION.skip,s=t.action==="skip"?"Not imported.":`${t.action==="update"?"Updates the block":t.action==="keep"?"The block (edited here - left as it is)":"A new block"} "${t.block}"${t.coming<t.count?` with ${u(t.coming,"widget")}`:""}.`;return{area:t.id,label:t.label||t.id,meta:[u(t.count||0,"widget"),`"${t.id}"`,(t.types||[]).join(", ")].filter(Boolean).join(" \xB7 "),creates:s,placeText:t.footer?PLACE_TEXT[t.place]||"":t.action==="skip"?"":"A sidebar - a block only; put it on a page with [block].",rebuild:(t.rebuild||[]).length?`Needs rebuilding: ${t.rebuild.join("; ")}`:"",pill:o.text,pillClass:`is-${o.tone}`,canPlace:!!t.footer&&t.action!=="skip"&&t.place!=="there"&&t.place!=="removed",placeOn:t.place==="add"}})}export function widgetsFileText(e,t=0){const o=e?.widgets;return o?`${o.fileName} - ${u(o.areas||0,"widget area")}, ${u(o.widgets||0,"widget")}.`:`Optional: the widgets, as the .wie file the free "Widget Importer & Exporter" WordPress plugin exports${t?` (up to ${Math.max(1,Math.round(t/1048576))} MB)`:""}.`}const p=e=>`"${String(e||"").trim()||"Untitled"}"`;export function homeCard(e){const t=e?.home;if(!t)return null;const o=e.options||{},s=[],a=e.site?.platformName||"WordPress",i=a==="website"?"the old site":a,n=a==="website"?"The old site":a;let l;t.how==="page"&&t.page?l=`${n}'s home page was the page ${p(t.page.title)}${t.page.oldUrl?` (${t.page.oldUrl})`:""}.`:t.how==="unclear"?l=`${t.matches} pages had the home page's address in ${i}, so it cannot be told which one was the home page - none of them is made this site's home page.`:l=`${n} showed its latest posts on the home page (no page was set as the home page).`;const f=t.now?`This site's home page now: ${p(t.now.title)}.`:"This site has no home page now.";let r="",h="info";const c=t.question,$=c?`Make ${p(c.title)} the home page instead of ${p(c.current||"the page at /")}?`:"";c?c.answer===!0&&t.move?(r=`${p(c.title)} becomes the home page. ${p(c.current||"The page at /")} moves to ${t.move.to} as a draft - nothing is deleted.`,h="warn"):c.answer===!1&&(r=`${p(c.title)} is imported as an ordinary page${t.page?.target?` at ${t.page.target}`:""} - this site's home page stays as it is.`):t.done?.source?r=`An import of another site (${t.done.source}) set this site's home page - it is not changed.`:t.done?(r=t.done.how==="latest"?"An earlier import put the latest posts on the home page - it is not moved again.":"An earlier import made it this site's home page - it is not moved again.",t.done.previous&&(r+=` The home page from before is at ${t.done.previous}.`)):t.move?(r=`${t.how==="page"?p(t.page?.title):"A page showing the latest Blog posts"} becomes the home page. ${t.now?p(t.now.title):"The page at /"} moves to ${t.move.to} as a draft - nothing is deleted.`,h="warn"):t.page?.isHome||t.latest?.on?r=`${t.how==="page"?p(t.page?.title):"A page showing the latest Blog posts"} becomes the home page.`:t.how==="page"&&t.page?r=o.home===!1?`It is imported as an ordinary page${t.page.target?` at ${t.page.target}`:""} - this site's home page stays as it is.`:"":t.how==="latest"&&(r=t.latest?.offered?"This site's home page stays as it is unless you choose to show the latest posts on it.":"This site's home page stays as it is."),t.changed&&!t.done?.source&&!c&&(s.push(t.changed),h="warn");const d=t.postsPage;let m="";return d&&(m=d.confirmed?`${p(d.title)} was ${i}'s posts page: it is not made, and its old address (and links and menus that pointed to it) lead to ${d.to}.`:`${p(d.title)} has nothing in it and is called like a blog - it was probably ${i}'s posts page. If it was, it is not needed here: its address can lead to ${d.to} instead.`),{wp:l,now:f,after:r,tone:h,notes:s,frontSwitch:t.how==="page"&&!!t.page&&!t.done,frontLabel:"Make it this site's home page",latestSwitch:!!t.latest?.offered&&!t.done,postsSwitch:!!d,postsText:m,postsLabel:"It was the posts page - lead its address to the posts",postsId:d?.wpId||0,editNow:t.move&&t.now?"#/pages/edit/":"",question:$,answer:c&&typeof c.answer=="boolean"?c.answer:null}}
|
|
1
|
+
export const KIND_LABEL={page:"Page",post:"Post",product:"Product",custom:"Custom item",collection:"Collection",media:"Media",menu:"Menu",category:"Category",widgets:"Widget area"},KIND_PLURAL={page:"Pages",post:"Posts",product:"Products",custom:"Custom items",collection:"Collections",media:"Media",menu:"Menus",category:"Categories",widgets:"Widgets"},KIND_ICON={page:"file-text",post:"edit-3",product:"shopping-bag",custom:"box",collection:"database",media:"image",menu:"menu",category:"tag",widgets:"layout"},PLACE_TEXT={add:"Goes in the footer, after what is there now",there:"Already in the footer",off:"Not put in the footer (you chose this)",removed:"Not put back in the footer - it was taken out here since the last import",full:"Not put in the footer - it already has 8 blocks; make room in Site Settings \u203A Footer"},TYPE_AS={collection:{text:"Collection",tone:"ok"},pages:{text:"Pages",tone:"info"},skip:{text:"Skipped",tone:"muted"}},PRODUCT_TYPE_LABEL={simple:"Simple",variable:"With options",grouped:"Grouped",external:"External"},ACTION={create:{text:"New",tone:"ok"},rename:{text:"New, renamed",tone:"warn"},update:{text:"Update",tone:"info"},keep:{text:"Left as is",tone:"muted"},skip:{text:"Skipped",tone:"muted"}},RESULT={created:{text:"Made",tone:"ok"},updated:{text:"Updated",tone:"info"},kept:{text:"Left as is",tone:"muted"},skipped:{text:"Skipped",tone:"muted"},failed:{text:"Failed",tone:"bad"}},PLAN_FILTERS=[{id:"all",label:"All"},{id:"new",label:"New"},{id:"update",label:"Updates"},{id:"renamed",label:"Renamed"},{id:"keep",label:"Left as is"},{id:"skip",label:"Skipped"},{id:"rebuild",label:"Needs rebuilding"}],REPORT_FILTERS=[{id:"all",label:"All"},{id:"created",label:"Made"},{id:"updated",label:"Updated"},{id:"kept",label:"Left as is"},{id:"skipped",label:"Skipped"},{id:"failed",label:"Failed"},{id:"rebuild",label:"Needs rebuilding"}];const g=e=>!!(e.builder||e.needs||e.shortcodes?.length),w=e=>[e.builder?`Built with ${e.builder}`:"",e.needs||"",...(e.shortcodes||[]).map(t=>`[${t}]`)].filter(Boolean).join(" ");export function planMatches(e,t){switch(t){case"new":return e.action==="create"||e.action==="rename";case"update":return e.action==="update";case"renamed":return e.action==="rename"||!!e.replaces;case"keep":return e.action==="keep";case"skip":return e.action==="skip";case"rebuild":return g(e);default:return!0}}export function reportMatches(e,t){return t==="rebuild"?g(e):t==="all"||!t||e.result===t}export function counts(e,t,o,s=""){const n=e.filter(i=>!s||i.kind===s);return Object.fromEntries(t.map(i=>[i.id,n.filter(a=>o(a,i.id)).length]))}export function kindTabs(e){const t=["page","post","product","custom","collection","media","menu","category","widgets"],o={};for(const s of e)o[s.kind]=(o[s.kind]||0)+1;return[{id:"",label:"Everything",count:e.length},...t.filter(s=>o[s]).map(s=>({id:s,label:KIND_PLURAL[s],count:o[s]}))]}export function planRow(e){const t=ACTION[e.action]||ACTION.skip;let o=e.target?e.kind==="menu"?`Menu "${e.target}"`:e.kind==="collection"?`Collection "${e.target}"`:e.kind==="widgets"?`Block "${e.target}"`:e.target:"";e.kind==="widgets"&&e.place&&e.action!=="skip"&&(o=`${o}${o?" \xB7 ":""}${PLACE_TEXT[e.place]||""}`),e.kind==="custom"&&e.as==="collection"&&e.collection&&e.action!=="skip"&&(o=`In the collection "${e.collection}"${e.listAt?`, listed at ${e.listAt}`:""}`);const s=[e.kind==="custom"&&e.postType?`${KIND_LABEL.custom} (${e.postType})`:KIND_LABEL[e.kind]||e.kind];return e.listFor&&s.push("list page"),e.status&&(e.kind==="page"||e.kind==="post"||e.kind==="custom")&&s.push(e.status),e.kind==="collection"&&e.fields&&s.push(`${e.fields} fields`),e.kind==="product"&&(e.productType&&s.push(PRODUCT_TYPE_LABEL[e.productType]||e.productType),e.variants&&s.push(`${e.variants} option${e.variants===1?"":"s"}`),e.action!=="skip"&&e.status&&s.push(e.status==="active"?"on sale":"draft")),e.comments&&s.push(`${e.comments} comment${e.comments===1?"":"s"}`),e.count&&s.push(e.kind==="widgets"?`${e.count} widget${e.count===1?"":"s"}`:`${e.count} item${e.count===1?"":"s"}`),e.kind==="widgets"&&e.widgetTypes?.length&&s.push(e.widgetTypes.join(", ")),{key:e.key,kind:e.kind,icon:KIND_ICON[e.kind]||"file",title:e.title||"(untitled)",pill:e.replaces?"Replaces a page":t.text,pillClass:`is-${e.replaces?"warn":t.tone}`,where:o,meta:s.join(" \xB7 "),reason:e.reason||"",rebuild:w(e),chosen:!!e.choice}}export function reportRow(e){const t=RESULT[e.result]||RESULT.skipped;return{key:e.key,kind:e.kind,icon:KIND_ICON[e.kind]||"file",title:e.title||"(untitled)",pill:t.text,pillClass:`is-${t.tone}`,where:e.target||"",meta:[KIND_LABEL[e.kind]||e.kind,e.format==="html"?"kept as HTML":"",e.kind==="widgets"&&e.placed?"added to the footer":""].filter(Boolean).join(" \xB7 "),reason:[e.reason,...e.notes||[]].filter(Boolean).join(" "),rebuild:w(e)}}export function choiceItems(e,t){const o=[];return t&&o.push({id:"reset",label:"Undo my choice",icon:"rotate-ccw"}),t!=="skip"&&e.action!=="skip"&&e.action!=="keep"&&o.push({id:"skip",label:"Skip this",icon:"x-circle"}),t!=="overwrite"&&e.action==="keep"&&o.push({id:"overwrite",label:"Overwrite my changes here",icon:"refresh-cw"}),t!=="overwrite"&&e.action==="rename"&&(e.kind==="page"||e.kind==="post")&&e.wanted&&e.kind==="page"&&o.push({id:"overwrite",label:`Replace the page at ${e.wanted}`,icon:"refresh-cw"}),t!=="import"&&e.action==="skip"&&/Deleted (on this site|from the Blog|from the Shop|from the collection)/.test(e.reason||"")&&o.push({id:"import",label:"Import again",icon:"download"}),o}export function applyChoice(e,t,o){const s={...e||{}};return!o||o==="reset"?delete s[t]:s[t]=o,s}export function defaultOptions(e=!1){return{posts:e?"blog":"pages",media:"download",comments:!0,menus:!0,redirects:!0,drafts:!0,products:!0,types:{},listPages:{},choices:{},users:{},userRole:"",invite:!1,footer:{},home:!0,postsPage:0,latestPosts:!1,homeReplace:null}}export function cleanOptions(e={},t=!1){const o=defaultOptions(t),s=(n,i,a)=>i.includes(n)?n:a;return{posts:s(e.posts,t?["blog","pages","skip"]:["pages","skip"],o.posts),media:s(e.media,["download","zip","skip"],o.media),comments:e.comments!==!1,menus:e.menus!==!1,redirects:e.redirects!==!1,drafts:e.drafts!==!1,products:e.products!==!1,types:Object.fromEntries(Object.entries(e.types||{}).filter(([n,i])=>$.test(n)&&(i==="pages"||i==="skip"))),listPages:Object.fromEntries(Object.entries(e.listPages||{}).filter(([n,i])=>$.test(n)&&i===!1)),choices:Object.fromEntries(Object.entries(e.choices||{}).filter(([n,i])=>typeof n=="string"&&["skip","overwrite","import"].includes(i))),users:Object.fromEntries(Object.entries(e.users||{}).filter(([n,i])=>x.test(n)&&(i==="create"||i==="skip"))),userRole:typeof e.userRole=="string"&&y.test(e.userRole)?e.userRole:"",invite:e.invite===!0,footer:Object.fromEntries(Object.entries(e.footer||{}).filter(([n,i])=>k.test(n)&&i===!1)),home:e.home!==!1,postsPage:Number.isInteger(e.postsPage)&&e.postsPage>0?e.postsPage:0,latestPosts:e.latestPosts===!0,homeReplace:typeof e.homeReplace=="boolean"?e.homeReplace:null}}const k=/^[A-Za-z0-9_-]{1,100}$/;export function withFooterChoice(e,t,o){const s={...e.footer||{}};return o?delete s[t]:s[t]=!1,{...e,footer:s}}export function optionsSnapshot(e){const t=cleanOptions(e,!0),o=Object.keys(t.choices).sort().map(l=>`${l}=${t.choices[l]}`).join(","),s=Object.keys(t.types).sort().map(l=>`${l}=${t.types[l]}`).join(","),n=Object.keys(t.listPages).sort().join(","),i=Object.keys(t.users).sort().map(l=>`${l}=${t.users[l]}`).join(","),a=Object.keys(t.footer).sort().join(",");return[t.posts,t.media,t.comments,t.menus,t.redirects,t.drafts,t.products,o,s,n,i,t.userRole,t.invite,a,t.home,t.postsPage,t.latestPosts,t.homeReplace].join("|")}const $=/^[a-z0-9_-]{1,40}$/;export function withTypeChoice(e,t,o){const s={...e.types||{}};return o==="pages"||o==="skip"?s[t]=o:delete s[t],{...e,types:s}}export function withListPage(e,t,o){const s={...e.listPages||{}};return o?delete s[t]:s[t]=!1,{...e,listPages:s}}export const isDirty=(e,t)=>optionsSnapshot(e)!==optionsSnapshot(defaultOptions(t)),draftKey=e=>e?`wordpress-import.draft.${e}`:"";export function liveDrafts(e,t,o){if(!e||typeof e!="object"||!e.items||typeof e.items!="object")return{items:{},pruned:!1};if(e.owner&&o&&e.owner!==o)return{items:{},pruned:!1};const s={};let n=!1;for(const[i,a]of Object.entries(e.items))t.includes(i)&&a?.options&&a.was===i?s[i]=a:n=!0;return{items:s,pruned:n}}export function withDraft(e,t,o,s){const n={...e&&e.owner===t&&e.items||{}};return s?n[o]=s:delete n[o],{owner:t,items:n}}export function draftQuestion({when:e="",file:t=""}={}){return{title:"Choices you left last time",text:`You changed the import options${t?` for ${t}`:""}${e?` (${e})`:""} and left before running it. Throw away those choices and start from the defaults?`,confirmText:"Throw away",cancelText:"Keep them"}}export function progressText(e){if(!e)return"";const t=e.total?` \xB7 ${e.done} of ${e.total}`:"";return`${e.phase||"Working"}${t}${e.current?` \xB7 ${String(e.current).slice(0,80)}`:""}`}export const progressPercent=e=>e?.total?Math.min(100,Math.round(e.done/e.total*100)):0;export function planTiles(e){const t=e?.summary?.counts||{},o=s=>t[s]?t[s].total-t[s].skip:0;return[{id:"page",label:"Pages",value:o("page"),of:t.page?.total||0},{id:"post",label:"Posts",value:o("post"),of:t.post?.total||0},...t.product?[{id:"product",label:"Products",value:o("product"),of:t.product.total}]:[],...t.custom?[{id:"custom",label:"Custom items",value:o("custom"),of:t.custom.total}]:[],{id:"media",label:"Media",value:o("media"),of:t.media?.total||0},{id:"menu",label:"Menus",value:o("menu"),of:t.menu?.total||0},...e?.people?.rows?.length?[{id:"people",label:"New accounts",value:e.people.counts?.create||0,of:0}]:[],...t.widgets?[{id:"widgets",label:"Widget areas",value:o("widgets"),of:t.widgets.total}]:[],{id:"comments",label:"Comments",value:e?.summary?.comments||0,of:0},{id:"redirects",label:"Redirects",value:e?.summary?.redirects||0,of:0}].map(s=>({...s,sub:s.of&&s.of!==s.value?`of ${s.of}`:""}))}const x=/^author:(\d{1,12}|login-[\w.-]{1,60})$/,y=/^[a-z0-9][a-z0-9_-]{0,59}$/i;export const PERSON={create:{text:"New account",tone:"ok"},match:{text:"Matched",tone:"info"},linked:{text:"Linked before",tone:"info"},same:{text:"Same email",tone:"muted"},skip:{text:"No account",tone:"muted"}};export function creditText(e={}){const t=(o,s,n)=>e[o]?`${e[o]} ${e[o]===1?s:n}`:"";return[t("post","post","posts"),t("page","page","pages"),t("product","product","products"),t("custom","item","items")].filter(Boolean).join(", ")||"nothing in this import"}export function personRow(e){const t=PERSON[e.action]||PERSON.skip,o=e.problem==="email";return{key:e.key,name:e.name||"Author",meta:[e.email||(o?"no usable email":""),creditText(e.items)].filter(Boolean).join(" \xB7 "),reason:e.reason||"",pill:o?"No email":t.text,pillClass:`is-${o?"warn":t.tone}${e.choice?" is-chosen":""}`,choosable:!!e.choosable,segCreate:e.action==="create"?"is-on":"",segSkip:e.action==="skip"?"is-on":""}}export function chooseAllPeople(e,t){const o={};for(const s of e?.rows||[])s.choosable&&(o[s.key]=t);return o}export function choosePerson(e,t,o){const s={...e||{}},n=t.total?"create":"skip";return!o||o==="reset"||o===n?delete s[t.key]:s[t.key]=o,s}export function personMenuItems(e){const t=[];return e.choosable&&e.action!=="create"&&t.push({id:"create",label:"Make a new account",icon:"user-plus"}),e.choosable&&e.action!=="skip"&&t.push({id:"skip",label:"Do not make an account",icon:"user-x"}),e.choice&&t.push({id:"reset",label:"Undo my choice",icon:"rotate-ccw"}),e.email&&e.problem!=="email"&&t.push({id:"copy",label:"Copy the email address",icon:"copy"}),t.length||t.push({id:"none",label:"Nothing to choose for them",icon:"info",disabled:!0}),t}export function peopleSummary(e){const t=e?.counts||{};if(!e?.rows?.length)return{text:"This export names no authors.",tone:"info"};const o=[];t.create&&o.push(`${t.create} new account${t.create===1?"":"s"}`),t.match+t.linked&&o.push(`${t.match+t.linked} matched to ${t.match+t.linked===1?"a user":"users"} here`),t.skip&&o.push(`${t.skip} without an account`);let s=`${e.rows.length} author${e.rows.length===1?"":"s"}: ${o.join(", ")||"nothing to do"}.`;return t.create&&(s+=" New accounts have no password - nobody can sign in to one until a password is set."),!e.canCreate&&e.why&&(s+=` ${e.why}`),{text:s,tone:t.problems||!e.canCreate?"warn":"info"}}export function inviteNote(e){return e?.canCreate?e.mailReady?e.counts?.create?"Sent once the import has finished: an invitation saying an account has been made for them, with a link to set their password that works for 7 days.":"Nobody new to email.":"No mail server is set up (Settings \u203A Email), so this cannot be sent. After the import, use Users \u203A \u22EE \u203A Copy a reset link instead.":""}export function reportPersonRow(e){const t={created:{text:"Account made",tone:"ok"},matched:{text:"Matched",tone:"info"},linked:{text:"Linked before",tone:"info"},same:{text:"Same email",tone:"muted"},skipped:{text:"No account",tone:"muted"},failed:{text:"Failed",tone:"bad"}},o=t[e.result]||t.skipped,s=[creditText(e.items)];return e.result==="created"&&s.push(e.invited?"invited by email":e.inviteFailed?"the invitation was not sent":"no password set yet"),{key:e.key,name:e.name||"Author",meta:s.join(" \xB7 "),reason:e.reason||"",pill:o.text,pillClass:`is-${o.tone}`,userId:e.userId||""}}export function historyRow(e,t=o=>o){const o=e.summary||{},s=Object.values(o.kinds||{}).reduce((a,l)=>a+(l.created||0),0),n=Object.values(o.kinds||{}).reduce((a,l)=>a+(l.updated||0),0),i=[];return s&&i.push(`${s} made`),o.people?.created&&i.push(`${o.people.created} account${o.people.created===1?"":"s"}`),n&&i.push(`${n} updated`),o.redirects?.created&&i.push(`${o.redirects.created} redirect${o.redirects.created===1?"":"s"}`),o.rebuild&&i.push(`${o.rebuild} to rebuild`),o.failed&&i.push(`${o.failed} failed`),e.status==="failed"&&i.splice(0,i.length,"Stopped before the end - run it again to finish"),{id:e.id,title:e.siteTitle||e.source||"WordPress site",meta:[t(e.at),e.by,e.file].filter(Boolean).join(" \xB7 "),summary:i.join(", ")||"Nothing changed",pill:e.status==="failed"?"Stopped":e.status==="partial"?"Some failed":"Done",pillClass:e.status==="failed"||e.status==="partial"?"is-bad":"is-ok"}}export function stagedRow(e,t=o=>o){const o=e.counts||{},s=[o.page&&`${o.page} pages`,o.post&&`${o.post} posts`,o.product&&`${o.product} products`,o.attachment&&`${o.attachment} media`,e.widgets&&`${e.widgets.widgets} widget${e.widgets.widgets===1?"":"s"}`].filter(Boolean);return{id:e.id,title:e.siteTitle||e.fileName||"WordPress export",meta:[e.fileName,t(e.at),s.join(", ")].filter(Boolean).join(" \xB7 "),pill:e.uploads?"Uploads zip added":e.widgets?"Widgets added":e.source==="crawl"?"Read from the live site":e.platformName&&e.platformName!=="WordPress"?`${e.platformName} export`:"Waiting",pillClass:e.uploads||e.widgets?"is-ok":"is-muted"}}export function productSummary(e){const t=e?.summary?.products;if(!t?.total)return null;const o=t.shop||e.shop||{},s=e.options?.products!==!1,n=Object.entries(t.types||{}).map(([r,h])=>`${h} ${(PRODUCT_TYPE_LABEL[r]||r).toLowerCase()}`).join(", "),i=e.summary.counts?.product||{},a=[{label:"In the export",value:`${t.total}${n?` (${n})`:""}`}];o.available&&s&&(a.push({label:"On sale in the Shop",value:String(t.onSale||0)}),a.push({label:"As drafts",value:String(t.drafts||0)}),i.keep&&a.push({label:"Left as is",value:String(i.keep)}),a.push({label:"Skipped",value:String(i.skip||0)})),t.rebuild&&a.push({label:"Need rebuilding",value:String(t.rebuild)});let l,f="info";return o.available?s?l=`Products go to the Shop at ${o.basePath||"/shop"}.`:l='Products are not being imported - switch on "WooCommerce products" above to bring them in.':(l=o.reason||"Switch on the Shop to bring these in.",f="warn"),{note:l,tone:f,rows:a,notes:Array.isArray(t.notes)?t.notes:[]}}const d=(e,t,o=`${t}s`)=>`${e} ${e===1?t:o}`;export function customTypeRows(e){return(e?.summary?.customTypes||[]).map(t=>{const o=TYPE_AS[t.as]?t.as:"collection",s=TYPE_AS[o],n=t.rewrite?`was at /${t.rewrite}/\u2026`:"its old addresses are not in the export";let i;if(o==="skip")i="Nothing - left out.";else if(o==="pages")i=`${d(t.importing||0,"page")} under ${t.prefix}${t.drafts?` (${t.drafts} as draft${t.drafts===1?"":"s"})`:""}.`;else{const a=t.collection||{},l=a.action==="skip"?`The collection "${a.slug}" was deleted here - choose Import again on it below.`:`${a.action==="update"?"The collection":"A new collection"} "${a.slug}" with ${d(t.fields?.length||0,"field")}: ${d(t.importing||0,"entry","entries")}${t.drafts?` (${t.drafts} draft${t.drafts===1?"":"s"}, not shown on the site)`:""}.`,f=t.listPage?t.listAt?` A list page at ${t.listAt}${t.listAction==="keep"?" (edited here - left as it is)":""}; the old addresses lead there.`:"":" No list page - the old addresses are not redirected.";i=`${l}${f}`}return{type:t.type,label:t.label||t.type,meta:[d(t.count||0,"item"),`"${t.type}"`,n].join(" \xB7 "),samples:(t.samples||[]).length?`For example: ${t.samples.join(", ")}`:"",creates:i,pill:s.text,pillClass:`is-${s.tone}`,as:o,listOn:o==="collection"&&t.listPage!==!1,canList:o==="collection",listLabel:`List page at ${t.prefix||`/${t.type}`}`,segCollection:o==="collection"?"is-on":"",segPages:o==="pages"?"is-on":"",segSkip:o==="skip"?"is-on":""}})}export function internalTypeRows(e){return(e?.summary?.internalTypes||[]).map(t=>({type:t.type,text:`${t.type} (${t.count}) - ${t.reason}`}))}export function typeMenuItems(e){if(!e)return[];const t=[];return e.as!=="collection"&&t.push({id:"collection",label:"Import as a collection",icon:"database"}),e.as!=="pages"&&t.push({id:"pages",label:"Import as pages",icon:"file-text"}),e.as!=="skip"&&t.push({id:"skip",label:"Leave this type out",icon:"x-circle"}),e.as==="collection"&&t.push(e.listOn?{id:"nolist",label:"No list page",icon:"eye-off"}:{id:"list",label:"Make a list page",icon:"list"}),t.push({id:"show",label:"Show its items",icon:"filter"}),t}export function widgetAreaRows(e){return(e?.summary?.widgets?.areas||[]).map(t=>{const o=ACTION[t.action]||ACTION.skip,s=t.action==="skip"?"Not imported.":`${t.action==="update"?"Updates the block":t.action==="keep"?"The block (edited here - left as it is)":"A new block"} "${t.block}"${t.coming<t.count?` with ${d(t.coming,"widget")}`:""}.`;return{area:t.id,label:t.label||t.id,meta:[d(t.count||0,"widget"),`"${t.id}"`,(t.types||[]).join(", ")].filter(Boolean).join(" \xB7 "),creates:s,placeText:t.footer?PLACE_TEXT[t.place]||"":t.action==="skip"?"":"A sidebar - a block only; put it on a page with [block].",rebuild:(t.rebuild||[]).length?`Needs rebuilding: ${t.rebuild.join("; ")}`:"",pill:o.text,pillClass:`is-${o.tone}`,canPlace:!!t.footer&&t.action!=="skip"&&t.place!=="there"&&t.place!=="removed",placeOn:t.place==="add"}})}export function widgetsFileText(e,t=0){const o=e?.widgets;return o?`${o.fileName} - ${d(o.areas||0,"widget area")}, ${d(o.widgets||0,"widget")}.`:`Optional: the widgets, as the .wie file the free "Widget Importer & Exporter" WordPress plugin exports${t?` (up to ${Math.max(1,Math.round(t/1048576))} MB)`:""}.`}export function redirectsListText(e,t=null){const o=e?.redirects,s=t?.summary?.oldRedirects;if(o){const i=[`${o.fileName||"Your list"} - ${d(o.count||0,"redirect")} read`];return o.unread&&i.push(`${o.unread} could not be read (listed under Redirects, with why)`),o.more&&i.push(`${o.more} more than one import takes`),`${i.join(", ")}.${s?` ${d(s.planned||0,"redirect")} from the old site will be added.`:""}`}return`${s?.found?`${d(s.found,"redirect")} of the old site's own ${s.found===1?"was":"were"} found without a list. `:""}Optional: the redirects set up on the old site, as a list - paste Squarespace's URL mappings, or upload a redirect plugin's export (.csv or .json), a sheet of old and new addresses, or the .htaccess file.`}export function redirectRow(e){const t=e.code===410,o=e.old&&e.action!=="skip"?`The old site's own redirect${e.code&&e.code!==301?` (${e.code})`:""}`:"";return{...e,to:e.unread?"not read":t?"gone (410)":e.to,reason:e.reason||o,pill:e.action==="skip"?"Skipped":e.action==="update"?"Update":"New",pillClass:e.action==="skip"?"is-muted":"is-ok"}}const p=e=>`"${String(e||"").trim()||"Untitled"}"`;export function homeCard(e){const t=e?.home;if(!t)return null;const o=e.options||{},s=[],n=e.site?.platformName||"WordPress",i=n==="website"?"the old site":n,a=n==="website"?"The old site":n;let l;t.how==="page"&&t.page?l=`${a}'s home page was the page ${p(t.page.title)}${t.page.oldUrl?` (${t.page.oldUrl})`:""}.`:t.how==="unclear"?l=`${t.matches} pages had the home page's address in ${i}, so it cannot be told which one was the home page - none of them is made this site's home page.`:l=`${a} showed its latest posts on the home page (no page was set as the home page).`;const f=t.now?`This site's home page now: ${p(t.now.title)}.`:"This site has no home page now.";let r="",h="info";const c=t.question,b=c?`Make ${p(c.title)} the home page instead of ${p(c.current||"the page at /")}?`:"";c?c.answer===!0&&t.move?(r=`${p(c.title)} becomes the home page. ${p(c.current||"The page at /")} moves to ${t.move.to} as a draft - nothing is deleted.`,h="warn"):c.answer===!1&&(r=`${p(c.title)} is imported as an ordinary page${t.page?.target?` at ${t.page.target}`:""} - this site's home page stays as it is.`):t.done?.source?r=`An import of another site (${t.done.source}) set this site's home page - it is not changed.`:t.done?(r=t.done.how==="latest"?"An earlier import put the latest posts on the home page - it is not moved again.":"An earlier import made it this site's home page - it is not moved again.",t.done.previous&&(r+=` The home page from before is at ${t.done.previous}.`)):t.move?(r=`${t.how==="page"?p(t.page?.title):"A page showing the latest Blog posts"} becomes the home page. ${t.now?p(t.now.title):"The page at /"} moves to ${t.move.to} as a draft - nothing is deleted.`,h="warn"):t.page?.isHome||t.latest?.on?r=`${t.how==="page"?p(t.page?.title):"A page showing the latest Blog posts"} becomes the home page.`:t.how==="page"&&t.page?r=o.home===!1?`It is imported as an ordinary page${t.page.target?` at ${t.page.target}`:""} - this site's home page stays as it is.`:"":t.how==="latest"&&(r=t.latest?.offered?"This site's home page stays as it is unless you choose to show the latest posts on it.":"This site's home page stays as it is."),t.changed&&!t.done?.source&&!c&&(s.push(t.changed),h="warn");const u=t.postsPage;let m="";return u&&(m=u.confirmed?`${p(u.title)} was ${i}'s posts page: it is not made, and its old address (and links and menus that pointed to it) lead to ${u.to}.`:`${p(u.title)} has nothing in it and is called like a blog - it was probably ${i}'s posts page. If it was, it is not needed here: its address can lead to ${u.to} instead.`),{wp:l,now:f,after:r,tone:h,notes:s,frontSwitch:t.how==="page"&&!!t.page&&!t.done,frontLabel:"Make it this site's home page",latestSwitch:!!t.latest?.offered&&!t.done,postsSwitch:!!u,postsText:m,postsLabel:"It was the posts page - lead its address to the posts",postsId:u?.wpId||0,editNow:t.move&&t.now?"#/pages/edit/":"",question:b,answer:c&&typeof c.answer=="boolean"?c.answer:null}}
|
|
@@ -179,6 +179,17 @@
|
|
|
179
179
|
shops and bookings are not copied; the preview lists pages that came across with little text, and
|
|
180
180
|
any address that could not be read, so you know what to check. Reading the site again later and
|
|
181
181
|
running the import updates what it made, as with a WordPress export.</p>
|
|
182
|
+
<p><strong>The old site's own redirects.</strong> Redirects set up on the old site itself - a page that
|
|
183
|
+
moved years ago, a campaign address - come across too, into <strong>SEO > Redirects</strong>, each
|
|
184
|
+
with its own code (301, 302, 307, 308, or 410 for gone) and leading straight to where the import puts
|
|
185
|
+
the page it pointed at. Some are found without asking: the addresses WordPress kept when a page was
|
|
186
|
+
renamed, the Safe Redirect Manager plugin's rules, and any redirect met while reading a live site.
|
|
187
|
+
For the rest, use <strong>The old site's redirects</strong> in the preview and upload or paste a
|
|
188
|
+
list: Squarespace's <strong>URL Mappings</strong> box (<code>/old -> /new 301</code>), the export
|
|
189
|
+
from a WordPress redirect plugin (Redirection, Yoast, Rank Math), the site's <code>.htaccess</code>
|
|
190
|
+
file, or a sheet with the old address and the new one in two columns (Wix, Shopify and others). The
|
|
191
|
+
preview's Redirects card lists every one. A rule that depends on a pattern or on who is visiting is
|
|
192
|
+
shown as skipped with the reason, and none is added over an address a page here uses.</p>
|
|
182
193
|
|
|
183
194
|
<h3>Notifications</h3>
|
|
184
195
|
<p>The bell in the admin, and <strong>System > Notifications</strong>. Opening the screen marks
|
|
@@ -122,13 +122,33 @@
|
|
|
122
122
|
<small class="wpx-note" hidden data-bind-hidden="!widgetsUploadText.value" data-bind-text="widgetsUploadText.value"></small>
|
|
123
123
|
</div>
|
|
124
124
|
</div>
|
|
125
|
+
<div class="wpx-option">
|
|
126
|
+
<span class="form-label">The old site's redirects
|
|
127
|
+
<span data-help-title="The old site's redirects" data-help="Redirects set up on the old site itself - a page that moved years ago, a campaign address - are not part of its content, so most exports leave them out. Give them here as a list and each one is added to SEO › Redirects with its own code (301, 302, 307, 308, or 410 for gone), leading to where the import puts the page it pointed at. Squarespace: copy the box in Settings › Developer Tools › URL Mappings and paste it. WordPress: export from your redirect plugin (Redirection: Tools › Redirection › Import/Export; Yoast and Rank Math have a CSV export) or upload the .htaccess file. Wix, Shopify or anything else: a sheet with the old address and the new one in two columns. Found without a list: addresses WordPress kept when a page was renamed, Safe Redirect Manager's rules, and any redirect met while reading a live site. A rule that depends on a pattern or on who is visiting is listed with the reason, never guessed at, and none is added over an address a page here uses."></span></span>
|
|
128
|
+
<div class="wpx-zip">
|
|
129
|
+
<small class="wpx-note" data-bind-text="redirectsText.value"></small>
|
|
130
|
+
<div class="wpx-zip-actions">
|
|
131
|
+
<label class="btn btn-sm btn-outline wpx-zip-pick"><input type="file" class="wpx-redirects-file" accept=".csv,.tsv,.txt,.json,.conf,.htaccess,text/csv,text/plain,application/json" hidden>
|
|
132
|
+
<span data-bind-text="redirectsButton.value"></span></label>
|
|
133
|
+
<button type="button" class="btn btn-sm btn-outline" data-on-click="togglePaste" data-bind-text="pasteButton.value">Paste a list</button>
|
|
134
|
+
<button type="button" class="btn btn-sm btn-ghost" hidden data-bind-hidden="!redirectsInfo.value" data-on-click="removeRedirects">Remove</button>
|
|
135
|
+
</div>
|
|
136
|
+
<div class="wpx-paste" hidden data-bind-hidden="!pasteOpen.value">
|
|
137
|
+
<textarea class="form-input wpx-paste-text" rows="6" spellcheck="false" placeholder="/old-page -> /new-page 301" aria-label="The old site's redirects, one a line" data-model="pasteText.value"></textarea>
|
|
138
|
+
<div class="wpx-zip-actions">
|
|
139
|
+
<button type="button" class="btn btn-sm btn-primary" data-on-click="sendPaste" data-bind-disabled="pasteEmpty.value">Read the list</button>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
<small class="wpx-note" hidden data-bind-hidden="!redirectsUploadText.value" data-bind-text="redirectsUploadText.value"></small>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
125
145
|
<div class="wpx-toggles">
|
|
126
146
|
<label class="wpx-toggle" hidden data-bind-hidden="!fromWp.value"><input type="checkbox" class="form-switch" data-model="optComments.value" data-bind-disabled="opt.value.posts !== 'blog'"> Approved comments
|
|
127
147
|
<span data-help="Approved comments go to the Blog's comments, replies under the comment they answer. Spam, unapproved comments, pingbacks and trackbacks are never imported."></span></label>
|
|
128
148
|
<label class="wpx-toggle"><input type="checkbox" class="form-switch" data-model="optMenus.value"> Menus
|
|
129
149
|
<span data-help="Each WordPress menu becomes a menu here (wp-…), pointing at the new addresses. It is not put on the site until you choose it for the navbar or a footer in Menus › Locations."></span></label>
|
|
130
150
|
<label class="wpx-toggle"><input type="checkbox" class="form-switch" data-model="optRedirects.value"> Redirects from the old addresses
|
|
131
|
-
<span data-help-title="Redirects" data-help="Links and search results that point at the old addresses keep working: each old page, post, category and tag address answers with a permanent (301) redirect to its new one, in SEO › Redirects. ?p=123 and ?page_id=45 addresses are answered too. An address a page on this site already uses is never redirected."></span></label>
|
|
151
|
+
<span data-help-title="Redirects" data-help="Links and search results that point at the old addresses keep working: each old page, post, category and tag address answers with a permanent (301) redirect to its new one, in SEO › Redirects. ?p=123 and ?page_id=45 addresses are answered too. The old site's own redirects (above) are added with them. An address a page on this site already uses is never redirected."></span></label>
|
|
132
152
|
<label class="wpx-toggle"><input type="checkbox" class="form-switch" data-model="optDrafts.value"> Drafts and private items
|
|
133
153
|
<span data-help="Drafts, pending, private and password-protected pages, posts and products - imported as drafts, so nobody sees them until you publish them. Items in the WordPress bin are never imported."></span></label>
|
|
134
154
|
<label class="wpx-toggle" hidden data-bind-hidden="!hasProducts.value"><input type="checkbox" class="form-switch" data-model="optProducts.value" data-bind-disabled="!shopAvailable.value"> WooCommerce products
|
|
@@ -232,7 +252,7 @@
|
|
|
232
252
|
<div class="wpx-card" hidden data-bind-hidden="!redirectRows.value.length">
|
|
233
253
|
<div class="wpx-card-title">Redirects
|
|
234
254
|
<span data-bind-text="redirectCount.value" class="wpx-chip"></span>
|
|
235
|
-
<span data-help="The old addresses that will send visitors (and search engines) on to the new ones. Skipped ones say why."></span></div>
|
|
255
|
+
<span data-help="The old addresses that will send visitors (and search engines) on to the new ones, the old site's own redirects among them. Skipped ones say why."></span></div>
|
|
236
256
|
<div class="wpx-list wpx-redirects" data-each="redirectRows.value key=from"></div>
|
|
237
257
|
</div>
|
|
238
258
|
</div>
|
|
@@ -286,7 +306,9 @@
|
|
|
286
306
|
.wpx-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; }
|
|
287
307
|
.wpx-toggle { display: flex; align-items: center; gap: .5rem; font-size: var(--dm-text-sm); }
|
|
288
308
|
.wpx-zip { display: flex; flex-direction: column; gap: .4rem; padding: .5rem .65rem; border: 1px dashed var(--dm-border); border-radius: var(--dm-radius-md); }
|
|
289
|
-
.wpx-zip-actions { display: flex; gap: .4rem; align-items: center; }
|
|
309
|
+
.wpx-zip-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
|
|
310
|
+
.wpx-paste { display: flex; flex-direction: column; gap: .4rem; }
|
|
311
|
+
.wpx-paste-text { width: 100%; font-family: var(--dm-font-mono, monospace); font-size: .85rem; resize: vertical; }
|
|
290
312
|
.wpx-zip-pick { cursor: pointer; }
|
|
291
313
|
.wpx-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--dm-border); border-radius: var(--dm-radius-md); overflow: hidden; align-self: flex-start; }
|
|
292
314
|
.wpx-seg button { display: inline-flex; align-items: center; gap: .35rem; border: 0; background: none; color: var(--dm-text); padding: .35rem .75rem; cursor: pointer; font: inherit; font-size: var(--dm-text-sm); }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{apiRequest as
|
|
1
|
+
import{apiRequest as x,getToken as No}from"../api.js";import{addBannerAction as Oo}from"../lib/plugin-chrome.js";import{helpPopovers as Dt}from"../lib/help-popover.js";import{onceClosed as Bo,openMenuAt as B,sidebarCount as q,viewLifetime as Do}from"../lib/tool-kit.js";import{SHAPES as Ut,whileLoading as Ht}from"../lib/loading.js";import{fmtDateTime as Uo}from"../lib/dates.js";import{applyChoice as Ho,chooseAllPeople as _t,choosePerson as _o,choiceItems as jt,cleanOptions as Le,counts as zt,customTypeRows as jo,homeCard as zo,inviteNote as Wo,peopleSummary as Fo,personMenuItems as Ko,personRow as Zo,reportPersonRow as Jo,defaultOptions as Ge,draftKey as Vo,draftQuestion as Yo,historyRow as Go,internalTypeRows as Qo,isDirty as Xo,kindTabs as es,liveDrafts as Wt,optionsSnapshot as Ft,PLAN_FILTERS as Kt,planMatches as Zt,planRow as ts,planTiles as Jt,productSummary as as,progressPercent as os,progressText as ss,REPORT_FILTERS as Vt,redirectRow as ns,redirectsListText as rs,reportMatches as Yt,reportRow as ls,stagedRow as is,typeMenuItems as cs,widgetAreaRows as ps,widgetsFileText as ds,withDraft as Gt,withFooterChoice as us,withListPage as ms,withTypeChoice as hs}from"../lib/wordpress-import-arrange.js";const Qt=/^#\/wordpress-import\/?(\?.*)?$/,X="#/wordpress-import",b="/import/wordpress",Pe=400,vs=`
|
|
2
2
|
<div class="wpx-row" data-id="{{id}}" tabindex="0">
|
|
3
3
|
<span class="wpx-main"><strong>{{title}}</strong><small>{{meta}}</small></span>
|
|
4
4
|
<span class="wpx-chips"><span class="wpx-chip" data-bind-class="pillClass">{{pill}}</span></span>
|
|
5
5
|
<button type="button" class="wpx-kebab" aria-label="Actions for {{title}}" title="Actions">\u22EE</button>
|
|
6
|
-
</div>`,
|
|
6
|
+
</div>`,Xt=`
|
|
7
7
|
<div class="wpx-row" data-key="{{key}}" tabindex="0">
|
|
8
8
|
<span class="wpx-main">
|
|
9
9
|
<strong>{{title}}</strong>
|
|
@@ -14,17 +14,17 @@ import{apiRequest as $,getToken as Mo}from"../api.js";import{addBannerAction as
|
|
|
14
14
|
</span>
|
|
15
15
|
<span class="wpx-chips"><span class="wpx-chip" data-bind-class="pillCls">{{pill}}</span></span>
|
|
16
16
|
<button type="button" class="wpx-kebab" aria-label="Actions for {{title}}" title="Actions">\u22EE</button>
|
|
17
|
-
</div>`,
|
|
17
|
+
</div>`,ea=`
|
|
18
18
|
<div class="wpx-row" data-from="{{from}}" tabindex="0">
|
|
19
19
|
<span class="wpx-main"><span class="wpx-where">{{from}} \u2192 {{to}}</span><span class="wpx-reason" data-bind-hidden="!reason">{{reason}}</span></span>
|
|
20
20
|
<span class="wpx-chips"><span class="wpx-chip" data-bind-class="pillClass">{{pill}}</span></span>
|
|
21
21
|
<button type="button" class="wpx-kebab" aria-label="Actions for {{from}}" title="Actions">\u22EE</button>
|
|
22
|
-
</div>`,
|
|
22
|
+
</div>`,ws=`
|
|
23
23
|
<div class="wpx-row" data-id="{{id}}" tabindex="0">
|
|
24
24
|
<span class="wpx-main"><strong>{{title}}</strong><small>{{meta}}</small><span class="wpx-reason">{{summary}}</span></span>
|
|
25
25
|
<span class="wpx-chips"><span class="wpx-chip" data-bind-class="pillClass">{{pill}}</span></span>
|
|
26
26
|
<button type="button" class="wpx-kebab" aria-label="Actions for {{title}}" title="Actions">\u22EE</button>
|
|
27
|
-
</div>`,
|
|
27
|
+
</div>`,fs=`
|
|
28
28
|
<div class="wpx-row wpx-type-row" data-type="{{type}}" tabindex="0">
|
|
29
29
|
<span class="wpx-main">
|
|
30
30
|
<strong>{{label}}</strong>
|
|
@@ -42,7 +42,7 @@ import{apiRequest as $,getToken as Mo}from"../api.js";import{addBannerAction as
|
|
|
42
42
|
</span>
|
|
43
43
|
<span class="wpx-chips"><span class="wpx-chip" data-bind-class="pillClass">{{pill}}</span></span>
|
|
44
44
|
<button type="button" class="wpx-kebab" aria-label="Actions for {{label}}" title="Actions">\u22EE</button>
|
|
45
|
-
</div>`,
|
|
45
|
+
</div>`,bs=`
|
|
46
46
|
<div class="wpx-row wpx-person" data-key="{{key}}" tabindex="0">
|
|
47
47
|
<span class="wpx-main">
|
|
48
48
|
<strong>{{name}}</strong>
|
|
@@ -57,12 +57,12 @@ import{apiRequest as $,getToken as Mo}from"../api.js";import{addBannerAction as
|
|
|
57
57
|
</span>
|
|
58
58
|
<span class="wpx-chips"><span class="wpx-chip" data-bind-class="pillClass">{{pill}}</span></span>
|
|
59
59
|
<button type="button" class="wpx-kebab" aria-label="Actions for {{name}}" title="Actions">\u22EE</button>
|
|
60
|
-
</div>`,
|
|
60
|
+
</div>`,gs=`
|
|
61
61
|
<div class="wpx-row" data-key="{{key}}" tabindex="0">
|
|
62
62
|
<span class="wpx-main"><strong>{{name}}</strong><small>{{meta}}</small><span class="wpx-reason" data-bind-hidden="!reason">{{reason}}</span></span>
|
|
63
63
|
<span class="wpx-chips"><span class="wpx-chip" data-bind-class="pillClass">{{pill}}</span></span>
|
|
64
64
|
<button type="button" class="wpx-kebab" aria-label="Actions for {{name}}" title="Actions">\u22EE</button>
|
|
65
|
-
</div>`,
|
|
65
|
+
</div>`,ys=`
|
|
66
66
|
<div class="wpx-row wpx-widget-row" data-area="{{area}}" tabindex="0">
|
|
67
67
|
<span class="wpx-main">
|
|
68
68
|
<strong>{{label}}</strong>
|
|
@@ -76,7 +76,7 @@ import{apiRequest as $,getToken as Mo}from"../api.js";import{addBannerAction as
|
|
|
76
76
|
</span>
|
|
77
77
|
<span class="wpx-chips"><span class="wpx-chip" data-bind-class="pillClass">{{pill}}</span></span>
|
|
78
78
|
<button type="button" class="wpx-kebab" aria-label="Actions for {{label}}" title="Actions">\u22EE</button>
|
|
79
|
-
</div>`,Vt='<div class="wpx-tile"><strong>{{value}}</strong><small>{{label}} <span data-bind-hidden="!sub">{{sub}}</span></small></div>',Ze='<p class="wpx-alert"><span>{{text}}</span></p>',Jt="<li>{{text}}</li>",ls='<div class="wpx-fact"><dt>{{label}}</dt><dd>{{value}}</dd></div>',Ve='<button type="button" data-on-click="$root.pickSeg($data)" data-bind-class="cls">{{label}} <b>{{count}}</b></button>',f=$o(Ft);function Je(m,r,i){return new Promise((g,L)=>{const w=new XMLHttpRequest,A=new FormData;A.append("file",r),w.open("POST",`/api${m}`);const b=Mo();b&&w.setRequestHeader("Authorization",`Bearer ${b}`),w.upload.onprogress=u=>{u.lengthComputable&&i(u.loaded/u.total)},w.onload=()=>{let u=null;try{u=JSON.parse(w.responseText)}catch{}w.status>=200&&w.status<300?g(u):L(new Error(u?.error||`The upload failed (${w.status}).`))},w.onerror=()=>L(new Error("The upload failed - the connection dropped.")),w.send(A),f.add(()=>{w.readyState!==4&&w.abort()})})}const Se=m=>m>=1048576?`${Math.round(m/1048576)} MB`:`${Math.max(1,Math.round(m/1024))} KB`,ee=m=>String(m??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function is(m){const r=document.createElement("template");return r.innerHTML=m.trim(),r.content.firstElementChild}async function Le(m,r){const i=E.confirm(m,r);let g=null;try{g=[...document.querySelectorAll(".dm-dialog-overlay")].at(-1)??null}catch{}const L=f.add(()=>{if(!g)return;const w=g;g=null;try{w.querySelector(".dm-dialog-cancel")?.click(),w.remove()}catch{}});try{return await i}finally{g=null,L()}}function Ye(m){navigator.clipboard?.writeText(m).then(()=>E.toast("Copied.",{type:"success"}),()=>E.toast(m,{type:"info",duration:8e3}))}function z(m,r,i,g){const L=E.contextMenu(m,{cursor:"glyph",match:r,inherit:!1,density:"compact",items:i});f.add(()=>L?.destroy?.());const w=b=>{const u=b.target.closest(r);if(!u||!m.contains(u))return;const p=b.target.closest(".wpx-kebab");if(p){B(p);return}g?.(u)},A=b=>{const u=b.target.closest(r);u&&(b.key==="F10"&&b.shiftKey?(b.preventDefault(),B(u)):b.key==="Enter"&&b.target===u&&g&&(b.preventDefault(),b.stopPropagation(),g(u)))};m.addEventListener("click",w),m.addEventListener("keydown",A),f.add(()=>{m.removeEventListener("click",w),m.removeEventListener("keydown",A)})}export const wordpressImportView={templateUrl:"/admin/js/templates/wordpress-import.html",async onMount(m){f.reset();const r=m.get(0).querySelector(".wpx")||m.get(0),i=()=>Ft.test(location.hash)&&r.isConnected;let g="";try{g=S.get("auth_user")?.id||""}catch{}const L=Bo(g),w=()=>{try{return L?S.get(L):null}catch{return null}},A=e=>{try{L&&S.set(L,e)}catch{}},b=r.querySelector(".wpx-loading");let u;try{u=await At(b,$(`${y}/status`),qt.rows)}catch(e){if(!r.isConnected)return;b&&(b.hidden=!0);const t=r.querySelector(".wpx-failed");t&&(t.textContent=`Could not load the importer: ${e.message||e}. Reload the page to try again.`,t.hidden=!1);return}if(!i())return;b&&(b.hidden=!0),r.querySelector(".wpx-body").hidden=!1;const p=M.observable(u.staged||[]),j=M.observable(u.history||[]),te=M.observable(u.blog||{available:!1}),Ge=M.observable(u.shop||{available:!1}),W=u.limits||{},Qe=u.people?.defaultRole||"",x=M.observable(u.running||null),h=M.observable(""),v=M.observable(null),de=M.observable(!1),Pe=M.observable(!1),Ce=M.observable(""),c=M.observable(Ke(te.peek().available)),F=M.observable("all"),D=M.observable(""),ae=M.observable(""),ue=M.observable(""),oe=M.observable(""),me=M.observable(""),he=M.observable(!1),U=M.observable(u.crawl||null),we=M.observable(""),ve=M.observable(""),Yt=M.computed(()=>U.value?.status==="running"),Gt=M.computed(()=>!!String(we.value||"").trim()),Qt=M.computed(()=>{const e=U.value;if(!e)return"";const t=e.found?` - ${e.read} of ${e.found} page${e.found===1?"":"s"} read${e.failed?`, ${e.failed} could not be read`:""}`:"";return`${e.phase||"Reading"} on ${e.url}${t}\u2026`});let fe=!0;const cs=()=>p.peek().find(e=>e.id===h.peek())||null,K=M.computed(()=>p.value.find(e=>e.id===h.value)||null),Xt=M.computed(()=>h.value?"preview":"start"),H=M.computed(()=>!!te.value.available),ea=M.computed(()=>!!(v.value?.shop||Ge.value).available),Xe=M.computed(()=>!!h.value&&_o(c.value,H.value)),Z=e=>M.computed({read:()=>c.value[e]!==!1,write:t=>{c.value={...c.peek(),[e]:!!t}}}),P=e=>{c.value={...c.peek(),...e}},_=e=>{try{return So(e)}catch{return e}},ta=M.computed(()=>p.value.map(e=>Vo(e,_))),aa=M.computed(()=>j.value.map(e=>Uo(e,_))),V=M.computed(()=>(v.value?.items||[]).map(e=>({...e,choice:c.value.choices?.[e.key]}))),oa=M.computed(()=>zo(V.value).map(e=>({...e,cls:D.value===e.id?"is-on":"",seg:"kind"}))),sa=M.computed(()=>Ot(V.value,Ut,Ht,D.value)),na=M.computed(()=>Ut.map(e=>({...e,count:sa.value[e.id],cls:F.value===e.id?"is-on":"",seg:"filter"}))),Re=M.computed(()=>{const e=ae.value.trim().toLowerCase();return V.value.filter(t=>(!D.value||t.kind===D.value)&&Ht(t,F.value)&&(!e||`${t.title} ${t.target} ${t.oldUrl} ${t.postType||""}`.toLowerCase().includes(e)))}),ra=M.computed(()=>Re.value.slice(0,$e).map(e=>{const t=jo(e);return{...t,pillCls:`${t.pillClass}${e.choice?" is-chosen":""}`}})),la=M.computed(()=>Re.value.length>$e?`Showing the first ${$e} of ${Re.value.length} - search or filter to find the rest.`:""),ia=M.computed(()=>V.value.length?"Nothing matches.":"This export has nothing to import."),ca=M.computed(()=>_t(v.value)),pa=M.computed(()=>(v.value?.notes||[]).map(e=>({text:e}))),da=M.computed(()=>(v.value?.redirects||[]).slice(0,$e).map(e=>({...e,pill:e.action==="skip"?"Skipped":e.action==="update"?"Update":"New",pillClass:e.action==="skip"?"is-muted":"is-ok"}))),ua=M.computed(()=>String((v.value?.redirects||[]).filter(e=>e.action!=="skip").length)),ma=M.computed(()=>v.value?.site?.title||K.value?.siteTitle||"WordPress export"),et=M.computed(()=>(v.value?.site?.platform||K.value?.platform||"wordpress")==="wordpress"),ha=M.computed(()=>{const e=K.value,t=v.value?.site;return e?.source==="crawl"?[t?.url||e?.siteUrl,e?.at&&`read from the live site ${_(e.at)}`].filter(Boolean).join(" \xB7 "):et.value?[t?.url||e?.siteUrl,e?.fileName,t?.wxrVersion&&`WXR ${t.wxrVersion}`,e?.at&&`uploaded ${_(e.at)}`].filter(Boolean).join(" \xB7 "):[t?.url||e?.siteUrl,e?.fileName,`${t?.platformName||e?.platformName} export`,e?.at&&`uploaded ${_(e.at)}`].filter(Boolean).join(" \xB7 ")}),se=M.computed(()=>Wo(v.value)),wa=M.computed(()=>se.value?.note||""),va=M.computed(()=>se.value?.tone==="warn"?"is-warn":"is-info"),fa=M.computed(()=>(se.value?.rows||[]).map(e=>({...e,id:e.label}))),ba=M.computed(()=>(se.value?.notes||[]).map(e=>({text:e}))),ga=M.computed(()=>!!se.value),k=M.computed(()=>Ro(v.value)),ya=M.computed(()=>!!k.value),xa=M.computed(()=>k.value?.wp||""),ka=M.computed(()=>k.value?.now||""),Ma=M.computed(()=>k.value?.after||""),Ta=M.computed(()=>k.value?.tone==="warn"?"":"is-info"),Ea=M.computed(()=>(k.value?.notes||[]).map(e=>({text:e}))),$a=M.computed(()=>k.value?.editNow||""),Sa=M.computed(()=>!!k.value?.frontSwitch),La=M.computed(()=>!!k.value?.latestSwitch),Pa=M.computed(()=>!!k.value?.postsSwitch),Ca=M.computed(()=>k.value?.postsText||""),tt=M.computed(()=>k.value?.question||""),at=M.computed(()=>!!tt.value&&typeof c.value.homeReplace!="boolean"),Ra=M.computed({read:()=>c.value.latestPosts===!0,write:e=>P({latestPosts:!!e})}),qa=M.computed({read:()=>!!k.value?.postsId&&c.value.postsPage===k.value.postsId,write:e=>P({postsPage:e&&k.peek()?.postsId||0})}),qe=M.computed(()=>Co(v.value)),Ae=M.computed(()=>Ho(v.value)),Aa=M.computed(()=>!!(qe.value.length||Ae.value.length)),Ia=M.computed(()=>{const e=Ae.value.length;return e?`Not imported: ${e} kind${e===1?"":"s"} of WordPress or plugin housekeeping`:""}),C=M.computed(()=>v.value?.people||null),Na=M.computed(()=>!!C.value?.rows?.length),Oa=M.computed(()=>(C.value?.rows||[]).map(No)),Ba=M.computed(()=>!!C.value?.canCreate),Da=M.computed(()=>(C.value?.rows||[]).some(e=>e.choosable)),ot=M.computed(()=>Ao(C.value)),Ua=M.computed(()=>ot.value.text),Ha=M.computed(()=>ot.value.tone==="warn"?"is-warn":"is-info"),_a=M.computed(()=>!!(C.value?.canCreate&&C.value?.mailReady&&C.value?.counts?.create)),za=M.computed(()=>qo(C.value)),ja=M.computed({read:()=>c.value.invite===!0,write:e=>{c.value={...c.peek(),invite:!!e}}}),Wa=M.computed(()=>H.value?`Posts go to ${te.value.basePath||"/blog"}.`:te.value.reason||"No Blog is switched on here."),be=M.computed(()=>K.value?.uploads||null),Fa=M.computed(()=>{const e=be.value;return e?`${e.fileName} - ${e.files} file${e.files===1?"":"s"}, ${Se(e.size)}${e.unsafe?`. ${e.unsafe} with unsafe names (like ../) were ignored`:""}.`:`Zip the wp-content/uploads folder and upload it here (up to ${Se(W.uploads||0)}).`}),Ka=M.computed(()=>be.value?"Replace the zip":"Upload the uploads zip"),st=M.computed(()=>K.value?.widgets||null),Za=M.computed(()=>Go(K.value,W.widgets||0)),Va=M.computed(()=>st.value?"Replace the widgets file":"Upload the widgets file"),Ie=M.observable(""),nt=M.computed(()=>Yo(v.value)),Ja=M.computed(()=>at.value?"Answer the home page question first.":""),rt=M.computed(()=>!!v.value&&!x.value&&!de.value&&!(c.value.media==="zip"&&!be.value)&&!at.value),Ya=M.computed(()=>x.value?`Importing${x.value.siteTitle?` ${x.value.siteTitle}`:""}\u2026`:""),Ga=M.computed(()=>Ko(x.value)),lt=M.computed(()=>Fo(x.value)),Qa=M.observable(Se(W.wxr||0)),it=r.querySelector(".wpx-running .wpx-bar-fill");f.add(M.effect(()=>{it&&(it.style.width=`${lt.value}%`)}));async function Ne(){const e=await $(`${y}/status`);return i()?(p.value=e.staged||[],j.value=e.history||[],te.value=e.blog||{available:!1},Ge.value=e.shop||{available:!1},e.running&&!x.peek()&&(x.value=e.running,le()),e):null}let ge=0,Oe=null;async function J({first:e=!1}={}){const t=h.peek();if(!t)return;const a=++ge;Ce.value="";const o=$(`${y}/staged/${t}/preview`,{method:"POST",body:JSON.stringify({options:Ee(c.peek(),H.peek())})});try{let l;if(e?(de.value=!0,l=await At(r.querySelector(".wpx-plan-loading"),o,qt.table)):(Pe.value=!0,l=await o),a!==ge||!i()||h.peek()!==t)return;v.value=l.plan}catch(l){if(a!==ge||!i())return;if(l.status===404){E.toast("That upload has gone - upload the export again.",{type:"warning"}),re(),Ne().catch(()=>{});return}Ce.value=`Could not read the export: ${l.message||l}`}finally{a===ge&&(de.value=!1,Pe.value=!1)}}let ye="";f.add(M.effect(()=>{const e=`${h.value}|${Dt(c.value)}`;if(e===ye)return;const t=ye.split("|")[0];ye=e,!(!h.value||t!==h.value)&&(clearTimeout(Oe),Oe=setTimeout(()=>J(),250))})),f.add(()=>clearTimeout(Oe)),f.add(M.effect(()=>{const e=h.value,t=c.value,a=Xe.value;if(!e||!fe||!L)return;const o=w();A(Wt(o,g,e,a?{options:Ee(t,!0),at:new Date().toISOString(),was:e}:null))}));const Be=e=>{L&&A(Wt(w(),g,e,null))};async function ne(e){if(!p.peek().some(d=>d.id===e))return;const t=p.peek().find(d=>d.id===e),a=Bt(w(),p.peek().map(d=>d.id),g).items[e];if(fe=!a,v.value=null,F.value="all",D.value="",ae.value="",c.value=Ke(H.peek()),ye=`${e}|${Dt(c.peek())}`,h.value=e,await J({first:!0}),!i()||h.peek()!==e||!a)return;await new Promise(d=>setTimeout(d,0));const o=Do({when:a.at?_(a.at):"",file:t?.fileName||""}),l=await Le(ee(o.text),{title:o.title,confirmText:o.confirmText,cancelText:o.cancelText});!i()||h.peek()!==e||(fe=!0,l?Be(e):c.value=Ee(a.options,H.peek()))}function re(){h.value="",v.value=null,fe=!0}async function ct(e=h.peek()){const t=p.peek().find(a=>a.id===e);if(t&&await Le(`Discard the upload of <strong>${ee(t.siteTitle||t.fileName)}</strong>? Nothing has been imported from it.`,{title:"Discard upload",confirmText:"Discard",danger:!0}))try{if(await $(`${y}/staged/${e}`,{method:"DELETE"}),Be(e),!i())return;h.peek()===e&&re(),p.value=p.peek().filter(a=>a.id!==e),q(X)}catch(a){E.toast(`Not discarded: ${a.message||a}`,{type:"error"})}}async function pt(e){if(!e)return;if(oe.value="",!/\.(xml|zip)$/i.test(e.name)){oe.value="Upload the .xml file WordPress exports, or a .zip holding it.";return}if(W.wxr&&e.size>W.wxr*1.2&&/\.xml$/i.test(e.name)){oe.value=`That file is over ${Se(W.wxr)}.`;return}const t=r.querySelector(".wpx-start .wpx-upload .wpx-bar-fill");ue.value=`Uploading ${e.name}\u2026`;try{const a=await Je(`${y}/upload`,e,o=>{t&&(t.style.width=`${Math.round(o*100)}%`),ue.value=o<1?`Uploading ${e.name} - ${Math.round(o*100)}%`:`Reading ${e.name}\u2026`});if(!i())return;p.value=[a,...p.peek().filter(o=>o.id!==a.id)],q(X),await ne(a.id)}catch(a){i()&&(oe.value=a.message||String(a))}finally{i()&&(ue.value="",t&&(t.style.width="0"))}}async function Xa(e){const t=h.peek();if(!e||!t)return;if(!/\.zip$/i.test(e.name)){E.toast("Zip the wp-content/uploads folder and upload the .zip.",{type:"warning"});return}const a=r.querySelector(".wpx-zip-fill");me.value=`Uploading ${e.name}\u2026`;try{const o=await Je(`${y}/staged/${t}/uploads`,e,l=>{a&&(a.style.width=`${Math.round(l*100)}%`),me.value=l<1?`Uploading ${e.name} - ${Math.round(l*100)}%`:`Checking ${e.name}\u2026`});if(!i())return;p.value=p.peek().map(l=>l.id===o.id?o:l),h.peek()===t&&J()}catch(o){i()&&E.toast(o.message||String(o),{type:"error"})}finally{i()&&(me.value="",a&&(a.style.width="0"))}}async function eo(e){const t=h.peek();if(!(!e||!t)){if(!/\.(wie|json)$/i.test(e.name)){E.toast('Upload the .wie file the "Widget Importer & Exporter" plugin exports.',{type:"warning"});return}Ie.value=`Reading ${e.name}\u2026`;try{const a=await Je(`${y}/staged/${t}/widgets`,e,()=>{});if(!i())return;p.value=p.peek().map(o=>o.id===a.id?a:o),h.peek()===t&&J()}catch(a){i()&&E.toast(a.message||String(a),{type:"error"})}finally{i()&&(Ie.value="")}}}async function to(){const e=h.peek();try{const t=await $(`${y}/staged/${e}/widgets`,{method:"DELETE"});if(!i())return;p.value=p.peek().map(a=>a.id===t.id?t:a),J()}catch(t){E.toast(`Not removed: ${t.message||t}`,{type:"error"})}}async function ao(){const e=h.peek();try{const t=await $(`${y}/staged/${e}/uploads`,{method:"DELETE"});if(!i())return;p.value=p.peek().map(a=>a.id===t.id?t:a),J()}catch(t){E.toast(`Not removed: ${t.message||t}`,{type:"error"})}}async function oo(){const e=h.peek(),t=v.peek();if(!e||!t||!rt.peek())return;const o=_t(t).filter(d=>d.value&&d.id!=="comments").map(d=>`${d.value} ${d.label.toLowerCase()}`);if(!(!await Le(`Import <strong>${ee(t.site?.title||"this export")}</strong>: ${ee(o.join(", ")||"nothing new")}? Pages edited here since an earlier import are left alone unless you chose Overwrite.`,{title:"Run the import",confirmText:"Run import"})||!i()||h.peek()!==e))try{const d=await $(`${y}/staged/${e}/run`,{method:"POST",body:JSON.stringify({options:Ee(c.peek(),H.peek())})});if(Be(e),!i())return;x.value={...d.job,siteTitle:t.site?.title||""},re(),q(X),le()}catch(d){E.toast(`The import did not start: ${d.message||d}`,{type:"error"})}}let De=null;function le(){clearTimeout(De);const e=x.peek();e&&(De=setTimeout(async()=>{try{const t=await $(`${y}/jobs/${e.id}`);if(!i())return;if(x.value={...t.job,siteTitle:e.siteTitle},t.job.status==="running")return le();if(x.value=null,await Ne().catch(()=>{}),q(X),q("#/pages"),q("#/media"),q("#/plugins/shopping-cart"),q("#/collections"),q("#/blocks"),!i())return;t.job.status==="done"?(E.toast("The import has finished - here is its report.",{type:"success"}),ke(t.job.reportId)):(E.toast(`The import stopped: ${t.job.error||"an error"}`,{type:"error"}),t.job.reportId&&ke(t.job.reportId))}catch(t){if(!i())return;if(t.status===404){x.value=null,Ne().catch(()=>{});return}le()}},700))}f.add(()=>clearTimeout(De)),x.peek()&&le();async function so(){ve.value="";try{U.value=await $(`${y}/crawl`,{method:"POST",body:JSON.stringify({url:String(we.peek()||"").trim()})}),xe()}catch(e){i()&&(ve.value=e.message||String(e))}}async function no(){try{U.value=(await $(`${y}/crawl`,{method:"DELETE"})).crawl}catch(e){E.toast(e.message||String(e),{type:"error"})}}let Ue=null;function xe(){clearTimeout(Ue),Ue=setTimeout(async()=>{let e;try{e=(await $(`${y}/crawl`)).crawl}catch{i()&&xe();return}if(i()){if(U.value=e,e?.status==="running")return xe();e?.status==="done"&&e.meta?(we.value="",await $(`${y}/crawl`,{method:"DELETE"}).catch(()=>{}),U.value=null,p.value=[e.meta,...p.peek().filter(t=>t.id!==e.meta.id)],q(X),E.toast("The site has been read - here is what the import would do.",{type:"success"}),await ne(e.meta.id)):e&&e.status!=="running"&&(ve.value=e.status==="stopped"?"Stopped - nothing was kept.":`The site could not be read: ${e.error||"an error"}`,await $(`${y}/crawl`,{method:"DELETE"}).catch(()=>{}),U.value=null)}},1e3)}f.add(()=>clearTimeout(Ue)),U.peek()&&xe();let Y=!1;async function ke(e){if(Y||!e)return;Y=!0;let t;try{t=await $(`${y}/history/${e}`)}catch(s){Y=!1,E.toast(`Could not open the report: ${s.message||s}`,{type:"error"});return}if(!i()){Y=!1;return}let a;try{a=E.slideover({title:ee(`Report - ${t.run?.siteTitle||"WordPress import"}`),size:"lg",position:"right"})}catch(s){throw Y=!1,s}const o=is(`
|
|
79
|
+
</div>`,ta='<div class="wpx-tile"><strong>{{value}}</strong><small>{{label}} <span data-bind-hidden="!sub">{{sub}}</span></small></div>',Qe='<p class="wpx-alert"><span>{{text}}</span></p>',aa="<li>{{text}}</li>",xs='<div class="wpx-fact"><dt>{{label}}</dt><dd>{{value}}</dd></div>',Xe='<button type="button" data-on-click="$root.pickSeg($data)" data-bind-class="cls">{{label}} <b>{{count}}</b></button>',f=Do(Qt);function Re(h,n,i){return new Promise((y,L)=>{const v=new XMLHttpRequest,A=new FormData;A.append("file",n),v.open("POST",`/api${h}`);const g=No();g&&v.setRequestHeader("Authorization",`Bearer ${g}`),v.upload.onprogress=m=>{m.lengthComputable&&i(m.loaded/m.total)},v.onload=()=>{let m=null;try{m=JSON.parse(v.responseText)}catch{}v.status>=200&&v.status<300?y(m):L(new Error(m?.error||`The upload failed (${v.status}).`))},v.onerror=()=>L(new Error("The upload failed - the connection dropped.")),v.send(A),f.add(()=>{v.readyState!==4&&v.abort()})})}const Ce=h=>h>=1048576?`${Math.round(h/1048576)} MB`:`${Math.max(1,Math.round(h/1024))} KB`,ee=h=>String(h??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function ks(h){const n=document.createElement("template");return n.innerHTML=h.trim(),n.content.firstElementChild}async function qe(h,n){const i=E.confirm(h,n);let y=null;try{y=[...document.querySelectorAll(".dm-dialog-overlay")].at(-1)??null}catch{}const L=f.add(()=>{if(!y)return;const v=y;y=null;try{v.querySelector(".dm-dialog-cancel")?.click(),v.remove()}catch{}});try{return await i}finally{y=null,L()}}function et(h){navigator.clipboard?.writeText(h).then(()=>E.toast("Copied.",{type:"success"}),()=>E.toast(h,{type:"info",duration:8e3}))}function W(h,n,i,y){const L=E.contextMenu(h,{cursor:"glyph",match:n,inherit:!1,density:"compact",items:i});f.add(()=>L?.destroy?.());const v=g=>{const m=g.target.closest(n);if(!m||!h.contains(m))return;const p=g.target.closest(".wpx-kebab");if(p){B(p);return}y?.(m)},A=g=>{const m=g.target.closest(n);m&&(g.key==="F10"&&g.shiftKey?(g.preventDefault(),B(m)):g.key==="Enter"&&g.target===m&&y&&(g.preventDefault(),g.stopPropagation(),y(m)))};h.addEventListener("click",v),h.addEventListener("keydown",A),f.add(()=>{h.removeEventListener("click",v),h.removeEventListener("keydown",A)})}export const wordpressImportView={templateUrl:"/admin/js/templates/wordpress-import.html",async onMount(h){f.reset();const n=h.get(0).querySelector(".wpx")||h.get(0),i=()=>Qt.test(location.hash)&&n.isConnected;let y="";try{y=S.get("auth_user")?.id||""}catch{}const L=Vo(y),v=()=>{try{return L?S.get(L):null}catch{return null}},A=e=>{try{L&&S.set(L,e)}catch{}},g=n.querySelector(".wpx-loading");let m;try{m=await Ht(g,x(`${b}/status`),Ut.rows)}catch(e){if(!n.isConnected)return;g&&(g.hidden=!0);const t=n.querySelector(".wpx-failed");t&&(t.textContent=`Could not load the importer: ${e.message||e}. Reload the page to try again.`,t.hidden=!1);return}if(!i())return;g&&(g.hidden=!0),n.querySelector(".wpx-body").hidden=!1;const p=M.observable(m.staged||[]),F=M.observable(m.history||[]),te=M.observable(m.blog||{available:!1}),tt=M.observable(m.shop||{available:!1}),K=m.limits||{},at=m.people?.defaultRole||"",k=M.observable(m.running||null),d=M.observable(""),w=M.observable(null),ue=M.observable(!1),Ae=M.observable(!1),Ie=M.observable(""),c=M.observable(Ge(te.peek().available)),Z=M.observable("all"),D=M.observable(""),ae=M.observable(""),me=M.observable(""),oe=M.observable(""),he=M.observable(""),ve=M.observable(!1),U=M.observable(m.crawl||null),we=M.observable(""),fe=M.observable(""),oa=M.computed(()=>U.value?.status==="running"),sa=M.computed(()=>!!String(we.value||"").trim()),na=M.computed(()=>{const e=U.value;if(!e)return"";const t=e.found?` - ${e.read} of ${e.found} page${e.found===1?"":"s"} read${e.failed?`, ${e.failed} could not be read`:""}`:"";return`${e.phase||"Reading"} on ${e.url}${t}\u2026`});let be=!0;const Ms=()=>p.peek().find(e=>e.id===d.peek())||null,H=M.computed(()=>p.value.find(e=>e.id===d.value)||null),ra=M.computed(()=>d.value?"preview":"start"),_=M.computed(()=>!!te.value.available),la=M.computed(()=>!!(w.value?.shop||tt.value).available),ot=M.computed(()=>!!d.value&&Xo(c.value,_.value)),J=e=>M.computed({read:()=>c.value[e]!==!1,write:t=>{c.value={...c.peek(),[e]:!!t}}}),P=e=>{c.value={...c.peek(),...e}},z=e=>{try{return Uo(e)}catch{return e}},ia=M.computed(()=>p.value.map(e=>is(e,z))),ca=M.computed(()=>F.value.map(e=>Go(e,z))),V=M.computed(()=>(w.value?.items||[]).map(e=>({...e,choice:c.value.choices?.[e.key]}))),pa=M.computed(()=>es(V.value).map(e=>({...e,cls:D.value===e.id?"is-on":"",seg:"kind"}))),da=M.computed(()=>zt(V.value,Kt,Zt,D.value)),ua=M.computed(()=>Kt.map(e=>({...e,count:da.value[e.id],cls:Z.value===e.id?"is-on":"",seg:"filter"}))),Ne=M.computed(()=>{const e=ae.value.trim().toLowerCase();return V.value.filter(t=>(!D.value||t.kind===D.value)&&Zt(t,Z.value)&&(!e||`${t.title} ${t.target} ${t.oldUrl} ${t.postType||""}`.toLowerCase().includes(e)))}),ma=M.computed(()=>Ne.value.slice(0,Pe).map(e=>{const t=ts(e);return{...t,pillCls:`${t.pillClass}${e.choice?" is-chosen":""}`}})),ha=M.computed(()=>Ne.value.length>Pe?`Showing the first ${Pe} of ${Ne.value.length} - search or filter to find the rest.`:""),va=M.computed(()=>V.value.length?"Nothing matches.":"This export has nothing to import."),wa=M.computed(()=>Jt(w.value)),fa=M.computed(()=>(w.value?.notes||[]).map(e=>({text:e}))),ba=M.computed(()=>(w.value?.redirects||[]).slice(0,Pe).map(ns)),ga=M.computed(()=>String((w.value?.redirects||[]).filter(e=>e.action!=="skip").length)),ya=M.computed(()=>w.value?.site?.title||H.value?.siteTitle||"WordPress export"),st=M.computed(()=>(w.value?.site?.platform||H.value?.platform||"wordpress")==="wordpress"),xa=M.computed(()=>{const e=H.value,t=w.value?.site;return e?.source==="crawl"?[t?.url||e?.siteUrl,e?.at&&`read from the live site ${z(e.at)}`].filter(Boolean).join(" \xB7 "):st.value?[t?.url||e?.siteUrl,e?.fileName,t?.wxrVersion&&`WXR ${t.wxrVersion}`,e?.at&&`uploaded ${z(e.at)}`].filter(Boolean).join(" \xB7 "):[t?.url||e?.siteUrl,e?.fileName,`${t?.platformName||e?.platformName} export`,e?.at&&`uploaded ${z(e.at)}`].filter(Boolean).join(" \xB7 ")}),se=M.computed(()=>as(w.value)),ka=M.computed(()=>se.value?.note||""),Ma=M.computed(()=>se.value?.tone==="warn"?"is-warn":"is-info"),Ta=M.computed(()=>(se.value?.rows||[]).map(e=>({...e,id:e.label}))),Ea=M.computed(()=>(se.value?.notes||[]).map(e=>({text:e}))),$a=M.computed(()=>!!se.value),T=M.computed(()=>zo(w.value)),Sa=M.computed(()=>!!T.value),La=M.computed(()=>T.value?.wp||""),Pa=M.computed(()=>T.value?.now||""),Ra=M.computed(()=>T.value?.after||""),Ca=M.computed(()=>T.value?.tone==="warn"?"":"is-info"),qa=M.computed(()=>(T.value?.notes||[]).map(e=>({text:e}))),Aa=M.computed(()=>T.value?.editNow||""),Ia=M.computed(()=>!!T.value?.frontSwitch),Na=M.computed(()=>!!T.value?.latestSwitch),Oa=M.computed(()=>!!T.value?.postsSwitch),Ba=M.computed(()=>T.value?.postsText||""),nt=M.computed(()=>T.value?.question||""),rt=M.computed(()=>!!nt.value&&typeof c.value.homeReplace!="boolean"),Da=M.computed({read:()=>c.value.latestPosts===!0,write:e=>P({latestPosts:!!e})}),Ua=M.computed({read:()=>!!T.value?.postsId&&c.value.postsPage===T.value.postsId,write:e=>P({postsPage:e&&T.peek()?.postsId||0})}),Oe=M.computed(()=>jo(w.value)),Be=M.computed(()=>Qo(w.value)),Ha=M.computed(()=>!!(Oe.value.length||Be.value.length)),_a=M.computed(()=>{const e=Be.value.length;return e?`Not imported: ${e} kind${e===1?"":"s"} of WordPress or plugin housekeeping`:""}),R=M.computed(()=>w.value?.people||null),ja=M.computed(()=>!!R.value?.rows?.length),za=M.computed(()=>(R.value?.rows||[]).map(Zo)),Wa=M.computed(()=>!!R.value?.canCreate),Fa=M.computed(()=>(R.value?.rows||[]).some(e=>e.choosable)),lt=M.computed(()=>Fo(R.value)),Ka=M.computed(()=>lt.value.text),Za=M.computed(()=>lt.value.tone==="warn"?"is-warn":"is-info"),Ja=M.computed(()=>!!(R.value?.canCreate&&R.value?.mailReady&&R.value?.counts?.create)),Va=M.computed(()=>Wo(R.value)),Ya=M.computed({read:()=>c.value.invite===!0,write:e=>{c.value={...c.peek(),invite:!!e}}}),Ga=M.computed(()=>_.value?`Posts go to ${te.value.basePath||"/blog"}.`:te.value.reason||"No Blog is switched on here."),ge=M.computed(()=>H.value?.uploads||null),Qa=M.computed(()=>{const e=ge.value;return e?`${e.fileName} - ${e.files} file${e.files===1?"":"s"}, ${Ce(e.size)}${e.unsafe?`. ${e.unsafe} with unsafe names (like ../) were ignored`:""}.`:`Zip the wp-content/uploads folder and upload it here (up to ${Ce(K.uploads||0)}).`}),Xa=M.computed(()=>ge.value?"Replace the zip":"Upload the uploads zip"),it=M.computed(()=>H.value?.widgets||null),eo=M.computed(()=>ds(H.value,K.widgets||0)),to=M.computed(()=>it.value?"Replace the widgets file":"Upload the widgets file"),De=M.observable(""),ct=M.computed(()=>ps(w.value)),pt=M.computed(()=>H.value?.redirects||null),ao=M.computed(()=>rs(H.value,w.value)),oo=M.computed(()=>pt.value?"Replace the list":"Upload a list"),Ue=M.observable(""),ne=M.observable(!1),ye=M.observable(""),so=M.computed(()=>ne.value?"Close":"Paste a list"),no=M.computed(()=>!String(ye.value||"").trim()),ro=M.computed(()=>rt.value?"Answer the home page question first.":""),dt=M.computed(()=>!!w.value&&!k.value&&!ue.value&&!(c.value.media==="zip"&&!ge.value)&&!rt.value),lo=M.computed(()=>k.value?`Importing${k.value.siteTitle?` ${k.value.siteTitle}`:""}\u2026`:""),io=M.computed(()=>ss(k.value)),ut=M.computed(()=>os(k.value)),co=M.observable(Ce(K.wxr||0)),mt=n.querySelector(".wpx-running .wpx-bar-fill");f.add(M.effect(()=>{mt&&(mt.style.width=`${ut.value}%`)}));async function He(){const e=await x(`${b}/status`);return i()?(p.value=e.staged||[],F.value=e.history||[],te.value=e.blog||{available:!1},tt.value=e.shop||{available:!1},e.running&&!k.peek()&&(k.value=e.running,ie()),e):null}let xe=0,_e=null;async function j({first:e=!1}={}){const t=d.peek();if(!t)return;const a=++xe;Ie.value="";const o=x(`${b}/staged/${t}/preview`,{method:"POST",body:JSON.stringify({options:Le(c.peek(),_.peek())})});try{let l;if(e?(ue.value=!0,l=await Ht(n.querySelector(".wpx-plan-loading"),o,Ut.table)):(Ae.value=!0,l=await o),a!==xe||!i()||d.peek()!==t)return;w.value=l.plan}catch(l){if(a!==xe||!i())return;if(l.status===404){E.toast("That upload has gone - upload the export again.",{type:"warning"}),le(),He().catch(()=>{});return}Ie.value=`Could not read the export: ${l.message||l}`}finally{a===xe&&(ue.value=!1,Ae.value=!1)}}let ke="";f.add(M.effect(()=>{const e=`${d.value}|${Ft(c.value)}`;if(e===ke)return;const t=ke.split("|")[0];ke=e,!(!d.value||t!==d.value)&&(clearTimeout(_e),_e=setTimeout(()=>j(),250))})),f.add(()=>clearTimeout(_e)),f.add(M.effect(()=>{const e=d.value,t=c.value,a=ot.value;if(!e||!be||!L)return;const o=v();A(Gt(o,y,e,a?{options:Le(t,!0),at:new Date().toISOString(),was:e}:null))}));const je=e=>{L&&A(Gt(v(),y,e,null))};async function re(e){if(!p.peek().some(u=>u.id===e))return;const t=p.peek().find(u=>u.id===e),a=Wt(v(),p.peek().map(u=>u.id),y).items[e];if(be=!a,w.value=null,Z.value="all",D.value="",ae.value="",c.value=Ge(_.peek()),ke=`${e}|${Ft(c.peek())}`,d.value=e,await j({first:!0}),!i()||d.peek()!==e||!a)return;await new Promise(u=>setTimeout(u,0));const o=Yo({when:a.at?z(a.at):"",file:t?.fileName||""}),l=await qe(ee(o.text),{title:o.title,confirmText:o.confirmText,cancelText:o.cancelText});!i()||d.peek()!==e||(be=!0,l?je(e):c.value=Le(a.options,_.peek()))}function le(){d.value="",w.value=null,be=!0}async function ht(e=d.peek()){const t=p.peek().find(a=>a.id===e);if(t&&await qe(`Discard the upload of <strong>${ee(t.siteTitle||t.fileName)}</strong>? Nothing has been imported from it.`,{title:"Discard upload",confirmText:"Discard",danger:!0}))try{if(await x(`${b}/staged/${e}`,{method:"DELETE"}),je(e),!i())return;d.peek()===e&&le(),p.value=p.peek().filter(a=>a.id!==e),q(X)}catch(a){E.toast(`Not discarded: ${a.message||a}`,{type:"error"})}}async function vt(e){if(!e)return;if(oe.value="",!/\.(xml|zip)$/i.test(e.name)){oe.value="Upload the .xml file WordPress exports, or a .zip holding it.";return}if(K.wxr&&e.size>K.wxr*1.2&&/\.xml$/i.test(e.name)){oe.value=`That file is over ${Ce(K.wxr)}.`;return}const t=n.querySelector(".wpx-start .wpx-upload .wpx-bar-fill");me.value=`Uploading ${e.name}\u2026`;try{const a=await Re(`${b}/upload`,e,o=>{t&&(t.style.width=`${Math.round(o*100)}%`),me.value=o<1?`Uploading ${e.name} - ${Math.round(o*100)}%`:`Reading ${e.name}\u2026`});if(!i())return;p.value=[a,...p.peek().filter(o=>o.id!==a.id)],q(X),await re(a.id)}catch(a){i()&&(oe.value=a.message||String(a))}finally{i()&&(me.value="",t&&(t.style.width="0"))}}async function po(e){const t=d.peek();if(!e||!t)return;if(!/\.zip$/i.test(e.name)){E.toast("Zip the wp-content/uploads folder and upload the .zip.",{type:"warning"});return}const a=n.querySelector(".wpx-zip-fill");he.value=`Uploading ${e.name}\u2026`;try{const o=await Re(`${b}/staged/${t}/uploads`,e,l=>{a&&(a.style.width=`${Math.round(l*100)}%`),he.value=l<1?`Uploading ${e.name} - ${Math.round(l*100)}%`:`Checking ${e.name}\u2026`});if(!i())return;p.value=p.peek().map(l=>l.id===o.id?o:l),d.peek()===t&&j()}catch(o){i()&&E.toast(o.message||String(o),{type:"error"})}finally{i()&&(he.value="",a&&(a.style.width="0"))}}async function uo(e){const t=d.peek();if(!(!e||!t)){if(!/\.(wie|json)$/i.test(e.name)){E.toast('Upload the .wie file the "Widget Importer & Exporter" plugin exports.',{type:"warning"});return}De.value=`Reading ${e.name}\u2026`;try{const a=await Re(`${b}/staged/${t}/widgets`,e,()=>{});if(!i())return;p.value=p.peek().map(o=>o.id===a.id?a:o),d.peek()===t&&j()}catch(a){i()&&E.toast(a.message||String(a),{type:"error"})}finally{i()&&(De.value="")}}}async function wt({file:e=null,text:t=""}){const a=d.peek();if(!(!a||!e&&!t.trim())){if(e&&!/(\.(csv|tsv|txt|json|conf)|htaccess)$/i.test(e.name)){E.toast("Upload the redirects as a .csv, .txt, .json or .htaccess file - or paste the list.",{type:"warning"});return}Ue.value=e?`Reading ${e.name}\u2026`:"Reading the list\u2026";try{const o=e?await Re(`${b}/staged/${a}/redirects`,e,()=>{}):await x(`${b}/staged/${a}/redirects`,{method:"POST",body:JSON.stringify({text:t})});if(!i())return;p.value=p.peek().map(l=>l.id===o.id?o:l),ne.value=!1,ye.value="",d.peek()===a&&j()}catch(o){i()&&E.toast(o.message||String(o),{type:"error"})}finally{i()&&(Ue.value="")}}}async function mo(){const e=d.peek();try{const t=await x(`${b}/staged/${e}/redirects`,{method:"DELETE"});if(!i())return;p.value=p.peek().map(a=>a.id===t.id?t:a),j()}catch(t){E.toast(`Not removed: ${t.message||t}`,{type:"error"})}}async function ho(){const e=d.peek();try{const t=await x(`${b}/staged/${e}/widgets`,{method:"DELETE"});if(!i())return;p.value=p.peek().map(a=>a.id===t.id?t:a),j()}catch(t){E.toast(`Not removed: ${t.message||t}`,{type:"error"})}}async function vo(){const e=d.peek();try{const t=await x(`${b}/staged/${e}/uploads`,{method:"DELETE"});if(!i())return;p.value=p.peek().map(a=>a.id===t.id?t:a),j()}catch(t){E.toast(`Not removed: ${t.message||t}`,{type:"error"})}}async function wo(){const e=d.peek(),t=w.peek();if(!e||!t||!dt.peek())return;const o=Jt(t).filter(u=>u.value&&u.id!=="comments").map(u=>`${u.value} ${u.label.toLowerCase()}`);if(!(!await qe(`Import <strong>${ee(t.site?.title||"this export")}</strong>: ${ee(o.join(", ")||"nothing new")}? Pages edited here since an earlier import are left alone unless you chose Overwrite.`,{title:"Run the import",confirmText:"Run import"})||!i()||d.peek()!==e))try{const u=await x(`${b}/staged/${e}/run`,{method:"POST",body:JSON.stringify({options:Le(c.peek(),_.peek())})});if(je(e),!i())return;k.value={...u.job,siteTitle:t.site?.title||""},le(),q(X),ie()}catch(u){E.toast(`The import did not start: ${u.message||u}`,{type:"error"})}}let ze=null;function ie(){clearTimeout(ze);const e=k.peek();e&&(ze=setTimeout(async()=>{try{const t=await x(`${b}/jobs/${e.id}`);if(!i())return;if(k.value={...t.job,siteTitle:e.siteTitle},t.job.status==="running")return ie();if(k.value=null,await He().catch(()=>{}),q(X),q("#/pages"),q("#/media"),q("#/plugins/shopping-cart"),q("#/collections"),q("#/blocks"),!i())return;t.job.status==="done"?(E.toast("The import has finished - here is its report.",{type:"success"}),Te(t.job.reportId)):(E.toast(`The import stopped: ${t.job.error||"an error"}`,{type:"error"}),t.job.reportId&&Te(t.job.reportId))}catch(t){if(!i())return;if(t.status===404){k.value=null,He().catch(()=>{});return}ie()}},700))}f.add(()=>clearTimeout(ze)),k.peek()&&ie();async function fo(){fe.value="";try{U.value=await x(`${b}/crawl`,{method:"POST",body:JSON.stringify({url:String(we.peek()||"").trim()})}),Me()}catch(e){i()&&(fe.value=e.message||String(e))}}async function bo(){try{U.value=(await x(`${b}/crawl`,{method:"DELETE"})).crawl}catch(e){E.toast(e.message||String(e),{type:"error"})}}let We=null;function Me(){clearTimeout(We),We=setTimeout(async()=>{let e;try{e=(await x(`${b}/crawl`)).crawl}catch{i()&&Me();return}if(i()){if(U.value=e,e?.status==="running")return Me();e?.status==="done"&&e.meta?(we.value="",await x(`${b}/crawl`,{method:"DELETE"}).catch(()=>{}),U.value=null,p.value=[e.meta,...p.peek().filter(t=>t.id!==e.meta.id)],q(X),E.toast("The site has been read - here is what the import would do.",{type:"success"}),await re(e.meta.id)):e&&e.status!=="running"&&(fe.value=e.status==="stopped"?"Stopped - nothing was kept.":`The site could not be read: ${e.error||"an error"}`,await x(`${b}/crawl`,{method:"DELETE"}).catch(()=>{}),U.value=null)}},1e3)}f.add(()=>clearTimeout(We)),U.peek()&&Me();let Y=!1;async function Te(e){if(Y||!e)return;Y=!0;let t;try{t=await x(`${b}/history/${e}`)}catch(s){Y=!1,E.toast(`Could not open the report: ${s.message||s}`,{type:"error"});return}if(!i()){Y=!1;return}let a;try{a=E.slideover({title:ee(`Report - ${t.run?.siteTitle||"WordPress import"}`),size:"lg",position:"right"})}catch(s){throw Y=!1,s}const o=ks(`
|
|
80
80
|
<div class="wpx wpx-report">
|
|
81
81
|
<p class="wpx-note" data-bind-text="meta.value"></p>
|
|
82
82
|
<div class="wpx-tiles" data-each="tiles.value key=id"></div>
|
|
@@ -92,4 +92,4 @@ import{apiRequest as $,getToken as Mo}from"../api.js";import{addBannerAction as
|
|
|
92
92
|
<div class="wpx-list wpx-report-people" data-each="people.value key=key"></div>
|
|
93
93
|
<div class="wpx-card-title" data-bind-hidden="!redirects.value.length">Redirects</div>
|
|
94
94
|
<div class="wpx-list wpx-report-redirects" data-each="redirects.value key=from"></div>
|
|
95
|
-
</div>`);o.querySelector(".wpx-tiles").innerHTML=Vt,o.querySelector(".wpx-note-list").innerHTML=Ze,o.querySelector(".wpx-seg").innerHTML=Ve,o.querySelector(".wpx-report-items").innerHTML=Kt,o.querySelector(".wpx-report-redirects").innerHTML=Zt,o.querySelector(".wpx-report-people").innerHTML=ns;const l=M.observable(t.run?.summary?.failed?"failed":"all"),d=/^\/[a-z0-9][a-z0-9/-]{0,200}$/.test(t.home?.previous||"")?t.home.previous:"",je=t.items||[],Lt=Ot(je,zt,jt),O=t.run?.summary||{},We=s=>Object.values(O.kinds||{}).reduce((n,T)=>n+(T[s]||0),0),po={meta:M.observable([_(t.run?.at),t.run?.by,t.run?.file,t.run?.durationMs?`${Math.max(1,Math.round(t.run.durationMs/1e3))} s`:""].filter(Boolean).join(" \xB7 ")),tiles:M.observable([{id:"made",label:"Made",value:We("created"),sub:""},{id:"updated",label:"Updated",value:We("updated"),sub:""},{id:"kept",label:"Left as is",value:We("kept"),sub:""},{id:"redirects",label:"Redirects",value:(O.redirects?.created||0)+(O.redirects?.updated||0),sub:""},...O.people?[{id:"people",label:"Accounts made",value:O.people.created||0,sub:O.people.invited?`${O.people.invited} emailed`:""}]:[],{id:"comments",label:"Comments",value:O.comments||0,sub:""},{id:"failed",label:"Failed",value:O.failed||0,sub:""}]),notes:M.observable((t.notes||[]).map(s=>({text:s}))),homePrevious:M.observable(d),homePreviousText:M.observable(d?`This site's home page from before the import${t.home?.previousTitle?` ("${t.home.previousTitle}")`:""} is now a draft at ${d} - nothing was deleted. Publish it there, or delete it, from Pages.`:""),people:M.observable((t.people||[]).map(Oo)),filters:M.computed(()=>zt.filter(s=>s.id==="all"||Lt[s.id]).map(s=>({...s,count:Lt[s.id],cls:l.value===s.id?"is-on":""}))),rows:M.computed(()=>je.filter(s=>jt(s,l.value)).slice(0,1e3).map(s=>{const n=Zo(s);return{...n,pillCls:n.pillClass}})),redirects:M.observable((t.redirects||[]).filter(s=>s.result!=="skipped").slice(0,1e3).map(s=>({...s,reason:s.error||"",pill:s.result==="failed"?"Failed":s.result==="updated"?"Updated":"Added",pillClass:s.result==="failed"?"is-bad":"is-ok"})))};a.element.appendChild(o);const uo=M.applyBindings(po,o,{methods:{pickSeg:s=>{l.value=s.id}}}),mo=Rt(o),Pt=new Map(je.map(s=>[s.key,s])),ho=o.querySelector(".wpx-report-items"),wo=s=>{const n=Pt.get(s.dataset.key);if(!n)return[];const T=typeof n.target=="string"&&n.target.startsWith("/")?n.target:"",R=[{header:n.title}];if(T&&n.result!=="failed"&&n.result!=="skipped"&&R.push({label:"Open on the site",icon:"external-link",action:()=>window.open(T,"_blank","noopener")}),T&&(n.kind==="page"||n.kind==="custom"&&!n.collection)&&(n.result==="created"||n.result==="updated"||n.result==="kept")&&R.push({label:"Edit the page",icon:"edit",action:()=>{a.close(),location.hash=`#/pages/edit${T}`}}),n.kind==="widgets"&&/^[a-z0-9][a-z0-9-]{0,79}$/.test(n.target||"")&&["created","updated","kept"].includes(n.result)&&(R.push({label:"Edit the block",icon:"edit",action:()=>{a.close(),location.hash=`#/blocks/edit/${n.target}`}}),n.footer&&R.push({label:"Footer settings",icon:"settings",action:()=>{a.close(),location.hash="#/settings"}})),(n.kind==="collection"||n.kind==="custom")&&n.result!=="failed"&&n.result!=="skipped"&&/^[a-z0-9-]{1,80}$/.test(n.kind==="collection"?n.target:n.collection||"")){const Q=n.kind==="collection"?n.target:n.collection;R.push({label:"Open the collection",icon:"database",action:()=>{a.close(),location.hash=`#/collections/${Q}/entries`}})}return n.kind==="product"&&n.entryId&&/^[\w-]{1,64}$/.test(n.entryId)&&R.push({label:"Edit in the Shop",icon:"shopping-bag",action:()=>{a.close(),location.hash=`#/plugins/shopping-cart/products/${encodeURIComponent(n.entryId)}`}}),/^https?:\/\//i.test(n.oldUrl)&&R.push({label:"Open the old address",icon:"link",action:()=>window.open(n.oldUrl,"_blank","noopener,noreferrer")}),T&&R.push({label:"Copy the new address",icon:"copy",action:()=>Ye(new URL(T,location.origin).href)}),R},vo=E.contextMenu(ho,{cursor:"glyph",match:".wpx-row",inherit:!1,density:"compact",items:wo}),fo=o.querySelector(".wpx-report-people"),bo=new Map((t.people||[]).map(s=>[s.key,s])),go=E.contextMenu(fo,{cursor:"glyph",match:".wpx-row",inherit:!1,density:"compact",items:s=>{const n=bo.get(s.dataset.key);if(!n)return[];const T=/^[0-9a-f-]{36}$/i.test(n.userId||"")?n.userId:"";return[{header:n.name},...T&&n.result!=="skipped"?[{label:"Open their account",icon:"user",action:()=>{a.close(),location.hash=`#/users/edit/${T}`}}]:[],{label:"Open Users",icon:"users",action:()=>{a.close(),location.hash="#/users"}}]}}),yo=o.querySelector(".wpx-report-redirects"),xo=E.contextMenu(yo,{cursor:"glyph",match:".wpx-row",inherit:!1,density:"compact",items:s=>[{header:s.dataset.from},...s.dataset.from.includes("*")?[]:[{label:"Try it on the site",icon:"external-link",action:()=>window.open(s.dataset.from,"_blank","noopener")}],{label:"Open SEO \u203A Redirects",icon:"corner-up-right",action:()=>{a.close(),location.hash="#/seo/redirects"}}]}),Fe=s=>{if(s.target.closest(".wpx-open-previous")&&d){a.close(),location.hash=`#/pages/edit${d}`;return}const n=s.target.closest(".wpx-kebab");if(n){B(n);return}const T=s.target.closest(".wpx-report-people .wpx-row");if(T){B(T.querySelector(".wpx-kebab")||T);return}const R=s.target.closest(".wpx-report-items .wpx-row");if(!R)return;const Q=Pt.get(R.dataset.key);Q?.target?.startsWith("/")&&Q.result!=="failed"&&Q.result!=="skipped"&&window.open(Q.target,"_blank","noopener")},Ct=s=>{const n=s.target.closest(".wpx-row");n&&(s.key==="F10"&&s.shiftKey?(s.preventDefault(),B(n)):s.key==="Enter"&&s.target===n&&(s.preventDefault(),s.stopPropagation(),Fe({target:n})))};o.addEventListener("click",Fe),o.addEventListener("keydown",Ct);const ko=f.add(()=>a.close());Eo(a,()=>{Y=!1,uo.dispose(),mo(),vo?.destroy?.(),xo?.destroy?.(),go?.destroy?.(),o.removeEventListener("click",Fe),o.removeEventListener("keydown",Ct),ko()}),a.open(),I.scan(o)}async function ro(e){const t=j.peek().find(a=>a.id===e);if(t&&await Le(`Remove the import of <strong>${ee(t.siteTitle||t.source)}</strong> from this list? Everything it imported stays on the site.`,{title:"Remove from the history",confirmText:"Remove"}))try{if(await $(`${y}/history/${e}`,{method:"DELETE"}),!i())return;j.value=j.peek().filter(a=>a.id!==e),q(X)}catch(a){E.toast(`Not removed: ${a.message||a}`,{type:"error"})}}r.querySelector(".wpx-staged").innerHTML=ts,r.querySelector(".wpx-items").innerHTML=Kt,r.querySelector(".wpx-redirects").innerHTML=Zt,r.querySelector(".wpx-history").innerHTML=as,r.querySelector(".wpx-tiles").innerHTML=Vt,r.querySelector(".wpx-note-list").innerHTML=Ze,r.querySelector(".wpx-home-notes").innerHTML=Ze,r.querySelector(".wpx-kinds").innerHTML=Ve,r.querySelector(".wpx-filters").innerHTML=Ve,r.querySelector(".wpx-facts").innerHTML=ls,r.querySelector(".wpx-product-notes").innerHTML=Jt,r.querySelector(".wpx-types").innerHTML=os,r.querySelector(".wpx-internal").innerHTML=Jt,r.querySelector(".wpx-people-list").innerHTML=ss,r.querySelector(".wpx-widget-areas").innerHTML=rs;const lo={mode:Xt,job:x,jobTitle:Ya,jobText:Ga,jobPct:lt,staged:p,stagedRows:ta,historyRows:aa,plan:v,planLoading:de,planError:Ce,refreshing:Pe,opt:c,blogAvailable:H,blogNote:Wa,dirty:Xe,canRun:rt,siteTitle:ma,siteMeta:ha,fromWp:et,tiles:ca,notes:pa,kinds:oa,filters:na,rows:ra,moreText:la,emptyText:ia,redirectRows:da,redirectCount:ua,query:ae,uploadText:ue,uploadError:oe,dropping:he,crawlUrl:we,crawlError:ve,crawlRunning:Yt,crawlReady:Gt,crawlText:Qt,wxrLimit:Qa,zipInfo:be,zipText:Fa,zipButton:Ka,zipUploadText:me,hasPeople:Na,peopleRows:Oa,peopleCanCreate:Ba,peopleChoosable:Da,peopleNote:Ua,peopleNoteCls:Ha,inviteAvailable:_a,inviteText:za,optInvite:ja,shopAvailable:ea,hasProducts:ga,productNote:wa,productNoteCls:va,productFacts:fa,productNotes:ba,typeRows:qe,internalRows:Ae,hasCustom:Aa,internalSummary:Ia,widgetsInfo:st,widgetsText:Za,widgetsButton:Va,widgetsUploadText:Ie,widgetRows:nt,hasHome:ya,homeWp:xa,homeNow:ka,homeAfter:Ma,homeAfterCls:Ta,homeNotes:Ea,homeEdit:$a,homeFrontSwitch:Sa,homeLatestSwitch:La,homePostsSwitch:Pa,homePostsText:Ca,homeQuestion:tt,runWhy:Ja,optHome:Z("home"),optLatest:Ra,optPostsPage:qa,optComments:Z("comments"),optMenus:Z("menus"),optRedirects:Z("redirects"),optDrafts:Z("drafts"),optProducts:Z("products")},io=M.applyBindings(lo,r,{methods:{back:()=>re(),startCrawl:()=>so(),stopCrawl:()=>no(),discard:()=>ct(),run:()=>oo(),resetChoices:()=>{c.value=Ke(H.peek())},postsBlog:()=>P({posts:"blog"}),postsPages:()=>P({posts:"pages"}),postsSkip:()=>P({posts:"skip"}),mediaDownload:()=>P({media:"download"}),mediaZip:()=>P({media:"zip"}),mediaSkip:()=>P({media:"skip"}),homeYes:()=>P({homeReplace:!0}),homeNo:()=>P({homeReplace:!1}),removeZip:()=>ao(),removeWidgets:()=>to(),peopleAll:()=>P({users:It(C.peek(),"create")}),peopleNone:()=>P({users:It(C.peek(),"skip")}),pickSeg:e=>{e.seg==="kind"?D.value=e.id:F.value=e.id},showProducts:()=>{D.value="product",F.value="all",ae.value="",r.querySelector(".wpx-items")?.closest(".wpx-card")?.scrollIntoView({behavior:"smooth",block:"start"})}}});f.add(()=>io.dispose()),f.add(Rt(r,{position:"bottom"}));const ie=r.querySelector(".wpx-file"),dt=()=>{const e=ie.files?.[0];ie.value="",pt(e)};ie.addEventListener("change",dt);const G=r.querySelector(".wpx-drop"),ut=e=>{e.preventDefault(),he.value=!0},mt=()=>{he.value=!1},ht=e=>{e.preventDefault(),he.value=!1,pt(e.dataTransfer?.files?.[0])};G.addEventListener("dragover",ut),G.addEventListener("dragleave",mt),G.addEventListener("drop",ht);const Me=r.querySelector(".wpx-zip-file"),wt=()=>{const e=Me.files?.[0];Me.value="",Xa(e)};Me.addEventListener("change",wt);const Te=r.querySelector(".wpx-wie-file"),vt=()=>{const e=Te.files?.[0];Te.value="",eo(e)};Te.addEventListener("change",vt),f.add(()=>Te.removeEventListener("change",vt)),f.add(()=>{ie.removeEventListener("change",dt),G.removeEventListener("dragover",ut),G.removeEventListener("dragleave",mt),G.removeEventListener("drop",ht),Me.removeEventListener("change",wt)}),z(r.querySelector(".wpx-staged"),".wpx-row",e=>[{header:p.peek().find(t=>t.id===e.dataset.id)?.siteTitle||"Upload"},{label:"Preview the import",icon:"eye",action:()=>ne(e.dataset.id)},{label:"Discard the upload",icon:"trash-2",action:()=>ct(e.dataset.id)}],e=>ne(e.dataset.id));const ft=(e,t)=>{c.value={...c.peek(),choices:Lo(c.peek().choices,e,t)}};z(r.querySelector(".wpx-items"),".wpx-row",e=>{const t=V.peek().find(o=>o.key===e.dataset.key);if(!t)return[];const a=[{header:t.title}];for(const o of Nt(t,t.choice))a.push({label:o.label,icon:o.icon,action:()=>ft(t.key,o.id)});return t.oldUrl&&/^https?:\/\//i.test(t.oldUrl)&&a.push({label:"Open the old address",icon:"link",action:()=>window.open(t.oldUrl,"_blank","noopener,noreferrer")}),t.target?.startsWith("/")&&(t.action==="update"||t.action==="keep")&&a.push({label:"Open it on this site",icon:"external-link",action:()=>window.open(t.target,"_blank","noopener")}),a.length===1&&a.push({label:"Nothing to change here",icon:"info",disabled:!0,action:()=>{}}),a},e=>B(e.querySelector(".wpx-kebab")||e));const bt=(e,t)=>{c.value=es(c.peek(),e,t)},gt=(e,t)=>{c.value=Xo(c.peek(),e,t)},co=e=>{D.value="",F.value="all",ae.value=e,r.querySelector(".wpx-items")?.closest(".wpx-card")?.scrollIntoView({behavior:"smooth",block:"start"})},ce=r.querySelector(".wpx-types"),yt=e=>{if(!e.target.closest(".wpx-type-ctl"))return;e.stopPropagation();const a=e.target.closest("button[data-as]"),o=e.target.closest(".wpx-type-row");a&&o&&bt(o.dataset.type,a.dataset.as)},xt=e=>{const t=e.target.closest("input[data-list-page]"),a=e.target.closest(".wpx-type-row");t&&a&>(a.dataset.type,t.checked)};ce.addEventListener("click",yt,!0),ce.addEventListener("change",xt),f.add(()=>{ce.removeEventListener("click",yt,!0),ce.removeEventListener("change",xt)}),z(ce,".wpx-type-row",e=>{const t=qe.peek().find(a=>a.type===e.dataset.type);return t?[{header:`${t.label} ("${t.type}")`},...Jo(t).map(a=>({label:a.label,icon:a.icon,action:()=>{a.id==="show"?co(t.type):a.id==="list"||a.id==="nolist"?gt(t.type,a.id==="list"):bt(t.type,a.id)}}))]:[]},e=>B(e.querySelector(".wpx-kebab")||e));const He=(e,t)=>{c.value=Qo(c.peek(),e,t)},pe=r.querySelector(".wpx-widget-areas"),kt=e=>{e.target.closest(".wpx-type-ctl")&&e.stopPropagation()},Mt=e=>{const t=e.target.closest("input[data-footer]"),a=e.target.closest(".wpx-widget-row");t&&a&&He(a.dataset.area,t.checked)};pe.addEventListener("click",kt,!0),pe.addEventListener("change",Mt),f.add(()=>{pe.removeEventListener("click",kt,!0),pe.removeEventListener("change",Mt)}),z(pe,".wpx-widget-row",e=>{const t=nt.peek().find(l=>l.area===e.dataset.area),a=V.peek().find(l=>l.key===`widgets:${e.dataset.area}`);if(!t)return[];const o=[{header:`${t.label} ("${t.area}")`}];if(t.canPlace&&o.push(t.placeOn?{label:"Leave it out of the footer",icon:"eye-off",action:()=>He(t.area,!1)}:{label:"Place in the footer",icon:"layout",action:()=>He(t.area,!0)}),a)for(const l of Nt(a,a.choice))o.push({label:l.label,icon:l.icon,action:()=>ft(a.key,l.id)});return o.length===1&&o.push({label:"Nothing to change here",icon:"info",disabled:!0,action:()=>{}}),o},e=>B(e.querySelector(".wpx-kebab")||e));const Tt=(e,t)=>{const a=C.peek()?.rows?.find(o=>o.key===e);a&&P({users:Po(c.peek().users,a,t)})},_e=r.querySelector(".wpx-people-list"),Et=e=>{if(!e.target.closest(".wpx-type-ctl"))return;e.stopPropagation();const a=e.target.closest("button[data-user]"),o=e.target.closest(".wpx-person");a&&o&&Tt(o.dataset.key,a.dataset.user)};_e.addEventListener("click",Et,!0),f.add(()=>_e.removeEventListener("click",Et,!0)),z(_e,".wpx-person",e=>{const t=C.peek()?.rows?.find(a=>a.key===e.dataset.key);return t?[{header:t.name},...Io(t).map(a=>({label:a.label,icon:a.icon,disabled:!!a.disabled,action:()=>{a.disabled||(a.id==="copy"?Ye(t.email):Tt(t.key,a.id))}}))]:[]},e=>B(e.querySelector(".wpx-kebab")||e));const N=r.querySelector(".wpx-role");f.add(M.effect(()=>{const e=C.value;if(!N)return;const t=e?.roles||[],a=e?.role||"",o=`${t.map(l=>l.name).join(",")}|${a}`;N.dataset.sig!==o&&(N.dataset.sig=o,N.replaceChildren(...t.map(l=>{const d=document.createElement("option");return d.value=l.name,d.textContent=l.name===Qe?`${l.label} (default)`:l.label,d})),N.value=a)}));const $t=()=>P({userRole:N.value===Qe?"":N.value});N?.addEventListener("change",$t),f.add(()=>N?.removeEventListener("change",$t)),z(r.querySelector(".wpx-redirects"),".wpx-row",e=>[{header:e.dataset.from},{label:"Copy the old address",icon:"copy",action:()=>Ye(e.dataset.from)}],null),z(r.querySelector(".wpx-history"),".wpx-row",e=>[{header:j.peek().find(t=>t.id===e.dataset.id)?.siteTitle||"Import"},{label:"Open the report",icon:"file-text",action:()=>ke(e.dataset.id)},{label:"Remove from the history",icon:"trash-2",action:()=>ro(e.dataset.id)}],e=>ke(e.dataset.id)),To(m,{id:"wpx-upload",icon:"upload",title:"Upload an export",onClick:()=>{h.peek()&&re(),setTimeout(()=>ie.click(),0)}}),I.scan(r);const ze=Bt(w(),p.peek().map(e=>e.id),g);ze.pruned&&L&&A({owner:g,items:ze.items});const St=Object.entries(ze.items).sort((e,t)=>String(t[1].at).localeCompare(String(e[1].at)))[0];St&&!x.peek()&&await ne(St[0])}};
|
|
95
|
+
</div>`);o.querySelector(".wpx-tiles").innerHTML=ta,o.querySelector(".wpx-note-list").innerHTML=Qe,o.querySelector(".wpx-seg").innerHTML=Xe,o.querySelector(".wpx-report-items").innerHTML=Xt,o.querySelector(".wpx-report-redirects").innerHTML=ea,o.querySelector(".wpx-report-people").innerHTML=gs;const l=M.observable(t.run?.summary?.failed?"failed":"all"),u=/^\/[a-z0-9][a-z0-9/-]{0,200}$/.test(t.home?.previous||"")?t.home.previous:"",Je=t.items||[],Nt=zt(Je,Vt,Yt),O=t.run?.summary||{},Ve=s=>Object.values(O.kinds||{}).reduce((r,$)=>r+($[s]||0),0),Mo={meta:M.observable([z(t.run?.at),t.run?.by,t.run?.file,t.run?.durationMs?`${Math.max(1,Math.round(t.run.durationMs/1e3))} s`:""].filter(Boolean).join(" \xB7 ")),tiles:M.observable([{id:"made",label:"Made",value:Ve("created"),sub:""},{id:"updated",label:"Updated",value:Ve("updated"),sub:""},{id:"kept",label:"Left as is",value:Ve("kept"),sub:""},{id:"redirects",label:"Redirects",value:(O.redirects?.created||0)+(O.redirects?.updated||0),sub:""},...O.people?[{id:"people",label:"Accounts made",value:O.people.created||0,sub:O.people.invited?`${O.people.invited} emailed`:""}]:[],{id:"comments",label:"Comments",value:O.comments||0,sub:""},{id:"failed",label:"Failed",value:O.failed||0,sub:""}]),notes:M.observable((t.notes||[]).map(s=>({text:s}))),homePrevious:M.observable(u),homePreviousText:M.observable(u?`This site's home page from before the import${t.home?.previousTitle?` ("${t.home.previousTitle}")`:""} is now a draft at ${u} - nothing was deleted. Publish it there, or delete it, from Pages.`:""),people:M.observable((t.people||[]).map(Jo)),filters:M.computed(()=>Vt.filter(s=>s.id==="all"||Nt[s.id]).map(s=>({...s,count:Nt[s.id],cls:l.value===s.id?"is-on":""}))),rows:M.computed(()=>Je.filter(s=>Yt(s,l.value)).slice(0,1e3).map(s=>{const r=ls(s);return{...r,pillCls:r.pillClass}})),redirects:M.observable((t.redirects||[]).filter(s=>s.result!=="skipped").slice(0,1e3).map(s=>({...s,reason:s.error||"",pill:s.result==="failed"?"Failed":s.result==="updated"?"Updated":"Added",pillClass:s.result==="failed"?"is-bad":"is-ok"})))};a.element.appendChild(o);const To=M.applyBindings(Mo,o,{methods:{pickSeg:s=>{l.value=s.id}}}),Eo=Dt(o),Ot=new Map(Je.map(s=>[s.key,s])),$o=o.querySelector(".wpx-report-items"),So=s=>{const r=Ot.get(s.dataset.key);if(!r)return[];const $=typeof r.target=="string"&&r.target.startsWith("/")?r.target:"",C=[{header:r.title}];if($&&r.result!=="failed"&&r.result!=="skipped"&&C.push({label:"Open on the site",icon:"external-link",action:()=>window.open($,"_blank","noopener")}),$&&(r.kind==="page"||r.kind==="custom"&&!r.collection)&&(r.result==="created"||r.result==="updated"||r.result==="kept")&&C.push({label:"Edit the page",icon:"edit",action:()=>{a.close(),location.hash=`#/pages/edit${$}`}}),r.kind==="widgets"&&/^[a-z0-9][a-z0-9-]{0,79}$/.test(r.target||"")&&["created","updated","kept"].includes(r.result)&&(C.push({label:"Edit the block",icon:"edit",action:()=>{a.close(),location.hash=`#/blocks/edit/${r.target}`}}),r.footer&&C.push({label:"Footer settings",icon:"settings",action:()=>{a.close(),location.hash="#/settings"}})),(r.kind==="collection"||r.kind==="custom")&&r.result!=="failed"&&r.result!=="skipped"&&/^[a-z0-9-]{1,80}$/.test(r.kind==="collection"?r.target:r.collection||"")){const Q=r.kind==="collection"?r.target:r.collection;C.push({label:"Open the collection",icon:"database",action:()=>{a.close(),location.hash=`#/collections/${Q}/entries`}})}return r.kind==="product"&&r.entryId&&/^[\w-]{1,64}$/.test(r.entryId)&&C.push({label:"Edit in the Shop",icon:"shopping-bag",action:()=>{a.close(),location.hash=`#/plugins/shopping-cart/products/${encodeURIComponent(r.entryId)}`}}),/^https?:\/\//i.test(r.oldUrl)&&C.push({label:"Open the old address",icon:"link",action:()=>window.open(r.oldUrl,"_blank","noopener,noreferrer")}),$&&C.push({label:"Copy the new address",icon:"copy",action:()=>et(new URL($,location.origin).href)}),C},Lo=E.contextMenu($o,{cursor:"glyph",match:".wpx-row",inherit:!1,density:"compact",items:So}),Po=o.querySelector(".wpx-report-people"),Ro=new Map((t.people||[]).map(s=>[s.key,s])),Co=E.contextMenu(Po,{cursor:"glyph",match:".wpx-row",inherit:!1,density:"compact",items:s=>{const r=Ro.get(s.dataset.key);if(!r)return[];const $=/^[0-9a-f-]{36}$/i.test(r.userId||"")?r.userId:"";return[{header:r.name},...$&&r.result!=="skipped"?[{label:"Open their account",icon:"user",action:()=>{a.close(),location.hash=`#/users/edit/${$}`}}]:[],{label:"Open Users",icon:"users",action:()=>{a.close(),location.hash="#/users"}}]}}),qo=o.querySelector(".wpx-report-redirects"),Ao=E.contextMenu(qo,{cursor:"glyph",match:".wpx-row",inherit:!1,density:"compact",items:s=>[{header:s.dataset.from},...s.dataset.from.includes("*")?[]:[{label:"Try it on the site",icon:"external-link",action:()=>window.open(s.dataset.from,"_blank","noopener")}],{label:"Open SEO \u203A Redirects",icon:"corner-up-right",action:()=>{a.close(),location.hash="#/seo/redirects"}}]}),Ye=s=>{if(s.target.closest(".wpx-open-previous")&&u){a.close(),location.hash=`#/pages/edit${u}`;return}const r=s.target.closest(".wpx-kebab");if(r){B(r);return}const $=s.target.closest(".wpx-report-people .wpx-row");if($){B($.querySelector(".wpx-kebab")||$);return}const C=s.target.closest(".wpx-report-items .wpx-row");if(!C)return;const Q=Ot.get(C.dataset.key);Q?.target?.startsWith("/")&&Q.result!=="failed"&&Q.result!=="skipped"&&window.open(Q.target,"_blank","noopener")},Bt=s=>{const r=s.target.closest(".wpx-row");r&&(s.key==="F10"&&s.shiftKey?(s.preventDefault(),B(r)):s.key==="Enter"&&s.target===r&&(s.preventDefault(),s.stopPropagation(),Ye({target:r})))};o.addEventListener("click",Ye),o.addEventListener("keydown",Bt);const Io=f.add(()=>a.close());Bo(a,()=>{Y=!1,To.dispose(),Eo(),Lo?.destroy?.(),Ao?.destroy?.(),Co?.destroy?.(),o.removeEventListener("click",Ye),o.removeEventListener("keydown",Bt),Io()}),a.open(),I.scan(o)}async function go(e){const t=F.peek().find(a=>a.id===e);if(t&&await qe(`Remove the import of <strong>${ee(t.siteTitle||t.source)}</strong> from this list? Everything it imported stays on the site.`,{title:"Remove from the history",confirmText:"Remove"}))try{if(await x(`${b}/history/${e}`,{method:"DELETE"}),!i())return;F.value=F.peek().filter(a=>a.id!==e),q(X)}catch(a){E.toast(`Not removed: ${a.message||a}`,{type:"error"})}}n.querySelector(".wpx-staged").innerHTML=vs,n.querySelector(".wpx-items").innerHTML=Xt,n.querySelector(".wpx-redirects").innerHTML=ea,n.querySelector(".wpx-history").innerHTML=ws,n.querySelector(".wpx-tiles").innerHTML=ta,n.querySelector(".wpx-note-list").innerHTML=Qe,n.querySelector(".wpx-home-notes").innerHTML=Qe,n.querySelector(".wpx-kinds").innerHTML=Xe,n.querySelector(".wpx-filters").innerHTML=Xe,n.querySelector(".wpx-facts").innerHTML=xs,n.querySelector(".wpx-product-notes").innerHTML=aa,n.querySelector(".wpx-types").innerHTML=fs,n.querySelector(".wpx-internal").innerHTML=aa,n.querySelector(".wpx-people-list").innerHTML=bs,n.querySelector(".wpx-widget-areas").innerHTML=ys;const yo={mode:ra,job:k,jobTitle:lo,jobText:io,jobPct:ut,staged:p,stagedRows:ia,historyRows:ca,plan:w,planLoading:ue,planError:Ie,refreshing:Ae,opt:c,blogAvailable:_,blogNote:Ga,dirty:ot,canRun:dt,siteTitle:ya,siteMeta:xa,fromWp:st,tiles:wa,notes:fa,kinds:pa,filters:ua,rows:ma,moreText:ha,emptyText:va,redirectRows:ba,redirectCount:ga,query:ae,uploadText:me,uploadError:oe,dropping:ve,crawlUrl:we,crawlError:fe,crawlRunning:oa,crawlReady:sa,crawlText:na,wxrLimit:co,zipInfo:ge,zipText:Qa,zipButton:Xa,zipUploadText:he,hasPeople:ja,peopleRows:za,peopleCanCreate:Wa,peopleChoosable:Fa,peopleNote:Ka,peopleNoteCls:Za,inviteAvailable:Ja,inviteText:Va,optInvite:Ya,shopAvailable:la,hasProducts:$a,productNote:ka,productNoteCls:Ma,productFacts:Ta,productNotes:Ea,typeRows:Oe,internalRows:Be,hasCustom:Ha,internalSummary:_a,widgetsInfo:it,widgetsText:eo,widgetsButton:to,widgetsUploadText:De,widgetRows:ct,redirectsInfo:pt,redirectsText:ao,redirectsButton:oo,redirectsUploadText:Ue,pasteOpen:ne,pasteText:ye,pasteButton:so,pasteEmpty:no,hasHome:Sa,homeWp:La,homeNow:Pa,homeAfter:Ra,homeAfterCls:Ca,homeNotes:qa,homeEdit:Aa,homeFrontSwitch:Ia,homeLatestSwitch:Na,homePostsSwitch:Oa,homePostsText:Ba,homeQuestion:nt,runWhy:ro,optHome:J("home"),optLatest:Da,optPostsPage:Ua,optComments:J("comments"),optMenus:J("menus"),optRedirects:J("redirects"),optDrafts:J("drafts"),optProducts:J("products")},xo=M.applyBindings(yo,n,{methods:{back:()=>le(),startCrawl:()=>fo(),stopCrawl:()=>bo(),discard:()=>ht(),run:()=>wo(),resetChoices:()=>{c.value=Ge(_.peek())},postsBlog:()=>P({posts:"blog"}),postsPages:()=>P({posts:"pages"}),postsSkip:()=>P({posts:"skip"}),mediaDownload:()=>P({media:"download"}),mediaZip:()=>P({media:"zip"}),mediaSkip:()=>P({media:"skip"}),homeYes:()=>P({homeReplace:!0}),homeNo:()=>P({homeReplace:!1}),removeZip:()=>vo(),removeWidgets:()=>ho(),removeRedirects:()=>mo(),togglePaste:()=>{ne.value=!ne.peek()},sendPaste:()=>wt({text:ye.peek()}),peopleAll:()=>P({users:_t(R.peek(),"create")}),peopleNone:()=>P({users:_t(R.peek(),"skip")}),pickSeg:e=>{e.seg==="kind"?D.value=e.id:Z.value=e.id},showProducts:()=>{D.value="product",Z.value="all",ae.value="",n.querySelector(".wpx-items")?.closest(".wpx-card")?.scrollIntoView({behavior:"smooth",block:"start"})}}});f.add(()=>xo.dispose()),f.add(Dt(n,{position:"bottom"}));const ce=n.querySelector(".wpx-file"),ft=()=>{const e=ce.files?.[0];ce.value="",vt(e)};ce.addEventListener("change",ft);const G=n.querySelector(".wpx-drop"),bt=e=>{e.preventDefault(),ve.value=!0},gt=()=>{ve.value=!1},yt=e=>{e.preventDefault(),ve.value=!1,vt(e.dataTransfer?.files?.[0])};G.addEventListener("dragover",bt),G.addEventListener("dragleave",gt),G.addEventListener("drop",yt);const Ee=n.querySelector(".wpx-zip-file"),xt=()=>{const e=Ee.files?.[0];Ee.value="",po(e)};Ee.addEventListener("change",xt);const $e=n.querySelector(".wpx-wie-file"),kt=()=>{const e=$e.files?.[0];$e.value="",uo(e)};$e.addEventListener("change",kt),f.add(()=>$e.removeEventListener("change",kt));const Se=n.querySelector(".wpx-redirects-file"),Mt=()=>{const e=Se.files?.[0];Se.value="",e&&wt({file:e})};Se.addEventListener("change",Mt),f.add(()=>Se.removeEventListener("change",Mt)),f.add(()=>{ce.removeEventListener("change",ft),G.removeEventListener("dragover",bt),G.removeEventListener("dragleave",gt),G.removeEventListener("drop",yt),Ee.removeEventListener("change",xt)}),W(n.querySelector(".wpx-staged"),".wpx-row",e=>[{header:p.peek().find(t=>t.id===e.dataset.id)?.siteTitle||"Upload"},{label:"Preview the import",icon:"eye",action:()=>re(e.dataset.id)},{label:"Discard the upload",icon:"trash-2",action:()=>ht(e.dataset.id)}],e=>re(e.dataset.id));const Tt=(e,t)=>{c.value={...c.peek(),choices:Ho(c.peek().choices,e,t)}};W(n.querySelector(".wpx-items"),".wpx-row",e=>{const t=V.peek().find(o=>o.key===e.dataset.key);if(!t)return[];const a=[{header:t.title}];for(const o of jt(t,t.choice))a.push({label:o.label,icon:o.icon,action:()=>Tt(t.key,o.id)});return t.oldUrl&&/^https?:\/\//i.test(t.oldUrl)&&a.push({label:"Open the old address",icon:"link",action:()=>window.open(t.oldUrl,"_blank","noopener,noreferrer")}),t.target?.startsWith("/")&&(t.action==="update"||t.action==="keep")&&a.push({label:"Open it on this site",icon:"external-link",action:()=>window.open(t.target,"_blank","noopener")}),a.length===1&&a.push({label:"Nothing to change here",icon:"info",disabled:!0,action:()=>{}}),a},e=>B(e.querySelector(".wpx-kebab")||e));const Et=(e,t)=>{c.value=hs(c.peek(),e,t)},$t=(e,t)=>{c.value=ms(c.peek(),e,t)},ko=e=>{D.value="",Z.value="all",ae.value=e,n.querySelector(".wpx-items")?.closest(".wpx-card")?.scrollIntoView({behavior:"smooth",block:"start"})},pe=n.querySelector(".wpx-types"),St=e=>{if(!e.target.closest(".wpx-type-ctl"))return;e.stopPropagation();const a=e.target.closest("button[data-as]"),o=e.target.closest(".wpx-type-row");a&&o&&Et(o.dataset.type,a.dataset.as)},Lt=e=>{const t=e.target.closest("input[data-list-page]"),a=e.target.closest(".wpx-type-row");t&&a&&$t(a.dataset.type,t.checked)};pe.addEventListener("click",St,!0),pe.addEventListener("change",Lt),f.add(()=>{pe.removeEventListener("click",St,!0),pe.removeEventListener("change",Lt)}),W(pe,".wpx-type-row",e=>{const t=Oe.peek().find(a=>a.type===e.dataset.type);return t?[{header:`${t.label} ("${t.type}")`},...cs(t).map(a=>({label:a.label,icon:a.icon,action:()=>{a.id==="show"?ko(t.type):a.id==="list"||a.id==="nolist"?$t(t.type,a.id==="list"):Et(t.type,a.id)}}))]:[]},e=>B(e.querySelector(".wpx-kebab")||e));const Fe=(e,t)=>{c.value=us(c.peek(),e,t)},de=n.querySelector(".wpx-widget-areas"),Pt=e=>{e.target.closest(".wpx-type-ctl")&&e.stopPropagation()},Rt=e=>{const t=e.target.closest("input[data-footer]"),a=e.target.closest(".wpx-widget-row");t&&a&&Fe(a.dataset.area,t.checked)};de.addEventListener("click",Pt,!0),de.addEventListener("change",Rt),f.add(()=>{de.removeEventListener("click",Pt,!0),de.removeEventListener("change",Rt)}),W(de,".wpx-widget-row",e=>{const t=ct.peek().find(l=>l.area===e.dataset.area),a=V.peek().find(l=>l.key===`widgets:${e.dataset.area}`);if(!t)return[];const o=[{header:`${t.label} ("${t.area}")`}];if(t.canPlace&&o.push(t.placeOn?{label:"Leave it out of the footer",icon:"eye-off",action:()=>Fe(t.area,!1)}:{label:"Place in the footer",icon:"layout",action:()=>Fe(t.area,!0)}),a)for(const l of jt(a,a.choice))o.push({label:l.label,icon:l.icon,action:()=>Tt(a.key,l.id)});return o.length===1&&o.push({label:"Nothing to change here",icon:"info",disabled:!0,action:()=>{}}),o},e=>B(e.querySelector(".wpx-kebab")||e));const Ct=(e,t)=>{const a=R.peek()?.rows?.find(o=>o.key===e);a&&P({users:_o(c.peek().users,a,t)})},Ke=n.querySelector(".wpx-people-list"),qt=e=>{if(!e.target.closest(".wpx-type-ctl"))return;e.stopPropagation();const a=e.target.closest("button[data-user]"),o=e.target.closest(".wpx-person");a&&o&&Ct(o.dataset.key,a.dataset.user)};Ke.addEventListener("click",qt,!0),f.add(()=>Ke.removeEventListener("click",qt,!0)),W(Ke,".wpx-person",e=>{const t=R.peek()?.rows?.find(a=>a.key===e.dataset.key);return t?[{header:t.name},...Ko(t).map(a=>({label:a.label,icon:a.icon,disabled:!!a.disabled,action:()=>{a.disabled||(a.id==="copy"?et(t.email):Ct(t.key,a.id))}}))]:[]},e=>B(e.querySelector(".wpx-kebab")||e));const N=n.querySelector(".wpx-role");f.add(M.effect(()=>{const e=R.value;if(!N)return;const t=e?.roles||[],a=e?.role||"",o=`${t.map(l=>l.name).join(",")}|${a}`;N.dataset.sig!==o&&(N.dataset.sig=o,N.replaceChildren(...t.map(l=>{const u=document.createElement("option");return u.value=l.name,u.textContent=l.name===at?`${l.label} (default)`:l.label,u})),N.value=a)}));const At=()=>P({userRole:N.value===at?"":N.value});N?.addEventListener("change",At),f.add(()=>N?.removeEventListener("change",At)),W(n.querySelector(".wpx-redirects"),".wpx-row",e=>[{header:e.dataset.from},{label:"Copy the old address",icon:"copy",action:()=>et(e.dataset.from)}],null),W(n.querySelector(".wpx-history"),".wpx-row",e=>[{header:F.peek().find(t=>t.id===e.dataset.id)?.siteTitle||"Import"},{label:"Open the report",icon:"file-text",action:()=>Te(e.dataset.id)},{label:"Remove from the history",icon:"trash-2",action:()=>go(e.dataset.id)}],e=>Te(e.dataset.id)),Oo(h,{id:"wpx-upload",icon:"upload",title:"Upload an export",onClick:()=>{d.peek()&&le(),setTimeout(()=>ce.click(),0)}}),I.scan(n);const Ze=Wt(v(),p.peek().map(e=>e.id),y);Ze.pruned&&L&&A({owner:y,items:Ze.items});const It=Object.entries(Ze.items).sort((e,t)=>String(t[1].at).localeCompare(String(e[1].at)))[0];It&&!k.peek()&&await re(It[0])}};
|
package/docs/DommaFeatures.md
CHANGED
|
@@ -1227,7 +1227,8 @@ The four Tools below were plugins until 0.67.0 and are now part of the CMS. They
|
|
|
1227
1227
|
- WordPress: the WXR export (`.xml` or a `.zip` holding one), media from the old site or a zip of `wp-content/uploads`, Yoast/Rank Math SEO, WooCommerce products, custom post types, widgets, authors, the home page.
|
|
1228
1228
|
- Squarespace (unreleased): its WordPress-format export. Images on the Squarespace CDN are downloaded at full size (sizes such as `?format=750w` dropped), images named only in page HTML (`data-src`) become attachments, and the preview says what Squarespace leaves out (products, events, audio/video, other blogs).
|
|
1229
1229
|
- Wix, or any site without an export (unreleased): **Copy a live site** - type the address, and the site's sitemap (or the links from its home page) is read, up to 500 pages, that host only, through `safeFetch`. Each page's words, headings, images, links and documents, blog posts (og:type article / JSON-LD BlogPosting) with dates, authors and descriptions, and the home page's menu are written as a WordPress-format export and staged like an upload. Wix images become their originals (`/v1/fill/...` dropped). The preview notes pages with little text and addresses that could not be read. Old addresses such as `/post/<slug>` redirect.
|
|
1230
|
-
|
|
1230
|
+
- The old site's own redirects (unreleased): the redirects its owner set up there come across into SEO › Redirects with their codes (301, 302, 307, 308, 410), each leading to where the import puts the page it pointed at (chains through the old site's other redirects are followed). Found without a list: WordPress's old-slug addresses (`_wp_old_slug`), Safe Redirect Manager's rules (`redirect_rule` posts in the export) and redirects met while reading a live site (written into the staged export as `redirect_rule` items). Given as a list, uploaded or pasted in the preview's "The old site's redirects" option: Squarespace URL mappings, the Redirection plugin's CSV/JSON, Yoast and Rank Math CSV, any two-column sheet, or `.htaccess` lines. Patterns and visitor-dependent rules are listed with the reason, never guessed; none is added over an address in use here; up to 2,000 a run.
|
|
1231
|
+
Where: **Tools > Maintenance > Import a site** (`#/wordpress-import`), `/api/import/wordpress` (`POST/GET/DELETE /crawl`, `POST/DELETE /staged/:id/redirects`), `server/services/wpImport/` (`platforms.js`, `crawl.js`, `redirects.js`); permission `import.wordpress`.
|
|
1231
1232
|
- **Tool switches** - Contacts, Notes, Todo, Analytics and SEO can each be switched off. A Tool that is off keeps its data, but it disappears from the sidebar, its API answers 404, and anything it feeds stops, including notification sources, calendar layers, related items and the analytics beacon. A switch takes effect after a restart.
|
|
1232
1233
|
Where: **Marketplace** (`#/plugins`) > "Built-in Tools"; `config/tools.json` (`{"notes": {"enabled": false, "locked": true}}`); `PUT /api/tools/:name`; `server/services/tools.js` - Since: 0.88.0.
|
|
1233
1234
|
- **Dependencies and cascades** - A plugin's `plugin.json` can declare dependencies:
|
|
@@ -2806,6 +2807,7 @@ Later changes to these features are in the CHANGELOG (for example 0.92.1: row-le
|
|
|
2806
2807
|
- Build your first page: create, write Markdown, preview in split and Live Preview at mobile width, publish.
|
|
2807
2808
|
- Leaving Wix: copy the live site with Import a site, read the preview's notes (thin pages, unreadable addresses), import to a staging site, check the redirects from `/post/...`, then move the domain.
|
|
2808
2809
|
- Leaving Squarespace: export the WordPress-format file, import it before closing the account, and rebuild what Squarespace leaves out.
|
|
2810
|
+
- Keep every old link working: bring the old site's own redirects across with Import a site (paste Squarespace's URL mappings, upload a Redirection export or the .htaccess file), read the skipped ones in the preview, then check them in SEO › Redirects.
|
|
2809
2811
|
- Teach the chat bot: add a chat launcher, replace the example Knowledge, try questions, then turn a week of Unanswered questions into entries and other ways of asking.
|
|
2810
2812
|
- Draft, review and publish: use the draft banner, send a client a 7-day share link, revoke it, publish from the banner.
|
|
2811
2813
|
- Members-only content: gate pages with "role and above" versus "role only" (`=role`), arrays for sibling roles, and matching menu item visibility.
|