domma-cms 1.35.0 → 1.37.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/admin/js/api.js +1 -1
  3. package/admin/js/app.js +2 -2
  4. package/admin/js/lib/image-editor.js +1 -1
  5. package/admin/js/lib/media-arrange.js +1 -1
  6. package/admin/js/lib/media-picker.js +2 -2
  7. package/admin/js/lib/media-upload.js +1 -1
  8. package/admin/js/lib/seo-redirects.js +1 -1
  9. package/admin/js/templates/docs/usage-media.html +6 -0
  10. package/admin/js/templates/media.html +1 -0
  11. package/admin/js/views/media.js +3 -3
  12. package/bin/lib/left-free-tier.js +4 -1
  13. package/bin/update.js +4 -0
  14. package/docs/DommaFeatures.md +10 -5
  15. package/docs/plugin-development.md +2 -2
  16. package/package.json +1 -1
  17. package/plugins/docs/tests/plugin.test.js +2 -0
  18. package/plugins/free-tier.lock.json +2 -50
  19. package/server/routes/api/media.js +3 -1
  20. package/server/routes/api/sidebar.js +2 -2
  21. package/server/services/content.js +26 -2
  22. package/server/services/hooks.js +27 -4
  23. package/server/services/plugins.js +9 -3
  24. package/server/services/renderer.js +3 -1
  25. package/server/services/siteGitignore.js +1 -1
  26. package/plugins/booking/CLAUDE.md +0 -204
  27. package/plugins/booking/admin/css/index.css +0 -192
  28. package/plugins/booking/admin/lib/details.js +0 -58
  29. package/plugins/booking/admin/lib/diary-layout.js +0 -158
  30. package/plugins/booking/admin/lib/drafts.js +0 -139
  31. package/plugins/booking/admin/lib/email.js +0 -191
  32. package/plugins/booking/admin/lib/extension-sections.js +0 -160
  33. package/plugins/booking/admin/lib/kit.js +0 -471
  34. package/plugins/booking/admin/templates/booking.html +0 -1
  35. package/plugins/booking/admin/views/booking.js +0 -216
  36. package/plugins/booking/admin/views/bookings.js +0 -132
  37. package/plugins/booking/admin/views/diary.js +0 -382
  38. package/plugins/booking/admin/views/panels.js +0 -603
  39. package/plugins/booking/admin/views/people.js +0 -318
  40. package/plugins/booking/admin/views/services.js +0 -264
  41. package/plugins/booking/admin/views/settings.js +0 -222
  42. package/plugins/booking/collections/booking-bookables.json +0 -17
  43. package/plugins/booking/collections/booking-bookings.json +0 -18
  44. package/plugins/booking/collections/booking-services.json +0 -17
  45. package/plugins/booking/config.js +0 -36
  46. package/plugins/booking/docs/guide.md +0 -73
  47. package/plugins/booking/inject/body.html +0 -1
  48. package/plugins/booking/lib/call.js +0 -88
  49. package/plugins/booking/lib/extensions.js +0 -169
  50. package/plugins/booking/lib/mail.js +0 -113
  51. package/plugins/booking/lib/store.js +0 -392
  52. package/plugins/booking/plugin.js +0 -905
  53. package/plugins/booking/plugin.json +0 -81
  54. package/plugins/booking/plugin.public.js +0 -175
  55. package/plugins/booking/public/booking.css +0 -159
  56. package/plugins/booking/public/booking.js +0 -808
  57. package/plugins/booking/public/lib/clean.js +0 -141
  58. package/plugins/booking/public/lib/page-format.js +0 -121
  59. package/plugins/booking/public/lib/slots.js +0 -247
  60. package/plugins/booking/public/lib/time.js +0 -131
  61. package/plugins/booking/templates/booking.html +0 -5
  62. package/plugins/booking/tests/admin-diary.test.js +0 -81
  63. package/plugins/booking/tests/admin-drafts.test.js +0 -67
  64. package/plugins/booking/tests/api.test.js +0 -651
  65. package/plugins/booking/tests/email.test.js +0 -69
  66. package/plugins/booking/tests/public.test.js +0 -72
  67. package/plugins/booking/tests/pure.test.js +0 -189
  68. package/plugins/booking/tests/seo.test.js +0 -71
@@ -1,4 +1,4 @@
1
- import{api as L}from"../api.js";import{catchFiles as qe,mediaUploader as Ne}from"../lib/media-upload.js";import{addBannerAction as ze}from"../lib/plugin-chrome.js";import{SHAPES as Ie,whileLoading as Re}from"../lib/loading.js";import{helpPopovers as be}from"../lib/help-popover.js";import{onceClosed as Ue,openMenuAt as ve,settingsStore as Be,sidebarCount as j,viewLifetime as Fe}from"../lib/tool-kit.js";import{openImageEditor as He}from"../lib/image-editor.js";import{KIND_LABEL as ye,arrangeMedia as Pe,formatBytes as he,isEditable as G,isPreviewable as Ke,kindCounts as Oe,kindOf as _e,markdownFor as J,mediaTile as Ve,normalisePrefs as Ye,safeName as T}from"../lib/media-arrange.js";import{fmtDateTime as je}from"../lib/dates.js";const ge=/^#\/media\/?(\?.*)?$/,Q="#/media",q="media.draft",we=Be("media.prefs",Ye),Ge=`
1
+ import{api as C}from"../api.js";import{catchFiles as qe,mediaUploader as ze}from"../lib/media-upload.js";import{addBannerAction as Ie}from"../lib/plugin-chrome.js";import{SHAPES as Re,whileLoading as Ue}from"../lib/loading.js";import{helpPopovers as ve}from"../lib/help-popover.js";import{onceClosed as Be,openMenuAt as ye,settingsStore as Fe,sidebarCount as j,viewLifetime as He}from"../lib/tool-kit.js";import{openImageEditor as Pe}from"../lib/image-editor.js";import{KIND_LABEL as he,arrangeMedia as Ke,formatBytes as ge,isEditable as G,isPreviewable as Oe,kindCounts as _e,kindOf as Ve,markdownFor as J,foldersText as Ye,mediaTile as je,normalisePrefs as Ge,safeName as L}from"../lib/media-arrange.js";import{fmtDateTime as Je}from"../lib/dates.js";const we=/^#\/media\/?(\?.*)?$/,Q="#/media",N="media.draft",ke=Fe("media.prefs",Ge),Qe=`
2
2
  <div class="mdx-tile" data-name="{{name}}" tabindex="0" title="{{name}}">
3
3
  <div class="mdx-thumb">
4
4
  <img data-bind-hidden="!preview" data-bind-src="thumb" alt="" loading="lazy" decoding="async">
@@ -7,7 +7,7 @@ import{api as L}from"../api.js";import{catchFiles as qe,mediaUploader as Ne}from
7
7
  <span class="mdx-chip">{{kindLabel}}</span>
8
8
  <button type="button" class="mdx-kebab" aria-label="Actions for {{name}}" title="Actions">\u22EE</button>
9
9
  <div class="mdx-info"><span class="mdx-name">{{name}}</span><span class="mdx-meta">{{meta}}</span></div>
