@mindful-web/marko-web-native-x 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -0
- package/LICENSE +21 -0
- package/README.md +243 -0
- package/apollo/create-client.js +42 -0
- package/apollo/graphql/fragments/image.js +12 -0
- package/apollo/graphql/fragments/publisher-stories.js +20 -0
- package/apollo/graphql/fragments/related-stories.js +20 -0
- package/apollo/graphql/fragments/story.js +24 -0
- package/apollo/graphql/queries/publisher-stories.js +19 -0
- package/apollo/graphql/queries/related-stories.js +19 -0
- package/apollo/graphql/queries/story.js +15 -0
- package/browser/.eslintrc.js +1 -0
- package/browser/index.js +10 -0
- package/browser/track-end-of-content.vue +20 -0
- package/browser/track-outbound-links.vue +26 -0
- package/browser/track-social-share.vue +23 -0
- package/components/fetch-elements.marko +21 -0
- package/components/fetch-elements.marko.js +58 -0
- package/components/gtm-init.marko +21 -0
- package/components/gtm-init.marko.js +60 -0
- package/components/init.marko +35 -0
- package/components/init.marko.js +63 -0
- package/components/marko.json +72 -0
- package/components/publisher-stories.marko +64 -0
- package/components/publisher-stories.marko.js +96 -0
- package/components/render.marko +33 -0
- package/components/render.marko.js +75 -0
- package/components/retrieve.marko +44 -0
- package/components/retrieve.marko.js +94 -0
- package/components/story/advertiser-related-stories.marko +51 -0
- package/components/story/advertiser-related-stories.marko.js +84 -0
- package/components/story/track-end-of-content.marko +1 -0
- package/components/story/track-end-of-content.marko.js +30 -0
- package/components/story/track-init.marko +13 -0
- package/components/story/track-init.marko.js +45 -0
- package/components/story/track-outbound-links.marko +3 -0
- package/components/story/track-outbound-links.marko.js +32 -0
- package/components/story/track-page-view.marko +1 -0
- package/components/story/track-page-view.marko.js +32 -0
- package/components/story/track-social-share.marko +1 -0
- package/components/story/track-social-share.marko.js +30 -0
- package/config.js +94 -0
- package/marko.json +6 -0
- package/middleware/with-story.js +35 -0
- package/package.json +32 -0
- package/services/fetch-elements.js +22 -0
- package/utils/convert-ad-to-content.js +39 -0
- package/utils/convert-ad-to-node.js +6 -0
- package/utils/convert-story-to-content.js +44 -0
- package/utils/create-headers.js +7 -0
- package/utils/gtm-events.js +20 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-native-x$1.0.0/components/gtm-init.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
|
+
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
9
|
+
module_objectPath_module = require("@mindful-web/object-path"),
|
|
10
|
+
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
11
|
+
get = module_objectPath_module.get,
|
|
12
|
+
getAsObject = module_objectPath_module.getAsObject,
|
|
13
|
+
marko_web_gtm_init_template = require("@mindful-web/marko-web-gtm/components/init.marko"),
|
|
14
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
15
|
+
marko_web_gtm_init_tag = marko_loadTag(marko_web_gtm_init_template),
|
|
16
|
+
marko_web_gtm_noscript_template = require("@mindful-web/marko-web-gtm/components/noscript.marko"),
|
|
17
|
+
marko_web_gtm_noscript_tag = marko_loadTag(marko_web_gtm_noscript_template);
|
|
18
|
+
|
|
19
|
+
function render(input, out, __component, component, state) {
|
|
20
|
+
var data = input;
|
|
21
|
+
|
|
22
|
+
const { req } = out.global;
|
|
23
|
+
|
|
24
|
+
const story = getAsObject(input, "story");
|
|
25
|
+
|
|
26
|
+
const on = defaultValue(input.on, "load");
|
|
27
|
+
|
|
28
|
+
const requestFrame = defaultValue(input.requestFrame, true);
|
|
29
|
+
|
|
30
|
+
const targetTag = defaultValue(input.targetTag, "body");
|
|
31
|
+
|
|
32
|
+
const containerId = "GTM-MNQH25L";
|
|
33
|
+
|
|
34
|
+
marko_web_gtm_init_tag({
|
|
35
|
+
name: "dataLayerNativeX",
|
|
36
|
+
start: true,
|
|
37
|
+
containerId: containerId,
|
|
38
|
+
on: on,
|
|
39
|
+
requestFrame: requestFrame,
|
|
40
|
+
targetTag: targetTag,
|
|
41
|
+
push: input.push
|
|
42
|
+
}, out, __component, "0");
|
|
43
|
+
|
|
44
|
+
marko_web_gtm_noscript_tag({
|
|
45
|
+
containerId: containerId
|
|
46
|
+
}, out, __component, "1");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
marko_template._ = marko_renderer(render, {
|
|
50
|
+
d_: true,
|
|
51
|
+
e_: marko_componentType
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
marko_template.meta = {
|
|
55
|
+
id: "/@mindful-web/marko-web-native-x$1.0.0/components/gtm-init.marko",
|
|
56
|
+
tags: [
|
|
57
|
+
"@mindful-web/marko-web-gtm/components/init.marko",
|
|
58
|
+
"@mindful-web/marko-web-gtm/components/noscript.marko"
|
|
59
|
+
]
|
|
60
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { warn } from "@mindful-web/utils";
|
|
2
|
+
|
|
3
|
+
$ const { uri, enabled, on } = input;
|
|
4
|
+
$ const src = "https://cdn.parameter1.com/native-x/v1.2.0/lib.min.js";
|
|
5
|
+
|
|
6
|
+
<if(uri)>
|
|
7
|
+
<if(enabled)>
|
|
8
|
+
<if(on)>
|
|
9
|
+
<marko-web-deferred-script-loader-register
|
|
10
|
+
name="fortnight"
|
|
11
|
+
src=src
|
|
12
|
+
on=on
|
|
13
|
+
esm=true
|
|
14
|
+
request-frame=input.requestFrame
|
|
15
|
+
target-tag=input.targetTag
|
|
16
|
+
init="var i = window, r = 'fortnight'; i['FortnightObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments); };"
|
|
17
|
+
init-only=input.initOnly
|
|
18
|
+
/>
|
|
19
|
+
</if>
|
|
20
|
+
<else>
|
|
21
|
+
<script>
|
|
22
|
+
(function (i,r) {
|
|
23
|
+
i['FortnightObject'] = r; i[r] = i[r] || function () {
|
|
24
|
+
(i[r].q = i[r].q || []).push(arguments);
|
|
25
|
+
}
|
|
26
|
+
})(window, 'fortnight');
|
|
27
|
+
</script>
|
|
28
|
+
<script type="module" src=src async defer></script>
|
|
29
|
+
</else>
|
|
30
|
+
<script>fortnight('init', { domain: '${uri}' });</script>
|
|
31
|
+
</if>
|
|
32
|
+
</if>
|
|
33
|
+
<else>
|
|
34
|
+
$ warn('Unable to init NativeX: a uri is required.');
|
|
35
|
+
</else>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-native-x$1.0.0/components/init.marko",
|
|
6
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
8
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
9
|
+
warn = module_utils_module.warn,
|
|
10
|
+
marko_web_deferred_script_loader_register_template = require("@mindful-web/marko-web-deferred-script-loader/components/register.marko"),
|
|
11
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
12
|
+
marko_web_deferred_script_loader_register_tag = marko_loadTag(marko_web_deferred_script_loader_register_template),
|
|
13
|
+
marko_attr = require("marko/dist/runtime/html/helpers/attr"),
|
|
14
|
+
helpers_escape_xml = require("marko/dist/runtime/html/helpers/escape-xml"),
|
|
15
|
+
marko_escapeXml = helpers_escape_xml.x,
|
|
16
|
+
marko_escapeScript = require("marko/dist/runtime/html/helpers/escape-script-placeholder");
|
|
17
|
+
|
|
18
|
+
function render(input, out, __component, component, state) {
|
|
19
|
+
var data = input;
|
|
20
|
+
|
|
21
|
+
const { uri, enabled, on } = input;
|
|
22
|
+
|
|
23
|
+
const src = "https://cdn.parameter1.com/native-x/v1.2.0/lib.min.js";
|
|
24
|
+
|
|
25
|
+
if (uri) {
|
|
26
|
+
if (enabled) {
|
|
27
|
+
if (on) {
|
|
28
|
+
marko_web_deferred_script_loader_register_tag({
|
|
29
|
+
name: "fortnight",
|
|
30
|
+
src: src,
|
|
31
|
+
on: on,
|
|
32
|
+
esm: true,
|
|
33
|
+
requestFrame: input.requestFrame,
|
|
34
|
+
targetTag: input.targetTag,
|
|
35
|
+
init: "var i = window, r = 'fortnight'; i['FortnightObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments); };",
|
|
36
|
+
initOnly: input.initOnly
|
|
37
|
+
}, out, __component, "0");
|
|
38
|
+
} else {
|
|
39
|
+
out.w("<script>\n (function (i,r) {\n i['FortnightObject'] = r; i[r] = i[r] || function () {\n (i[r].q = i[r].q || []).push(arguments);\n }\n })(window, 'fortnight');\n </script><script type=\"module\"" +
|
|
40
|
+
marko_attr("src", src) +
|
|
41
|
+
" async defer></script>");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
out.w("<script>" +
|
|
45
|
+
marko_escapeScript(("fortnight('init', { domain: '" + uri) + "' });") +
|
|
46
|
+
"</script>");
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
warn('Unable to init NativeX: a uri is required.');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
marko_template._ = marko_renderer(render, {
|
|
54
|
+
d_: true,
|
|
55
|
+
e_: marko_componentType
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
marko_template.meta = {
|
|
59
|
+
id: "/@mindful-web/marko-web-native-x$1.0.0/components/init.marko",
|
|
60
|
+
tags: [
|
|
61
|
+
"@mindful-web/marko-web-deferred-script-loader/components/register.marko"
|
|
62
|
+
]
|
|
63
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"<marko-web-native-x-init>": {
|
|
3
|
+
"template": "./init.marko",
|
|
4
|
+
"@uri": "string",
|
|
5
|
+
"@enabled": "boolean",
|
|
6
|
+
"@on": "string",
|
|
7
|
+
"@target-tag": "string",
|
|
8
|
+
"@request-frame": "boolean",
|
|
9
|
+
"@init-only": "boolean"
|
|
10
|
+
},
|
|
11
|
+
"<marko-web-native-x-retrieve>": {
|
|
12
|
+
"template": "./retrieve.marko",
|
|
13
|
+
"@uri": "string",
|
|
14
|
+
"@id": "string",
|
|
15
|
+
"@enabled": "boolean",
|
|
16
|
+
"@opts": "object",
|
|
17
|
+
"@section-name": "string"
|
|
18
|
+
},
|
|
19
|
+
"<marko-web-native-x-render>": {
|
|
20
|
+
"template": "./render.marko",
|
|
21
|
+
"@config": "object",
|
|
22
|
+
"@name": "string",
|
|
23
|
+
"@aliases": "array",
|
|
24
|
+
"@node": "object",
|
|
25
|
+
"@when": "boolean",
|
|
26
|
+
"@section-name": "string"
|
|
27
|
+
},
|
|
28
|
+
"<marko-web-native-x-fetch-elements>": {
|
|
29
|
+
"template": "./fetch-elements.marko",
|
|
30
|
+
"@uri": "string",
|
|
31
|
+
"@id": "string",
|
|
32
|
+
"@opts": "object"
|
|
33
|
+
},
|
|
34
|
+
"<marko-web-native-x-gtm-init>": {
|
|
35
|
+
"template": "./gtm-init.marko",
|
|
36
|
+
"@on": "string",
|
|
37
|
+
"@target-tag": "string",
|
|
38
|
+
"@request-frame": "boolean",
|
|
39
|
+
"@story": "object"
|
|
40
|
+
},
|
|
41
|
+
"<marko-web-native-x-story-advertiser-related-stories>": {
|
|
42
|
+
"template": "./story/advertiser-related-stories.marko",
|
|
43
|
+
"@advertiser-id": "string",
|
|
44
|
+
"@external-id": "string",
|
|
45
|
+
"@publisher-id": "string",
|
|
46
|
+
"@exclude-story-ids": "array"
|
|
47
|
+
},
|
|
48
|
+
"<marko-web-native-x-publisher-stories>": {
|
|
49
|
+
"template": "./publisher-stories.marko",
|
|
50
|
+
"@limit": "string",
|
|
51
|
+
"@domain-name": "string",
|
|
52
|
+
"@website": "string",
|
|
53
|
+
"@sort": "object"
|
|
54
|
+
},
|
|
55
|
+
"<marko-web-native-x-story-track-init>": {
|
|
56
|
+
"template": "./story/track-init.marko",
|
|
57
|
+
"@story": "object"
|
|
58
|
+
},
|
|
59
|
+
"<marko-web-native-x-story-track-page-view>": {
|
|
60
|
+
"template": "./story/track-page-view.marko"
|
|
61
|
+
},
|
|
62
|
+
"<marko-web-native-x-story-track-end-of-content>": {
|
|
63
|
+
"template": "./story/track-end-of-content.marko"
|
|
64
|
+
},
|
|
65
|
+
"<marko-web-native-x-story-track-social-share>": {
|
|
66
|
+
"template": "./story/track-social-share.marko"
|
|
67
|
+
},
|
|
68
|
+
"<marko-web-native-x-story-track-outbound-links>": {
|
|
69
|
+
"template": "./story/track-outbound-links.marko",
|
|
70
|
+
"@container": "string"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import defaultFragment from "../apollo/graphql/fragments/publisher-stories";
|
|
2
|
+
import buildQuery from "../apollo/graphql/queries/publisher-stories";
|
|
3
|
+
|
|
4
|
+
$ const { req, nativeX } = out.global;
|
|
5
|
+
|
|
6
|
+
$ const {
|
|
7
|
+
domainName,
|
|
8
|
+
website,
|
|
9
|
+
limit = 25,
|
|
10
|
+
after,
|
|
11
|
+
sort = {
|
|
12
|
+
order: -1,
|
|
13
|
+
field: "publishedAt",
|
|
14
|
+
},
|
|
15
|
+
} = input;
|
|
16
|
+
$ const args = {
|
|
17
|
+
config: nativeX,
|
|
18
|
+
sort,
|
|
19
|
+
pagination: {
|
|
20
|
+
first: limit,
|
|
21
|
+
after,
|
|
22
|
+
},
|
|
23
|
+
...(domainName && { domainName }),
|
|
24
|
+
...(website && { website }),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param NativeXConfiguration The NativeX config
|
|
29
|
+
* @param object The Marko template to render
|
|
30
|
+
* @param Document A query fragment to be used with the story query
|
|
31
|
+
*/
|
|
32
|
+
$ const getStories = async ({
|
|
33
|
+
config,
|
|
34
|
+
pagination,
|
|
35
|
+
sort,
|
|
36
|
+
queryFragment = defaultFragment,
|
|
37
|
+
domainName,
|
|
38
|
+
website,
|
|
39
|
+
} = {}) => {
|
|
40
|
+
|
|
41
|
+
const input = {
|
|
42
|
+
...(domainName && { domainName }),
|
|
43
|
+
...(website && { website }),
|
|
44
|
+
};
|
|
45
|
+
const query = buildQuery(queryFragment);
|
|
46
|
+
const variables = { input, pagination, sort };
|
|
47
|
+
|
|
48
|
+
const { data } = await config.client.query({ query, variables });
|
|
49
|
+
if (!data || !data.publisherStories) return { nodes: [], pageInfo: {} };
|
|
50
|
+
const { pageInfo } = data.publisherStories;
|
|
51
|
+
const nodes = data.publisherStories.edges
|
|
52
|
+
.map(edge => (edge && edge.node ? edge.node : null))
|
|
53
|
+
.filter(c => c);
|
|
54
|
+
return { nodes, pageInfo };
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
<if(nativeX && (domainName || website))>
|
|
58
|
+
<marko-web-resolve|{ resolved }| promise=getStories(args)>
|
|
59
|
+
<${input.renderBody} nodes=resolved.nodes pageInfo=resolved.pageInfo />
|
|
60
|
+
</marko-web-resolve>
|
|
61
|
+
</if>
|
|
62
|
+
<else>
|
|
63
|
+
$ warn('Unable to fetch elements from NativeX: a uri and advertiser ID are required.');
|
|
64
|
+
</else>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-native-x$1.0.0/components/publisher-stories.marko",
|
|
6
|
+
marko_component = require("./publisher-stories.marko"),
|
|
7
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
+
module_defaultFragment = require("../apollo/graphql/fragments/publisher-stories"),
|
|
9
|
+
defaultFragment = module_defaultFragment.default || module_defaultFragment,
|
|
10
|
+
module_buildQuery = require("../apollo/graphql/queries/publisher-stories"),
|
|
11
|
+
buildQuery = module_buildQuery.default || module_buildQuery,
|
|
12
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
13
|
+
marko_web_resolve_template = require("@mindful-web/marko-core/components/resolve.marko"),
|
|
14
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
15
|
+
marko_web_resolve_tag = marko_loadTag(marko_web_resolve_template);
|
|
16
|
+
|
|
17
|
+
function render(input, out, __component, component, state) {
|
|
18
|
+
var data = input;
|
|
19
|
+
|
|
20
|
+
const { req, nativeX } = out.global;
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
domainName,
|
|
24
|
+
website,
|
|
25
|
+
limit = 25,
|
|
26
|
+
after,
|
|
27
|
+
sort = {
|
|
28
|
+
order: -1,
|
|
29
|
+
field: "publishedAt",
|
|
30
|
+
},
|
|
31
|
+
} = input;
|
|
32
|
+
|
|
33
|
+
const args = {
|
|
34
|
+
config: nativeX,
|
|
35
|
+
sort,
|
|
36
|
+
pagination: {
|
|
37
|
+
first: limit,
|
|
38
|
+
after,
|
|
39
|
+
},
|
|
40
|
+
...(domainName && { domainName }),
|
|
41
|
+
...(website && { website }),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getStories = async ({
|
|
45
|
+
config,
|
|
46
|
+
pagination,
|
|
47
|
+
sort,
|
|
48
|
+
queryFragment = defaultFragment,
|
|
49
|
+
domainName,
|
|
50
|
+
website,
|
|
51
|
+
} = {}) => {
|
|
52
|
+
|
|
53
|
+
const input = {
|
|
54
|
+
...(domainName && { domainName }),
|
|
55
|
+
...(website && { website }),
|
|
56
|
+
};
|
|
57
|
+
const query = buildQuery(queryFragment);
|
|
58
|
+
const variables = { input, pagination, sort };
|
|
59
|
+
|
|
60
|
+
const { data } = await config.client.query({ query, variables });
|
|
61
|
+
if (!data || !data.publisherStories) return { nodes: [], pageInfo: {} };
|
|
62
|
+
const { pageInfo } = data.publisherStories;
|
|
63
|
+
const nodes = data.publisherStories.edges
|
|
64
|
+
.map(edge => (edge && edge.node ? edge.node : null))
|
|
65
|
+
.filter(c => c);
|
|
66
|
+
return { nodes, pageInfo };
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (nativeX && (domainName || website)) {
|
|
70
|
+
marko_web_resolve_tag({
|
|
71
|
+
promise: getStories(args),
|
|
72
|
+
renderBody: function(out, { resolved }) {
|
|
73
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
74
|
+
return {
|
|
75
|
+
nodes: resolved.nodes,
|
|
76
|
+
pageInfo: resolved.pageInfo
|
|
77
|
+
};
|
|
78
|
+
}, null, null, null, __component, "1");
|
|
79
|
+
}
|
|
80
|
+
}, out, __component, "0");
|
|
81
|
+
} else {
|
|
82
|
+
warn('Unable to fetch elements from NativeX: a uri and advertiser ID are required.');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
marko_template._ = marko_renderer(render, {
|
|
87
|
+
e_: marko_componentType
|
|
88
|
+
}, marko_component);
|
|
89
|
+
|
|
90
|
+
marko_template.meta = {
|
|
91
|
+
id: "/@mindful-web/marko-web-native-x$1.0.0/components/publisher-stories.marko",
|
|
92
|
+
component: "./publisher-stories.marko",
|
|
93
|
+
tags: [
|
|
94
|
+
"@mindful-web/marko-core/components/resolve.marko"
|
|
95
|
+
]
|
|
96
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
$ const {
|
|
2
|
+
config,
|
|
3
|
+
name,
|
|
4
|
+
aliases,
|
|
5
|
+
node,
|
|
6
|
+
when,
|
|
7
|
+
sectionName,
|
|
8
|
+
} = input;
|
|
9
|
+
|
|
10
|
+
$ const results = {
|
|
11
|
+
node,
|
|
12
|
+
containerAttrs: {},
|
|
13
|
+
linkAttrs: {},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
<if(config)>
|
|
17
|
+
<if(when)>
|
|
18
|
+
<marko-web-native-x-retrieve|{ wasFound, hasCampaign, campaign, linkAttrs, containerAttrs }| ...config.getPlacement({ name, aliases }) section-name=sectionName>
|
|
19
|
+
<if(wasFound)>
|
|
20
|
+
$ results.node = hasCampaign ? campaign : node;
|
|
21
|
+
$ results.containerAttrs = containerAttrs;
|
|
22
|
+
$ results.linkAttrs = linkAttrs;
|
|
23
|
+
<${input.renderBody} ...results />
|
|
24
|
+
</if>
|
|
25
|
+
<else>
|
|
26
|
+
<${input.renderBody} ...results />
|
|
27
|
+
</else>
|
|
28
|
+
</marko-web-native-x-retrieve>
|
|
29
|
+
</if>
|
|
30
|
+
<else>
|
|
31
|
+
<${input.renderBody} ...results />
|
|
32
|
+
</else>
|
|
33
|
+
</if>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-native-x$1.0.0/components/render.marko",
|
|
6
|
+
marko_component = require("./render.marko"),
|
|
7
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
9
|
+
marko_assign = require("marko/dist/runtime/helpers/assign"),
|
|
10
|
+
marko_web_native_x_retrieve_template = require("./retrieve.marko"),
|
|
11
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
12
|
+
marko_web_native_x_retrieve_tag = marko_loadTag(marko_web_native_x_retrieve_template);
|
|
13
|
+
|
|
14
|
+
function render(input, out, __component, component, state) {
|
|
15
|
+
var data = input;
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
config,
|
|
19
|
+
name,
|
|
20
|
+
aliases,
|
|
21
|
+
node,
|
|
22
|
+
when,
|
|
23
|
+
sectionName,
|
|
24
|
+
} = input;
|
|
25
|
+
|
|
26
|
+
const results = {
|
|
27
|
+
node,
|
|
28
|
+
containerAttrs: {},
|
|
29
|
+
linkAttrs: {},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (config) {
|
|
33
|
+
if (when) {
|
|
34
|
+
marko_web_native_x_retrieve_tag(marko_assign({}, config.getPlacement({
|
|
35
|
+
name: name,
|
|
36
|
+
aliases: aliases
|
|
37
|
+
}), {
|
|
38
|
+
sectionName: sectionName,
|
|
39
|
+
renderBody: function(out, { wasFound, hasCampaign, campaign, linkAttrs, containerAttrs }) {
|
|
40
|
+
if (wasFound) {
|
|
41
|
+
results.node = hasCampaign ? campaign : node;
|
|
42
|
+
|
|
43
|
+
results.containerAttrs = containerAttrs;
|
|
44
|
+
|
|
45
|
+
results.linkAttrs = linkAttrs;
|
|
46
|
+
|
|
47
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
48
|
+
return results;
|
|
49
|
+
}, null, null, null, __component, "1");
|
|
50
|
+
} else {
|
|
51
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
52
|
+
return results;
|
|
53
|
+
}, null, null, null, __component, "2");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}), out, __component, "0");
|
|
57
|
+
} else {
|
|
58
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
59
|
+
return results;
|
|
60
|
+
}, null, null, null, __component, "3");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
marko_template._ = marko_renderer(render, {
|
|
66
|
+
e_: marko_componentType
|
|
67
|
+
}, marko_component);
|
|
68
|
+
|
|
69
|
+
marko_template.meta = {
|
|
70
|
+
id: "/@mindful-web/marko-web-native-x$1.0.0/components/render.marko",
|
|
71
|
+
component: "./render.marko",
|
|
72
|
+
tags: [
|
|
73
|
+
"./retrieve.marko"
|
|
74
|
+
]
|
|
75
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defaultValue } from "@mindful-web/marko-web/utils";
|
|
2
|
+
import { warn } from "@mindful-web/utils";
|
|
3
|
+
import convertAdToContent from "../utils/convert-ad-to-content";
|
|
4
|
+
|
|
5
|
+
$ const { uri, id, sectionName } = input;
|
|
6
|
+
$ const enabled = defaultValue(input.enabled, true);
|
|
7
|
+
$ const results = {
|
|
8
|
+
wasFound: false,
|
|
9
|
+
hasCampaign: false,
|
|
10
|
+
campaign: {},
|
|
11
|
+
containerAttrs: {},
|
|
12
|
+
linkAttrs: {},
|
|
13
|
+
response: {},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
<if(enabled)>
|
|
17
|
+
<if(uri && id)>
|
|
18
|
+
<marko-web-native-x-fetch-elements|{ ads }| uri=uri id=id opts=input.opts>
|
|
19
|
+
$ const hasAd = ads && ads.length && ads[0];
|
|
20
|
+
<if(hasAd)>
|
|
21
|
+
$ const ad = ads[0];
|
|
22
|
+
|
|
23
|
+
$ results.wasFound = true;
|
|
24
|
+
$ results.response = ad;
|
|
25
|
+
$ results.hasCampaign = ad.hasCampaign;
|
|
26
|
+
$ results.containerAttrs = ad.attributes.container;
|
|
27
|
+
$ results.linkAttrs = ad.attributes.link;
|
|
28
|
+
$ if (ad.hasCampaign) results.campaign = convertAdToContent(ad, { sectionName });
|
|
29
|
+
|
|
30
|
+
<${input.renderBody} ...results />
|
|
31
|
+
</if>
|
|
32
|
+
<else>
|
|
33
|
+
<${input.renderBody} ...results />
|
|
34
|
+
</else>
|
|
35
|
+
</marko-web-native-x-fetch-elements>
|
|
36
|
+
</if>
|
|
37
|
+
<else>
|
|
38
|
+
$ warn('Unable to render NativeX placement: a uri and placement ID are required.');
|
|
39
|
+
<${input.renderBody} ...results />
|
|
40
|
+
</else>
|
|
41
|
+
</if>
|
|
42
|
+
<else>
|
|
43
|
+
<${input.renderBody} ...results />
|
|
44
|
+
</else>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-native-x$1.0.0/components/retrieve.marko",
|
|
6
|
+
marko_component = require("./retrieve.marko"),
|
|
7
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
+
module_utils_module = require("@mindful-web/marko-web/utils"),
|
|
9
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
10
|
+
defaultValue = module_utils_module.defaultValue,
|
|
11
|
+
module_utils_module2 = require("@mindful-web/utils"),
|
|
12
|
+
warn = module_utils_module2.warn,
|
|
13
|
+
module_convertAdToContent = require("../utils/convert-ad-to-content"),
|
|
14
|
+
convertAdToContent = module_convertAdToContent.default || module_convertAdToContent,
|
|
15
|
+
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
16
|
+
marko_web_native_x_fetch_elements_template = require("./fetch-elements.marko"),
|
|
17
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
18
|
+
marko_web_native_x_fetch_elements_tag = marko_loadTag(marko_web_native_x_fetch_elements_template);
|
|
19
|
+
|
|
20
|
+
function render(input, out, __component, component, state) {
|
|
21
|
+
var data = input;
|
|
22
|
+
|
|
23
|
+
const { uri, id, sectionName } = input;
|
|
24
|
+
|
|
25
|
+
const enabled = defaultValue(input.enabled, true);
|
|
26
|
+
|
|
27
|
+
const results = {
|
|
28
|
+
wasFound: false,
|
|
29
|
+
hasCampaign: false,
|
|
30
|
+
campaign: {},
|
|
31
|
+
containerAttrs: {},
|
|
32
|
+
linkAttrs: {},
|
|
33
|
+
response: {},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (enabled) {
|
|
37
|
+
if (uri && id) {
|
|
38
|
+
marko_web_native_x_fetch_elements_tag({
|
|
39
|
+
uri: uri,
|
|
40
|
+
id: id,
|
|
41
|
+
opts: input.opts,
|
|
42
|
+
renderBody: function(out, { ads }) {
|
|
43
|
+
const hasAd = ads && ads.length && ads[0];
|
|
44
|
+
|
|
45
|
+
if (hasAd) {
|
|
46
|
+
const ad = ads[0];
|
|
47
|
+
|
|
48
|
+
results.wasFound = true;
|
|
49
|
+
|
|
50
|
+
results.response = ad;
|
|
51
|
+
|
|
52
|
+
results.hasCampaign = ad.hasCampaign;
|
|
53
|
+
|
|
54
|
+
results.containerAttrs = ad.attributes.container;
|
|
55
|
+
|
|
56
|
+
results.linkAttrs = ad.attributes.link;
|
|
57
|
+
|
|
58
|
+
if (ad.hasCampaign) results.campaign = convertAdToContent(ad, { sectionName });
|
|
59
|
+
|
|
60
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
61
|
+
return results;
|
|
62
|
+
}, null, null, null, __component, "1");
|
|
63
|
+
} else {
|
|
64
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
65
|
+
return results;
|
|
66
|
+
}, null, null, null, __component, "2");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, out, __component, "0");
|
|
70
|
+
} else {
|
|
71
|
+
warn('Unable to render NativeX placement: a uri and placement ID are required.');
|
|
72
|
+
|
|
73
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
74
|
+
return results;
|
|
75
|
+
}, null, null, null, __component, "3");
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
79
|
+
return results;
|
|
80
|
+
}, null, null, null, __component, "4");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
marko_template._ = marko_renderer(render, {
|
|
85
|
+
e_: marko_componentType
|
|
86
|
+
}, marko_component);
|
|
87
|
+
|
|
88
|
+
marko_template.meta = {
|
|
89
|
+
id: "/@mindful-web/marko-web-native-x$1.0.0/components/retrieve.marko",
|
|
90
|
+
component: "./retrieve.marko",
|
|
91
|
+
tags: [
|
|
92
|
+
"./fetch-elements.marko"
|
|
93
|
+
]
|
|
94
|
+
};
|