@mindful-web/marko-web-theme-monorail 1.100.0 → 1.105.1

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 (162) hide show
  1. package/README.md +6 -0
  2. package/components/ads/fixed-ad-bottom.marko.js +2 -2
  3. package/components/ads/reveal-ad-handler.marko.js +2 -2
  4. package/components/blocks/author-bios.marko.js +2 -2
  5. package/components/blocks/callout-cards.marko.js +2 -2
  6. package/components/blocks/company-inquiry-form.marko.js +2 -2
  7. package/components/blocks/company-search.marko.js +2 -2
  8. package/components/blocks/content-card-deck.marko.js +2 -2
  9. package/components/blocks/content-meter.marko.js +2 -2
  10. package/components/blocks/full-width-native-ad.marko.js +2 -2
  11. package/components/blocks/geo-summary.marko.js +2 -2
  12. package/components/blocks/header-announcement.marko.js +2 -2
  13. package/components/blocks/hero-card.marko.js +2 -2
  14. package/components/blocks/latest-content-list.marko.js +2 -2
  15. package/components/blocks/latest-podcast.marko.js +2 -2
  16. package/components/blocks/latest-products-feed.marko.js +2 -2
  17. package/components/blocks/more-products.marko.js +2 -2
  18. package/components/blocks/most-popular-list.marko.js +2 -2
  19. package/components/blocks/most-popular.marko.js +2 -2
  20. package/components/blocks/native-x-card-deck.marko.js +2 -2
  21. package/components/blocks/native-x-promo-card.marko.js +2 -2
  22. package/components/blocks/newsletter-signup-banner-external.marko.js +2 -2
  23. package/components/blocks/newsletter-signup-banner-large.marko.js +2 -2
  24. package/components/blocks/newsletter-signup-banner.marko.js +2 -2
  25. package/components/blocks/opinion.marko.js +2 -2
  26. package/components/blocks/primary-image.marko.js +2 -2
  27. package/components/blocks/products.marko.js +2 -2
  28. package/components/blocks/read-next.marko.js +2 -2
  29. package/components/blocks/related-stories.marko.js +2 -2
  30. package/components/blocks/resource-library.marko.js +2 -2
  31. package/components/blocks/section-body-feed.marko.js +2 -2
  32. package/components/blocks/section-card-deck-featured.marko.js +2 -2
  33. package/components/blocks/section-card-deck.marko.js +2 -2
  34. package/components/blocks/section-card-list.marko.js +2 -2
  35. package/components/blocks/section-feed.marko.js +2 -2
  36. package/components/blocks/section-forbes.marko.js +2 -2
  37. package/components/blocks/section-list-deck.marko.js +2 -2
  38. package/components/blocks/section-list.marko.js +2 -2
  39. package/components/blocks/section-search.marko.js +2 -2
  40. package/components/blocks/section-title-feed.marko.js +2 -2
  41. package/components/blocks/top-stories-menu.marko.js +2 -2
  42. package/components/blocks/top-stories.marko.js +2 -2
  43. package/components/blocks/white-papers.marko.js +2 -2
  44. package/components/breadcrumbs/content-page.marko.js +2 -2
  45. package/components/breadcrumbs/index.marko.js +2 -2
  46. package/components/breadcrumbs/website-section.marko.js +2 -2
  47. package/components/breadcrumbs/with-home.marko.js +2 -2
  48. package/components/client-side-block-loader.marko.js +2 -2
  49. package/components/client-side-blocks/most-popular-list.marko.js +2 -2
  50. package/components/client-side-blocks/most-popular.marko.js +2 -2
  51. package/components/content/body-with-injection.marko.js +2 -2
  52. package/components/content/contact-details/index.marko.js +2 -2
  53. package/components/content/contact-details/section.marko.js +2 -2
  54. package/components/content/download/form-dot-com.marko.js +2 -2
  55. package/components/content/download/identity-x.marko.js +2 -2
  56. package/components/content/download/index.marko.js +2 -2
  57. package/components/content/download/link.marko.js +2 -2
  58. package/components/content/download/wufoo.marko.js +2 -2
  59. package/components/content/link-url/index.marko.js +2 -2
  60. package/components/content/sections-listed-in.marko.js +2 -2
  61. package/components/content-attribution/attribution.marko.js +2 -2
  62. package/components/content-attribution/components/authors.marko.js +2 -2
  63. package/components/content-attribution/components/byline.marko.js +2 -2
  64. package/components/content-attribution/components/company.marko.js +2 -2
  65. package/components/content-attribution/components/contributors.marko.js +2 -2
  66. package/components/content-attribution/components/photographers.marko.js +2 -2
  67. package/components/content-attribution/components/source.marko.js +2 -2
  68. package/components/content-attribution/components/speakers.marko.js +2 -2
  69. package/components/content-attribution/components/sponsors.marko.js +2 -2
  70. package/components/content-attribution/index.marko.js +2 -2
  71. package/components/directory-facets/facet-container/facet-container.marko.js +2 -2
  72. package/components/directory-facets/facet-list/facet-list.marko.js +2 -2
  73. package/components/directory-facets/facet.marko.js +2 -2
  74. package/components/directory-facets/index.marko.js +2 -2
  75. package/components/facebook-connect.marko.js +2 -2
  76. package/components/flows/card-deck.marko.js +2 -2
  77. package/components/flows/content/card-deck-col.marko.js +2 -2
  78. package/components/flows/content/directory-section.marko.js +2 -2
  79. package/components/flows/content/list.marko.js +2 -2
  80. package/components/flows/section-feed.marko.js +2 -2
  81. package/components/gam/components/define-display-ad.marko.js +2 -2
  82. package/components/gam/define-display-ad.marko.js +2 -2
  83. package/components/gam/inject-ads.marko.js +2 -2
  84. package/components/gam/wallpaper-ad.marko.js +2 -2
  85. package/components/google-preferred-source/index.marko.js +2 -2
  86. package/components/google-preferred-source/init.marko.js +2 -2
  87. package/components/identity-x/comment-stream.marko.js +2 -2
  88. package/components/identity-x/content-page-gate.marko.js +2 -2
  89. package/components/identity-x/newsletter-footer.marko.js +2 -2
  90. package/components/identity-x/newsletter-inline.marko.js +2 -2
  91. package/components/identity-x/newsletter-modal.marko.js +2 -2
  92. package/components/identity-x/newsletter-pushdown.marko.js +2 -2
  93. package/components/identity-x/progressive-profile-gate.marko.js +2 -2
  94. package/components/layouts/ad-preview.marko.js +2 -2
  95. package/components/menu-toggle-button.marko.js +2 -2
  96. package/components/native-x/render.marko.js +2 -2
  97. package/components/nodes/author-bio.marko.js +2 -2
  98. package/components/nodes/author-card.marko.js +2 -2
  99. package/components/nodes/author-published.marko.js +2 -2
  100. package/components/nodes/author.marko.js +2 -2
  101. package/components/nodes/components/attribution.marko.js +2 -2
  102. package/components/nodes/components/authors.marko.js +2 -2
  103. package/components/nodes/components/company-name.marko.js +2 -2
  104. package/components/nodes/components/dates.marko.js +2 -2
  105. package/components/nodes/components/section-sponsor.marko.js +2 -2
  106. package/components/nodes/content-published.marko.js +2 -2
  107. package/components/nodes/content.marko.js +2 -2
  108. package/components/nodes/directory-section-feed-content.marko.js +2 -2
  109. package/components/nodes/featured-products-card.marko.js +2 -2
  110. package/components/nodes/product-feed-content.marko.js +2 -2
  111. package/components/nodes/section-feed-content.marko.js +2 -2
  112. package/components/nodes/standard-promo.marko.js +2 -2
  113. package/components/nodes/youtube-card.marko.js +2 -2
  114. package/components/page/attribution.marko.js +2 -2
  115. package/components/page/contact-details.marko.js +2 -2
  116. package/components/page/content.marko.js +2 -2
  117. package/components/page/contents.marko.js +2 -2
  118. package/components/page/dates.marko.js +2 -2
  119. package/components/page/default.marko.js +2 -2
  120. package/components/page/website-section.marko.js +2 -2
  121. package/components/pagination-controls.marko.js +2 -2
  122. package/components/query-total-count.marko.js +2 -2
  123. package/components/reveal-ad-handler.marko.js +2 -2
  124. package/components/site-footer/container.marko.js +2 -2
  125. package/components/site-footer/copyright.marko.js +2 -2
  126. package/components/site-footer/index.marko.js +2 -2
  127. package/components/site-footer/social-icons.marko.js +2 -2
  128. package/components/site-header.marko.js +2 -2
  129. package/components/site-menu/components/search.marko.js +2 -2
  130. package/components/site-menu/components/social-icons.marko.js +2 -2
  131. package/components/site-menu/header.marko.js +2 -2
  132. package/components/site-menu/index.marko.js +2 -2
  133. package/components/site-menu/section.marko.js +2 -2
  134. package/components/site-navbar/brand.marko.js +2 -2
  135. package/components/site-navbar/index.marko.js +2 -2
  136. package/components/site-navbar/item.marko.js +2 -2
  137. package/components/site-navbar/items.marko.js +2 -2
  138. package/components/site-navbar/logo.marko.js +2 -2
  139. package/components/site-navbar/search.marko.js +2 -2
  140. package/components/site-newsletter-menu.marko.js +2 -2
  141. package/components/social/icon-link.marko.js +2 -2
  142. package/components/social/icons.marko.js +2 -2
  143. package/components/social-follow.marko.js +2 -2
  144. package/components/sponsored-label-logo.marko.js +2 -2
  145. package/components/sponsored-section-logo.marko.js +2 -2
  146. package/components/sponsored-section-name-logo.marko.js +2 -2
  147. package/components/ssr-html-inject.marko.js +2 -2
  148. package/graphql/fragments/content-meter.js +13 -0
  149. package/middleware/content-metering.js +31 -1
  150. package/middleware/progressive-profiling.js +15 -0
  151. package/package.json +4 -4
  152. package/templates/ad-preview.marko.js +2 -2
  153. package/templates/content/components/presented-by.marko.js +2 -2
  154. package/templates/content/native-x-story.marko.js +2 -2
  155. package/templates/content/print.marko.js +2 -2
  156. package/templates/email-preview.marko.js +2 -2
  157. package/templates/search.marko.js +2 -2
  158. package/templates/taxonomy.marko.js +2 -2
  159. package/test/middleware/content-metering.spec.js +131 -0
  160. package/test/middleware/progressive-profiling.spec.js +45 -1
  161. package/test/utils/current-site-scheduled-sections.spec.js +33 -0
  162. package/utils/current-site-scheduled-sections.js +23 -0
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-theme-monorail$1.100.0/templates/taxonomy.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-theme-monorail$1.105.1/templates/taxonomy.marko",
6
6
  marko_component = require("./taxonomy.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_hierarchyAliases = require("@mindful-web/marko-web/utils/hierarchy-aliases"),
@@ -183,7 +183,7 @@ marko_template._ = marko_renderer(render, {
183
183
  }, marko_component);
184
184
 
185
185
  marko_template.meta = {
186
- id: "/@mindful-web/marko-web-theme-monorail$1.100.0/templates/taxonomy.marko",
186
+ id: "/@mindful-web/marko-web-theme-monorail$1.105.1/templates/taxonomy.marko",
187
187
  component: "./taxonomy.marko",
188
188
  tags: [
189
189
  "@mindful-web/marko-web-p1-events/components/track-static-route-view.marko",
@@ -0,0 +1,131 @@
1
+ const { describe, it } = require('mocha');
2
+ const { expect } = require('chai');
3
+ const { shouldMeter } = require('../../middleware/content-metering');
4
+
5
+ const site = { id: 'site-1' };
6
+ const siteConfig = { website: (key) => (key === 'id' ? site.id : undefined) };
7
+
8
+ const article = (overrides = {}) => ({
9
+ id: 15835845,
10
+ type: 'article',
11
+ labels: [],
12
+ primarySection: { id: 1, alias: 'news' },
13
+ websiteSchedules: [
14
+ { section: { id: 1, site, alias: 'news' } },
15
+ { section: { id: 7, site, alias: 'quizzes' } },
16
+ ],
17
+ userRegistration: { isCurrentlyRequired: false, bypassGating: false },
18
+ ...overrides,
19
+ });
20
+
21
+ // `loadGatingContent` memoizes on the request, so a pre-resolved promise stands in for the query.
22
+ const makeReq = (content) => ({
23
+ app: { locals: { config: siteConfig } },
24
+ $gatingContent: Promise.resolve(content),
25
+ });
26
+
27
+ describe('middleware/content-metering shouldMeter', () => {
28
+ it('meters an ordinary article', async () => {
29
+ expect(await shouldMeter(makeReq(article()), {})).to.equal(true);
30
+ });
31
+
32
+ it('excludes content scheduled to an excluded section id, primary or not', async () => {
33
+ const config = { excludeScheduledSectionIds: [7] };
34
+ expect(await shouldMeter(makeReq(article()), config)).to.equal(false);
35
+ });
36
+
37
+ it('excludes content scheduled to an excluded section alias, primary or not', async () => {
38
+ const config = { excludeScheduledSectionAlias: ['quizzes'] };
39
+ expect(await shouldMeter(makeReq(article()), config)).to.equal(false);
40
+ });
41
+
42
+ it('matches aliases exactly, not child sections', async () => {
43
+ const content = article({ websiteSchedules: [{ section: { id: 8, site, alias: 'quizzes/fitness' } }] });
44
+ const config = { excludeScheduledSectionAlias: ['quizzes'] };
45
+ expect(await shouldMeter(makeReq(content), config)).to.equal(true);
46
+ });
47
+
48
+ describe('with descendants', () => {
49
+ // `hierarchy` is the section's ancestor chain, root first, ending with the section itself.
50
+ const grandchild = article({
51
+ websiteSchedules: [{
52
+ section: {
53
+ id: 9,
54
+ site,
55
+ alias: 'quizzes/fitness/strength',
56
+ hierarchy: [{ id: 7, alias: 'quizzes' }, { id: 8, alias: 'quizzes/fitness' }, { id: 9, alias: 'quizzes/fitness/strength' }],
57
+ },
58
+ }],
59
+ });
60
+
61
+ it('excludes content scheduled to a descendant, by id', async () => {
62
+ const config = { excludeScheduledSectionIdsWithDescendants: [7] };
63
+ expect(await shouldMeter(makeReq(grandchild), config)).to.equal(false);
64
+ });
65
+
66
+ it('excludes content scheduled to a descendant, by alias', async () => {
67
+ const config = { excludeScheduledSectionAliasWithDescendants: ['quizzes'] };
68
+ expect(await shouldMeter(makeReq(grandchild), config)).to.equal(false);
69
+ });
70
+
71
+ it('excludes content scheduled to the section itself, with or without self in hierarchy', async () => {
72
+ const config = { excludeScheduledSectionAliasWithDescendants: ['quizzes'] };
73
+ const noHierarchy = article({ websiteSchedules: [{ section: { id: 7, site, alias: 'quizzes' } }] });
74
+ expect(await shouldMeter(makeReq(noHierarchy), config)).to.equal(false);
75
+ });
76
+
77
+ it('does not exclude content scheduled to an ancestor of the configured section', async () => {
78
+ const parent = article({
79
+ websiteSchedules: [{
80
+ section: {
81
+ id: 7,
82
+ site,
83
+ alias: 'quizzes',
84
+ hierarchy: [{ id: 7, alias: 'quizzes' }],
85
+ },
86
+ }],
87
+ });
88
+ const config = { excludeScheduledSectionAliasWithDescendants: ['quizzes/fitness'] };
89
+ expect(await shouldMeter(makeReq(parent), config)).to.equal(true);
90
+ });
91
+
92
+ it('leaves the exact-match options exact', async () => {
93
+ const config = { excludeScheduledSectionAlias: ['quizzes'], excludeScheduledSectionIds: [7] };
94
+ expect(await shouldMeter(makeReq(grandchild), config)).to.equal(true);
95
+ });
96
+ });
97
+
98
+ it('ignores schedules on other sites, for every scheduled-section option', async () => {
99
+ const sibling = { id: 'site-2' };
100
+ const content = article({
101
+ websiteSchedules: [{
102
+ section: {
103
+ id: 7,
104
+ site: sibling,
105
+ alias: 'quizzes',
106
+ hierarchy: [{ id: 7, alias: 'quizzes' }],
107
+ },
108
+ }],
109
+ });
110
+ const configs = [
111
+ { excludeScheduledSectionIds: [7] },
112
+ { excludeScheduledSectionAlias: ['quizzes'] },
113
+ { excludeScheduledSectionIdsWithDescendants: [7] },
114
+ { excludeScheduledSectionAliasWithDescendants: ['quizzes'] },
115
+ ];
116
+ const results = await Promise.all(configs.map((c) => shouldMeter(makeReq(content), c)));
117
+ expect(results).to.deep.equal([true, true, true, true]);
118
+ });
119
+
120
+ it('meters content not scheduled to an excluded section', async () => {
121
+ const config = { excludeScheduledSectionAlias: ['webinars'], excludeScheduledSectionIds: [99] };
122
+ expect(await shouldMeter(makeReq(article()), config)).to.equal(true);
123
+ });
124
+
125
+ it('tolerates missing schedules and null sections', async () => {
126
+ const config = { excludeScheduledSectionAlias: ['quizzes'] };
127
+ expect(await shouldMeter(makeReq(article({ websiteSchedules: null })), config)).to.equal(true);
128
+ const nullSection = article({ websiteSchedules: [{ section: null }] });
129
+ expect(await shouldMeter(makeReq(nullSection), config)).to.equal(true);
130
+ });
131
+ });
@@ -13,7 +13,12 @@ const espIdentityBypass = ({ identified }) => ({ content }) => {
13
13
  return Boolean(content && content.userRegistration && content.userRegistration.bypassGating);
14
14
  };
15
15
 
16
- const makeReq = ({ locals = {}, cookies = {} } = {}) => ({ app: { locals }, cookies });
16
+ const site = { id: 'site-1' };
17
+ const siteConfig = { website: (key) => (key === 'id' ? site.id : undefined) };
18
+ const makeReq = ({ locals = {}, cookies = {} } = {}) => ({
19
+ app: { locals: { config: siteConfig, ...locals } },
20
+ cookies,
21
+ });
17
22
  const identifiedReq = () => makeReq({
18
23
  locals: { contentBypassGatingHandler: espIdentityBypass({ identified: true }) },
19
24
  });
@@ -62,6 +67,45 @@ describe('middleware/progressive-profiling contentBlockReason', () => {
62
67
  expect(excludedLabel).to.equal('excluded-label');
63
68
  });
64
69
 
70
+ it('applies scheduled-section exclusions to non-primary schedules', () => {
71
+ const req = makeReq();
72
+ const byId = { excludeScheduledSectionIds: [7] };
73
+ const byAlias = { excludeScheduledSectionAlias: ['quizzes'] };
74
+ const content = article({
75
+ websiteSchedules: [{ section: { id: 1, site, alias: 'news' } }, { section: { id: 7, site, alias: 'quizzes' } }],
76
+ });
77
+ expect(contentBlockReason({ req, content, config: byId })).to.equal('excluded-scheduled-section-id');
78
+ expect(contentBlockReason({ req, content, config: byAlias })).to.equal('excluded-scheduled-section-alias');
79
+ const nullSection = article({ websiteSchedules: [{ section: null }] });
80
+ expect(contentBlockReason({ req, content: nullSection, config: byAlias })).to.equal(null);
81
+ });
82
+
83
+ it('applies scheduled-section descendant exclusions through the section hierarchy', () => {
84
+ const req = makeReq();
85
+ const content = article({
86
+ websiteSchedules: [{
87
+ section: {
88
+ id: 8,
89
+ site,
90
+ alias: 'quizzes/fitness',
91
+ hierarchy: [{ id: 7, alias: 'quizzes' }, { id: 8, alias: 'quizzes/fitness' }],
92
+ },
93
+ }],
94
+ });
95
+ const byId = { excludeScheduledSectionIdsWithDescendants: [7] };
96
+ const byAlias = { excludeScheduledSectionAliasWithDescendants: ['quizzes'] };
97
+ expect(contentBlockReason({ req, content, config: byId })).to.equal('excluded-scheduled-section-descendant-id');
98
+ expect(contentBlockReason({ req, content, config: byAlias })).to.equal('excluded-scheduled-section-descendant-alias');
99
+ });
100
+
101
+ it('ignores scheduled sections on other sites', () => {
102
+ const content = article({
103
+ websiteSchedules: [{ section: { id: 7, site: { id: 'site-2' }, alias: 'quizzes' } }],
104
+ });
105
+ const config = { excludeScheduledSectionAlias: ['quizzes'] };
106
+ expect(contentBlockReason({ req: makeReq(), content, config })).to.equal(null);
107
+ });
108
+
65
109
  it('returns null for an ordinary article', () => {
66
110
  expect(contentBlockReason({ req: makeReq(), content: article(), config: {} })).to.equal(null);
67
111
  });
@@ -0,0 +1,33 @@
1
+ const { describe, it } = require('mocha');
2
+ const { expect } = require('chai');
3
+ const currentSiteScheduledSections = require('../../utils/current-site-scheduled-sections');
4
+
5
+ const reqFor = (siteId) => ({
6
+ app: { locals: { config: { website: (key) => (key === 'id' ? siteId : undefined) } } },
7
+ });
8
+
9
+ describe('utils/current-site-scheduled-sections', () => {
10
+ const content = {
11
+ websiteSchedules: [
12
+ { section: { id: 1, alias: 'quizzes', site: { id: 'site-1' } } },
13
+ { section: { id: 2, alias: 'quizzes', site: { id: 'site-2' } } },
14
+ { section: null },
15
+ ],
16
+ };
17
+
18
+ it('keeps only sections on the requesting site', () => {
19
+ const ids = currentSiteScheduledSections(reqFor('site-1'), content).map(({ id }) => id);
20
+ expect(ids).to.deep.equal([1]);
21
+ });
22
+
23
+ it('reads the config through the request prototype, as Express sets `req.app`', () => {
24
+ const req = Object.create(reqFor('site-1'));
25
+ const ids = currentSiteScheduledSections(req, content).map(({ id }) => id);
26
+ expect(ids).to.deep.equal([1]);
27
+ });
28
+
29
+ it('returns nothing without a site config or schedules', () => {
30
+ expect(currentSiteScheduledSections({ app: { locals: {} } }, content)).to.deep.equal([]);
31
+ expect(currentSiteScheduledSections(reqFor('site-1'), {})).to.deep.equal([]);
32
+ });
33
+ });
@@ -0,0 +1,23 @@
1
+ const { get, getAsArray } = require('@mindful-web/object-path');
2
+
3
+ /**
4
+ * The sections a content item is scheduled to on the requesting site.
5
+ *
6
+ * `websiteSchedules` returns the content's schedules on every site in the tenant, and section
7
+ * aliases are only unique within a site, so alias matching against unfiltered schedules would
8
+ * also match a same-named section on a sibling site. Expired and future schedules are included.
9
+ *
10
+ * @param {import('express').Request} req
11
+ * @param {object} content The content node (needs `websiteSchedules.section.site.id`).
12
+ * @returns {object[]} The scheduled sections, each with `id`, `alias` and `hierarchy`.
13
+ */
14
+ module.exports = (req, content) => {
15
+ // Read directly: Express sets `req.app` on the request prototype, which object-path's `get`
16
+ // (own properties only) does not follow.
17
+ const { config } = req.app.locals;
18
+ const siteId = config ? config.website('id') : undefined;
19
+ if (!siteId) return [];
20
+ return getAsArray(content, 'websiteSchedules')
21
+ .map((schedule) => get(schedule, 'section') || {})
22
+ .filter((section) => `${get(section, 'site.id')}` === `${siteId}`);
23
+ };