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.
Files changed (85) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/CLAUDE.md +2 -0
  3. package/admin/js/lib/layouts-arrange.js +1 -1
  4. package/admin/js/lib/rich-field.js +9 -2
  5. package/admin/js/lib/seo-defaults.js +1 -1
  6. package/admin/js/templates/docs/api-content.html +3 -2
  7. package/admin/js/templates/docs/api-layouts.html +1 -1
  8. package/admin/js/templates/docs/usage-navigation.html +2 -1
  9. package/admin/js/templates/docs/usage-pages.html +3 -1
  10. package/admin/js/templates/docs/usage-search-engines.html +3 -0
  11. package/admin/js/templates/page-editor.html +3 -3
  12. package/admin/js/views/form-editor.js +5 -5
  13. package/admin/js/views/layouts.js +7 -7
  14. package/admin/js/views/menu-editor.js +20 -20
  15. package/admin/js/views/page-editor.js +9 -9
  16. package/admin/js/views/seo.js +31 -30
  17. package/docs/DommaFeatures.md +6 -2
  18. package/docs/api-reference.md +7 -3
  19. package/docs/guides/multi-page-forms.md +1 -1
  20. package/docs/markdown-shortcodes.md +1 -1
  21. package/docs/plugin-development.md +20 -0
  22. package/package.json +1 -1
  23. package/plugins/blog/CHANGELOG.md +3 -0
  24. package/plugins/blog/CLAUDE.md +15 -0
  25. package/plugins/blog/admin/views/categories.js +5 -2
  26. package/plugins/blog/admin/views/kit.js +19 -0
  27. package/plugins/blog/docs/guide.md +2 -0
  28. package/plugins/blog/plugin.js +18 -2
  29. package/plugins/blog/plugin.json +6 -6
  30. package/plugins/blog/plugin.public.js +16 -2
  31. package/plugins/blog/public/blog.css +3 -0
  32. package/plugins/blog/tests/public.test.js +29 -2
  33. package/plugins/feedback/CLAUDE.md +22 -0
  34. package/plugins/feedback/admin/css/index.css +2 -0
  35. package/plugins/feedback/admin/views/inbox.js +5 -2
  36. package/plugins/feedback/admin/views/send.js +12 -5
  37. package/plugins/feedback/docs/guide.md +3 -2
  38. package/plugins/feedback/lib/sender.js +1 -1
  39. package/plugins/feedback/lib/shape.js +72 -11
  40. package/plugins/feedback/plugin.js +3 -3
  41. package/plugins/feedback/plugin.json +3 -2
  42. package/plugins/feedback/tests/api.test.js +47 -1
  43. package/plugins/feedback/tests/shape.test.js +87 -1
  44. package/plugins/free-tier.lock.json +43 -42
  45. package/plugins/shopping-cart/CHANGELOG.md +20 -0
  46. package/plugins/shopping-cart/CLAUDE.md +38 -1
  47. package/plugins/shopping-cart/admin/css/index.css +4 -0
  48. package/plugins/shopping-cart/admin/lib/kit.js +1 -0
  49. package/plugins/shopping-cart/admin/views/products.js +95 -3
  50. package/plugins/shopping-cart/admin/views/shop.js +2 -1
  51. package/plugins/shopping-cart/docs/guide.md +6 -1
  52. package/plugins/shopping-cart/inject/body.html +2 -2
  53. package/plugins/shopping-cart/lib/description.js +173 -0
  54. package/plugins/shopping-cart/lib/render.js +3 -2
  55. package/plugins/shopping-cart/lib/shop.js +4 -1
  56. package/plugins/shopping-cart/plugin.js +17 -2
  57. package/plugins/shopping-cart/plugin.json +3 -2
  58. package/plugins/shopping-cart/plugin.public.js +6 -9
  59. package/plugins/shopping-cart/public/lib/products.js +40 -3
  60. package/plugins/shopping-cart/public/shop.css +1 -0
  61. package/plugins/shopping-cart/tests/pure.test.js +26 -1
  62. package/plugins/shopping-cart/tests/seo.test.js +174 -0
  63. package/public/js/collection-browser.js +1 -1
  64. package/public/js/menu-cards.mjs +4 -4
  65. package/public/js/menu-look.mjs +1 -1
  66. package/public/js/rich-text.mjs +4 -4
  67. package/public/js/site.js +1 -1
  68. package/server/routes/api/collections.js +26 -12
  69. package/server/routes/api/forms.js +5 -3
  70. package/server/routes/api/layouts.js +8 -4
  71. package/server/routes/api/seo.js +10 -4
  72. package/server/services/adapters/FileAdapter.js +4 -3
  73. package/server/services/adapters/MongoAdapter.js +4 -2
  74. package/server/services/content.js +23 -0
  75. package/server/services/contentApi.js +27 -4
  76. package/server/services/filterEngine.js +33 -0
  77. package/server/services/forms.js +58 -2
  78. package/server/services/health.js +3 -1
  79. package/server/services/markdown.js +288 -38
  80. package/server/services/menus.js +56 -6
  81. package/server/services/renderer.js +28 -4
  82. package/server/services/richText.js +56 -3
  83. package/server/services/search.js +5 -2
  84. package/server/services/sitemap.js +5 -3
  85. package/server/templates/page.html +2 -2