10
- </div>`,N=c=>String(c??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Je(c){const s=document.createElement("template");return s.innerHTML=c.trim(),s.content.firstElementChild}const l=Fe(ge);let W=null;async function z(c,s){try{await navigator.clipboard.writeText(c),E.toast(`${s} copied.`,{type:"success"})}catch{E.toast("Copy failed - the browser refused the clipboard.",{type:"error"})}}export const mediaView={templateUrl:"/admin/js/templates/media.html",async onMount(c){l.reset();const s=c.get(0).querySelector(".mdx")||c.get(0),u=()=>ge.test(location.hash)&&s.isConnected,X=we.read(),p=M.observable([]),Z=M.observable(!0),R=M.observable(""),b=M.observable(X.kind),U=M.observable(X.sort),ee=M.observable(""),te=M.observable(!1),ae=M.observable("");let B=String(Date.now());l.add(M.effect(()=>we.write({kind:b.value,sort:U.value})));const C=M.observable([]);l.add(M.effect(()=>{const e=Date.now();C.value=Pe(p.value,{kind:b.value,query:ee.value,sort:U.value}).map(a=>Ve(a,{now:e,stamp:B}))}));const ne=M.computed(()=>Oe(p.value));l.add(M.effect(()=>{b.value!=="all"&&!ne.value[b.value]&&p.value.length&&(b.value="all")}));const ke=M.computed(()=>{const e=p.value,a=C.value.length,i=he(e.reduce((n,m)=>n+(Number(m.size)||0),0));return a===e.length?`${e.length} file${e.length===1?"":"s"} \xB7 ${i}`:`${a} of ${e.length} \xB7 ${i} in all`}),xe=M.computed(()=>p.value.length?"No files match.":"Nothing uploaded yet - drop files here, or Upload in the banner."),h=e=>p.peek().find(a=>a.name===e);async function g(){try{const e=await Re(s.querySelector(".dm-loading-slot"),L.media.list(),Ie.tiles);if(!u())return;B=String(Date.now()),p.value=Array.isArray(e)?e:[],R.value=""}catch(e){R.value=`Could not load the media: ${e.message||e}`}finally{Z.value=!1}}async function F(e){if(!await E.confirm(`Delete "${N(e.name)}"? Pages that show it will show a broken image or link. This cannot be undone.`))return!1;try{return await L.media.delete(e.name),E.toast(`Deleted "${e.name}".`,{type:"success"}),j(Q),u()&&await g(),!0}catch(a){return E.toast(`Not deleted: ${a.message||a}`,{type:"error"}),!1}}async function oe(e){const a=await He(e);return a&&u()&&(j(Q),await g()),a}const H=e=>window.location.origin+e.url;let v=null,se=!1;const P=new Set;function w(e,{focusRename:a=!1,draftName:i=null}={}){const n=h(e);if(!n){E.toast(`"${e}" is not here any more.`,{type:"warning"});return}const m=M.observable(i??n.name),D=M.observable(!1),de=M.computed(()=>{const t=m.value.trim();if(!t)return"A file needs a name.";const o=T(t);return o!==n.name&&h(o)?`"${o}" is already here.`:""}),Ae=M.computed(()=>{const t=m.value.trim(),o=T(t);return t&&o!==t?`Saved as "${o}" - only letters, numbers, dots, hyphens and underscores are kept.`:""}),ce=()=>m.peek().trim()!==n.name,me={newName:m,saving:D,renameErr:de,renameHint:Ae,cannotRename:M.computed(()=>D.value||!!de.value||T(m.value.trim())===n.name),editable:G(n.name)},d=E.slideover({title:N(n.name),size:"md",position:"right"}),r=Je(`
10
+ </div>`,q=c=>String(c??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function We(c){const s=document.createElement("template");return s.innerHTML=c.trim(),s.content.firstElementChild}const l=He(we);let W=null;async function z(c,s){try{await navigator.clipboard.writeText(c),E.toast(`${s} copied.`,{type:"success"})}catch{E.toast("Copy failed - the browser refused the clipboard.",{type:"error"})}}export const mediaView={templateUrl:"/admin/js/templates/media.html",async onMount(c){l.reset();const s=c.get(0).querySelector(".mdx")||c.get(0),m=()=>we.test(location.hash)&&s.isConnected,X=ke.read(),p=M.observable([]),Z=M.observable(!0),R=M.observable(""),b=M.observable(X.kind),U=M.observable(X.sort),ee=M.observable(""),te=M.observable(!1),ae=M.observable(""),ne=M.observable("");let B=String(Date.now());l.add(M.effect(()=>ke.write({kind:b.value,sort:U.value})));const D=M.observable([]);l.add(M.effect(()=>{const e=Date.now();D.value=Ke(p.value,{kind:b.value,query:ee.value,sort:U.value}).map(a=>je(a,{now:e,stamp:B}))}));const oe=M.computed(()=>_e(p.value));l.add(M.effect(()=>{b.value!=="all"&&!oe.value[b.value]&&p.value.length&&(b.value="all")}));const xe=M.computed(()=>{const e=p.value,a=D.value.length,i=ge(e.reduce((n,u)=>n+(Number(u.size)||0),0));return a===e.length?`${e.length} file${e.length===1?"":"s"} \xB7 ${i}`:`${a} of ${e.length} \xB7 ${i} in all`}),Ee=M.computed(()=>p.value.length?"No files match.":"Nothing uploaded yet - drop files here, or Upload in the banner."),h=e=>p.peek().find(a=>a.name===e);async function g(){try{const e=await Ue(s.querySelector(".dm-loading-slot"),C.media.list(),Re.tiles);if(!m())return;B=String(Date.now()),p.value=Array.isArray(e)?e:[],R.value=""}catch(e){R.value=`Could not load the media: ${e.message||e}`}finally{Z.value=!1}}async function F(e){if(!await E.confirm(`Delete "${q(e.name)}"? Pages that show it will show a broken image or link. This cannot be undone.`))return!1;try{return await C.media.delete(e.name),E.toast(`Deleted "${e.name}".`,{type:"success"}),j(Q),m()&&await g(),!0}catch(a){return E.toast(`Not deleted: ${a.message||a}`,{type:"error"}),!1}}async function se(e){const a=await Pe(e);return a&&m()&&(j(Q),await g()),a}const H=e=>window.location.origin+e.url;let v=null,ie=!1;const P=new Set;function w(e,{focusRename:a=!1,draftName:i=null}={}){const n=h(e);if(!n){E.toast(`"${e}" is not here any more.`,{type:"warning"});return}const u=M.observable(i??n.name),$=M.observable(!1),ce=M.computed(()=>{const t=u.value.trim();if(!t)return"A file needs a name.";const o=L(t);return o!==n.name&&h(o)?`"${o}" is already here.`:""}),Ce=M.computed(()=>{const t=u.value.trim(),o=L(t);return t&&o!==t?`Saved as "${o}" - only letters, numbers, dots, hyphens and underscores are kept.`:""}),me=()=>u.peek().trim()!==n.name,ue={newName:u,saving:$,renameErr:ce,renameHint:Ce,cannotRename:M.computed(()=>$.value||!!ce.value||L(u.value.trim())===n.name),editable:G(n.name)},d=E.slideover({title:q(n.name),size:"md",position:"right"}),r=We(`
11
11
  <div class="mdx-panel">
12
12
  <div class="mdx-preview"></div>
13
13
  <dl class="mdx-facts"></dl>
@@ -37,4 +37,4 @@ import{api as L}from"../api.js";import{catchFiles as qe,mediaUploader as Ne}from
37
37
  <a class="btn btn-sm btn-ghost mdx-open" target="_blank" rel="noopener"><span data-icon="external-link" data-icon-size="13"></span> Open</a>
38
38
  <button type="button" class="btn btn-sm btn-outline" data-on-click="edit" data-bind-hidden="!editable"><span data-icon="edit" data-icon-size="13"></span> Edit image</button>
39
39
  </div>
