domma-cms 1.67.2 → 1.69.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 +39 -0
- package/CLAUDE.md +2 -0
- package/admin/js/lib/layouts-arrange.js +1 -1
- package/admin/js/lib/rich-field.js +9 -2
- package/admin/js/lib/seo-defaults.js +1 -1
- package/admin/js/templates/docs/api-content.html +3 -2
- package/admin/js/templates/docs/api-layouts.html +1 -1
- package/admin/js/templates/docs/usage-navigation.html +2 -1
- package/admin/js/templates/docs/usage-pages.html +3 -1
- package/admin/js/templates/docs/usage-search-engines.html +3 -0
- package/admin/js/templates/page-editor.html +3 -3
- package/admin/js/views/form-editor.js +5 -5
- package/admin/js/views/layouts.js +7 -7
- package/admin/js/views/menu-editor.js +20 -20
- package/admin/js/views/page-editor.js +9 -9
- package/admin/js/views/seo.js +31 -30
- package/docs/DommaFeatures.md +6 -2
- package/docs/api-reference.md +7 -3
- package/docs/guides/multi-page-forms.md +1 -1
- package/docs/markdown-shortcodes.md +1 -1
- package/docs/plugin-development.md +20 -0
- package/package.json +1 -1
- package/plugins/blog/CHANGELOG.md +3 -0
- package/plugins/blog/CLAUDE.md +15 -0
- package/plugins/blog/admin/views/categories.js +5 -2
- package/plugins/blog/admin/views/kit.js +19 -0
- package/plugins/blog/docs/guide.md +2 -0
- package/plugins/blog/plugin.js +18 -2
- package/plugins/blog/plugin.json +6 -6
- package/plugins/blog/plugin.public.js +16 -2
- package/plugins/blog/public/blog.css +3 -0
- package/plugins/blog/tests/public.test.js +29 -2
- package/plugins/feedback/CLAUDE.md +22 -0
- package/plugins/feedback/admin/css/index.css +2 -0
- package/plugins/feedback/admin/views/inbox.js +5 -2
- package/plugins/feedback/admin/views/send.js +12 -5
- package/plugins/feedback/docs/guide.md +3 -2
- package/plugins/feedback/lib/sender.js +1 -1
- package/plugins/feedback/lib/shape.js +72 -11
- package/plugins/feedback/plugin.js +3 -3
- package/plugins/feedback/plugin.json +3 -2
- package/plugins/feedback/tests/api.test.js +47 -1
- package/plugins/feedback/tests/shape.test.js +87 -1
- package/plugins/free-tier.lock.json +43 -42
- package/plugins/shopping-cart/CHANGELOG.md +20 -0
- package/plugins/shopping-cart/CLAUDE.md +38 -1
- package/plugins/shopping-cart/admin/css/index.css +4 -0
- package/plugins/shopping-cart/admin/lib/kit.js +1 -0
- package/plugins/shopping-cart/admin/views/products.js +95 -3
- package/plugins/shopping-cart/admin/views/shop.js +2 -1
- package/plugins/shopping-cart/docs/guide.md +6 -1
- package/plugins/shopping-cart/inject/body.html +2 -2
- package/plugins/shopping-cart/lib/description.js +173 -0
- package/plugins/shopping-cart/lib/render.js +3 -2
- package/plugins/shopping-cart/lib/shop.js +4 -1
- package/plugins/shopping-cart/plugin.js +17 -2
- package/plugins/shopping-cart/plugin.json +3 -2
- package/plugins/shopping-cart/plugin.public.js +6 -9
- package/plugins/shopping-cart/public/lib/products.js +40 -3
- package/plugins/shopping-cart/public/shop.css +1 -0
- package/plugins/shopping-cart/tests/pure.test.js +26 -1
- package/plugins/shopping-cart/tests/seo.test.js +174 -0
- package/public/js/collection-browser.js +1 -1
- package/public/js/menu-cards.mjs +4 -4
- package/public/js/menu-look.mjs +1 -1
- package/public/js/rich-text.mjs +4 -4
- package/public/js/site.js +1 -1
- package/server/routes/api/collections.js +26 -12
- package/server/routes/api/forms.js +5 -3
- package/server/routes/api/layouts.js +8 -4
- package/server/routes/api/seo.js +10 -4
- package/server/services/adapters/FileAdapter.js +4 -3
- package/server/services/adapters/MongoAdapter.js +4 -2
- package/server/services/content.js +23 -0
- package/server/services/contentApi.js +27 -4
- package/server/services/filterEngine.js +33 -0
- package/server/services/forms.js +58 -2
- package/server/services/health.js +3 -1
- package/server/services/markdown.js +288 -38
- package/server/services/menus.js +56 -6
- package/server/services/renderer.js +28 -4
- package/server/services/richText.js +56 -3
- package/server/services/search.js +5 -2
- package/server/services/sitemap.js +5 -3
- package/server/templates/page.html +2 -2
package/admin/js/views/seo.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{apiRequest as
|
|
1
|
+
import{apiRequest as Ss}from"../api.js";import{addBannerAction as Es}from"../lib/plugin-chrome.js";import{helpPopovers as Ts}from"../lib/help-popover.js";import{onceClosed as Cs,openMenuAt as Os,viewLifetime as Ls}from"../lib/tool-kit.js";import{snippet as Rs}from"../lib/seo-analyse.js";import{checkRule as kt,matchRedirect as Is}from"../lib/seo-redirects.js";import{checkSettings as As,mergeDefaults as Mt,ORG_TYPES as Ps}from"../lib/seo-settings.js";import{pickMedia as Fe}from"../lib/media-picker.js";import{checkSeoDefaults as js,seoDefaults as Ds}from"../lib/seo-defaults.js";import{mountGoogleBusiness as Ns}from"../lib/google-business-panel.js";import{fmtDate as qs,fmtDateTime as ze}from"../lib/dates.js";import{richDescription as $t,richTextLine as St}from"../lib/rich-field.js";import{SHAPES as Us,whileLoading as Bs}from"../lib/loading.js";import{countText as ge,draftAction as _s,draftKey as Je,filterPages as Hs,fingerprint as J,pageCounts as Ws,restoreQuestion as Ye,usableDraft as Et}from"../lib/seo-arrange.js";const Ks="/seo",Qe=/^#\/seo(\/[a-z0-9-]+)?\/?(\?.*)?$/,Tt=["overview","redirects","sitemap"],Gs="#/seo",Fs={pass:"\u2713",warn:"!",fail:"\u2715",info:"i"},zs={301:"301 moved",302:"302 for now",307:"307 for now",308:"308 moved",410:"410 gone"},Js={apiRequest:Ss,addBannerAction:Es,helpPopovers:Ts,onceClosed:Cs,openMenuAt:Os,viewLifetime:Ls},Ys=async()=>Js,R=i=>String(i??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function Ve(i){const c=document.createElement("template");return c.innerHTML=i.trim(),c.content.firstElementChild}async function ye(i,c){try{await navigator.clipboard.writeText(i),E.toast(`Copied ${c}.`,{type:"success"})}catch{E.toast(`Could not copy - ${i}`,{type:"warning",duration:6e3})}}const A={user(){try{return S.get("auth_user")?.id||""}catch{return""}},get(i){try{return i?S.get(i)??null:null}catch{return null}},set(i,c){try{i&&S.set(i,c)}catch{}},drop(i){try{i&&(S.remove?S.remove(i):S.set(i,null))}catch{}},keys(i){try{return(S.keys?.()||[]).filter(c=>c.startsWith(i))}catch{return[]}}},Qs=()=>new Promise(i=>setTimeout(i,0)),Xe=async(i,c)=>(await Qs(),E.confirm(R(i),c)),Ze=i=>Xe(i.text,{title:i.title,confirmText:i.confirmText,cancelText:i.cancelText});function Ct(){try{window.dispatchEvent(new CustomEvent("dm:sidebar-count",{detail:{url:Gs}}))}catch{}}const Ot=i=>typeof i!="number"?"":i>=85?"good":i>=60?"poor":"bad",Lt=i=>i?qs(i):"",Rt=i=>{if(!i)return"";const c=Math.round((Date.now()-Date.parse(i))/6e4);if(c<1)return"just now";if(c<60)return`${c} min ago`;const U=Math.round(c/60);return U<48?`${U} hour${U===1?"":"s"} ago`:Lt(i)};function Vs(i){const c=m=>{let n=String(m??"");return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\n\r]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},U=Object.keys(i[0]||{});return`\uFEFF${[U.join(","),...i.map(m=>U.map(n=>c(m[n])).join(","))].join(`\r
|
|
2
2
|
`)}\r
|
|
3
|
-
`}function
|
|
3
|
+
`}function Xs(i,c,U="text/csv;charset=utf-8"){const m=URL.createObjectURL(new Blob([c],{type:U})),n=Object.assign(document.createElement("a"),{href:m,download:i});document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(m),1e4)}const Zs=`
|
|
4
4
|
<div class="sox-row" data-bind-data-row="id" tabindex="0" data-bind-title="path">
|
|
5
5
|
<span class="sox-pill" data-bind-data-tone="tone" data-bind-text="scoreText"></span>
|
|
6
6
|
<span class="sox-cell"><span data-bind-text="path"></span><small data-bind-text="sourceText"></small></span>
|
|
7
7
|
<span class="sox-cell sox-hide-sm" data-bind-text="title" data-bind-title="title"></span>
|
|
8
8
|
<span class="sox-cell sox-muted sox-hide-sm" data-bind-text="problems" data-bind-title="problems"></span>
|
|
9
9
|
<button type="button" class="sox-kebab" aria-label="Actions" title="Actions">\u22EE</button>
|
|
10
|
-
</div>`,
|
|
10
|
+
</div>`,ea=`
|
|
11
11
|
<div class="sox-row" data-bind-data-row="id" tabindex="0">
|
|
12
12
|
<span class="sox-cell"><span data-bind-text="text" data-bind-title="text"></span><small data-bind-text="detail" data-bind-title="detail"></small></span>
|
|
13
13
|
<span class="sox-pill" data-bind-data-tone="tone" data-bind-text="badge"></span>
|
|
14
14
|
<button type="button" class="sox-kebab" aria-label="Actions" title="Actions">\u22EE</button>
|
|
15
|
-
</div>`,
|
|
15
|
+
</div>`,ta=`
|
|
16
16
|
<div class="sox-row" data-bind-data-row="id" tabindex="0" data-bind-title="note">
|
|
17
17
|
<span class="sox-cell sox-mono" data-bind-text="from" data-bind-title="from"></span>
|
|
18
18
|
<span class="sox-arrow" aria-hidden="true">\u2192</span>
|
|
@@ -20,40 +20,40 @@ import{apiRequest as ks}from"../api.js";import{addBannerAction as Ms}from"../lib
|
|
|
20
20
|
<span class="sox-pill sox-hide-sm" data-bind-data-tone="tone" data-bind-text="code"></span>
|
|
21
21
|
<span class="sox-cell sox-muted sox-hide-sm" data-bind-text="hits" data-bind-title="lastHit"></span>
|
|
22
22
|
<button type="button" class="sox-kebab" aria-label="Actions" title="Actions">\u22EE</button>
|
|
23
|
-
</div>`,
|
|
23
|
+
</div>`,sa=`
|
|
24
24
|
<div class="sox-row" data-bind-data-row="id" tabindex="0">
|
|
25
25
|
<span class="sox-cell"><span data-bind-text="path" data-bind-title="path"></span><small data-bind-text="title"></small></span>
|
|
26
26
|
<span class="sox-cell sox-muted sox-hide-sm" data-bind-text="source"></span>
|
|
27
27
|
<span class="sox-cell sox-muted sox-hide-sm" data-bind-text="note" data-bind-title="note"></span>
|
|
28
28
|
<button type="button" class="sox-kebab" aria-label="Actions" title="Actions">\u22EE</button>
|
|
29
|
-
</div>`,
|
|
29
|
+
</div>`,aa=`
|
|
30
30
|
<div class="sox-row" data-bind-data-row="id" tabindex="0">
|
|
31
31
|
<span class="sox-cell"><span data-bind-text="label"></span><small data-bind-text="detail"></small></span>
|
|
32
32
|
<span class="sox-pill" data-bind-data-tone="tone" data-bind-text="state"></span>
|
|
33
33
|
<button type="button" class="sox-kebab" aria-label="Actions" title="Actions">\u22EE</button>
|
|
34
|
-
</div>`,
|
|
34
|
+
</div>`,oa=`
|
|
35
35
|
<div>
|
|
36
36
|
<div class="sox-group" data-bind-hidden="!head" data-bind-text="head"></div>
|
|
37
37
|
<div class="sox-check" data-bind-hidden="!title">
|
|
38
38
|
<span class="sox-status" data-bind-data-status="status" data-bind-text="glyph"></span>
|
|
39
39
|
<span class="sox-check-main"><strong data-bind-text="title"></strong><small data-bind-text="detail"></small><small data-bind-text="fix" data-bind-hidden="!fix"></small></span>
|
|
40
40
|
</div>
|
|
41
|
-
</div>`;export const seoView={templateUrl:"/admin/js/templates/seo.html",async onMount(i){const c=await
|
|
41
|
+
</div>`;export const seoView={templateUrl:"/admin/js/templates/seo.html",async onMount(i){const c=await Ys();if(!Qe.test(location.hash))return;const U=seoView._lifetime??(seoView._lifetime=c.viewLifetime(Qe));U.reset();const m=i.get(0).querySelector(".sox")||i.get(0),n=()=>Qe.test(location.hash)&&m.isConnected,O=e=>(U.add(e),e),v=(e,t)=>c.apiRequest(`${Ks}${e}`,t);let et=null;const It=()=>et??(et=v("/audit").then(e=>(e?.results||[]).filter(t=>t.status===200)).catch(()=>[]).then(e=>e.length?e:c.apiRequest("/pages").then(t=>(Array.isArray(t)?t:[]).filter(s=>s.status==="published")).catch(()=>[])));async function tt(e){if(!e)return null;try{const t=await import("/plugins/_lib/admin/ui/page-menu.js");return e.isConnected?t.attachPageMenu(e,{load:It}):null}catch{return null}}const At=location.hash.match(/^#\/seo\/([a-z0-9-]+)/)?.[1]||"overview",Y=M.observable(At),Oe=M.observable(!0),Le=M.observable(""),B=M.observable(!0),w=M.observable(null),xe=M.observable({results:[]}),te=M.observable("all"),we=M.observable(""),Re=M.observable(""),D=M.observable({rules:[],chains:[],onRename:!0}),Ie=M.observable(""),ke=M.observable(""),Me=M.observable(""),st=M.observable("301"),W=M.observable({entries:[],left:[],sources:[],labels:{},robots:""}),ue=M.observable("in"),Ae=M.observable(""),at=M.observable([]),Pt=M.computed(()=>!Tt.includes(Y.value)),ot=M.observable(!0),nt=M.observable(!0),it=M.observable(!0);let Q=null;const se=e=>W.value.labels?.[e]||(e==="pages"?"Pages":e),jt=M.computed(()=>(w.value?.score??null)===null?"\u2014":`${w.value.score}%`),Dt=M.computed(()=>`${w.value?.score??0}%`),Nt=M.computed(()=>Ot(w.value?.score)),qt=M.computed(()=>{const e=w.value;return e?{pages:String(e.pages),failing:String(e.failing),duplicates:String(e.duplicates),redirects:String(e.redirects)}:{pages:"\u2014",failing:"\u2014",duplicates:"\u2014",redirects:"\u2014"}}),Ut=M.computed(()=>w.value?.failing?String(w.value.failing):""),Bt=M.computed(()=>{const e=w.value;return e?.running?`Checking\u2026 ${e.progress?.done||0} of ${e.progress?.total||"?"}`:e?.at?`Checked ${Rt(e.at)}`:"Not checked yet"}),rt=M.computed(()=>[...new Set((xe.value.results||[]).map(e=>e.source))]),lt=M.observable([]);let $e=[];const _t=M.computed(()=>{const e=Ws(xe.value.results,{source:we.value});return{all:ge(e.all),problems:ge(e.problems),hidden:ge(e.hidden)}});O(M.effect(()=>{$e=Hs(xe.value.results,{show:te.value,source:we.value,query:Re.value}),lt.value=$e.slice(0,1e3).map((e,t)=>({id:`p${t}`,path:e.urlPath,sourceText:[se(e.source),e.noindex?"hidden from search engines":e.unlisted?"not in the sitemap":""].filter(Boolean).join(" \xB7 "),title:e.title||e.label||"",scoreText:e.error?"!":typeof e.score=="number"?String(e.score):"\u2014",tone:e.error?"bad":e.noindex?"info":Ot(e.score),problems:e.error||(e.problems?.length?e.problems.join(" \xB7 "):"Nothing to fix")}))}));const Ht=M.computed(()=>w.value?.at?Re.value.trim()?"No page matches.":te.value==="problems"?"Nothing needs attention.":"No pages.":w.value?.running?"Checking every page - this takes a moment\u2026":"Not checked yet. Check now with the button top right."),ct=M.observable([]);let G=[];O(M.effect(()=>{const e=w.value;if(G=[],e){const t=e.siteSeo||{};for(const s of e.issues?.duplicateTitles||[])G.push({kind:"dupe",text:`Title on ${s.paths.length} pages: "${s.text}"`,detail:s.paths.join(", "),paths:s.paths,tone:"poor",badge:"duplicate"});for(const s of e.issues?.duplicateDescriptions||[]){const a=t.defaultDescription&&s.text===St(t.defaultDescription);G.push({kind:"dupe",text:a?`${s.paths.length} pages use the site's default description`:`Description on ${s.paths.length} pages: "${s.text}"`,detail:s.paths.join(", "),paths:s.paths,tone:"poor",badge:a?"default":"duplicate"})}t.defaultImage||G.push({kind:"setting",text:"No default share image",detail:"Pages without their own image share with none. Set one in SEO settings.",link:"#/seo?settings=1",tone:"poor",badge:"setting"}),(!e.origin||/localhost|127\.0\.0\.1/.test(e.origin))&&G.push({kind:"setting",text:"The site address is not set",detail:"Canonical links and the sitemap use whatever address a visitor came in on. Set the site address in Settings.",link:"#/settings",tone:"poor",badge:"setting"}),e.chains&&G.push({kind:"chains",text:`${e.chains} redirect${e.chains===1?" leads":"s lead"} to another redirect`,detail:"Each hop is slower and loses a little standing. The Redirects tab shows which.",tone:"poor",badge:"redirects"})}ct.value=G.map((t,s)=>({id:`s${s}`,text:t.text,detail:t.detail||"",tone:t.tone,badge:t.badge}))}));const Pe=M.observable([]);let pe=[];O(M.effect(()=>{const e=Ie.value.trim().toLowerCase(),t=new Set(D.value.chains.map(s=>s.id));pe=D.value.rules.filter(s=>!e||`${s.from} ${s.to} ${s.note}`.toLowerCase().includes(e)),Pe.value=pe.map((s,a)=>({id:`r${a}`,from:s.from,to:s.code===410?"(gone)":s.to,note:[s.auto?"Added when the page moved":s.note,t.has(s.id)?"leads to another redirect":""].filter(Boolean).join(" \xB7 "),code:String(s.code),tone:s.code===410?"bad":t.has(s.id)?"poor":s.code===301||s.code===308?"good":"info",hits:s.hits?`${s.hits.toLocaleString("en-GB")} use${s.hits===1?"":"s"}`:"unused",lastHit:s.lastHit?`Last used ${Rt(s.lastHit)}`:"Not used yet"}))}));const Wt=M.computed(()=>D.value.rules.length?String(D.value.rules.length):""),Kt=M.computed(()=>`${pe.length+0*Pe.value.length} of ${D.value.rules.length}`),Gt=M.computed(()=>Ie.value.trim()?"No redirect matches.":"No redirects yet."),Ft=M.computed(()=>{const e=D.value.chains.length;return e?`${e} redirect${e===1?" leads":"s lead"} to another. Right-click one and choose "Go straight there" to make it one hop.`:""}),zt=M.computed(()=>D.value.onRename?"When a page is renamed, a redirect from its old address is added for you.":"Redirects are not added when a page is renamed (see Settings)."),dt=M.observable([]);O(M.effect(()=>{dt.value=W.value.sources.map((e,t)=>({id:`x${t}`,label:se(e.id),detail:`${e.listed} of ${e.count} listed`,state:e.on?"on":"off",tone:e.on?"good":""}))}));const je=M.observable([]);let ae=[];O(M.effect(()=>{const e=Ae.value.trim().toLowerCase();ae=(ue.value==="in"?W.value.entries:W.value.left).filter(s=>!e||`${s.urlPath} ${s.title}`.toLowerCase().includes(e)),je.value=ae.slice(0,2e3).map((s,a)=>({id:`e${a}`,path:s.urlPath,title:s.title||"",source:se(s.source),note:s.why||[s.lastmod?`Changed ${Lt(s.lastmod)}`:"",s.changefreq||"",s.priority!==void 0?`priority ${s.priority}`:""].filter(Boolean).join(" \xB7 ")}))}));const Jt=M.computed(()=>W.value.robots||""),Yt=M.computed(()=>({in:ge((W.value.entries||[]).length),out:ge((W.value.left||[]).length)})),Qt=M.computed(()=>`${ae.length+0*je.value.length} address${ae.length===1?"":"es"}`),Vt=M.computed(()=>W.value.hooks?Ae.value.trim()?"No address matches.":ue.value==="in"?"The sitemap is empty.":"Nothing is left out.":"This version of Domma CMS lists only its own pages in the sitemap."),Se=e=>/403|forbidden/i.test(String(e?.message));async function oe(){try{const e=await v("/overview");if(!n()||!e)return;w.value=e,Le.value="",e.running&&ut()}catch(e){n()&&(Le.value=Se(e)?"You do not have access to SEO.":`Could not load SEO: ${e.message||e}`)}}const De=(e,t,s,a=Us.rows)=>e.peek()?Bs(m.querySelector(t),s,a).finally(()=>{n()&&(e.value=!1)}):s;async function Ne(){try{const e=await De(ot,".sox-pages-loading",v("/audit"));n()&&e&&(xe.value=e)}catch{}}async function me(){try{const e=await De(nt,".sox-rules-loading",v("/redirects"));if(!n()||!e)return;D.value=e,ss(e.rules||[])}catch{}}async function qe(){try{const e=await De(it,".sox-entries-loading",v("/sitemap"));n()&&e&&(W.value=e)}catch(e){n()&&!Se(e)&&E.toast(`Could not load the sitemap: ${e.message||e}`,{type:"error"})}}async function Ue(){Oe.value=!0,await Promise.all([oe(),Ne(),me(),qe()]),n()&&(Oe.value=!1)}function ut(){Q||(Q=setInterval(async()=>{if(!n()){clearInterval(Q),Q=null;return}await oe(),w.peek()?.running||(clearInterval(Q),Q=null,await Ne(),Ct())},1500))}O(()=>{Q&&clearInterval(Q)});async function pt(){try{const e=await v("/audit",{method:"POST",body:JSON.stringify({})});n()&&(w.value={...w.peek(),...e,running:!0}),ut()}catch(e){n()&&E.toast(`Could not start the check: ${e.message||e}`,{type:"error"})}}async function Be(e,t,s=me){try{const a=await e();return n()&&(t&&E.toast(t,{type:"success"}),await Promise.all([s(),oe()])),a}catch(a){return n()&&(Se(a)?(B.value=!1,E.toast("Only people who may manage SEO can change this.",{type:"warning"})):E.toast(`Not done: ${a.message||a}`,{type:"error"})),null}}const Xt=(e,t=`Redirect from ${e.from} added.`)=>Be(()=>v("/redirects",{method:"POST",body:JSON.stringify(e)}),t),Zt=(e,t)=>Be(()=>v(`/redirects/${encodeURIComponent(e.join(","))}`,{method:"DELETE"}),`${t} removed.`);async function es(e){try{const t=await v(`/redirects/test?path=${encodeURIComponent(e.replace(/\/\*$/,"/example"))}`);if(!n())return;const s=t.hops||[];E.toast(s.length?s.map(a=>`${a.from} \u2192 ${a.code===410?"gone":a.to} (${a.code})`).join(" \xB7 "):"No redirect applies.",{type:s.length>1?"warning":"info",duration:7e3})}catch(t){n()&&E.toast(`Could not test: ${t.message||t}`,{type:"error"})}}const mt=e=>({from:e.from||"",to:e.code===410?"":e.to||"",code:String(e.code||301),note:e.note||""});function _e(e,{asNew:t=!1,adopt:s=null}={}){const a=t?{from:"",to:"",code:"301",note:""}:mt(e),r={from:M.observable(a.from),to:M.observable(a.to),code:M.observable(a.code),note:M.observable(a.note)},o=t?"":J(mt(e));ft(t?"New redirect":`Redirect from ${e.from}`,r,`
|
|
42
42
|
<div class="sox-form-grid">
|
|
43
43
|
<div class="sox-wide"><label class="form-label" for="sox-r-from">From</label><input id="sox-r-from" class="form-input sox-mono" data-model="from.value"></div>
|
|
44
44
|
<div class="sox-wide"><label class="form-label" for="sox-r-to">To</label><input id="sox-r-to" class="form-input sox-mono" data-model="to.value" data-bind-disabled="code.value === '410'"></div>
|
|
45
45
|
<div><label class="form-label" for="sox-r-code">Kind</label><select id="sox-r-code" class="form-input" data-model="code.value">
|
|
46
|
-
${Object.entries(
|
|
46
|
+
${Object.entries(zs).map(([l,d])=>`<option value="${l}">${d}</option>`).join("")}</select></div>
|
|
47
47
|
<div><label class="form-label" for="sox-r-note">Note</label><input id="sox-r-note" class="form-input" data-model="note.value"></div>
|
|
48
|
-
</div>`,()=>{const
|
|
48
|
+
</div>`,()=>{const l={from:r.from.value,to:r.to.value,code:Number(r.code.value),note:r.note.value},d=D.peek().rules.filter(y=>t||y.id!==e.id);return{body:l,errors:kt(l,d).errors}},async l=>{t?await v("/redirects",{method:"POST",body:JSON.stringify(l)}):await v(`/redirects/${encodeURIComponent(e.id)}`,{method:"PUT",body:JSON.stringify(l)}),n()&&(E.toast(t?`Redirect from ${l.from} added.`:"Redirect saved.",{type:"success"}),await Promise.all([me(),oe()]))},t?"Add":"Save",{kind:"redirect",id:e.id,what:t?`the redirect from ${s?.from||e.from||"?"}`:`the redirect from ${e.from}`,was:o,adopt:s}),tt(document.getElementById("sox-r-to"))}function ts(){const e={csv:M.observable("")};ft("Import redirects",e,`
|
|
49
49
|
<p class="sox-note">One redirect per line: <span class="sox-mono">from, to</span>, and optionally the kind (301, 302, 307, 308, 410) and a note. A header line is skipped. Paste from a spreadsheet, or another CMS's export.</p>
|
|
50
|
-
<textarea class="form-input sox-mono" rows="14" data-model="csv.value" placeholder="/old-page, /new-page /news/*, /blog/*, 301 /retired, , 410"></textarea>`,()=>({body:{csv:e.csv.value},errors:e.csv.value.trim()?{}:{csv:"Paste some redirects first."}}),async t=>{const s=await v("/redirects/import",{method:"POST",body:JSON.stringify(t)});if(!n())return;const a=s.skipped||[];E.toast(`${s.added} added${a.length?`, ${a.length} skipped - line ${a[0].line}: ${a[0].why}`:"."}`,{type:a.length?"warning":"success",duration:a.length?9e3:4e3}),await Promise.all([
|
|
50
|
+
<textarea class="form-input sox-mono" rows="14" data-model="csv.value" placeholder="/old-page, /new-page /news/*, /blog/*, 301 /retired, , 410"></textarea>`,()=>({body:{csv:e.csv.value},errors:e.csv.value.trim()?{}:{csv:"Paste some redirects first."}}),async t=>{const s=await v("/redirects/import",{method:"POST",body:JSON.stringify(t)});if(!n())return;const a=s.skipped||[];E.toast(`${s.added} added${a.length?`, ${a.length} skipped - line ${a[0].line}: ${a[0].why}`:"."}`,{type:a.length?"warning":"success",duration:a.length?9e3:4e3}),await Promise.all([me(),oe()])},"Import",{kind:"import",what:"the redirects you were importing"})}let ht=!1;async function ss(e){if(ht||!B.peek())return;ht=!0;const t=Je(A.user(),"redirect","");if(!t)return;const s=new Set(e.map(a=>String(a.id)));for(const a of A.keys(`${t}.`)){let r;try{r=decodeURIComponent(a.slice(t.length+1))}catch{continue}if(s.has(r))continue;const o=Et(A.get(a),{from:"",to:"",code:"301",note:""});if(!o){A.drop(a);continue}if(await Ze(Ye({what:`the redirect from ${o.values.from||"?"}`,when:o.at?ze(o.at):"",gone:"Keep them to add it again as a new redirect."}))){A.drop(a);continue}n()&&_e({id:r},{asNew:!0,adopt:o.values});return}}function He(e,{kind:t,id:s="",what:a,read:r,write:o,was:l=""}){const d=Je(A.user(),t,s);let y=J(r()),$=l,k=!0,L=!1,_=!1;const H=()=>J(r())!==y,f=()=>{const u=_s({dirty:H(),owns:k});u==="write"?A.set(d,{values:r(),was:$,at:new Date().toISOString()}):u==="remove"&&A.drop(d)},C=u=>{L||(f(),H()&&(u.preventDefault(),u.returnValue=""))};window.addEventListener("beforeunload",C);const P=e.close.bind(e);let j=()=>{};const T=()=>{L=!0,window.removeEventListener("beforeunload",C),j()};return e.close=async u=>{if(L)return P(u);if(!(u!==!0&&!k)){if(u!==!0&&H()){if(_)return;_=!0;const h=await Xe("Throw away the changes you have not saved?",{title:"Unsaved changes",confirmText:"Throw away",cancelText:"Keep editing"});if(_=!1,!h||L)return;k&&A.drop(d)}else u!==!0&&f();return T(),P(u)}},j=U.add(()=>{if(!L){f(),T();try{P(!0)}catch{}}}),{saved(u,h=$){y=J(u),$=h,k=!0,f()},adopt(u,h=""){o(u),$=h,k=!0},async offer(u=l){const h=A.get(d),X=t==="settings"?Object.fromEntries(["defaultTitle","titleSeparator","defaultDescription","defaultImage"].map(p=>[p,r()[p]])):{},be=h?.values?{...h,values:{...X,...h.values}}:h,N=Et(be,r());return N?(k=!1,await Ze(Ye({what:a,when:N.at?ze(N.at):"",stale:N.was!==u}))?(A.drop(d),k=!0,!1):L?!1:(k=!0,o(N.values),$=N.was,!0)):(h&&A.drop(d),!1)}}}let Ee=!1;function ft(e,t,s,a,r,o="Save",l=null){if(Ee)return;Ee=!0;let d=null;try{const y=M.observable(!1),$=M.computed(()=>a()),k=M.computed(()=>Object.values($.value.errors).join(" ")),L={...t,saving:y,errText:k,cannot:M.computed(()=>y.value||!!k.value)},_=()=>Object.fromEntries(Object.entries(t).map(([u,h])=>[u,h.peek()])),H=u=>{for(const[h,X]of Object.entries(t))h in u&&(X.value=u[h])};d=E.slideover({title:e,size:"md",position:"right"});const f=Ve(`<div class="sox-form">${s}
|
|
51
51
|
<p class="sox-err" data-bind-hidden="!errText.value" data-bind-text="errText.value"></p>
|
|
52
52
|
<div class="sox-actions"><small class="sox-muted">Ctrl+Enter ${o.toLowerCase()}s.</small><span class="sox-spacer"></span>
|
|
53
53
|
<button type="button" class="btn btn-sm btn-ghost" data-on-click="cancel">Cancel</button>
|
|
54
|
-
<button type="button" class="btn btn-sm btn-primary" data-on-click="save" data-bind-disabled="cannot.value">${R(o)}</button></div></div>`);let
|
|
54
|
+
<button type="button" class="btn btn-sm btn-primary" data-on-click="save" data-bind-disabled="cannot.value">${R(o)}</button></div></div>`);let C=null;async function P(){if(L.cannot.peek())return;y.value=!0;const u=_();f.inert=!0;try{await r($.peek().body),C?.saved(u,""),d.close(!0)}catch(h){f.inert=!1,n()&&E.toast(`Not saved: ${h.message||h}`,{type:"error"})}finally{y.value=!1}}d.element.appendChild(f);const j=c.helpPopovers(f),T=M.applyBindings(L,f,{methods:{save:P,cancel:()=>d.close()}});f.addEventListener("keydown",u=>{(u.ctrlKey||u.metaKey)&&u.key==="Enter"&&(u.preventDefault(),P())}),c.onceClosed(d,()=>{T.dispose(),j(),Ee=!1}),l?(C=He(d,{...l,read:_,write:H}),l.adopt?C.adopt(l.adopt,""):C.offer(l.was)):O(()=>{try{d.close(!0)}catch{}}),I.scan(f),d.open(),f.querySelector("input, textarea")?.focus()}catch(y){Ee=!1;try{d?.close(!0)}catch{}E.toast(`Could not open ${e}: ${y.message||y}`,{type:"error"})}}let ne=!1;const as=e=>({title:String(e.title??"").trim().slice(0,200),description:String(e.description??"").trim(),image:String(e.image??"").trim().slice(0,500),noindex:e.noindex===!0,focus:String(e.focus??"").trim().slice(0,100)});async function ee(e){if(ne)return;ne=!0;let t;try{t=await v(`/item?path=${encodeURIComponent(e)}`)}catch(s){if(ne=!1,!n())return;const a=s?.status===404?Je(A.user(),"item",e):null,r=a?A.get(a):null;if(r?.values){await Ze(Ye({what:e,when:r.at?ze(r.at):"",gone:"Keep them and they are offered again if the address is served again."}))&&A.drop(a);return}E.toast(`Could not open ${e}: ${s.message||s}`,{type:"error"});return}if(!n()){ne=!1;return}try{os(e,t)}catch(s){ne=!1,E.toast(`Could not open ${e}: ${s.message||s}`,{type:"error"})}}function os(e,t){const s={title:M.observable(t.fields.title),description:M.observable(t.fields.description),focus:M.observable(t.fields.focus),image:M.observable(t.fields.image),noindex:M.observable(t.fields.noindex)},a=t.limits||{},r=t.page?.title||t.live?.h1||"",o=t.kind==="page"?`${r}${t.defaults.separator}${t.defaults.siteTitle}`:t.live?.title||"",l=t.kind==="page"?t.defaults.description||"":t.live?.description||"",d=t.kind==="page"?t.defaults.image:t.live?.image||"",y=M.computed(()=>s.title.value.trim()||o),$=M.computed(()=>St(s.description.value)||l),k=M.computed(()=>s.image.value.trim()||d),L=t.origin||location.origin,_=M.computed(()=>Rs({title:y.value,description:$.value,url:`${L}${e}`,limits:a})),H=(x,g,de)=>{const Z=x.length;return{text:`${Z} / ${de}`,width:`${Math.min(100,Z/de*100)}%`,tone:Z?Z<g||Z>de?"poor":"good":"bad"}},f=M.computed(()=>H(y.value,a.titleMin||30,a.titleMax||60)),C=M.computed(()=>H($.value,a.descMin||70,a.descMax||160)),P=(()=>{try{return new URL(L).host}catch{return location.host}})(),j=M.computed(()=>k.value?`url("${k.value.replace(/["\\\n\r]/g,"")}")`:"none"),T=M.observable([]),u=x=>{const g=[],de=x?.checks||[],Z={fail:0,warn:1,pass:2,info:3};for(const Ke of[...new Set(de.map(z=>z.group))]){g.push({id:`g-${Ke}`,head:Ke,title:"",detail:"",fix:"",status:"",glyph:""});for(const z of de.filter(Ge=>Ge.group===Ke).sort((Ge,$s)=>Z[Ge.status]-Z[$s.status]))g.push({id:`c-${z.id}`,head:"",title:z.title,detail:z.detail,fix:z.status==="pass"?"":z.fix,status:z.status,glyph:Fs[z.status]||"?"})}T.value=g};u(t.analysis);const h=M.observable(t.analysis?`Score ${t.analysis.score}% \xB7 ${t.analysis.failing} failing, ${t.analysis.warnings} could be better`:t.status===200?"":`Not live (answers ${t.status||"nothing"}) - the checks run once it is published.`),X=()=>({title:s.title.peek(),description:s.description.peek(),focus:s.focus.peek(),image:s.image.peek(),noindex:s.noindex.peek()}),be=x=>{for(const g of Object.keys(s))g in x&&(s[g].value=x[g])},N=M.observable(!1),ve=M.computed(()=>s.image.value.trim()&&!/^(https?:\/\/|\/)/i.test(s.image.value.trim())?"The image: a path like /media/photo.jpg, or a full web address.":""),p={...s,saving:N,errText:ve,checks:T,scoreLine:h,serp:_,titleMeter:f,descMeter:C,shareBg:j,effTitle:y,effDesc:$,host:P,hasImage:M.computed(()=>!!k.value),defTitle:o,defDesc:l,canManage:B,cannot:M.computed(()=>N.value||!!ve.value||!B.value)},b=E.slideover({title:`SEO \xB7 ${e}`,size:"lg",position:"right"}),K=t.kind==="url"?'<p class="sox-note is-warn">A plugin serves this address (a blog post, a listing). What you set here takes the place of its own SEO fields.</p>':t.page?.status!=="published"?`<p class="sox-note is-warn">This page is a ${R(t.page?.status||"draft")} - not live yet.</p>`:"",le=t.redirect?`<p class="sox-note is-bad">A redirect sends visitors from here to ${R(t.redirect.to||"(gone)")} - they never see this page.</p>`:"",q=Ve(`
|
|
55
55
|
<div class="sox-form">
|
|
56
|
-
${
|
|
56
|
+
${K}${le}
|
|
57
57
|
<section><h4>As it will look <span data-help="The search result is drawn the way Google draws it, cut where it cuts (roughly - it measures pixels). The share card is what Facebook, LinkedIn, WhatsApp and others show when someone shares the link."></span>
|
|
58
58
|
<span class="sox-spacer"></span><a class="btn btn-xs btn-ghost" href="${R(e)}" target="_blank" rel="noopener"><span data-icon="external-link" data-icon-size="12"></span> Open</a></h4>
|
|
59
59
|
<div class="sox-previews">
|
|
@@ -72,8 +72,8 @@ import{apiRequest as ks}from"../api.js";import{addBannerAction as Ms}from"../lib
|
|
|
72
72
|
<div class="sox-wide"><label class="form-label" for="sox-i-title">Title <span data-help="The blue link in search results and the headline of a share. Say what the page is about, words that matter first. Empty uses the page title and the site name."></span></label>
|
|
73
73
|
<input id="sox-i-title" class="form-input" data-model="title.value" placeholder="${R(o)}" maxlength="200">
|
|
74
74
|
<div class="sox-meter" data-bind-data-tone="titleMeter.value.tone"><span class="sox-bar"><span data-bind-style-width="titleMeter.value.width"></span></span><span data-bind-text="titleMeter.value.text"></span></div></div>
|
|
75
|
-
<div class="sox-wide"><label class="form-label" for="sox-i-desc">Description <span data-help="The grey text under the link. One or two sentences that make someone want to click. Empty uses the site's default - which every other such page shares."></span></label>
|
|
76
|
-
<textarea id="sox-i-desc" rows="3" class="form-input" data-model="description.value" placeholder="${R(
|
|
75
|
+
<div class="sox-wide"><label class="form-label" for="sox-i-desc">Description <span data-help="The grey text under the link. One or two sentences that make someone want to click. Empty uses the site's default - which every other such page shares. Search engines and share cards show the words only: formatting is not carried over, and the counter counts the words."></span></label>
|
|
76
|
+
<textarea id="sox-i-desc" rows="3" class="form-input" data-model="description.value" placeholder="${R(l)}"></textarea>
|
|
77
77
|
<div class="sox-meter" data-bind-data-tone="descMeter.value.tone"><span class="sox-bar"><span data-bind-style-width="descMeter.value.width"></span></span><span data-bind-text="descMeter.value.text"></span></div></div>
|
|
78
78
|
<div><label class="form-label" for="sox-i-focus">Focus keyphrase <span data-help="The search this page should be found for - 'garden tools', 'plumber in Leeds'. The checks then look for it in the title, description, heading, address and opening. It is not shown anywhere."></span></label>
|
|
79
79
|
<input id="sox-i-focus" class="form-input" data-model="focus.value" maxlength="100"></div>
|
|
@@ -92,15 +92,16 @@ import{apiRequest as ks}from"../api.js";import{addBannerAction as Ms}from"../lib
|
|
|
92
92
|
<button type="button" class="btn btn-sm btn-ghost" data-on-click="cancel">Close</button>
|
|
93
93
|
<button type="button" class="btn btn-sm btn-primary" data-on-click="save" data-bind-disabled="cannot.value"><span data-icon="save" data-icon-size="13"></span> Save and check</button>
|
|
94
94
|
</div>
|
|
95
|
-
</div>`);
|
|
95
|
+
</div>`);q.querySelector(".sox-checks").innerHTML=oa,ns(q.querySelector("#sox-media"));let ce=null;async function xt(){if(p.cannot.peek())return;N.value=!0;const x=X();try{if(await v("/item",{method:"PUT",body:JSON.stringify({path:e,...x})}),ce?.saved(x,J(as(x))),!n())return;E.toast("Saved.",{type:"success"});const g=await v(`/item?path=${encodeURIComponent(e)}`).catch(()=>null);if(!n())return;g?.fields&&ce?.saved(x,J(g.fields)),g?.analysis&&(u(g.analysis),h.value=`Score ${g.analysis.score}% \xB7 ${g.analysis.failing} failing, ${g.analysis.warnings} could be better`),Ne(),oe(),Ct()}catch(g){if(!n())return;Se(g)&&(B.value=!1),E.toast(`Not saved: ${g.message||g}`,{type:"error"})}finally{N.value=!1}}b.element.appendChild(q);const ys=c.helpPopovers(q),xs=M.applyBindings(p,q,{methods:{save:xt,cancel:()=>b.close(),pickImage:async()=>{const x=await Fe({title:"Choose a share image",current:s.image.peek()});x&&(s.image.value=x)}}}),ws=q.querySelector(".sox-share-img"),ks=M.effect(()=>{ws.style.backgroundImage=j.value});q.addEventListener("keydown",x=>{(x.ctrlKey||x.metaKey)&&x.key==="Enter"&&(x.preventDefault(),xt())});const Ms=$t(q.querySelector("#sox-i-desc"));c.onceClosed(b,()=>{Ms.destroy(),xs.dispose(),ys(),ks?.(),ne=!1});const wt=J(t.fields);ce=He(b,{kind:"item",id:e,what:e,read:X,write:be,was:wt}),I.scan(q),b.open(),ce.offer(wt)}let Te=null;async function ns(e){try{Te??(Te=await c.apiRequest("/media").then(t=>Array.isArray(t)?t:t?.files||t?.items||[]));for(const t of Te){const s=t.url||t.path||(t.filename?`/media/${t.filename}`:"");s&&/\.(jpe?g|png|webp|gif|avif|svg)$/i.test(s)&&e.appendChild(Object.assign(document.createElement("option"),{value:s}))}}catch{Te=[]}}let ie=!1;async function bt(){if(ie)return;ie=!0;let e,t,s;try{const a=await v("/settings");e=Mt(a.settings),t=a.defaults||Ds(),s=J({settings:a.settings,defaults:t})}catch(a){ie=!1,n()&&E.toast(`Could not load the settings: ${a.message||a}`,{type:"error"});return}if(!n()){ie=!1;return}try{is(e,s,t)}catch(a){ie=!1,E.toast(`Could not open the settings: ${a.message||a}`,{type:"error"})}}function is(e,t,s){const a=e.organisation,r=w.peek()?.siteSeo?.defaultTitle||"The site's name",o={defaultTitle:M.observable(s.defaultTitle),titleSeparator:M.observable(s.titleSeparator),defaultDescription:M.observable(s.defaultDescription),defaultImage:M.observable(s.defaultImage),orgOn:M.observable(a.enabled),orgType:M.observable(a.type),orgName:M.observable(a.name),orgUrl:M.observable(a.url),orgLogo:M.observable(a.logo),orgEmail:M.observable(a.email),orgPhone:M.observable(a.phone),orgSame:M.observable(a.sameAs.join(`
|
|
96
96
|
`)),street:M.observable(a.address.street),locality:M.observable(a.address.locality),region:M.observable(a.address.region),postcode:M.observable(a.address.postcode),country:M.observable(a.address.country),articles:M.observable(e.articles),exclude:M.observable(e.sitemap.exclude.join(`
|
|
97
|
-
`)),blockAll:M.observable(e.robots.blockAll),llms:M.observable(e.llms.enabled),robotsExtra:M.observable(e.robots.extra),onRename:M.observable(e.redirects.onRename),every:M.observable(String(e.audit.everyHours)),tMin:M.observable(String(e.audit.titleMin)),tMax:M.observable(String(e.audit.titleMax)),dMin:M.observable(String(e.audit.descMin)),dMax:M.observable(String(e.audit.descMax)),words:M.observable(String(e.audit.minWords))},
|
|
98
|
-
<input id="sox-s-${p}" class="form-input" data-model="${b}.value" ${
|
|
97
|
+
`)),blockAll:M.observable(e.robots.blockAll),llms:M.observable(e.llms.enabled),robotsExtra:M.observable(e.robots.extra),onRename:M.observable(e.redirects.onRename),every:M.observable(String(e.audit.everyHours)),tMin:M.observable(String(e.audit.titleMin)),tMax:M.observable(String(e.audit.titleMax)),dMin:M.observable(String(e.audit.descMin)),dMax:M.observable(String(e.audit.descMax)),words:M.observable(String(e.audit.minWords))},l=()=>({organisation:{enabled:o.orgOn.value,type:o.orgType.value,name:o.orgName.value,url:o.orgUrl.value,logo:o.orgLogo.value,email:o.orgEmail.value,phone:o.orgPhone.value,sameAs:o.orgSame.value,address:{street:o.street.value,locality:o.locality.value,region:o.region.value,postcode:o.postcode.value,country:o.country.value}},articles:o.articles.value,sitemap:{exclude:o.exclude.value,sources:e.sitemap.sources},robots:{blockAll:o.blockAll.value,extra:o.robotsExtra.value},llms:{enabled:o.llms.value},redirects:{onRename:o.onRename.value},audit:{everyHours:o.every.value,titleMin:o.tMin.value,titleMax:o.tMax.value,descMin:o.dMin.value,descMax:o.dMax.value,minWords:o.words.value}}),d=()=>Object.fromEntries(Object.entries(o).map(([p,b])=>[p,b.peek()])),y=p=>{for(const[b,K]of Object.entries(o))b in p&&(K.value=p[b])},$=M.observable(!1),k=M.computed(()=>As(l(),e)),L=M.computed(()=>js(Object.fromEntries(Object.keys(s).map(p=>[p,o[p].value])))),_=M.computed(()=>[Object.values(k.value.errors).join(" "),L.value.error].filter(Boolean).join(" ")),H={...o,saving:$,errText:_,cannot:M.computed(()=>$.value||!!_.value),isPerson:M.computed(()=>o.orgType.value==="Person")},f=(p,b,K,le="",q="")=>`<div><label class="form-label" for="sox-s-${p}">${K}${le?` <span data-help="${R(le)}"></span>`:""}</label>
|
|
98
|
+
<input id="sox-s-${p}" class="form-input" data-model="${b}.value" ${q}></div>`,C=(p,b,K,le,q,ce="")=>f(p,b,K,ce,`type="number" min="${le}" max="${q}"`),P=(p,b,K="")=>`<label class="sox-wide" style="display:flex;align-items:center;gap:.5rem"><input type="checkbox" class="form-switch" data-model="${p}.value"> ${b}${K?` <span data-help="${R(K)}"></span>`:""}</label>`,j=E.slideover({title:"SEO settings",size:"md",position:"right"}),T=Ve(`
|
|
99
99
|
<div class="sox-form">
|
|
100
100
|
<section><h4>Site defaults</h4><p class="sox-note">Used by pages without their own SEO values.</p><div class="sox-form-grid">
|
|
101
101
|
${f("default-title","defaultTitle","Default site title")}
|
|
102
102
|
${f("separator","titleSeparator","Title separator")}
|
|
103
|
-
|
|
103
|
+
<div class="sox-wide"><label class="form-label" for="sox-s-default-description">Default meta description <span data-help="Used in search results and share cards for pages without their own. They show the words only - formatting is not carried over."></span></label>
|
|
104
|
+
<textarea id="sox-s-default-description" class="form-input" rows="2" data-model="defaultDescription.value"></textarea></div>
|
|
104
105
|
<div><label class="form-label" for="sox-default-image">Default share image</label>
|
|
105
106
|
<div class="sox-pick"><input id="sox-default-image" class="form-input" data-model="defaultImage.value" placeholder="/media/share.jpg">
|
|
106
107
|
<button type="button" class="btn btn-sm btn-ghost" data-on-click="pickDefaultImage">Choose image</button></div></div>
|
|
@@ -109,8 +110,8 @@ import{apiRequest as ks}from"../api.js";import{addBannerAction as Ms}from"../lib
|
|
|
109
110
|
<section><h4>Who is behind the site <span data-help="Structured data on the home page, so search engines can show the name, logo and contact details - a knowledge panel, or a local business in maps."></span></h4><div class="sox-form-grid">
|
|
110
111
|
${P("orgOn","Tell search engines who runs the site")}
|
|
111
112
|
<div><label class="form-label" for="sox-s-type">It is</label><select id="sox-s-type" class="form-input" data-model="orgType.value">
|
|
112
|
-
${
|
|
113
|
-
${f("name","orgName","Name","Empty uses the site's name.",`placeholder="${R(
|
|
113
|
+
${Ps.map(p=>`<option value="${p}">${{Organization:"An organisation",LocalBusiness:"A local business",Person:"A person"}[p]}</option>`).join("")}</select></div>
|
|
114
|
+
${f("name","orgName","Name","Empty uses the site's name.",`placeholder="${R(r)}"`)}
|
|
114
115
|
${f("url","orgUrl","Web address","Empty uses the site address.",'placeholder="https://\u2026"')}
|
|
115
116
|
<div><label class="form-label" for="sox-s-logo">Logo (or photo) <span data-help="A square image works best. Choose it from Media (or upload one), or type a full address."></span></label>
|
|
116
117
|
<div class="sox-pick"><input id="sox-s-logo" class="form-input sox-mono" data-model="orgLogo.value" placeholder="/media/logo.png">
|
|
@@ -137,12 +138,12 @@ import{apiRequest as ks}from"../api.js";import{addBannerAction as Ms}from"../lib
|
|
|
137
138
|
${P("onRename","Add a redirect when a page is renamed","The old address keeps working, and any redirect that pointed at it is re-aimed at the new one - so there are never chains.")}
|
|
138
139
|
</div></section>
|
|
139
140
|
<section><h4>The checks</h4><div class="sox-form-grid">
|
|
140
|
-
${
|
|
141
|
-
${
|
|
142
|
-
${
|
|
143
|
-
${
|
|
144
|
-
${
|
|
145
|
-
${
|
|
141
|
+
${C("every","every","Check every page every (hours)",0,168,"0 checks only when you ask.")}
|
|
142
|
+
${C("words","words","Words a page should have",0,5e3)}
|
|
143
|
+
${C("tmin","tMin","Shortest title",10,70)}
|
|
144
|
+
${C("tmax","tMax","Longest title",30,100,"Google cuts titles at about 60 characters.")}
|
|
145
|
+
${C("dmin","dMin","Shortest description",30,160)}
|
|
146
|
+
${C("dmax","dMax","Longest description",80,320,"Google cuts descriptions at about 155-160 characters.")}
|
|
146
147
|
</div></section>
|
|
147
148
|
<p class="sox-err" data-bind-hidden="!errText.value" data-bind-text="errText.value"></p>
|
|
148
149
|
<div class="sox-actions">
|
|
@@ -150,7 +151,7 @@ import{apiRequest as ks}from"../api.js";import{addBannerAction as Ms}from"../lib
|
|
|
150
151
|
<button type="button" class="btn btn-sm btn-ghost" data-on-click="cancel">Cancel</button>
|
|
151
152
|
<button type="button" class="btn btn-sm btn-primary" data-on-click="save" data-bind-disabled="cannot.value"><span data-icon="save" data-icon-size="13"></span> Save</button>
|
|
152
153
|
</div>
|
|
153
|
-
</div>`);let u=null;async function h(){if(H.cannot.peek())return;$.value=!0;const p=d();
|
|
154
|
+
</div>`);let u=null;async function h(){if(H.cannot.peek())return;$.value=!0;const p=d();T.inert=!0;try{const b=await v("/settings",{method:"PUT",body:JSON.stringify({...k.peek().settings,siteDefaults:L.peek().defaults})});if(u?.saved(p,J({settings:b?.settings,defaults:b?.defaults})),j.close(!0),!n())return;E.toast("Settings saved.",{type:"success"}),Ue()}catch(b){T.inert=!1,n()&&E.toast(`Not saved: ${b.message||b}`,{type:"error"})}finally{$.value=!1}}j.element.appendChild(T);const X=c.helpPopovers(T),be=M.applyBindings(H,T,{methods:{save:h,cancel:()=>j.close(),pickDefaultImage:async()=>{const p=await Fe({title:"Choose a default share image",current:o.defaultImage.peek()});p&&(o.defaultImage.value=p)},pickLogo:async()=>{const p=await Fe({title:"Choose a logo",current:o.orgLogo.peek()});p&&(o.orgLogo.value=p)}}}),N=Ns(T.querySelector("[data-google-business]"),{read:d,apply:y});T.addEventListener("keydown",p=>{(p.ctrlKey||p.metaKey)&&p.key==="Enter"&&(p.preventDefault(),h())});const ve=$t(T.querySelector("#sox-s-default-description"),{compact:!0});c.onceClosed(j,()=>{ve.destroy(),N(),be.dispose(),X(),ie=!1}),u=He(j,{kind:"settings",what:"the SEO settings",read:d,write:y,was:t}),I.scan(T),j.open(),u.offer(t)}async function rs(e,t){try{const s=await v("/settings"),a=Mt(s.settings);if(a.sitemap.sources[e]=t,await v("/settings",{method:"PUT",body:JSON.stringify(a)}),!n())return;E.toast(`${se(e)} ${t?"back in":"left out of"} the sitemap.`,{type:"success"}),qe()}catch(s){n()&&E.toast(`Not changed: ${s.message||s}`,{type:"error"})}}const F=e=>Number(String(e?.dataset?.row||"").slice(1));function ls(e){const t=$e[F(e)];return t?[{header:t.urlPath},{label:"Title, description and checks\u2026",icon:"edit-3",action:()=>ee(t.urlPath)},{label:"Open the page",icon:"external-link",action:()=>window.open(t.urlPath,"_blank","noopener")},{label:"Redirect it elsewhere\u2026",icon:"corner-up-right",disabled:!B.peek(),action:()=>{V("redirects"),ke.value=t.urlPath,Me.value=""}},{type:"divider"},{label:"Copy the address",icon:"copy",action:()=>ye(t.urlPath,"the address")},{label:"Copy the problems",icon:"clipboard",disabled:!t.problems?.length&&!t.error,action:()=>ye(`${t.urlPath}
|
|
154
155
|
${t.error||t.problems.join(`
|
|
155
|
-
`)}`,"the problems")}]:[]}function
|
|
156
|
-
`),"the addresses")}]:t.kind==="chains"?[{label:"Show the redirects",icon:"corner-up-right",action:()=>V("redirects")}]:[{label:"Go to Settings",icon:"settings",action:()=>{location.hash=t.link}}]:[]}function
|
|
156
|
+
`)}`,"the problems")}]:[]}function cs(e){const t=G[F(e)];return t?t.kind==="dupe"?[{header:"Open one of them"},...t.paths.slice(0,12).map(s=>({label:s,icon:"edit-3",action:()=>ee(s)})),{type:"divider"},{label:"Copy the addresses",icon:"copy",action:()=>ye(t.paths.join(`
|
|
157
|
+
`),"the addresses")}]:t.kind==="chains"?[{label:"Show the redirects",icon:"corner-up-right",action:()=>V("redirects")}]:[{label:"Go to Settings",icon:"settings",action:()=>{location.hash=t.link}}]:[]}function ds(e){const t=G[F(e)];t?.kind==="dupe"?ee(t.paths[0]):t?.kind==="chains"?V("redirects"):t?.link&&(location.hash=t.link)}function us(e){const t=pe[F(e)];if(!t)return[];const s=D.peek().rules,a=D.peek().chains.some(o=>o.id===t.id);let r=null;if(a){r=t.to;for(let o=0;o<10;o++){const l=Is(s,r);if(!l)break;if(l.code===410){r=null;break}if(r=l.location,/^https?:/i.test(r))break}}return[{header:`${t.from} \u2192 ${t.code===410?"gone":t.to}`},{label:"Edit\u2026",icon:"edit-3",disabled:!B.peek(),action:()=>_e(t)},{label:"Test it",icon:"play",action:()=>es(t.from)},{label:"Go straight there",icon:"fast-forward",disabled:!r||!B.peek(),action:()=>Be(()=>v(`/redirects/${encodeURIComponent(t.id)}`,{method:"PUT",body:JSON.stringify({to:r})}),`${t.from} now goes straight to ${r}.`)},{label:"Open the old address",icon:"external-link",disabled:t.from.endsWith("/*"),action:()=>window.open(t.from,"_blank","noopener")},{type:"divider"},{label:"Copy",icon:"copy",action:()=>ye(`${t.from} ${t.to} ${t.code}`,"the redirect")},{label:"Remove",icon:"trash-2",danger:!0,disabled:!B.peek(),action:async()=>{await Xe(`Remove the redirect from ${t.from}? Visitors to it will get "not found".`)&&Zt([t.id],"Redirect")}}]}function ps(e){const t=ae[F(e)];return t?[{header:t.urlPath},{label:"Title, description and checks\u2026",icon:"edit-3",action:()=>ee(t.urlPath)},{label:"Open",icon:"external-link",action:()=>window.open(t.urlPath,"_blank","noopener")},{type:"divider"},{label:"Copy the address",icon:"copy",action:()=>ye(t.urlPath,"the address")}]:[]}function ms(e){const t=W.peek().sources[F(e)];return t?[{header:se(t.id)},{label:t.on?"Leave all of it out":"List it again",icon:t.on?"eye-off":"eye",disabled:!B.peek(),action:()=>rs(t.id,!t.on)}]:[]}function he(e,t,s){const a=E.contextMenu(e,{cursor:"glyph",match:"[data-row]",inherit:!1,density:"compact",items:l=>t(l)});O(()=>a?.destroy?.());const r=l=>{const d=l.target.closest("[data-row]");if(!(!d||l.target.closest("a"))){if(l.target.closest(".sox-kebab")){c.openMenuAt(d);return}s?.(d)}},o=l=>{const d=l.target.closest("[data-row]");d&&(l.key==="F10"&&l.shiftKey?(l.preventDefault(),c.openMenuAt(d)):l.key==="Enter"&&l.target===d&&(l.preventDefault(),l.stopPropagation(),setTimeout(()=>{n()&&d.isConnected&&s?.(d)},0)))};e.addEventListener("click",r),e.addEventListener("keydown",o),O(()=>{e.removeEventListener("click",r),e.removeEventListener("keydown",o)})}const hs=m.querySelector(".sox-ext"),We=m.querySelector(".sox-ext-tabs");let re=null,Ce="",fe=0;const vt=()=>{const e=re;re=null;try{e?.dispose?.()}catch{}e?.box?.remove()};async function fs(){let e=[];try{e=(await v("/extensions"))?.tabs||[]}catch{}n()&&(at.value=e,We.replaceChildren(...e.map(t=>{const s=document.createElement("button");return s.type="button",s.setAttribute("role","tab"),s.dataset.ext=t.key,s.innerHTML=`<span data-icon="${R(t.icon||"box")}" data-icon-size="14"></span> ${R(t.label)} <span class="sox-pro">PRO</span>`,t.help&&(s.title=t.help),s.addEventListener("click",()=>V(t.key)),s})),I.scan(We),gt())}async function gt(){if(!n())return;for(const r of We.querySelectorAll("button"))r.classList.toggle("is-on",r.dataset.ext===Y.peek());const e=at.peek().find(r=>r.key===Y.peek());if(re&&re.key!==e?.key&&vt(),!e){Ce="",fe++,Tt.includes(Y.peek())||V("overview");return}if(re?.key===e.key||Ce===e.key)return;const t=++fe;Ce=e.key;const s=document.createElement("div");s.className="sox-panel sox-ext-body",hs.replaceChildren(s);const a=()=>t===fe&&n()&&Y.peek()===e.key;try{const r=await import(e.module);if(!a())return;const o=await r.mount(s,{kit:c,api:c.apiRequest,scope:O,here:n,openItem:ee,reload:Ue,E,M,I});if(!a()){try{o?.()}catch{}s.remove();return}re={key:e.key,dispose:o,box:s}}catch(r){a()&&(s.innerHTML=`<p class="sox-note is-bad">${R(e.label)} could not be shown: ${R(r.message||r)}</p>`)}finally{t===fe&&(Ce="")}}O(()=>{fe++,vt()}),m.querySelector(".sox-pages").innerHTML=Zs,m.querySelector(".sox-site").innerHTML=ea,m.querySelector(".sox-rules").innerHTML=ta,m.querySelector(".sox-entries").innerHTML=sa,m.querySelector(".sox-sources").innerHTML=aa;const yt=m.querySelector(".sox-select");O(M.effect(()=>{const e=rt.value;yt.replaceChildren(new Option("Everything",""),...e.map(t=>new Option(se(t),t))),yt.value=we.peek()}));function V(e){Y.peek()!==e&&(Y.value=e,history.replaceState(null,"",`#/seo${e==="overview"?"":`/${e}`}`),e==="redirects"&&me(),e==="sitemap"&&qe()),gt()}const bs={tab:Y,busy:Oe,error:Le,canManage:B,scoreText:jt,scoreWidth:Dt,scoreTone:Nt,ov:qt,attention:Ut,asOf:Bt,sourceOptions:rt,source:we,show:te,query:Re,pageRows:lt,pagesEmpty:Ht,siteRows:ct,ruleRows:Pe,ruleCount:Wt,ruleText:Kt,rulesEmpty:Gt,chainText:Ft,renameText:zt,ruleQuery:Ie,newFrom:ke,newTo:Me,newCode:st,sourceRows:dt,smRows:je,smShow:ue,smQuery:Ae,smText:Qt,smEmpty:Vt,robots:Jt,extOn:Pt,counts:_t,smCounts:Yt,pagesLoading:ot,rulesLoading:nt,smLoading:it},vs={tab_overview:()=>V("overview"),tab_redirects:()=>V("redirects"),tab_sitemap:()=>V("sitemap"),show_all:()=>{te.value="all"},show_problems:()=>{te.value="problems"},show_hidden:()=>{te.value="hidden"},sm_in:()=>{ue.value="in"},sm_out:()=>{ue.value="out"},importCsv:ts,exportRules:()=>{const e=D.peek().rules;if(!e.length){E.toast("Nothing to export.",{type:"info"});return}Xs(`redirects-${location.hostname}-${new Date().toISOString().slice(0,10)}.csv`,Vs(e.map(t=>({from:t.from,to:t.to,code:t.code,note:t.note||"",hits:t.hits||0,last_used:t.lastHit||""}))))},addRule:()=>{const e={from:ke.peek(),to:Me.peek(),code:Number(st.peek())},{errors:t}=kt(e,D.peek().rules);return Object.keys(t).length?(E.toast(Object.values(t).join(" "),{type:"warning"}),!1):(Xt(e).then(s=>{s&&(ke.value="",Me.value="")}),!1)}},gs=M.applyBindings(bs,m,{methods:vs});tt(m.querySelector('.sox-add input[aria-label="To"]')).then(e=>{e&&O(()=>e.dispose())}),O(()=>gs.dispose()),O(c.helpPopovers(m,{position:"bottom"})),he(m.querySelector(".sox-pages"),ls,e=>{const t=$e[F(e)];t&&ee(t.urlPath)}),he(m.querySelector(".sox-site"),cs,ds),he(m.querySelector(".sox-rules"),us,e=>{const t=pe[F(e)];t&&B.peek()&&_e(t)}),he(m.querySelector(".sox-entries"),ps,e=>{const t=ae[F(e)];t&&ee(t.urlPath)}),he(m.querySelector(".sox-sources"),ms),c.addBannerAction(i,{id:"seo-check",icon:"refresh-cw",title:"Check every page again",onClick:pt}),c.addBannerAction(i,{id:"seo-settings",icon:"settings",title:"SEO settings",onClick:bt}),I.scan(m),await Promise.all([Ue(),fs()]),n()&&new URLSearchParams(location.hash.split("?")[1]||"").get("settings")==="1"&&bt(),n()&&I.scan(m),n()&&!w.peek()?.at&&!w.peek()?.running&&pt()}};
|
package/docs/DommaFeatures.md
CHANGED
|
@@ -1086,10 +1086,14 @@ Where: `server/services/presetCollections.js` (`PRESETS`, `seedAll()`), `server/
|
|
|
1086
1086
|
|
|
1087
1087
|
### Rich text descriptions
|
|
1088
1088
|
|
|
1089
|
-
- **Description fields are a small rich text editor** - bold, italic, underline, bullet and numbered lists, links, undo and redo. In core: collections, actions, views, menus (the admin note), projects and forms.
|
|
1089
|
+
- **Description fields are a small rich text editor** - bold, italic, underline, bullet and numbered lists, links, undo and redo. In core: collections, actions, views, menus (the admin note), projects and forms (1.67.0); a page's Description and SEO Description, the SEO Tool's per-address Description and Default meta description, layouts, menu items (the card dropdown caption), a form's step descriptions and chooser option descriptions (Unreleased).
|
|
1090
1090
|
- **One string, plain or rich.** A description is stored where it always was. Text typed before (or sent by an API client) is plain and is left alone until edited; text from the editor is HTML that starts with a block element (`isRichText()` in `public/js/rich-text.mjs`). Plain text that mentions a tag stays plain and is escaped wherever it is shown.
|
|
1091
1091
|
- **Cleaned on save and again on render** by `server/services/richText.js` (`cleanRichText`, `renderRichText`): p, br, strong/b, em/i, u, s, ul, ol, li, a (http, https, mailto, tel; `rel="noopener noreferrer"`), h2-h4, blockquote, code. No images, classes, styles, embeds or scripts. Far stricter than the page sanitiser on purpose.
|
|
1092
|
-
- **Plain text everywhere that is not a page**: `richTextToPlain()` / `richTextSummary()` feed list rows, searches and the form's read-aloud summary.
|
|
1092
|
+
- **Plain text everywhere that is not a page**: `richTextToPlain()` / `richTextSummary()` feed list rows, searches and the form's read-aloud summary. `richTextLine()` (one line, not cut; the server's cleans first) feeds the meta description, og/twitter tags, JSON-LD (`plainSeoDescriptions()` in `renderer.js`, after the `seo:meta` transforms too), `/llms.txt`, site search results, the Content API and the "pages missing description" health check. Counters count the words: the SEO Tool's length meters and a menu item caption's 160 limit (`DESCRIPTION_MAX`; markup has its own, `DESCRIPTION_MARKUP_MAX`).
|
|
1093
|
+
- **Inside a line of text**: `renderRichTextPhrasing(value, {links, legacyHtml})` gives inline formatting only (paragraphs and list items become line breaks). A menu item's caption is served to the page as `description` (words) plus `descriptionHtml` (made only by `resolveMenuDecorations`, never read from the menu file; no links, it sits inside the item's link) and `menu-cards.mjs` rebuilds it from an allow-list of inline elements. A wizard step's description is given to the page as cleaned inline HTML, links allowed (`publicFormDescriptions()` in `forms.js`, used by the `[form]` embed and `GET /api/forms/:slug/public`); Domma's wizard writes it into a `<p>` as HTML. A chooser option's description is given as its words: Domma's chooser sets `textContent`.
|
|
1094
|
+
- **Content API**: `description` stays plain text; `descriptionHtml` is `renderRichText()` of the same value (page list and single page). `seo.description` and the site's `seo.defaultDescription` are plain.
|
|
1095
|
+
- **Compact field**: `richDescription(textarea, {compact: true})` - a line tall, no word count, the toolbar opens under the text while the editor has the focus (under, so the line being clicked does not move). Used where the field was a single-line input in a dense screen.
|
|
1096
|
+
- **Typed into an empty editor**: the browser leaves the first line without a paragraph; `asBlocks()` in `rich-field.js` wraps loose text before it is stored, so the value is rich and not plain text holding entities and tags.
|
|
1093
1097
|
- **In the admin**: `richDescription(textarea)` (`admin/js/lib/rich-field.js`) swaps the textarea for the editor and keeps the textarea as the field, so `data-model` bindings, `.val()` and drafts carry on; `showRichText(el, value)` draws a stored description (through DOMPurify).
|
|
1094
1098
|
|
|
1095
1099
|
### My Profile & avatars
|
package/docs/api-reference.md
CHANGED
|
@@ -1136,7 +1136,7 @@ A page the API serves is exactly a page the site would serve the same caller: bo
|
|
|
1136
1136
|
| `project` | - | Only pages in this project |
|
|
1137
1137
|
| `sort` / `order` | site order | `title`, `updatedAt` or `createdAt`; `order=desc` reverses |
|
|
1138
1138
|
|
|
1139
|
-
Summaries carry `urlPath`, `title`, `description`, `tags`, `category`, `layout`, `updatedAt`. A site can
|
|
1139
|
+
Summaries carry `urlPath`, `title`, `description`, `descriptionHtml`, `tags`, `category`, `layout`, `updatedAt`. A site can
|
|
1140
1140
|
turn the list off (`listable: false`) and keep single pages, so callers must know a path.
|
|
1141
1141
|
|
|
1142
1142
|
### A page
|
|
@@ -1147,8 +1147,8 @@ GET /api/content/v1/pages/about?format=html|markdown|both
|
|
|
1147
1147
|
|
|
1148
1148
|
```json
|
|
1149
1149
|
{
|
|
1150
|
-
"urlPath": "/about", "title": "About", "description": "…", "
|
|
1151
|
-
"layout": "default", "createdAt": "…", "updatedAt": "…",
|
|
1150
|
+
"urlPath": "/about", "title": "About", "description": "…", "descriptionHtml": "<p>…</p>",
|
|
1151
|
+
"tags": ["company"], "category": "general", "layout": "default", "createdAt": "…", "updatedAt": "…",
|
|
1152
1152
|
"seo": {"title": "…", "description": "…", "image": "…"},
|
|
1153
1153
|
"html": "<section>…</section>",
|
|
1154
1154
|
"requires": {"domma": true, "components": ["tabs", "effects"]},
|
|
@@ -1163,6 +1163,10 @@ GET /api/content/v1/pages/about?format=html|markdown|both
|
|
|
1163
1163
|
any custom `[component]`s. Without Domma's CSS and JS those parts are inert.
|
|
1164
1164
|
- Front matter is **allowlisted**: only the keys above appear. `seo` keeps `title`, `description`,
|
|
1165
1165
|
`image`, `canonical`, `noindex`.
|
|
1166
|
+
- `description` is always **plain text**, on one line. A description written in the admin's rich text
|
|
1167
|
+
editor has formatting; `descriptionHtml` is the same words as safe HTML (`p`, `strong`, `em`, `u`, lists,
|
|
1168
|
+
links), and escaped paragraphs when the description is plain. It is absent when there is no description.
|
|
1169
|
+
`seo.description` and the site's `seo.defaultDescription` are plain text, as the meta tag carries them.
|
|
1166
1170
|
- `perViewer: true` means the body was rendered for this caller (a row-scoped `[view]`) and must not be
|
|
1167
1171
|
shared between users.
|
|
1168
1172
|
- **Drafts:** in role mode only, `?preview=1` from a caller holding `pages.read` returns unpublished pages
|
|
@@ -16,7 +16,7 @@ Each break carries two fields of its own:
|
|
|
16
16
|
| Field | Effect |
|
|
17
17
|
|-----------------|---------------------------------------------------------------|
|
|
18
18
|
| **Step Title** | Heading shown above that page |
|
|
19
|
-
| **Description** | Smaller line under the heading; leave blank to omit it
|
|
19
|
+
| **Description** | Smaller line under the heading; leave blank to omit it. Bold, italic, underline and links are shown; a list becomes lines |
|
|
20
20
|
|
|
21
21
|
The first page has no break before it, so it takes its heading from the form's own title.
|
|
22
22
|
Give it a different one by putting a page break at the very top - a break with nothing before
|
|
@@ -1445,7 +1445,7 @@ would be unnecessary.
|
|
|
1445
1445
|
| Placeholder | Behaviour |
|
|
1446
1446
|
|---|---|
|
|
1447
1447
|
| `{{field}}` | Value is HTML-escaped before substitution |
|
|
1448
|
-
| `{{{field}}}` | Value is inserted **raw**, without escaping - use only for trusted HTML |
|
|
1448
|
+
| `{{{field}}}` | Value is inserted **raw**, without escaping - use only for trusted HTML. Inside an attribute value (`href="{{{url}}}"`) its quotes, brackets and line breaks are written as entities, so it stays in that attribute. From a collection entry it is content only: no `data-` attributes, `<style>` or component tags |
|
|
1449
1449
|
| `{{field:FORMAT}}` | Formats the value as a date, e.g. `{{date:DD MMM YYYY}}`. Tokens: `YYYY YY MMMM MMM MM M DD D dddd ddd HH H hh h mm m ss s A a`. A value that is not a valid date is output unformatted |
|
|
1450
1450
|
|
|
1451
1451
|
**Notes:**
|
|
@@ -789,6 +789,26 @@ const meta = richTextSummary(record.description, 160); // meta
|
|
|
789
789
|
const text = richTextToPlain(record.description); // plain email, CSV, ICS, JSON-LD, search
|
|
790
790
|
```
|
|
791
791
|
|
|
792
|
+
**In a dense screen** - where the Description was a single-line input in a row of other inputs, ask for the compact field:
|
|
793
|
+
|
|
794
|
+
```js
|
|
795
|
+
richDescription(row.querySelector('.my-caption'), {compact: true});
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
It is a line tall (`minHeight` 40 unless you pass one), leaves out the word count, and shows its toolbar only while the editor has the focus. The toolbar opens under the text, so the line being clicked does not move. Without `compact` the field behaves as before. Call `handle.destroy()` (the value `richDescription` returns) when you remove the row.
|
|
799
|
+
|
|
800
|
+
**Not a page** - three more helpers for the places a description is not a block of HTML:
|
|
801
|
+
|
|
802
|
+
```js
|
|
803
|
+
import {richTextLine, renderRichTextPhrasing} from '../../server/services/richText.js';
|
|
804
|
+
|
|
805
|
+
const meta = richTextLine(record.description); // one line of plain text, NOT cut: meta/og tags, JSON-LD, llms.txt, counters
|
|
806
|
+
const caption = renderRichTextPhrasing(record.description); // inside a <p>, a caption: inline formatting, paragraphs become <br>
|
|
807
|
+
const inLink = renderRichTextPhrasing(record.description, {links: false}); // inside a link or a button: no link of its own
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
Count characters on `richTextLine(value).length`, never on the stored string. If something else draws the value for you (a framework component), find out how: one that sets text gets `richTextLine()`, one that sets HTML gets `renderRichTextPhrasing()` or `renderRichText()`. A script on a public page must only set HTML the server made from the cleaned value; anything else is text. In the admin, `richTextLine` is exported from `rich-field.js` too, and `richTextInlineHtml(value)` is the admin's copy of `renderRichTextPhrasing` (through DOMPurify) for previews.
|
|
811
|
+
|
|
792
812
|
Do not collapse whitespace or strip characters from the value before `cleanRichText`, and do not pass it through `escapeHtml` on a page: `renderRichText` escapes a plain description and cleans a rich one. Public scripts can import `/public/js/rich-text.mjs` for `isRichText`, `richTextToPlain` and `richTextSummary`; it does no cleaning, so use the server's `renderRichText` output for anything drawn as HTML.
|
|
793
813
|
|
|
794
814
|
## AI Assist: listing your AI chats
|
package/package.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.11.0] - 2026-11-15
|
|
4
|
+
- **A category's Description is a rich text editor** (bold, italic, underline, lists, links). The category's page shows it formatted; the category list shows one plain line. Text saved before stays as it is until edited. Needs Domma CMS 1.67.0.
|
|
5
|
+
|
|
3
6
|
## [1.10.3] - 2026-11-08
|
|
4
7
|
- **Security: the post preview runs no scripts.** The editor's preview iframe is sandboxed (`allow-same-origin`, no `allow-scripts`). It showed the rendered post same-origin with the admin and ran the site's scripts, so markup in a post someone else wrote - another author, or an API token - could run as the admin previewing it. The preview lifts the page cloak itself, so it still shows; interactive bits (tabs, carousels) are static in the preview.
|
|
5
8
|
|
package/plugins/blog/CLAUDE.md
CHANGED
|
@@ -357,3 +357,18 @@ Declared in plugin.json `permissions` (granted once to `admin`), checked on EVER
|
|
|
357
357
|
## 1.10.1
|
|
358
358
|
|
|
359
359
|
- **Email (openEmail).** Email actions go through `admin/lib/email.js`: `emailTo()` for menu actions (several people always in Bcc), `routeMailLinks(root)` for visible `mailto:` links. Core's `/admin/js/lib/mail-compose.js` (CMS 1.6.61+) opens Email Pro's compose window when the user has a mailbox there; older cores keep a cleaned, capped `mailto:` (over 1800 chars the addresses are copied instead). Stored addresses are encoded into links, or shown as text when invalid. Never set `location.href = 'mailto:…'` directly.
|
|
360
|
+
|
|
361
|
+
## Unreleased: the category Description is rich text (CMS 1.67+)
|
|
362
|
+
|
|
363
|
+
- The contract is core's: `docs/plugin-development.md` "Rich text Description fields" in domma-cms. One string in the
|
|
364
|
+
same `description` field: plain (typed before, or from an API client) or HTML from the editor. Never migrate it.
|
|
365
|
+
- Admin (`admin/views/categories.js`): `kit.richField()` loads core's `rich-field.js` at run time (fallback: the plain
|
|
366
|
+
textarea); `richDescription(#blog-cat-desc)` before `M.applyBindings`, destroyed when the slideover closes. Rows show
|
|
367
|
+
`richTextSummary(description, 140)`.
|
|
368
|
+
- Save: `categoryDescription()` in plugin.js = `cleanRichText(value, {max: 4000})` (POST and PUT /categories). No trim,
|
|
369
|
+
no escaping around it.
|
|
370
|
+
- Site: `archiveIntroHtml()` in plugin.public.js = `<div class="blog-archive-intro">` + `renderRichText()`. A div, not
|
|
371
|
+
a p (the value holds paragraphs and lists), and never escaped again. `blog.css` styles its children.
|
|
372
|
+
- Nothing else reads a category's description (no feed, meta or shortcode does). If one is added: HTML gets
|
|
373
|
+
`renderRichText`, everything else `richTextToPlain` / `richTextSummary`.
|
|
374
|
+
- `ASSET_V` in plugin.public.js still needs moving with the release (blog.css changed).
|
|
@@ -67,6 +67,7 @@ export const categoriesView = {
|
|
|
67
67
|
.catch(() => { /* no cog is better than no screen */ });
|
|
68
68
|
|
|
69
69
|
const kit = await import(`./kit.js?v=${ASSET_VERSION}`);
|
|
70
|
+
const rich = await kit.richField();
|
|
70
71
|
const {BASE} = kit;
|
|
71
72
|
const add = kit.viewScope('categories', /^#\/plugins\/blog\/categories\b/);
|
|
72
73
|
const here = add.here;
|
|
@@ -92,7 +93,7 @@ export const categoriesView = {
|
|
|
92
93
|
const n = usage(c.id);
|
|
93
94
|
return {
|
|
94
95
|
id: c.id, name: c.name || c.slug || 'Unnamed', slug: c.slug ?? '',
|
|
95
|
-
description: c.description ?? '',
|
|
96
|
+
description: rich.richTextSummary(c.description ?? '', 140),
|
|
96
97
|
count: `${n} post${n === 1 ? '' : 's'}`,
|
|
97
98
|
countTitle: n ? 'Right-click to show them' : 'No post uses this category'
|
|
98
99
|
};
|
|
@@ -214,6 +215,8 @@ export const categoriesView = {
|
|
|
214
215
|
const el = kit.fragment(EDITOR);
|
|
215
216
|
el.querySelector('#blog-cat-slug').addEventListener('input', () => { slugTouched = true; });
|
|
216
217
|
const disposeHelp = await kit.scanHelp(el);
|
|
218
|
+
// The Description is the shared rich text editor; the textarea stays the field.
|
|
219
|
+
const richDesc = rich.richDescription(el.querySelector('#blog-cat-desc'));
|
|
217
220
|
const handle = M.applyBindings({name, slug, description, saving, focusName}, el, {
|
|
218
221
|
methods: {
|
|
219
222
|
cancel: () => so.close(),
|
|
@@ -250,7 +253,7 @@ export const categoriesView = {
|
|
|
250
253
|
});
|
|
251
254
|
so.element.appendChild(el);
|
|
252
255
|
let unhook = () => {};
|
|
253
|
-
kit.onceClosed(so, () => { open = false; unhook(); handle.dispose(); disposeHelp(); stopFollow(); release(); });
|
|
256
|
+
kit.onceClosed(so, () => { open = false; unhook(); handle.dispose(); richDesc.destroy(); disposeHelp(); stopFollow(); release(); });
|
|
254
257
|
const guard = kit.guardSlideover(so, {dirty: () => !saving.peek() && isDirty()});
|
|
255
258
|
const keep = () => {
|
|
256
259
|
if (!isDirty()) return false;
|
|
@@ -45,6 +45,25 @@ export async function adminLib(file) {
|
|
|
45
45
|
try { return await import(`/admin/js/lib/${file}`); } catch { return null; }
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* The shared rich text Description field (core 1.67+). On an older admin the
|
|
50
|
+
* textarea is left as it is and a description reads as the text it is.
|
|
51
|
+
*
|
|
52
|
+
* @returns {Promise<{richDescription: Function, richTextSummary: Function, showRichText: Function}>}
|
|
53
|
+
*/
|
|
54
|
+
export async function richField() {
|
|
55
|
+
const lib = await adminLib('rich-field.js');
|
|
56
|
+
if (lib?.richDescription) return lib;
|
|
57
|
+
return {
|
|
58
|
+
richDescription: () => ({destroy() {}}),
|
|
59
|
+
richTextSummary: (value, max = 160) => {
|
|
60
|
+
const line = String(value ?? '').replace(/\s+/g, ' ').trim();
|
|
61
|
+
return line.length > max ? `${line.slice(0, max - 1).trimEnd()}…` : line;
|
|
62
|
+
},
|
|
63
|
+
showRichText: (el, value) => { if (el) el.textContent = String(value ?? ''); }
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
48
67
|
/**
|
|
49
68
|
* Give every `[data-help]` under `el` its (?) popover. Run it BEFORE
|
|
50
69
|
* M.applyBindings: a `data-if` lifts its element out of the document, and
|
|
@@ -62,6 +62,8 @@ The **Status** card shows the status, the scheduled or published date, when it w
|
|
|
62
62
|
|
|
63
63
|
Lists every category with its post count. Click **New category** and enter a **Name**, **Slug** and optional **Description**. Each category has a page at `/blog/category/<slug>`.
|
|
64
64
|
|
|
65
|
+
The **Description** is a small text editor: bold, italic, underline, bullet and numbered lists, and links. It is shown, with its formatting, at the top of the category's page. The list of categories shows it as one line of plain text. Descriptions typed before the editor arrived stay exactly as they were until you edit them.
|
|
66
|
+
|
|
65
67
|
Right-click a category (or use its three-dot button) for **Edit**, **Show its posts**, **View on site** and **Delete**.
|
|
66
68
|
|
|
67
69
|
### Comments
|