Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨Add RnetPlus ad exchange support to amp-ad #22024

Merged
merged 3 commits into from Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions 3p/integration.js
Expand Up @@ -215,6 +215,7 @@ import {relap} from '../ads/relap';
import {revcontent} from '../ads/revcontent';
import {revjet} from '../ads/revjet';
import {rfp} from '../ads/rfp';
import {rnetplus} from '../ads/rnetplus';
import {rubicon} from '../ads/rubicon';
import {runative} from '../ads/runative';
import {sas} from '../ads/sas';
Expand Down Expand Up @@ -459,6 +460,7 @@ register('relap', relap);
register('revcontent', revcontent);
register('revjet', revjet);
register('rfp', rfp);
register('rnetplus', rnetplus);
register('rubicon', rubicon);
register('runative', runative);
register('sas', sas);
Expand Down
2 changes: 2 additions & 0 deletions ads/_config.js
Expand Up @@ -838,6 +838,8 @@ export const adConfig = {
renderStartImplemented: true,
},

'rnetplus': {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, preload/prefetch are popular options here if you know your creative will be requesting a certain file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, but from the technical manner we have JSONP request and it cannot be precached. The images and other stuff are relied to server response and we cannot prefetch it too... Anyway I'll review code to think if we still have something to declare, thank you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.


'rubicon': {},

'runative': {
Expand Down
57 changes: 57 additions & 0 deletions ads/rnetplus.js
@@ -0,0 +1,57 @@
/**
* Copyright 2015 The AMP HTML Authors. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2019

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

*
* 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, validateSrcPrefix} from '../3p/3p';

const jsnPrefix = 'https://api.rnet.plus/';

/**
* @param {!Window} global
* @param {!Object} data
*/
export function rnetplus(global, data) {
validateData(data, ['src']);
const {src} = data;
validateSrcPrefix(jsnPrefix, src);
createContainer(global, 'rnetplus_' + getBlockId(src));
loadScript(global, src);
}

/**
* @param {!Window} global
* @param {string} renderTo
*/
function createContainer(global, renderTo) {
const d = global.document.createElement('div');
d.id = renderTo;
global.document.getElementById('c').appendChild(d);
}

/**
* @param {string} src
* @return {string}
*/
function getBlockId(src) {
const parts = src.split('?');
const vars = parts[1].split('&');
for (let j = 0; j < vars.length; ++j) {
const pair = vars[j].split('=');
if (pair[0] == 'blockId') {
return pair[1];
}
}
return '660';
}
36 changes: 36 additions & 0 deletions ads/rnetplus.md
@@ -0,0 +1,36 @@
<!---
Copyright 2017 The AMP HTML Authors. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2019

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


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.
-->

# RnetPlus

Provides support for [rnetplus](https://admin.rnet.plus/help/) Rambler&Co RNetPlus.

## Example

```html
<amp-ad width="250" height="250"
type="rnetplus"
src="https://api.rnet.plus/Scripts/rnet_amp_embed.js?blockId=660">
</amp-ad>
```

## Configuration

For details on the configuration semantics, please contact [Rambler](https://admin.rnet.plus/).

### Required parameters

- `src`
8 changes: 8 additions & 0 deletions examples/ads.amp.html
Expand Up @@ -199,6 +199,7 @@
<option>revcontent</option>
<option>revjet</option>
<option>rfp</option>
<option>rnetplus</option>
<option>rubicon</option>
<option>runative</option>
<option>sas</option>
Expand Down Expand Up @@ -1580,6 +1581,13 @@ <h2>Rambler&Co</h2>
json='{"params":{"p1":"bvpkq","p2":"y","pct":"a"}}'>
</amp-ad>

<h2>Rambler&Co RNetPlus</h2>
<amp-ad width="300" height="400"
type="rnetplus"
layout="responsive"
src="https://api.rnet.plus/Scripts/rnet_amp_embed.js?blockId=660">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is up to you but you may want to hardcode this url, and have the block-id be a separate attribute? May be less likely for your users to break.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it is little bit corporate specific, I am sorry.

In few words, without RNetPlus team, you have no chances to place certain block to your pages with desired content; the empty blocks displays nothing. So, from the other side of this tube, somebody need to collect couple of teasers to display and assign to the particular block.

As result, RNetPlus Team is always involved into embedding the teasers and it provides the code snippets to place teasers for AMP case and for casual web cases.

It means the exact form is not important.

But if the form will be important for somebody I able to redesign this piece, thank you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM.

</amp-ad>

<h2>RbInfox</h2>
<amp-embed width="240" height="400"
type="rbinfox"
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-ad/amp-ad.md
Expand Up @@ -341,6 +341,7 @@ See [amp-ad rules](https://github.com/ampproject/amphtml/blob/master/extensions/
- [Relap](../../ads/relap.md)
- [Revcontent](../../ads/revcontent.md)
- [RevJet](../../ads/revjet.md)
- [rnetplus](../../ads/rnetplus.md)
- [Rubicon Project](../../ads/rubicon.md)
- [RUNative](../../ads/runative.md)
- [SAS CI 360 Match](../../ads/sas.md)
Expand Down