From 41d406d1d0f45db9447cc3ae92ad8900ea8df6b9 Mon Sep 17 00:00:00 2001 From: protonate Date: Mon, 10 Oct 2016 07:45:54 -0700 Subject: [PATCH 1/9] and postMessage listener and handler --- src/prebid.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/prebid.js b/src/prebid.js index 5ee59e25ad8..90c0ca4d84e 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -517,6 +517,35 @@ $$PREBID_GLOBAL$$.clearAuction = function() { } }; +var sendAdToCreative = function (ev) { + var key = ev.message ? "message" : "data"; + var data = {}; + try { + data = JSON.parse(ev[key]); + } catch (e) { + // Do nothing. No ad found. + } + if (data.adId) { + var adObject = $$PREBID_GLOBAL$$._bidsReceived.find(function (bid) { + return bid.adId === data.adId; + }); + var ad = adObject.ad; + var adUrl = adObject.adUrl; + var message = JSON.stringify({ + message: 'send ad', + ad: ad, + adUrl: adUrl + }); + ev.source.postMessage(message, 'https://amp.prebidapp.com:5000'); + + // document.getElementsByTagName('iframe')[0].contentWindow.postMessage(message, 'https://prebid.org'); + } +}; + +var listenAdRequestFromCreative = function () { + addEventListener('message', sendAdToCreative, false); +}; + /** * * @param bidsBackHandler @@ -571,6 +600,7 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a } adaptermanager.callBids({ adUnits, adUnitCodes, cbTimeout }); + listenAdRequestFromCreative(); }; /** From 657604c89d167c48d0e8fb496de83a86f0ee945f Mon Sep 17 00:00:00 2001 From: protonate Date: Mon, 10 Oct 2016 22:22:19 -0700 Subject: [PATCH 2/9] edit to sandbox domain --- src/prebid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prebid.js b/src/prebid.js index 90c0ca4d84e..99edc4bad30 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -536,7 +536,7 @@ var sendAdToCreative = function (ev) { ad: ad, adUrl: adUrl }); - ev.source.postMessage(message, 'https://amp.prebidapp.com:5000'); + ev.source.postMessage(message, 'https://securepubads.g.doubleclick.net'); // document.getElementsByTagName('iframe')[0].contentWindow.postMessage(message, 'https://prebid.org'); } From b0d81b168733cae3ad8bf3ecda84bdc0b4c066cb Mon Sep 17 00:00:00 2001 From: protonate Date: Mon, 10 Oct 2016 23:55:27 -0700 Subject: [PATCH 3/9] update postMessage domain --- src/prebid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prebid.js b/src/prebid.js index 99edc4bad30..90c0ca4d84e 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -536,7 +536,7 @@ var sendAdToCreative = function (ev) { ad: ad, adUrl: adUrl }); - ev.source.postMessage(message, 'https://securepubads.g.doubleclick.net'); + ev.source.postMessage(message, 'https://amp.prebidapp.com:5000'); // document.getElementsByTagName('iframe')[0].contentWindow.postMessage(message, 'https://prebid.org'); } From b78ac77267f5925485e45fadeac00334224cb0bb Mon Sep 17 00:00:00 2001 From: protonate Date: Tue, 11 Oct 2016 00:28:16 -0700 Subject: [PATCH 4/9] update postMessage domain --- src/prebid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prebid.js b/src/prebid.js index 90c0ca4d84e..99edc4bad30 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -536,7 +536,7 @@ var sendAdToCreative = function (ev) { ad: ad, adUrl: adUrl }); - ev.source.postMessage(message, 'https://amp.prebidapp.com:5000'); + ev.source.postMessage(message, 'https://securepubads.g.doubleclick.net'); // document.getElementsByTagName('iframe')[0].contentWindow.postMessage(message, 'https://prebid.org'); } From 787fb462be0f2905432a2095bf4994b6e5d0d807 Mon Sep 17 00:00:00 2001 From: protonate Date: Tue, 11 Oct 2016 12:31:04 -0700 Subject: [PATCH 5/9] work on render second ad bug --- src/prebid.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/prebid.js b/src/prebid.js index 99edc4bad30..97d7c76bd1f 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -526,17 +526,18 @@ var sendAdToCreative = function (ev) { // Do nothing. No ad found. } if (data.adId) { + console.log('sendAdToCreative ev: ', ev); var adObject = $$PREBID_GLOBAL$$._bidsReceived.find(function (bid) { return bid.adId === data.adId; }); var ad = adObject.ad; var adUrl = adObject.adUrl; var message = JSON.stringify({ - message: 'send ad', + message: 'send ad ' + data.adID, ad: ad, adUrl: adUrl }); - ev.source.postMessage(message, 'https://securepubads.g.doubleclick.net'); + ev.source.postMessage(message, '*'); // document.getElementsByTagName('iframe')[0].contentWindow.postMessage(message, 'https://prebid.org'); } From 4011153190d9efeecd0dc2b58357234fbdd497a4 Mon Sep 17 00:00:00 2001 From: protonate Date: Sat, 29 Oct 2016 23:24:09 -0700 Subject: [PATCH 6/9] rollback changes to match master --- src/prebid.js | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/src/prebid.js b/src/prebid.js index 97d7c76bd1f..5ee59e25ad8 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -517,36 +517,6 @@ $$PREBID_GLOBAL$$.clearAuction = function() { } }; -var sendAdToCreative = function (ev) { - var key = ev.message ? "message" : "data"; - var data = {}; - try { - data = JSON.parse(ev[key]); - } catch (e) { - // Do nothing. No ad found. - } - if (data.adId) { - console.log('sendAdToCreative ev: ', ev); - var adObject = $$PREBID_GLOBAL$$._bidsReceived.find(function (bid) { - return bid.adId === data.adId; - }); - var ad = adObject.ad; - var adUrl = adObject.adUrl; - var message = JSON.stringify({ - message: 'send ad ' + data.adID, - ad: ad, - adUrl: adUrl - }); - ev.source.postMessage(message, '*'); - - // document.getElementsByTagName('iframe')[0].contentWindow.postMessage(message, 'https://prebid.org'); - } -}; - -var listenAdRequestFromCreative = function () { - addEventListener('message', sendAdToCreative, false); -}; - /** * * @param bidsBackHandler @@ -601,7 +571,6 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a } adaptermanager.callBids({ adUnits, adUnitCodes, cbTimeout }); - listenAdRequestFromCreative(); }; /** From 2a4284f907e82853bab023e4abbf9ac1fafd5683 Mon Sep 17 00:00:00 2001 From: protonate Date: Sun, 30 Oct 2016 00:05:54 -0700 Subject: [PATCH 7/9] add AMP example --- integrationExamples/gpt/amp/amp_page.html | 59 ++++++ integrationExamples/gpt/amp/creative.html | 38 ++++ integrationExamples/gpt/amp/gulpfile.js | 12 ++ integrationExamples/gpt/amp/remote.html | 207 ++++++++++++++++++++++ 4 files changed, 316 insertions(+) create mode 100644 integrationExamples/gpt/amp/amp_page.html create mode 100644 integrationExamples/gpt/amp/creative.html create mode 100644 integrationExamples/gpt/amp/gulpfile.js create mode 100644 integrationExamples/gpt/amp/remote.html diff --git a/integrationExamples/gpt/amp/amp_page.html b/integrationExamples/gpt/amp/amp_page.html new file mode 100644 index 00000000000..027e83e4ca4 --- /dev/null +++ b/integrationExamples/gpt/amp/amp_page.html @@ -0,0 +1,59 @@ + + + + + + Hello, AMPs + + + + + + + + + +

Welcome to the mobile web

+ + + + + + + +
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquam ac orci vitae cursus. + Nulla rutrum egestas felis ut bibendum. Maecenas blandit tellus eu turpis posuere condimentum sit amet eget eros. Donec sollicitudin sit amet enim ut ultricies. Nunc semper enim a dignissim convallis. Vestibulum faucibus eget ante non pellentesque. Maecenas convallis consectetur dolor, non facilisis felis interdum id. Cras ac leo et massa facilisis porttitor ut vitae dolor. Phasellus odio felis, pharetra vel sem vitae, ultricies ornare sapien. In sodales semper ultricies. + +Suspendisse potenti. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Integer tempus rutrum libero, sit amet finibus sapien rutrum sed. Vestibulum accumsan turpis vel est cursus vulputate. Nam id risus ligula. Praesent metus elit, iaculis sit amet egestas id, interdum id nibh. Nullam egestas tempor lorem at consectetur. Fusce sit amet mattis massa, id semper elit. Mauris blandit lectus a orci lobortis malesuada. + +Donec id turpis quam. Morbi fringilla justo nisi, et mattis nibh laoreet non. Aliquam orci eros, tincidunt a feugiat id, gravida ut nisl. Morbi et arcu facilisis, congue mauris ut, ultricies ligula. Vivamus vulputate est non facilisis iaculis. Phasellus quis auctor odio. Nulla facilisi. Sed convallis feugiat erat, sit amet tincidunt justo bibendum ut. Sed maximus justo sit amet pharetra tincidunt. Vivamus laoreet nisi vel est feugiat, sed egestas ante congue. + +Nunc ultricies sodales dolor eget semper. Phasellus ac ligula ac mi fermentum ornare sed et lacus. Curabitur ante enim, maximus ac lacus in, hendrerit mollis enim. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas posuere nisl ac nisl sagittis faucibus. Quisque pellentesque vehicula lectus, ac malesuada dui mollis pulvinar. Nam in lectus placerat eros feugiat dictum ut vel quam. Etiam magna mauris, euismod in felis sodales, interdum ultricies nisl. Nunc elit mi, pellentesque vel est nec, tempus dignissim purus. Praesent pharetra, odio ut cursus dictum, erat felis gravida lorem, at pretium justo dolor quis odio. Mauris tincidunt accumsan mi, gravida condimentum enim vulputate at. Phasellus pretium hendrerit commodo. Quisque blandit rhoncus erat, sed tincidunt dolor rutrum et. + +Nunc nec condimentum mauris, vel porta sem. Donec finibus sapien lacus, quis faucibus neque lobortis non. Nam faucibus nunc odio. Aliquam dolor nisl, placerat sed ipsum quis, facilisis sollicitudin nisi. Nullam sed ultrices enim. Ut sollicitudin mi dignissim, faucibus massa in, pellentesque velit. Donec auctor vel libero in posuere. Ut venenatis odio nec euismod egestas. Nunc posuere pretium sapien finibus sagittis. Nunc volutpat ante eget eleifend consequat. Donec sed quam sit amet quam venenatis pulvinar. Nullam in ex id magna pellentesque tempus. +
+ + diff --git a/integrationExamples/gpt/amp/creative.html b/integrationExamples/gpt/amp/creative.html new file mode 100644 index 00000000000..e62d7791477 --- /dev/null +++ b/integrationExamples/gpt/amp/creative.html @@ -0,0 +1,38 @@ + + + diff --git a/integrationExamples/gpt/amp/gulpfile.js b/integrationExamples/gpt/amp/gulpfile.js new file mode 100644 index 00000000000..47338182473 --- /dev/null +++ b/integrationExamples/gpt/amp/gulpfile.js @@ -0,0 +1,12 @@ +var gulp = require('gulp'); +var connect = require('gulp-connect'); +var port = 5000; + +gulp.task('serve', function() { + connect.server({ + port: port, + root: './', + livereload: true, + https: true + }); +}); diff --git a/integrationExamples/gpt/amp/remote.html b/integrationExamples/gpt/amp/remote.html new file mode 100644 index 00000000000..a74f86bda43 --- /dev/null +++ b/integrationExamples/gpt/amp/remote.html @@ -0,0 +1,207 @@ + + + + + + + + + +
+ +
+ + + + From 086fe6cb95f4e306eee3337cd197f7b5dd7a39cb Mon Sep 17 00:00:00 2001 From: protonate Date: Tue, 1 Nov 2016 00:44:43 -0700 Subject: [PATCH 8/9] updates to address review notes --- integrationExamples/gpt/amp/gulpfile.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/integrationExamples/gpt/amp/gulpfile.js b/integrationExamples/gpt/amp/gulpfile.js index 47338182473..30dae86bb0a 100644 --- a/integrationExamples/gpt/amp/gulpfile.js +++ b/integrationExamples/gpt/amp/gulpfile.js @@ -1,3 +1,8 @@ +/** Run `gulp serve` to serve files from this directory in development + * Set two different entries in hosts to use x-domain iframes + * AMP requires https + */ + var gulp = require('gulp'); var connect = require('gulp-connect'); var port = 5000; From d1ddd97834c6dc71e658fa832c3c0dd305b830c5 Mon Sep 17 00:00:00 2001 From: protonate Date: Tue, 1 Nov 2016 00:46:10 -0700 Subject: [PATCH 9/9] updates to address review notes --- integrationExamples/gpt/amp/amp_page.html | 28 +++- integrationExamples/gpt/amp/remote.html | 166 +++++++++++----------- 2 files changed, 105 insertions(+), 89 deletions(-) diff --git a/integrationExamples/gpt/amp/amp_page.html b/integrationExamples/gpt/amp/amp_page.html index 027e83e4ca4..995b23174bf 100644 --- a/integrationExamples/gpt/amp/amp_page.html +++ b/integrationExamples/gpt/amp/amp_page.html @@ -2,14 +2,36 @@ Hello, AMPs - + + + + + + +