40
- </div>`),O=r.querySelector(".mdx-preview"),x=_e(n.name);if(Ke(n.name)){const t=document.createElement("img");t.src=`${n.url}?t=${encodeURIComponent(B)}`,t.alt=n.name,O.appendChild(t)}else if(x==="video"||x==="audio"){const t=document.createElement(x);t.src=n.url,t.controls=!0,t.preload="metadata",O.appendChild(t)}else{const t=document.createElement("span");t.setAttribute("data-icon",x==="document"?"file-text":"paperclip"),t.setAttribute("data-icon-size","40"),O.appendChild(t)}const Ce=r.querySelector(".mdx-facts"),$=(t,o)=>{const fe=document.createElement("dt");fe.textContent=t;const Y=document.createElement("dd");return Y.textContent=o,Ce.append(fe,Y),Y};if($("Type",`${ye[x]==="Images"?"Image":ye[x].replace(/s$/,"")} (${(n.name.split(".").pop()||"").toUpperCase()})`),$("Size",he(n.size)),$("Uploaded",n.createdAt?je(n.createdAt):"-"),G(n.name)){const t=$("Dimensions","\u2026");L.media.info(n.name).then(o=>{t.textContent=o?.width?`${o.width} \xD7 ${o.height} px`:"-"}).catch(()=>{t.textContent="-"})}r.querySelector(".mdx-url").value=H(n),r.querySelector(".mdx-md").value=J(n),r.querySelector(".mdx-open").href=n.url;let A=!1;async function ue(){if(!me.cannotRename.peek()){D.value=!0;try{const t=await L.media.rename(n.name,m.peek().trim());E.toast(`Renamed to "${t?.name||T(m.peek().trim())}".`,{type:"success"}),A=!0,d.close(),u()&&await g()}catch(t){E.toast(`Not renamed: ${t.message||t}`,{type:"error"})}finally{D.value=!1}}}d.element.appendChild(r);const De=be(r),$e=M.applyBindings(me,r,{methods:{rename:ue,copyUrl:()=>z(H(n),"Address"),copyMd:()=>z(J(n),"Markdown"),async del(){await F(n)&&(A=!0,d.close())},async edit(){A=!0,d.close(),await oe(n)}}}),_=r.querySelector("#mdx-rename"),Le=t=>{t.key==="Enter"&&t.target===_&&(t.preventDefault(),ue())};r.addEventListener("keydown",Le);const pe={name:n.name,dirty:ce,newName:()=>m.peek()};v=pe,P.add(d),Ue(d,()=>{$e.dispose(),De(),r.querySelectorAll("video, audio").forEach(t=>{try{t.pause()}catch{}}),P.delete(d),v===pe&&(v=null)});const Te=d.close.bind(d);let V=!1;d.close=async t=>{if(!A&&!se&&t!==!0&&ce()){if(V)return;V=!0;const o=await E.confirm("Discard the new name you typed?");if(V=!1,!o)return}return A=!0,Te()},I.scan(r),d.open(),(a||i)&&(_.focus(),_.select())}function Ee(e){const a=h(e);return a?[{header:a.name},{label:"Details\u2026",icon:"info",action:()=>w(a.name)},{label:"Copy address",icon:"link",action:()=>z(H(a),"Address")},{label:"Copy for a page",icon:"copy",action:()=>z(J(a),"Markdown")},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(a.url,"_blank","noopener")},{type:"divider"},{label:"Rename\u2026",icon:"type",action:()=>w(a.name,{focusRename:!0})},...G(a.name)?[{label:"Edit image\u2026",icon:"edit",action:()=>oe(a)}]:[],{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>F(a)}]:[]}const f=s.querySelector(".mdx-grid");f.innerHTML=Ge;const k=e=>()=>{b.value=e},Me=M.applyBindings({files:p,loading:Z,loadError:R,kind:b,sort:U,query:ee,tiles:C,counts:ne,totalText:ke,emptyText:xe,hintText:ae,dragging:te},s,{methods:{kindAll:k("all"),kindImage:k("image"),kindVideo:k("video"),kindAudio:k("audio"),kindDocument:k("document"),kindOther:k("other")}});l.add(()=>Me.dispose()),l.add(be(s,{position:"bottom"})),l.add(M.effect(()=>{C.value,requestAnimationFrame(()=>{f.isConnected&&I.scan(f)})}));const Se=E.contextMenu(f,{cursor:"glyph",match:".mdx-tile",inherit:!1,density:"compact",items:e=>Ee(e.dataset.name)});l.add(()=>Se?.destroy?.());const ie=e=>{const a=e.target.closest(".mdx-tile");if(!a)return;const i=e.target.closest(".mdx-kebab");if(i){ve(i);return}w(a.dataset.name)},le=e=>{const a=e.target.closest(".mdx-tile");if(!a||e.target!==a)return;const i=h(a.dataset.name);i&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),ve(a)):e.key==="Enter"?w(i.name):e.key==="F2"?(e.preventDefault(),w(i.name,{focusRename:!0})):e.key==="Delete"&&(e.preventDefault(),F(i)))};f.addEventListener("click",ie),f.addEventListener("keydown",le),l.add(()=>{f.removeEventListener("click",ie),f.removeEventListener("keydown",le)});const K=Ne(s.querySelector(".mdx-zone"),{input:s.querySelector(".mdx-file-input"),exists:e=>!!h(e),showing:u,onHint:e=>{ae.value=e},onUploaded(){j(Q),u()?g():W?.()}});W=()=>{u()&&g()},l.add(()=>{W=null,K.release()}),ze(c,{id:"media-upload",icon:"upload",title:"Upload files",onClick:()=>K.browse()}),l.add(qe(c.get(0),K.addFiles,{onDragging:e=>{te.value=e}}));const re=e=>{v?.dirty()&&(e.preventDefault(),e.returnValue="")};if(window.addEventListener("beforeunload",re),l.add(()=>window.removeEventListener("beforeunload",re)),l.add(()=>{if(v?.dirty())try{S.set(q,{name:v.name,newName:v.newName(),at:new Date().toISOString()})}catch{}se=!0,[...P].forEach(e=>{try{e.close(!0)}catch{}})}),I.scan(s),await g(),!u())return;let y=null;try{y=S.get(q)}catch{}if(y?.name){try{S.remove?S.remove(q):S.set(q,null)}catch{}h(y.name)&&await E.confirm(`You were renaming "${N(y.name)}" to "${N(y.newName)}" and left before saving. Pick up where you left off?`)&&u()&&w(y.name,{draftName:y.newName})}}};
40
+ </div>`),O=r.querySelector(".mdx-preview"),x=Ve(n.name);if(Oe(n.name)){const t=document.createElement("img");t.src=`${n.url}?t=${encodeURIComponent(B)}`,t.alt=n.name,O.appendChild(t)}else if(x==="video"||x==="audio"){const t=document.createElement(x);t.src=n.url,t.controls=!0,t.preload="metadata",O.appendChild(t)}else{const t=document.createElement("span");t.setAttribute("data-icon",x==="document"?"file-text":"paperclip"),t.setAttribute("data-icon-size","40"),O.appendChild(t)}const De=r.querySelector(".mdx-facts"),T=(t,o)=>{const be=document.createElement("dt");be.textContent=t;const Y=document.createElement("dd");return Y.textContent=o,De.append(be,Y),Y};if(T("Type",`${he[x]==="Images"?"Image":he[x].replace(/s$/,"")} (${(n.name.split(".").pop()||"").toUpperCase()})`),T("Size",ge(n.size)),T("Uploaded",n.createdAt?Je(n.createdAt):"-"),G(n.name)){const t=T("Dimensions","\u2026");C.media.info(n.name).then(o=>{t.textContent=o?.width?`${o.width} \xD7 ${o.height} px`:"-"}).catch(()=>{t.textContent="-"})}r.querySelector(".mdx-url").value=H(n),r.querySelector(".mdx-md").value=J(n),r.querySelector(".mdx-open").href=n.url;let A=!1;async function pe(){if(!ue.cannotRename.peek()){$.value=!0;try{const t=await C.media.rename(n.name,u.peek().trim());E.toast(`Renamed to "${t?.name||L(u.peek().trim())}".`,{type:"success"}),A=!0,d.close(),m()&&await g()}catch(t){E.toast(`Not renamed: ${t.message||t}`,{type:"error"})}finally{$.value=!1}}}d.element.appendChild(r);const $e=ve(r),Te=M.applyBindings(ue,r,{methods:{rename:pe,copyUrl:()=>z(H(n),"Address"),copyMd:()=>z(J(n),"Markdown"),async del(){await F(n)&&(A=!0,d.close())},async edit(){A=!0,d.close(),await se(n)}}}),_=r.querySelector("#mdx-rename"),Le=t=>{t.key==="Enter"&&t.target===_&&(t.preventDefault(),pe())};r.addEventListener("keydown",Le);const fe={name:n.name,dirty:me,newName:()=>u.peek()};v=fe,P.add(d),Be(d,()=>{Te.dispose(),$e(),r.querySelectorAll("video, audio").forEach(t=>{try{t.pause()}catch{}}),P.delete(d),v===fe&&(v=null)});const Ne=d.close.bind(d);let V=!1;d.close=async t=>{if(!A&&!ie&&t!==!0&&me()){if(V)return;V=!0;const o=await E.confirm("Discard the new name you typed?");if(V=!1,!o)return}return A=!0,Ne()},I.scan(r),d.open(),(a||i)&&(_.focus(),_.select())}function Me(e){const a=h(e);return a?[{header:a.name},{label:"Details\u2026",icon:"info",action:()=>w(a.name)},{label:"Copy address",icon:"link",action:()=>z(H(a),"Address")},{label:"Copy for a page",icon:"copy",action:()=>z(J(a),"Markdown")},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(a.url,"_blank","noopener")},{type:"divider"},{label:"Rename\u2026",icon:"type",action:()=>w(a.name,{focusRename:!0})},...G(a.name)?[{label:"Edit image\u2026",icon:"edit",action:()=>se(a)}]:[],{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>F(a)}]:[]}const f=s.querySelector(".mdx-grid");f.innerHTML=Qe;const k=e=>()=>{b.value=e},Se=M.applyBindings({files:p,loading:Z,loadError:R,kind:b,sort:U,query:ee,tiles:D,counts:oe,totalText:xe,emptyText:Ee,hintText:ae,foldersNote:ne,dragging:te},s,{methods:{kindAll:k("all"),kindImage:k("image"),kindVideo:k("video"),kindAudio:k("audio"),kindDocument:k("document"),kindOther:k("other")}});l.add(()=>Se.dispose()),l.add(ve(s,{position:"bottom"})),l.add(M.effect(()=>{D.value,requestAnimationFrame(()=>{f.isConnected&&I.scan(f)})}));const Ae=E.contextMenu(f,{cursor:"glyph",match:".mdx-tile",inherit:!1,density:"compact",items:e=>Me(e.dataset.name)});l.add(()=>Ae?.destroy?.());const le=e=>{const a=e.target.closest(".mdx-tile");if(!a)return;const i=e.target.closest(".mdx-kebab");if(i){ye(i);return}w(a.dataset.name)},re=e=>{const a=e.target.closest(".mdx-tile");if(!a||e.target!==a)return;const i=h(a.dataset.name);i&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),ye(a)):e.key==="Enter"?w(i.name):e.key==="F2"?(e.preventDefault(),w(i.name,{focusRename:!0})):e.key==="Delete"&&(e.preventDefault(),F(i)))};f.addEventListener("click",le),f.addEventListener("keydown",re),l.add(()=>{f.removeEventListener("click",le),f.removeEventListener("keydown",re)});const K=ze(s.querySelector(".mdx-zone"),{input:s.querySelector(".mdx-file-input"),exists:e=>!!h(e),showing:m,onHint:e=>{ae.value=e},onUploaded(){j(Q),m()?g():W?.()}});W=()=>{m()&&g()},l.add(()=>{W=null,K.release()}),Ie(c,{id:"media-upload",icon:"upload",title:"Upload files",onClick:()=>K.browse()}),l.add(qe(c.get(0),K.addFiles,{onDragging:e=>{te.value=e}}));const de=e=>{v?.dirty()&&(e.preventDefault(),e.returnValue="")};if(window.addEventListener("beforeunload",de),l.add(()=>window.removeEventListener("beforeunload",de)),l.add(()=>{if(v?.dirty())try{S.set(N,{name:v.name,newName:v.newName(),at:new Date().toISOString()})}catch{}ie=!0,[...P].forEach(e=>{try{e.close(!0)}catch{}})}),I.scan(s),await g(),!m())return;C.media.folders().then(e=>{m()&&e?.files&&(ne.value=Ye(e))}).catch(()=>{});let y=null;try{y=S.get(N)}catch{}if(y?.name){try{S.remove?S.remove(N):S.set(N,null)}catch{}h(y.name)&&await E.confirm(`You were renaming "${q(y.name)}" to "${q(y.newName)}" and left before saving. Pick up where you left off?`)&&m()&&w(y.name,{draftName:y.newName})}}};
@@ -7,6 +7,9 @@
7
7
  * the plugins it ships - so without this step every site would keep its old
