Skip to content

Commit

Permalink
Add rcmwidget ads extension (#33888)
Browse files Browse the repository at this point in the history
  • Loading branch information
yulya9060 authored Apr 27, 2021
1 parent 472bac3 commit 9803959
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 0 deletions.
1 change: 1 addition & 0 deletions 3p/integration-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const AMP_EMBED_ALLOWED = {
pubexchange: true,
pulse: true,
rbinfox: true,
rcmwidget: true,
readmo: true,
recreativ: true,
runative: true,
Expand Down
2 changes: 2 additions & 0 deletions 3p/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ import {purch} from '../ads/vendors/purch';
import {quoraad} from '../ads/vendors/quoraad';
import {rakutenunifiedads} from '../ads/vendors/rakutenunifiedads';
import {rbinfox} from '../ads/vendors/rbinfox';
import {rcmwidget} from '../ads/vendors/rcmwidget';
import {readmo} from '../ads/vendors/readmo';
import {realclick} from '../ads/vendors/realclick';
import {recomad} from '../ads/vendors/recomad';
Expand Down Expand Up @@ -504,6 +505,7 @@ register('purch', purch);
register('quoraad', quoraad);
register('rakutenunifiedads', rakutenunifiedads);
register('rbinfox', rbinfox);
register('rcmwidget', rcmwidget);
register('readmo', readmo);
register('realclick', realclick);
register('reddit', reddit);
Expand Down
28 changes: 28 additions & 0 deletions 3p/vendors/rcmwidget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2021 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// src/polyfills.js must be the first import.
import '../polyfills';

import {draw3p, init} from '../integration-lib';
import {register} from '../3p';

import {rcmwidget} from '../../ads/vendors/rcmwidget';

init(window);
register('rcmwidget', rcmwidget);

window.draw3p = draw3p;
5 changes: 5 additions & 0 deletions ads/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,11 @@ const adConfig = jsonConfiguration({
renderStartImplemented: true,
},

'rcmwidget': {
prefetch: 'https://rcmjs.rambler.ru/static/rcmw/rcmw-amp.js',
renderStartImplemented: true,
},

'readmo': {
renderStartImplemented: true,
},
Expand Down
49 changes: 49 additions & 0 deletions ads/vendors/rcmwidget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright 2021 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {loadScript, validateData} from '../../3p/3p';

const WIDGET_DEFAULT_NODE_ID = 'rcm-widget';

/**
* @param {!Window} global
* @param {!Object} data
*/
export function rcmwidget(global, data) {
validateData(
data,
['rcmId', 'nodeId', 'blockId', 'templateName', 'projectId'],
['contextItemId']
);

global.rcmWidgetInit = data;

createContainer(global, data.nodeId);

// load the rcmwidget initializer asynchronously
loadScript(global, 'https://rcmjs.rambler.ru/static/rcmw/rcmw-amp.js');
}

/**
* @param {!Window} global
* @param {string} nodeId
*/
function createContainer(global, nodeId = WIDGET_DEFAULT_NODE_ID) {
const container = global.document.createElement('div');
container.id = nodeId;

global.document.getElementById('c').appendChild(container);
}
31 changes: 31 additions & 0 deletions ads/vendors/rcmwidget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!---
Copyright 2021 The AMP HTML Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Rcmwidget

## Example

```html
<amp-embed width="auto" height="300" type="rcmwidget"></amp-embed>
```

### Required parameters

- `data-rcm-id`
- `data-node-id`
- `data-block-id`
- `data-template-name`
- `data-project-id`
9 changes: 9 additions & 0 deletions examples/amp-ad/ads.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
<option>purch</option>
<option>rakutenunifiedads</option>
<option>rbinfox</option>
<option>rcmwidget</option>
<option>readmo</option>
<option>realclick</option>
<option>recomad</option>
Expand Down Expand Up @@ -1652,6 +1653,14 @@ <h2>RbInfox</h2>
<amp-embed width="240" height="400" type="rbinfox" src="https://rb.infox.sg/infox/503">
</amp-embed>

<h2>RcmWidget</h2>
<amp-embed
width="auto"
height="500"
type="rcmwidget"
>
</amp-embed>

<h2>ReadMo</h2>
<amp-embed width="400" height="400" type="readmo" layout="responsive"
heights="(min-width: 1200px) 50%, (min-width: 780px) 60%, (max-width: 480px) 180%, 100%" data-section="amp-test"
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-ad/amp-ad.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ See [amp-ad rules](validator-amp-ad.protoascii) in the AMP validator specificati
- [Rakuten Unified Ads](../../ads/vendors/rakutenunifiedads.md)
- [Rambler&Co](../../ads/vendors/capirs.md)
- [RbInfoxSg](../../ads/vendors/rbinfox.md)
- [Rcmwidget](../../ads/vendors/rcmwidget.md)
- [Realclick](../../ads/vendors/realclick.md)
- [recomAD](../../ads/vendors/recomad.md)
- [recreativ](../../ads/vendors/recreativ.md)
Expand Down

0 comments on commit 9803959

Please sign in to comment.