@@ -11,6 +11,7 @@ import {getInjectionSnippets} from './plugins.js';
11
11
  import {applyTransforms} from './hooks.js';
12
12
  import {contentsPaint, readContentsOverride, resolveContents} from './pageContents.js';
13
13
  import {applyMenuOverride, hasThemeSwitcherItem, resolveLocation, resolveMenuDecorations, resolveOverlaysForPage} from './menus.js';
14
+ import {isRichText, richTextLine} from './richText.js';
14
15
  import {buildMenuNav} from './menuRender.js';
15
16
  import {buildFooterFallback, buildNavFallback} from './nojsLinks.js';
16
17
  import {getProjectForPage} from './projects.js';
@@ -818,7 +819,7 @@ function buildSeoMeta({page, site, baseUrl, title, description, image}) {
818
819
  '@context': 'https://schema.org',
819
820
  '@type': 'WebPage',
820
821
  name: page.title || '',
821
- description: page.seo?.description || site.seo?.defaultDescription || ''
822
+ description: richTextLine(page.seo?.description || site.seo?.defaultDescription || '')
822
823
  };
823
824
  if (canonical) webPage.url = canonical;
824
825
  if (absImage) webPage.image = absImage;
@@ -848,7 +849,8 @@ function buildSeoMeta({page, site, baseUrl, title, description, image}) {
848
849
 
849
850
  return {
850
851
  title,
851
- description,
852
+ // An SEO description may be rich text (the editor's); a tag holds its words.
853
+ description: richTextLine(description),
852
854
  image: absImage,
853
855
  ogType: page.seo?.ogType || 'article',
854
856
  noindex: page.seo?.noindex === true,
@@ -902,13 +904,35 @@ function absoluteUrl(url, origin) {
902
904
  function transformSeoMeta(meta, context) {
903
905
  try {
904
906
  const out = applyTransforms('seo:meta', meta, context);
905
- return out && typeof out === 'object' ? out : meta;
907
+ return plainSeoDescriptions(out && typeof out === 'object' ? out : meta);
906
908
  } catch (err) {
907
909
  console.warn(`[seo] a seo:meta transform failed, using the page's own: ${err.message}`);
908
- return meta;
910
+ return plainSeoDescriptions(meta);
909
911
  }
910
912
  }
911
913
 
914
+ /**
915
+ * Every description in the SEO model as one line of plain text. The SEO
916
+ * description fields are rich text editors, and a transform (the SEO Tool's
917
+ * per-address override, a plugin's own) may hand a rich value back: a meta
918
+ * tag, a share card and JSON-LD carry the words, never the markup. A value
919
+ * that is not rich is left exactly as it is. Pure.
920
+ *
921
+ * @param {object} meta - buildSeoMeta()'s model
922
+ * @returns {object}
923
+ */
924
+ export function plainSeoDescriptions(meta) {
925
+ const line = (v) => (isRichText(v) ? richTextLine(v) : v);
926
+ const part = (o) => (o && typeof o === 'object' && isRichText(o.description) ? {...o, description: line(o.description)} : o);
927
+ return {
928
+ ...meta,
929
+ description: line(meta.description),
930
+ og: part(meta.og),
931
+ twitter: part(meta.twitter),
932
+ ...(Array.isArray(meta.jsonLd) && {jsonLd: meta.jsonLd.map(part)})
933
+ };
934
+ }
935
+
912
936
  const SAFE_ATTR = /^[a-z][a-z0-9:_-]*$/i;
913
937
 
914
938
  /**
@@ -10,8 +10,12 @@
10
10
  * HTML email. A rich value is cleaned again (what is stored may predate a
11
11
  * rule, or have been written around the API); a plain one is escaped into
12
12
  * paragraphs. Its result is always safe to put in a page.
13
- * - `richTextToPlain` / `richTextSummary` (re-exported) for everything that is
14
- * not HTML: meta descriptions, plain emails, CSV, ICS, search, JSON-LD.
13
+ * - `renderRichTextPhrasing(value)` where a description is drawn INSIDE a
14
+ * line of text (a `<p>`, a link, a button): the same words with only inline
15
+ * formatting, so it cannot break the element it sits in.
16
+ * - `richTextToPlain` / `richTextSummary` / `richTextLine` (re-exported) for
17
+ * everything that is not HTML: meta descriptions, plain emails, CSV, ICS,
18
+ * search, JSON-LD.
15
19
  *
16
20
  * Deliberately far stricter than `sanitizePageHtml`: a description is a few
17
21
  * formatted paragraphs, not a page. No images, classes, styles or embeds.
@@ -19,7 +23,7 @@
19
23
  * @module server/services/richText
20
24
  */
21
25
  import sanitizeHtml from 'sanitize-html';
22
- import {isRichText, plainToRichHtml, richTextToPlain, richTextSummary, escapeHtml} from '../../public/js/rich-text.mjs';
26
+ import {isRichText, plainToRichHtml, richTextToPlain, richTextSummary, richTextLine as plainLine, escapeHtml} from '../../public/js/rich-text.mjs';
23
27
 
24
28
  export {isRichText, plainToRichHtml, richTextToPlain, richTextSummary};
25
29
 
@@ -96,3 +100,52 @@ export function renderRichText(value) {
96
100
  export function renderRichTextInline(value, max = 160) {
97
101
  return escapeHtml(richTextSummary(value, max));
98
102
  }
103
+
104
+ /**
105
+ * A description as one line of plain text, not cut: for a meta description, a
106
+ * JSON-LD value, an llms.txt line, a search result. A rich value is cleaned
107
+ * first - what is stored may have been written by hand, and the text inside a
108
+ * `<script>` is not one of its words. A plain value is returned as stored
109
+ * (trimmed).
110
+ *
111
+ * @param {*} value - as stored
112
+ * @returns {string}
113
+ */
114
+ export function richTextLine(value) {
115
+ return plainLine(isRichText(value) ? clean(value) : value);
116
+ }
117
+
118
+ /** What may sit inside a line of text: no blocks, no lists. */
119
+ const PHRASING_TAGS = ['strong', 'b', 'em', 'i', 'u', 's', 'code', 'br'];
120
+
121
+ /**
122
+ * A description as HTML that is safe to put INSIDE a line of text - a `<p>`,
123
+ * a link, a button, a caption - where a paragraph or a list would break the
124
+ * element around it. Paragraphs and list items become line breaks (a list
125
+ * item starts "- "), headings and quotes lose their element and keep their
126
+ * words, and only inline formatting is left.
127
+ *
128
+ * A rich value is cleaned first. A plain value is escaped, unless `legacyHtml`
129
+ * is set: for a field whose plain text was drawn as HTML before it was rich,
130
+ * so inline markup somebody typed by hand keeps working and anything else in
131
+ * it (scripts, images, event handlers) is dropped.
132
+ *
133
+ * @param {*} value - as stored
134
+ * @param {{links?: boolean, legacyHtml?: boolean}} [options] - `links: false`
135
+ * where the text sits inside a link already
136
+ * @returns {string} '' for nothing
137
+ */
138
+ export function renderRichTextPhrasing(value, {links = true, legacyHtml = false} = {}) {
139
+ if (typeof value !== 'string' || !value.trim()) return '';
140
+ const rich = isRichText(value);
141
+ if (!rich && !legacyHtml) return escapeHtml(value.trim()).replace(/\r\n?|\n/g, '<br>');
142
+ const flat = (rich ? clean(value) : value.trim())
143
+ .replace(/<li(\s[^<>]*)?>/gi, '- ')
144
+ .replace(/<\/(p|h[1-6]|blockquote|li|ul|ol|div)>/gi, '<br>');
145
+ const out = sanitizeHtml(flat, {
146
+ ...OPTIONS,
147
+ allowedTags: links ? [...PHRASING_TAGS, 'a'] : PHRASING_TAGS,
148
+ transformTags: {a: OPTIONS.transformTags.a}
149
+ });
150
+ return out.replace(/<br \/>/g, '<br>').replace(/(\s*<br>\s*){2,}/g, '<br>').replace(/^(\s|<br>)+|(\s|<br>)+$/g, '');
151
+ }
@@ -12,6 +12,7 @@
12
12
  import {getConfig, saveConfig} from '../config.js';
13
13
  import {checkVisibility} from '../middleware/auth.js';
14
14
  import {normalisePath} from '../../admin/js/lib/seo-redirects.js';
15
+ import {richTextLine} from './richText.js';
15
16
 
16
17
  /**
17
18
  * Settings, and the shape of them.
@@ -318,7 +319,8 @@ function buildSnippet(rawContent, term, length = 120) {
318
319
  export function scorePage(page, query, words) {
319
320
  let score = 0;
320
321
  const title = (page.title || '').toLowerCase();
321
- const description = (page.description || '').toLowerCase();
322
+ // The words alone: a rich description is not matched on its markup.
323
+ const description = richTextLine(page.description).toLowerCase();
322
324
  // Coerced, not trusted. A tag list is `Array.isArray` true and still full
323
325
  // of nulls - `tags:\n - null` is what a page ends up with when something
324
326
  // writes an empty tag - and `null.toLowerCase()` threw, which took the
@@ -519,7 +521,8 @@ export function searchPages(pages, query, {maxResults = 10, onError = () => {},
519
521
  results.push({
520
522
  title: page.title || 'Untitled',
521
523
  url: page.urlPath,
522
- description: page.description || '',
524
+ // Results are drawn as text (the site's search box, the Content API).
525
+ description: richTextLine(page.description),
523
526
  tags: Array.isArray(page.tags) ? page.tags : [],
524
527
  snippet: buildSnippet(page.content || '', query),
525
528
  score
@@ -11,6 +11,7 @@ import {listPages} from './content.js';
11
11
  import {offlinePageUrls} from './projects.js';
12
12
  import {getConfig} from '../config.js';
13
13
  import {applyTransforms, getSitemapSources} from './hooks.js';
14
+ import {richTextLine} from './richText.js';
14
15
 
15
16
  const CHANGEFREQ = new Set(['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never']);
16
17
  const validPriority = (p) => p !== undefined && p !== null && p !== '' && Number(p) >= 0 && Number(p) <= 1;
@@ -37,7 +38,8 @@ function shouldIncludeInSitemap(page) {
37
38
 
38
39
  /** The sitemap entry of a core page. `description` is for llms.txt; the XML ignores it. */
39
40
  function pageEntry(page) {
40
- const description = String(page.seo?.description || page.description || '').trim();
41
+ // Either may be rich text (the editors'): llms.txt is plain text.
42
+ const description = richTextLine(page.seo?.description || page.description || '');
41
43
  return {urlPath: page.urlPath, title: page.title || '', lastmod: page.updatedAt || null,
42
44
  ...(description && {description}), source: 'pages'};
43
45
  }
@@ -197,7 +199,7 @@ export async function buildLlmsTxt(baseUrl, opts = {}) {
197
199
  const labels = new Map(getSitemapSources().map(s => [s.id, s.label || s.id]));
198
200
 
199
201
  const title = oneLine(site.title || site.seo?.defaultTitle || 'Website');
200
- const description = oneLine(site.seo?.defaultDescription || site.description || '');
202
+ const description = oneLine(richTextLine(site.seo?.defaultDescription || site.description || ''));
201
203
  const out = [`# ${title}`, ''];
202
204
  if (description) out.push(`> ${description}`, '');
203
205
 
@@ -213,7 +215,7 @@ export async function buildLlmsTxt(baseUrl, opts = {}) {
213
215
  for (const e of list) {
214
216
  const url = `${normalised}${e.urlPath}`;
215
217
  const name = linkText(e.title || e.urlPath);
216
- const about = oneLine(e.description || '');
218
+ const about = oneLine(richTextLine(e.description || ''));
217
219
  out.push(`- [${name}](${linkUrl(url)})${about ? `: ${about}` : ''}`);
218
220
  }
219
221
  out.push('');
@@ -184,12 +184,12 @@
184
184
  searchable / filterable / sortable / paginate attributes) -->
185
185
  <!-- Its range-filter arithmetic; a module that runs first and sets window.DommaCollectionRange -->
186
186
  <script src="/public/js/collection-range.mjs?v=20261025-range-slider" type="module"></script>
187
- <script src="/public/js/collection-browser.js?v=20261108-hero-outline" defer></script>
187
+ <script src="/public/js/collection-browser.js?v=20261115-safe-links" defer></script>
188
188
  <!-- Core Forms logic engine (must run before forms.js and site.js) -->
189
189
  <script src="/public/js/form-logic-engine.js?v=20261031-forms-reduce-motion" defer></script>
190
190
 
191
191
  <!-- Site initialisation -->
192
- <script src="/public/js/site.js?v=20261112-card-body-align" type="module"></script>
192
+ <script src="/public/js/site.js?v=20261115-table-titles-2" type="module"></script>
193
193
  <script src="/public/js/collection-context.js?v=20261010-utf8-payloads" type="module"></script>
194
194
  {{ctxMenusModule}}
195
195
  <!-- [image zoom] pictures' full-size view - only on a page that has one -->