8
8
  * free copy forever, runnable without a licence.
9
9
  *
10
+ * Booking joined the paid Calendar in 1.37.0. Its old free copy is retired
11
+ * under the same rule, with runtime files retained for Calendar to migrate.
12
+ *
10
13
  * So the update removes the OLD FREE COPY, and only that:
11
14
  *
12
15
  * - a copy with `.entitlement.json` beside it is a licensed (or gifted) one,
@@ -30,7 +33,7 @@ import {existsSync, lstatSync, readFileSync, readdirSync, rmSync} from 'node:fs'
30
33
  import path from 'node:path';
31
34
 
32
35
  /** Slug -> the version that left the free tier. */
33
- export const LEFT_FREE_TIER = Object.freeze({quiz: '1.3.0', crossword: '1.3.0'});
36
+ export const LEFT_FREE_TIER = Object.freeze({quiz: '1.3.0', crossword: '1.3.0', booking: '1.37.0'});
34
37
 
35
38
  /** Never removed from a copy that goes: runtime state, and a licence (which would have kept the copy anyway). */
36
39
  export const KEEP = Object.freeze(['data', 'backups', '.entitlement.json']);
package/bin/update.js CHANGED
@@ -459,6 +459,10 @@ export default async function update(_positional, flags) {
459
459
  for (const r of left) {
460
460
  if (r.action === 'keep') { info(` → plugins/${r.name}/ kept: ${r.reason}`); continue; }
461
461
  info(` → plugins/${r.name}/ removed: ${r.reason} - it is a paid Tool now${r.kept.length ? ` (${r.kept.join(', ')} kept)` : ''}`);
462
+ if (r.name === 'booking') {
463
+ info(' → Booking is included in Calendar; existing booking records and runtime data are retained.');
464
+ continue;
465
+ }
462
466
  if (enabled[r.name]?.enabled) warn(`${r.name} was switched on here: it stays off until this site is licensed for it (or gifted it).`);
463
467
  }
464
468
  }
@@ -36,10 +36,9 @@ Code was treated as the truth. Where docs disagree with it, the disagreement is
36
36
  | `bingo` | paid (giftable) | 1.0.0 | Bingo for quiz nights, events and classrooms: 75-ball, 90-ball tickets, or word and picture cards. A caller screen with auto-draw and a projector view, players on their phones with server-dealt cards, claims checked against the real calls, and printable numbered cards with a checker. |
37
37
  | `blog` | free | 1.9.6 | Public-facing blog with posts, categories and comments - layouts and listings built from editable blocks. |
