Skip to content

Commit

Permalink
Merge branch 'master' into coy
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinsina authored Jul 9, 2024
2 parents 58445c4 + 00c5811 commit 9afd6ba
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 105 deletions.
23 changes: 23 additions & 0 deletions packages/global/graphql/fragments/dynamic-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const gql = require('graphql-tag');

module.exports = gql`
fragment DynamicPageFragment on ContentPage {
id
type
name
body
primarySection {
id
name
alias
}
gating {
surveyType
surveyId
}
userRegistration {
isCurrentlyRequired
accessLevels
}
}
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { withDynamicPage } = require('@parameter1/base-cms-marko-web/middleware');
const queryFragment = require('@parameter1/base-cms-marko-web-theme-monorail/graphql/fragments/dynamic-page');
const page = require('@randall-reilly/package-global/templates/dynamic-page');
const queryFragment = require('../graphql/fragments/dynamic-page');
const page = require('../templates/dynamic-page');

module.exports = (app) => {
app.get('/page/:alias(*)', withDynamicPage({
Expand Down
4 changes: 4 additions & 0 deletions packages/global/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const renderBlock = require('@parameter1/base-cms-marko-web-theme-monorail/route
const search = require('@parameter1/base-cms-marko-web-theme-monorail/routes/search');
const taxonomy = require('@parameter1/base-cms-marko-web-theme-monorail/routes/taxonomy');
const omedaNewsletters = require('@parameter1/base-cms-marko-web-omeda/routes/omeda-newsletters');
const dynamicPages = require('./dynamic-page');
const feed = require('./feed');
const nativeX = require('./native-x');
const printContent = require('./print-content');
Expand All @@ -11,6 +12,9 @@ const redirects = require('./redirects');
const staticPage = require('./static-page');

module.exports = (app, siteConfig) => {
// Dynamic Pages
dynamicPages(app);

// Feed
feed(app);

Expand Down
59 changes: 58 additions & 1 deletion packages/global/templates/dynamic-page/index.marko
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { getAsArray, getAsObject, get } from "@parameter1/base-cms-object-path";
import hasOmedaId from "@parameter1/base-cms-marko-web-theme-monorail/utils/has-omeda-id";
import getContentPreview from "@parameter1/base-cms-marko-web-theme-monorail/utils/get-content-preview";
import { cmShowOverlay, cmRestrictContentByReg, cmTruncateBody } from "../../utils/content-meter-helpers";

$ const { global: $global } = out;
$ const { contentMeterState, req } = $global;
$ const { id, type, pageNode } = input;
$ const showOverlay = cmShowOverlay(contentMeterState);
$ const bypassGate = hasOmedaId(req);

<global-content-wrapper-layout
id=id
Expand Down Expand Up @@ -29,8 +38,56 @@ $ const { id, type, pageNode } = input;
<theme-page-contents|{ blockName }| attrs={ "data-gallery-id": id }>

$ const bodyId = `content-body-${content.id}`;
<marko-web-content-body block-name=blockName obj=content attrs={ id: bodyId } />

$ const contentRequiresRegistration = get(content, "userRegistration.isCurrentlyRequired");
$ const requiresRegistration = !bypassGate && (contentRequiresRegistration || cmRestrictContentByReg(contentMeterState, content));
$ const accessLevels = getAsArray(content, "userRegistration.accessLevels");
$ console.log(contentRequiresRegistration, requiresRegistration, accessLevels)
<marko-web-identity-x-access|context|
enabled=requiresRegistration
required-access-level-ids=accessLevels
>
<if(cmTruncateBody(contentMeterState))>
$ const body = showOverlay ? getContentPreview({ body: content.body, selector: "p:lt(7)" }) : getContentPreview({ body: content.body, selector: "p:nth-of-type(1)" });
<marko-web-content-body block-name=blockName obj={ body } lazyload-first-image=lazyloadFirstImage />

<div class="content-page-preview-overlay" />
<if(!showOverlay)>
<theme-content-page-gate
can-access=context.canAccess
is-logged-in=context.isLoggedIn
has-required-access-level=context.hasRequiredAccessLevel
requires-access-level=context.requiresAccessLevel
requires-user-input=context.requiresUserInput
messages="context.messages"
user-input-title="Step 2 of 2"
profile-call-to-action=""
profile-button-label="Create Account"
profile-event-name="content_meter_profile"
title="Login to Access!"
/>
</if>
</if>
<else-if(!context.canAccess || context.requiresUserInput)>
$ const body = getContentPreview({ body: content.body, selector: "p:lt(4)" });
<marko-web-content-body block-name=blockName obj={ body } />

<div class="content-page-preview-overlay" />
<theme-content-page-gate
can-access=context.canAccess
is-logged-in=context.isLoggedIn
has-required-access-level=context.hasRequiredAccessLevel
requires-access-level=context.requiresAccessLevel
requires-user-input=context.requiresUserInput
messages=context.messages
title="Login to Access!"
/>
<marko-web-content-body block-name=blockName attrs={ style: "display: none;" } obj=content modifiers=["ld-json"] />
</else-if>
<else>
<marko-web-content-body block-name=blockName obj=content attrs={ id: bodyId } />
</else>
</marko-web-identity-x-access>
</theme-page-contents>
</div>
</@section>
Expand Down
4 changes: 0 additions & 4 deletions sites/ccjdigital.com/server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const home = require('./home');
const content = require('./content');
const dynamicPages = require('./dynamic-page');
const top250 = require('./top250');
const websiteSections = require('./website-section');

Expand All @@ -11,9 +10,6 @@ module.exports = (app) => {
// Spec Guides
top250(app);

// Dynamic Pages
dynamicPages(app);

// Content Pages
content(app);

Expand Down
10 changes: 0 additions & 10 deletions sites/cleantrucking.com/server/routes/dynamic-page.js

This file was deleted.

4 changes: 0 additions & 4 deletions sites/cleantrucking.com/server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
const home = require('./home');
const content = require('./content');
const dynamicPages = require('./dynamic-page');
const websiteSections = require('./website-section');

module.exports = (app) => {
// Homepage
home(app);

// Dynamic Pages
dynamicPages(app);

// Content Pages
content(app);

Expand Down
10 changes: 0 additions & 10 deletions sites/equipmentworld.com/server/routes/dynamic-page.js

This file was deleted.

4 changes: 0 additions & 4 deletions sites/equipmentworld.com/server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const EERouter = require('@randall-reilly/equipment-experts');
const home = require('./home');
const content = require('./content');
const dynamicPages = require('./dynamic-page');
const staticPages = require('./static');
const websiteSections = require('./website-section');

Expand All @@ -13,9 +12,6 @@ module.exports = (app) => {
const { parseEmbeddedMedia } = app.locals;
app.use('/api/marketplace-articles', EERouter({ parseEmbeddedMedia, sectionAlias: 'equipment-experts' }));

// Dynamic Pages
dynamicPages(app);

// Content Pages
content(app);

Expand Down
10 changes: 0 additions & 10 deletions sites/hardworkingtrucks.com/server/routes/dynamic-page.js

This file was deleted.

4 changes: 0 additions & 4 deletions sites/hardworkingtrucks.com/server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
const home = require('./home');
const content = require('./content');
const dynamicPages = require('./dynamic-page');
const websiteSections = require('./website-section');

module.exports = (app) => {
// Homepage
home(app);

// Dynamic Pages
dynamicPages(app);

// Content Pages
content(app);

Expand Down
10 changes: 0 additions & 10 deletions sites/overdriveonline.com/server/routes/dynamic-page.js

This file was deleted.

4 changes: 0 additions & 4 deletions sites/overdriveonline.com/server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const rigdig = require('@randall-reilly/package-rigdig');
const home = require('./home');
const content = require('./content');
const dynamicPages = require('./dynamic-page');
const websiteSections = require('./website-section');

module.exports = (app) => {
Expand All @@ -11,9 +10,6 @@ module.exports = (app) => {
// Homepage
home(app);

// Dynamic Pages
dynamicPages(app);

// Content Pages
content(app);

Expand Down
10 changes: 0 additions & 10 deletions sites/totallandscapecare.com/server/routes/dynamic-page.js

This file was deleted.

4 changes: 0 additions & 4 deletions sites/totallandscapecare.com/server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
const home = require('./home');
const content = require('./content');
const dynamicPages = require('./dynamic-page');
const websiteSections = require('./website-section');

module.exports = (app) => {
// Homepage
home(app);

// Dynamic Pages
dynamicPages(app);

// Content Pages
content(app);

Expand Down
10 changes: 0 additions & 10 deletions sites/truckersnews.com/server/routes/dynamic-page.js

This file was deleted.

4 changes: 0 additions & 4 deletions sites/truckersnews.com/server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
const home = require('./home');
const content = require('./content');
const dynamicPages = require('./dynamic-page');
const websiteSections = require('./website-section');

module.exports = (app) => {
// Homepage
home(app);

// Dynamic Pages
dynamicPages(app);

// Content Pages
content(app);

Expand Down
10 changes: 0 additions & 10 deletions sites/truckpartsandservice.com/server/routes/dynamic-page.js

This file was deleted.

4 changes: 0 additions & 4 deletions sites/truckpartsandservice.com/server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
const home = require('./home');
const content = require('./content');
const dynamicPages = require('./dynamic-page');
const websiteSections = require('./website-section');
const staticPages = require('./static');

module.exports = (app) => {
// Homepage
home(app);

// Dynamic Pages
dynamicPages(app);

// Content Pages
content(app);

Expand Down

0 comments on commit 9afd6ba

Please sign in to comment.