38
38
  | `blog-pro` | paid | 0.7.0 | Several blogs on one site, each with its own address, look and settings - dozens of layouts, self-hosted fonts, colours, page transitions, author pages, and privacy-first media: videos, audio, galleries, link cards and maps. |
39
- | `booking` | free | 1.6.3 | Let people book appointments with you or your team, and rooms or equipment, from a booking page on your site (`/booking`, or the `[booking /]` shortcode). Opening hours, days off, buffers and notice; confirmation and reminder emails with a link to move or cancel; a Diary in the admin; an online booking's call chat kept on the booking, and Add people during its call. Book straight from a contact or an email; bookings show in the Calendar. |
40
- | `booking-pro` | paid | 0.4.1 | More for Booking: online appointments as a video call on your site (optional host recording), Call now - open a booking's call at once or call anyone from a contact or an email (switches on the CMS's instant calls), a person and a room together, classes with places and a waiting list that fills a freed place by itself, repeat bookings, questions on the booking form, a daily limit and one booking per customer every N days. A lapse leaves Booking and every booking as they were. |
41
- | `calendar` | paid | 1.15.4 | Events calendar - month, day and list views, online meetings as a video call on your site (with the call's chat kept, and Add people during the call), call anyone now from a contact or an email, all-day and recurring events, sharing with people and roles, RSVPs and an iCal feed. |
39
+ | `calendar` | paid | 2.0.1 | Events, appointments, availability and Google Calendar in one Tool. Includes the former Booking and Booking Pro features: classes, waiting lists, repeat bookings, linked staff and rooms, booking questions and online appointments. |
42
40
  | `campaigns-pro` | paid | 1.6.0 | Marketing campaigns, one paid Tool: compose a message, send it to Contacts groups (read live when it sends) or an audience of its own (shared with Surveys), from the site's sending or your own Email mailbox (small lists), schedule sends, attach an offer that closes by a date or a claim limit. Opens and clicks (cookieless), links tagged for Analytics, a linked Shop discount code, send a survey as a campaign, follow-up sequences, resend to non-openers, A/B subject tests, and a version-1 stats feed other Tools read. |
41
+ | `media-pro` | paid | 0.2.0 | Media, properly organised: folders inside folders, choose from them anywhere, and move or rename anything without breaking a page. Select several, see where each file is used, find what is unused or duplicated, shrink big pictures, alt text and credits with each file, Trash, and a whole folder as a gallery. Works on the same files as the built-in Tool. |
43
42
  | `contacts-pro` | paid | 0.13.0 | Contacts, with more to them: send a campaign to a group or the selected contacts (with Campaigns Pro), your own custom fields, birthdays and ages with the ones coming up and a reminder in the sidebar, and groups with their own emblem and colours. Share a contact, several, or a whole group with people or roles - to view, or to edit. Call a contact now on a video call on your site. Works over the same contacts as the built-in Tool, so nothing moves and nothing is lost. |
44
43
  | `crossword` | paid (giftable) | 1.5.1 | Crosswords on your site: type the answers and clues and the grid lays itself out (live preview, Another layout). Players type a name and race the server's clock, checks and wrong guesses cost time, fastest solvers on a leaderboard. Hints for a time penalty, personal best and Share, animations, export and import. Test it from the Tool - a test go never reaches the board. Rotation (a new quiz every day or week from a queue, off by default) and fresh quizzes from Domma for review. |
45
44
  | `daily-word` | paid (giftable) | 1.3.0 | One hidden word a day, the same for everyone: six guesses, each letter marked right place, in the word or not; real words only (a bundled dictionary, switchable), an archive of past days, streaks, Share as coloured squares, a calendar of what is coming. Fewest guesses tops the day's board, then the fastest. |
@@ -335,6 +334,8 @@ Fast, file-based and friendly.
335
334
  ### Media library
336
335
 
337
336
  - **Media library** - upload by button or by dropping files anywhere on the screen (images, documents, audio, video; 10 MB default limit). Tiles with thumbnail, size, age and type; filter All / Images / Video / Audio / Documents / Other; sort newest, oldest, name or largest. Details slideover with rename, Copy address and Copy for a page (Markdown); right-click menu, F2 to rename, Delete key. Replacing a same-named file asks first.
337
+ - **Files in folders** - the built-in screen lists the top of the library; when there are files in folders it says how many, and they keep working at their addresses (`GET /api/media/_folders`). Managing folders is Media Pro.
338
+ - **Media Pro** (paid, `media-pro`, marketplace; in the Pro bundle since CMS 1.36.0) - takes over the Media screen and every image picker. Nested folders that are real folders (`/media/products/shoes/red.jpg`), drag to move, upload a whole folder keeping its shape, select several (move, tag, shrink, zip, Trash). Moving or renaming anything updates pages, collections and settings that use it and adds a redirect in the SEO Tool; blocks, forms, menus, custom.css and other Tools' data are reported and kept working by that redirect. Used-on list per file, Tidy up (unused, duplicates, big pictures, no alt text), alt text, caption, credit and tags with each file, Replace keeping the address, Shrink (optionally to WebP), upload rules (longest side, remove location data, store as WebP), Trash with restore, thumbnails, `[media-gallery folder="…" /]`. 0.2.0: pages offer phones smaller copies (`srcset`), a focal point per picture is kept in crops, and Claude writes alt text for a person to check, included in the plan (the Manager holds the key: site-manager `mediaAltRoutes.js`, `tools/media-alt`; 5,000 per site per month). Over the same files as the built-in Tool: a lapsed licence loses no file and breaks no address. Hooks in core: `BUILT_IN_TOOLS` takes `media`, `admin.mediaPicker` in a manifest, `openImageEditor(file, {api})`, `mediaUploader(zone, {url})`.
338
339
  - Where: **Content > Media**; `content/media/`; `config/server.json` `uploads.maxFileSize`
339
340
  - Since: 0.5.0
340
341
  - **Image editor** - edit JPEG, PNG, WebP, GIF or TIFF in place: crop (aspect lock), resize, rotate, flip, colour presets (grayscale, sepia, warm, cool, enhance, sharpen, soften, invert), adjustments, watermark (position, scale, opacity), border (solid, mirror, repeat) and output format (JPEG, PNG, WebP with quality). Save as a copy or overwrite.
@@ -2265,7 +2266,9 @@ An add-on for the SEO Tool built into Domma CMS. It brings Google Search Console
2265
2266
 
2266
2267
  **Where:** Tools > SEO (`#/seo/...`) - the Pro tabs appear in the built-in SEO screen, so they follow the core `seo` permission (level 0 and `admin` by default).
2267
2268
 
2268
- ### Booking (`booking`)
2269
+ ### Booking (included in Calendar)
2270
+
2271
+ Since Calendar 2.0, this is a bundled component rather than a standalone Tool. The legacy data and API names below remain compatible.
2269
2272
 
2270
2273
  Tier: free · Version: 1.6.0 · Requires: nothing · Uses: `contacts`, `calendar` · Core 0.103 for Book… on an email; the call chat needs a core with `_lib/call/chatStore.js` (unreleased)
2271
2274
 
@@ -2289,7 +2292,9 @@ Appointments and resources booked from the site. People (appointments) and resou
2289
2292
 
2290
2293
  1.6.0: Add people in an online booking's call - the person booked (host) searches their contacts and the team, or types a name and email; each gets their own link `?b=&g=<pass>` (signed with the session's `callExtraKey`, never the customer's token or the host key), names themselves and knocks; team members also get a notification and a Messages message. When the person booked has no account on the site (the host link may be anyone's), the call offers Copy link only - no directory, no contacts, nothing sent. Needs a core with `_lib/call/invite.js` (unreleased); an older core shows no button. 1.5.0 keeps an online booking's call chat per session (`data/call-chat.json`, `_lib/call/chatStore.js`; a class's shared call has one chat), so the call reopened shows it; the booking panel offers "Call chat (N messages)", read-only, to staff with booking read (`GET /bookings/:id/call-chat`; the host's lines on the right). 1.3.0 serves online bookings' calls (`<bookingPath>/call/<session>`, a class shares one call; emails, .ics and pages carry Join the call / Start the call) - see Booking Pro. 1.1.0 adds the extension registry Booking Pro uses (`lib/extensions.js`, `version: 2`): `rules` (places, companions, daily limit, waiting list), `form` / `answers` (extra questions), `check` (refuse a public booking), admin sections in Booking's own slideovers, extra tabs, and `registry.services` (book, cancel, mail, time helpers). Bookings carry `holds` (every bookable they block) and `alsoNames`. Without an extension every service is plain.
2291
2294
 
2292
- ### Booking Pro (`booking-pro`)
2295
+ ### Advanced booking (included in Calendar)
2296
+
2297
+ Since Calendar 2.0, these features are included in Calendar. There is no separate Booking Pro product or licence. The following describes its retained data and API contracts.
2293
2298
 
2294
2299
  Tier: paid (closed source) · Version: 0.4.0 · Requires: `booking` 1.1+ (1.3+ for online, 1.4+ for Call now) · An add-on that registers into Booking's registry (the Cart / Cart Pro pattern), not a `supersedes`
2295
2300
 
@@ -574,7 +574,7 @@ Tools claim their letters first (`CORE_HOTKEYS` in `admin/js/lib/hotkeys.js`: D
574
574
  M Media, L Collections, F Forms, V Views, U Users, A Analytics, N Notes, T Todo, C Contacts, `,` Site
575
575
  Settings); after that the first Tool in the sidebar to ask for a letter has it, and a later one goes
576
576
  without - the browser console names it. A Pro Tool that supersedes another takes over its entry, so it
577
- asks for the same letter (Blog Pro, like Blog, is B). Ours: E Email, R Mail Reader, B Blog, K Booking,
577
+ asks for the same letter (Blog Pro, like Blog, is B). Ours: E Email, R Mail Reader, B Blog,
578
578
  Y Calendar, C Contacts Pro, O Docs, I Invoices, H Shop, Q Surveys, W Waypoint, J Job Board, S Support.
579
579
 
580
580
 
@@ -703,7 +703,7 @@ shape, so every widget looks like part of the same admin.
703
703
 
704
704
  **You may already have one.** Every sidebar entry with a `countUrl` is offered as a `count` widget
705
705
  automatically - the badge's own answer (`{count, label, tone, details}`) is drawn as a big number with
706
- its `details` rows and items underneath. Email, Booking, Support and the rest arrive this way.
706
+ its `details` rows and items underneath. Email, Calendar, Support and the rest arrive this way.
707
707
 
708
708
  For anything more, list widgets in `plugin.json`:
709
709
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.35.0",
3
+ "version": "1.37.0",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -541,6 +541,8 @@ test('2.7: the sidebar badge counts your own documents as an inventory - shared
541
541
  assert.equal(before.tone, 'info');
542
542
  assert.ok(before.label, 'never an empty label');
543
543
  const a = await make(owner, {title: 'Badge one'});
544
+ // Newest first is by updatedAt: two saves in the same millisecond have no order (CI, about 1 run in 25).
545
+ await new Promise(r => setTimeout(r, 5));
544
546
  const b = await make(owner, {title: 'Badge two'});
545
547
  let r = await call(owner, 'GET', '/count');
546
548
  assert.equal(r.body.count, before.count + 2, 'a create clears the cached answer');
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "note": "Written by `make sync-free-tier` in dcms-marketplace. Do not edit these plugins here - edit them there and sync.",
3
- "source": "dcms-marketplace@ffeb277",
3
+ "source": "dcms-marketplace@03107ce",
4
4
  "plugins": {
5
5
  "blog": {
6
6
  "version": "1.10.1",
@@ -78,54 +78,6 @@
78
78
  "tests/public.test.js": "cd4cc53da9709d400d082ef6df01b3f49e6fc419e4b020b588464306a5d907e9"
79
79
  }
80
80
  },
81
- "booking": {
82
- "version": "1.7.2",
83
- "files": {
84
- "CLAUDE.md": "13885f82d5d1dfd5e356ac899d703ec0b0aa0c1956ff5b3d45ba7f47ab96daa1",
85
- "admin/css/index.css": "4f7731921c0c5038cb1566a6ab2d43ffc35bf9b161e58f87a0cff423e81b47fa",
86
- "admin/lib/details.js": "8b37536bfa9ccfcc5265cc957ba8266d3f5f777133e7c0946ae49540f1c80e3c",
87
- "admin/lib/diary-layout.js": "d0e36674ff454e5217b02c3ef3b820e4dece97a62df618a6052016dfeefab1c9",
88
- "admin/lib/drafts.js": "90d6c8403ef7c6a01569ad925939ce7634ab0853f7e3097d522c1e850636d6b1",
89
- "admin/lib/email.js": "46e3e24b6be5a4667054a31dc0e73641f763d189129c93457900273ee4c8d5a8",
90
- "admin/lib/extension-sections.js": "0588ad47660e511b0dd8077bb9c3999c775d97597333a75e87ee12d915bbf00b",
91
- "admin/lib/kit.js": "403e792195e95770f6304bafab14ff13295c2bcc68cccda27e019a6739d0e888",
92
- "admin/templates/booking.html": "20b9a3bfe3e5d5bbee613f29be99551b12790fb38f80d119585360cc38e9ec57",
93
- "admin/views/booking.js": "939bf77016880ee091a9ee6cd6633cac0014801426b4c5bff9863d63aecd87a6",
94
- "admin/views/bookings.js": "bbe1068448e78134a5102ad9d7af16892f75a4449f150e92e649e66e7232e56b",
95
- "admin/views/diary.js": "bea962e57fc3be6ed07f5c6588889fffb106bc251193c0c48743f1f2442a6eef",
96
- "admin/views/panels.js": "cf6abeb6fc5f37aa3a30eec98d3b90ece5adab9436a8479899216043b28be07c",
97
- "admin/views/people.js": "55cc6d07b98ed305d577772b921eb8d09b564b099cb8d35441c1b39631e4764a",
98
- "admin/views/services.js": "32a2539391d06ec576c0af6d7aef1bbf71e22d6335c3654acb80491e56f19f41",
99
- "admin/views/settings.js": "dc502a934656fe77fb21c157ed7913df4d5b1acccf300c3bf1bb1edf11479cec",
100
- "collections/booking-bookables.json": "9f1f305eceac3d880413d5477a631e48c1fed7ff389c434f34651f4082ca1a1c",
101
- "collections/booking-bookings.json": "fa0b15cc81b4a2114734a0bc8adc4b4d25049d16cf62549b83634cdbeb543b52",
102
- "collections/booking-services.json": "cecb500a9215a0eba894e6b4c9ae78f5fbeb209830d07d47050c56c75143f66a",
103
- "config.js": "5565fd627481cf809322257cc300a7cbb7ccbf6cae076b4cf8a7453fcf554bd3",
104
- "docs/guide.md": "0d90ae6d3bac0ffce8ca51c0c1ef888b97797dd7423a1033f0b6b8cd6191efaa",
105
- "inject/body.html": "ab55ce945eec2302eb0c836a4626cffa5e091d050c6a59c6f2af332b05570777",
106
- "lib/call.js": "87c11b8531e1a6d247d52d4e03ea8e5aa06a1af49cbd7cbd0af97e2586237f7b",
107
- "lib/extensions.js": "8cec28ff8685daad8083b23f034f1c3bf82fd2322943dd19d46570ccdc311105",
108
- "lib/mail.js": "cad8f409df62d6e42f0f4024ec364bbe018a62b842fa3f7c38786fd4e7f92408",
109
- "lib/store.js": "7aa7967e4694e5a3b85378f60302e5a47394b1d90c7dd86e09578156f1c13e03",
110
- "plugin.js": "4a303855a5a7f746e07e45a937dfeac8984dc9254c2f9b1a60b6f6306912ed84",
111
- "plugin.json": "856f1c48e8e3ecf49fbc78bfb2bf9b52ff90e4cf3dcf8a73733115d8683e706b",
112
- "plugin.public.js": "101f7c1334666a00db43ac6436f94ab3983f48c2c7aecdbd7c6753df64b58091",
113
- "public/booking.css": "8b88989fdd04e50efc1688a2f32fe2e422299d7d13b81bb8fce0cc162fa99df6",
114
- "public/booking.js": "7dfc3d205696967013886567f67a867443c2e370bac29019d69911d695fdbade",
115
- "public/lib/clean.js": "d591be9ea8462705b7bc8806670027fdd4d6d4764777da08e91a010d27ec1651",
116
- "public/lib/page-format.js": "a38454283c2b7256b38ea48578f6df2695a623e0fe2c5d80aae9952e7034a93d",
117
- "public/lib/slots.js": "6472e530f3f521e7a08625ed2ee86802a9065cbf2f97c2c7601229f5f032dc07",
118
- "public/lib/time.js": "48e13a23e3d7a4916e2097e8f87c03a87d37b71c4ef037a5a16143c6a4185c41",
119
- "templates/booking.html": "a4995de46dfdab7e692b56f21347f29c76320cf3b0477889dc3c5d14e0b6dcd7",
120
- "tests/admin-diary.test.js": "6bd117af798e748234c94e4e66339ff1ec3bba9633790a2a5fd291f64c30e484",
121
- "tests/admin-drafts.test.js": "c9e857b2326965b3dbb34e344282d874348f84b5cd9338ced2ca2c7a07713a25",
122
- "tests/api.test.js": "efb3767f7efde08c11c8edcb5753889773b421188798f725aff0e4e533860aff",
123
- "tests/email.test.js": "2190b6dd7cc9afad99d2170f002343fe3dad306aa14ac718428e5df0be54ded1",
124
- "tests/public.test.js": "0b7b626d60df5a3d73d7c0077b73f59b62a9fded98ce84a8d93cd32cd0333159",
125
- "tests/pure.test.js": "8ba0c8f76b4c9efcc422f39ff29509612544d81f760025a4b9a5594af14e7bcf",
126
- "tests/seo.test.js": "8d935319eb21fbb81feb663220384b3a4d52d0fe8597047994652daa8c981489"
127
- }
128
- },
129
81
  "docs": {
130
82
  "version": "2.14.1",
131
83
  "files": {
@@ -165,7 +117,7 @@
165
117
  "tests/convert.test.js": "27dc072e3a5f6fd482560e547048723bc7884aa8f53a3bc2f547758a28c535a4",
166
118
  "tests/drafts.test.js": "209c1691aa321e07c0ab24f747920b15d7bd56c2b3f5a581b116aad73c157d8f",
167
119
  "tests/pdf.test.js": "316c7b32fb4562f42fd59da1df9c8a3bccacb8286db6540b36e10f85c510d68e",
168
- "tests/plugin.test.js": "a76c3a5bab6e525bc201f73f4ed76b604b41331cbeba0c6155253b88b40b5bb0",
120
+ "tests/plugin.test.js": "766ce9418c2285128f74264c62eda013bafda386dba832e261254de26a4d753c",
169
121
  "tests/shortcuts.test.js": "7f96b63e91150e7670eb349a81034ce354f64ea42503d6a8ffcdae4867d7bba1"
170
122
  }
171
123
  },
@@ -3,11 +3,12 @@
3
3
  * GET /api/media - list media files
4
4
  * GET /api/media/_count - the sidebar badge (plain text; see mediaBadge)
5
5
  * GET /api/media/_limits - what an upload may be (types, size, name length)
6
+ * GET /api/media/_folders - how many folders and files in them (this list shows neither)
6
7
  * POST /api/media - upload a file
7
8
  * DELETE /api/media/:name - delete a file
8
9
  */
9
10
  import path from 'path';
10
- import {deleteMedia, listMedia, renameMedia, saveMedia} from '../../services/content.js';
11
+ import {deleteMedia, listMedia, mediaFolderSummary, renameMedia, saveMedia} from '../../services/content.js';
11
12
  import {getImageInfo, isEditableImage, transformImage} from '../../services/images.js';
12
13
  import {authenticate, requirePermission} from '../../middleware/auth.js';
13
14
  import {ago, clip, plural} from '../../services/sidebarBadges.js';
@@ -106,6 +107,7 @@ export async function mediaRoutes(fastify, opts = {}) {
106
107
  // `_count` is not a file route: the only GET under /media/:name is /media/:name/info.
107
108
  fastify.get('/media/_count', canRead, async () => mediaBadge(await listMedia()));
108
109
  fastify.get('/media/_limits', canCreate, async () => uploadLimits(opts.maxFileSize));
110
+ fastify.get('/media/_folders', canRead, async () => mediaFolderSummary());
109
111
 
110
112
  fastify.post('/media', canCreate, async (request, reply) => {
111
113
  const results = [];
@@ -18,7 +18,7 @@
18
18
  */
19
19
  import {authenticate as defaultAuthenticate, checkVisibility} from '../../middleware/auth.js';
20
20
  import {isDcmStaff} from '../../services/staffAccess.js';
21
- import {getRegisteredSidebarItems} from '../../services/hooks.js';
21
+ import {getRegisteredSidebarItems, withoutHiddenSidebarUrls} from '../../services/hooks.js';
22
22
  import {filterItemsForUser, getMenu} from '../../services/menus.js';
23
23
  import {isDashboardPro} from '../../services/widgets.js';
24
24
  import {boardName, readPrefs, readSite} from '../../services/dashboardSettings.js';
@@ -51,7 +51,7 @@ export async function sidebarRoutes(fastify, opts = {}) {
51
51
  // renderer needs them to place Tools before it drops them. An item
52
52
  // this user may not see (`visibility`) arrives as a label-less hidden
53
53
  // stub for the same reason - see restrictedStub() in menus.js.
54
- const items = filterItemsForUser(menu.items || [], request.user, {keepHidden: true});
54
+ const items = withoutHiddenSidebarUrls(filterItemsForUser(menu.items || [], request.user, {keepHidden: true}));
55
55
  const label = await dashboardsLabel(request);
56
56
  return {...menu, items: label ? relabel(items, label) : items};
57
57
  });
@@ -387,7 +387,9 @@ export async function deletePage(urlPath) {
387
387
  // ---------------------------------------------------------------------------
388
388
 
389
389
  /**
390
- * List all files in the media directory.
390
+ * List the files at the top of the media directory. A folder is not a file, so
391
+ * it is not listed; what is inside one is still served at its own address
392
+ * (mediaFolderSummary counts it).
391
393
  *
392
394
  * @returns {Promise<object[]>}
393
395
  */
@@ -398,6 +400,7 @@ export async function listMedia() {
398
400
  files.map(async (file) => {
399
401
  const filePath = path.join(MEDIA_DIR, file);
400
402
  const stat = await fs.stat(filePath);
403
+ if (!stat.isFile()) return null;
401
404
  return {
402
405
  name: file,
403
406
  url: `/media/${file}`,
@@ -406,7 +409,28 @@ export async function listMedia() {
406
409
  };
407
410
  })
408
411
  );
409
- return stats.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
412
+ return stats.filter(Boolean).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
413
+ }
414
+
415
+ /**
416
+ * What the media directory holds inside folders, which the flat list above leaves
417
+ * out: how many folders, how many files in them.
418
+ *
419
+ * @returns {Promise<{folders: number, files: number}>}
420
+ */
421
+ export async function mediaFolderSummary() {
422
+ const out = {folders: 0, files: 0};
423
+ async function walk(dir, top) {
424
+ let entries;
425
+ try { entries = await fs.readdir(dir, {withFileTypes: true}); } catch { return; }
426
+ for (const e of entries) {
427
+ if (e.name.startsWith('.') || e.isSymbolicLink()) continue;
428
+ if (e.isDirectory()) { out.folders++; await walk(path.join(dir, e.name), false); }
429
+ else if (!top && e.isFile()) out.files++;
430
+ }
431
+ }
432
+ await walk(MEDIA_DIR, true);
433
+ return out;
410
434
  }
411
435
 
412
436
  /**
@@ -150,17 +150,40 @@ export function registerSidebarItem(opts) {
150
150
  /** Where a Tool's sidebar entry goes when it names no folder. */
151
151
  export const DEFAULT_TOOL_FOLDER = 'tools';
152
152
 
153
- /** Sidebar URLs taken off the sidebar - a built-in Tool a plugin has taken over. */
154
- const _hiddenSidebarUrls = new Set();
153
+ /** Sidebar URLs taken off the sidebar - a built-in Tool a plugin has taken over - and the entry that replaces each, if any. */
154
+ const _hiddenSidebarUrls = new Map();
155
155
 
156
156
  /**
157
157
  * Leave the item with this URL out of the sidebar. For a core Tool whose entry
158
158
  * is registered before the plugins load, so it cannot simply not be registered.
159
159
  *
160
160
  * @param {string} url - e.g. '#/contacts'
161
+ * @param {string|null} [replacedBy] - the plugin entry that takes its place in a saved menu
161
162
  */
162
- export function hideSidebarUrl(url) {
163
- _hiddenSidebarUrls.add(url);
163
+ export function hideSidebarUrl(url, replacedBy = null) {
164
+ _hiddenSidebarUrls.set(url, replacedBy);
165
+ }
166
+
167
+ /**
168
+ * The same for a saved menu (config/menus/admin-sidebar.json, where Media, say, was written long
169
+ * ago): a replaced entry keeps its place and label and points at what replaced it, so the plugin's
170
+ * Tool lands where the admin put the old one; an entry with no replacement goes. The menu on disk
171
+ * is not touched, so a lapsed licence brings the old entry straight back. Pure over its input.
172
+ *
173
+ * @param {object[]} items
174
+ * @returns {object[]}
175
+ */
176
+ export function withoutHiddenSidebarUrls(items) {
177
+ if (!_hiddenSidebarUrls.size) return items;
178
+ const walk = (list) => (list || []).flatMap((it) => {
179
+ if (!it || typeof it !== 'object') return [it];
180
+ if (_hiddenSidebarUrls.has(it.url)) {
181
+ const to = _hiddenSidebarUrls.get(it.url);
182
+ return to ? [{...it, url: to}] : [];
183
+ }
184
+ return [Array.isArray(it.items) ? {...it, items: walk(it.items)} : it];
185
+ });
186
+ return walk(items);
164
187
  }
165
188
 
166
189
  /**
@@ -192,7 +192,7 @@ export function isCorePlugin(name) { return CORE_PLUGINS.has(name); }
192
192
  * same data - and, like supersession, nothing is written down: a lapsed
193
193
  * licence means the plugin does not load and the core Tool is simply back.
194
194
  */
195
- export const BUILT_IN_TOOLS = new Set(['notes', 'todo', 'analytics', 'contacts', 'seo']);
195
+ export const BUILT_IN_TOOLS = new Set(['notes', 'todo', 'analytics', 'contacts', 'seo', 'media']);
196
196
 
197
197
  /** Built-in Tool → {plugin, route}, for the plugins that loaded this boot. */
198
198
  const _toolTakeovers = {};
@@ -583,7 +583,7 @@ export async function registerPlugins(fastify) {
583
583
  // (the admin sends its screen to the plugin - getAdminPluginConfig).
584
584
  for (const [tool, claim] of Object.entries(toolTakeoversOf(manifest, _toolTakeovers))) {
585
585
  _toolTakeovers[tool] = claim;
586
- hideSidebarUrl(`#/${tool}`);
586
+ hideSidebarUrl(`#/${tool}`, claim.route ? `#${claim.route}` : null);
587
587
  fastify.log.info(`[plugins] built-in Tool "${tool}" taken over by "${manifest.name}".`);
588
588
  }
589
589
 
@@ -1368,6 +1368,9 @@ export async function getAdminPluginConfig(viewer = null) {
1368
1368
  const routes = [];
1369
1369
  const views = {};
1370
1370
  const css = [];
1371
+ // A Tool that brings its own media picker (Media Pro's, with folders): every
1372
+ // pickMedia() in the admin opens it. The first one loaded wins.
1373
+ let mediaPicker = null;
1371
1374
  // Per-view plugin identity, so the admin can put the same banner above
1372
1375
  // every plugin screen without each plugin having to render one (and each
1373
1376
  // rendering it differently, which is what it did before).
@@ -1381,6 +1384,9 @@ export async function getAdminPluginConfig(viewer = null) {
1381
1384
 
1382
1385
  if (manifest.admin.sidebar) sidebar.push(...manifest.admin.sidebar);
1383
1386
  if (manifest.admin.routes) routes.push(...manifest.admin.routes);
1387
+ if (!mediaPicker && typeof manifest.admin.mediaPicker === 'string' && manifest.admin.mediaPicker.startsWith(`${manifest.name}/admin/`)) {
1388
+ mediaPicker = manifest.admin.mediaPicker;
1389
+ }
1384
1390
 
1385
1391
  // Auto-stamp view entries with an mtime-based version.
1386
1392
  //
@@ -1446,5 +1452,5 @@ export async function getAdminPluginConfig(viewer = null) {
1446
1452
  const staff = isDcmStaff(viewer);
1447
1453
  const tools = Object.fromEntries(CORE_TOOLS.map(t => [t.name, {displayName: t.displayName, enabled: toolOpenAt(toolStates[t.name], staff)}]));
1448
1454
 
1449
- return { sidebar, routes, views, css, meta, takeovers: getToolTakeovers(), tools };
1455
+ return { sidebar, routes, views, css, meta, takeovers: getToolTakeovers(), tools, mediaPicker };
1450
1456
  }
@@ -1462,7 +1462,9 @@ export async function renderBlogPage(templatePath, data = {}, seoMeta = {}) {
1462
1462
  dconfigScript: ''
1463
1463
  };
1464
1464
 
1465
- return interpolate(template, vars);
1465
+ // The same last step as a page: a Tool's render:afterRender sees a blog post or a Tool's page too. Not a
1466
+ // bare page: its address is a credential, so nothing of a Tool's goes on it.
1467
+ return bare ? interpolate(template, vars) : applyTransforms('render:afterRender', interpolate(template, vars), {page: null});
1466
1468
  }
1467
1469
 
1468
1470
  /**
@@ -49,7 +49,7 @@ const SITE_ROOTS = ['content', 'config', 'plugins'];
49
49
  */
50
50
  export const RETIRED_PLUGINS = [
51
51
  'analytics', 'contacts', 'notes', 'todo', 'demo-viewer', 'theme-switcher', 'site-search',
52
- 'seo', 'seo-pro', 'shopping-cart', 'form-builder', 'calculator'
52
+ 'seo', 'seo-pro', 'shopping-cart', 'form-builder', 'calculator', 'booking', 'booking-pro'
53
53
  ];
54
54
 
55
55
  /**