Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/prebid/Prebid.js
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/prebid/Prebid.js: (43 commits)
  Merge Prebid 1.0 to Master (prebid#1936)
  Prebid.js 0.34.1 release
  Vertamedia adapter outstream support (prebid#1860)
  Expose native image-type asset dimensions on bid response object (prebid#1919)
  Remove for of (prebid#1932)
  Unit-test fix (prebid#1927)
  Remove description_url (prebid#1922)
  Trion Interactive Adapter Bugfix (prebid#1925)
  Remove config setting from Optimatic adapter (prebid#1909)
  IE bug fix (prebid#1930)
  Clarify ad unit media filtering warning (prebid#1903)
  Add ReadPeak Bid Adapter (prebid#1838)
  Change clone function to make deep copies (prebid#1910)
  Serverbid 1.0 (prebid#1802)
  sekindoUM for prebid1.0 (prebid#1777)
  update auctionId to be requestId (prebid#1896)
  bug fixed to populate userSync default values (prebid#1897)
  Increment pre version
  AdkernelAdn analytics adapter (prebid#1868)
  Justpremium Adapter: use `filter` instead of `...new Set` (prebid#1895)
  ...
  • Loading branch information
m.sorochuk committed Dec 8, 2017
2 parents f878902 + 377c4c2 commit 4273734
Show file tree
Hide file tree
Showing 246 changed files with 10,148 additions and 34,534 deletions.
6 changes: 5 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"presets": ["es2015"],
"plugins": ["transform-object-assign", "transform-es3-property-literals", "transform-es3-member-expression-literals"]
"plugins": [
"transform-object-assign",
"transform-es3-property-literals",
"transform-es3-member-expression-literals"
]
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ To run the unit tests:
```bash
gulp test
```
To run tests for a single file:

```bash
gulp test --file "path/to/spec/file.js"
```

To generate and view the code coverage reports:

Expand Down
18 changes: 15 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var gulpif = require('gulp-if');
var sourcemaps = require('gulp-sourcemaps');
var through = require('through2');
var fs = require('fs');
var jsEscape = require('gulp-js-escape');

var prebid = require('./package.json');
var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10);
Expand Down Expand Up @@ -296,10 +297,21 @@ gulp.task('e2etest-report', function() {
}, 5000);
});

gulp.task('build-postbid', function() {
// This task creates postbid.js. Postbid setup is different from prebid.js
// More info can be found here http://prebid.org/overview/what-is-post-bid.html
gulp.task('build-postbid', ['escape-postbid-config'], function() {
var fileContent = fs.readFileSync('./build/postbid/postbid-config.js', 'utf8');

return gulp.src('./integrationExamples/postbid/oas/postbid.js')
.pipe(uglify())
.pipe(gulp.dest('build/dist'));
.pipe(replace('\[%%postbid%%\]', fileContent))
.pipe(gulp.dest('build/postbid/'));
});

// Dependant task for building postbid. It escapes postbid-config file.
gulp.task('escape-postbid-config', function() {
gulp.src('./integrationExamples/postbid/oas/postbid-config.js')
.pipe(jsEscape())
.pipe(gulp.dest('build/postbid/'));
});

module.exports = nodeBundle;
170 changes: 85 additions & 85 deletions integrationExamples/gpt/hello_world.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,91 +12,91 @@
-->

<html>
<head>
<script>
var PREBID_TIMEOUT = 700;

var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
sizes: [[300, 250], [300,600]],

// Replace this object to test a new Adapter!
bids: [{
bidder: 'appnexus',
params: {
placementId: '10433394'
}
}]

}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

</script>

<script type="text/javascript" src="../../build/dev/prebid.js" async></script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest
});
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
<head>
<script>
var PREBID_TIMEOUT = 700;

var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
sizes: [[300, 250], [300,600]],

// Replace this object to test a new Adapter!
bids: [{
bidder: 'appnexusAst',
params: {
placementId: '10433394'
}
}]

}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

</script>

<script type="text/javascript" src="../../build/dev/prebid.js" async></script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest
});
});
}

setTimeout(function() {
sendAdserverRequest();
}, PREBID_TIMEOUT);

</script>

<script>
(function () {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
</script>

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
</body>
</html>

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

setTimeout(function() {
sendAdserverRequest();
}, PREBID_TIMEOUT);

</script>

<script>
(function () {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
</script>

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
</body>
</html>
54 changes: 54 additions & 0 deletions integrationExamples/postbid/oas/postbid-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script type="text/javascript">
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

(function() {
var pbjsEl = document.createElement("script"); pbjsEl.type = "text/javascript";
pbjsEl.async = true; var isHttps = 'https:' === document.location.protocol;
pbjsEl.src = (isHttps ? "https" : "http") + "://acdn.adnxs.com/prebid/not-for-prod/prebid.js";
var pbjsTargetEl = document.getElementsByTagName("head")[0];
pbjsTargetEl.insertBefore(pbjsEl, pbjsTargetEl.firstChild);
})();

pbjs.que.push(function() {
var adUnits = [{
code: '[%%adUnitCode%%]',
sizes: [%%sizes%%],
bids: [%%adUnitBids%%]
}];
pbjs.addAdUnits(adUnits);

pbjs.requestBids({
timeout: [%%timeout%%],
bidsBackHandler: function() {
var iframe = document.getElementById('postbid_if_3');
var iframeDoc = iframe.contentWindow.document;
var params = pbjs.getAdserverTargetingForAdUnitCode('[%%adUnitCode%%]');

// If any bidders return any creatives
var bid;
if(params && params['hb_adid']){
var bid;
for(i=0; i< pbjs._bidsReceived.length; i++ ) {
if (params['hb_adid'] === pbjs._bidsReceived[i].adId) {
bid = pbjs._bidsReceived[i];
break;
}
}
pbjs.renderAd(iframeDoc, params['hb_adid']);
} else {
// If no bidder return any creatives,
// Passback 3rd party tag in Javascript
iframe.width = [%%size0%%];
iframe.height = [%%size1%%];
iframeDoc.write('[%%passbackTagHtml%%]');
}

var iframeResize = window.parent.document.getElementById('[%%targetId%%]');
iframeResize.height = (bid.height) ? bid.height+'px' : '[%%size1%%]px';
iframeResize.width = (bid.width) ? bid.width+'px' : '[%%size0%%]px';
}
});
});
</script>
<iframe id='postbid_if_3' FRAMEBORDER="0" SCROLLING="no" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0" ALLOWTRANSPARENCY="true" WIDTH="0" HEIGHT="0"></iframe>
19 changes: 18 additions & 1 deletion integrationExamples/postbid/oas/postbid.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
(function(window){
var postbid = {};
postbid.que = [];
Expand Down Expand Up @@ -100,7 +101,22 @@
}

postbid.que.push(function(conf) {
var content = "\n <script type=\"text/javascript\">\n if (!Array.prototype.find) {\n Object.defineProperty(Array.prototype, 'find', {\n value: function(predicate) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n var o = Object(this);\n var len = o.length >>> 0;\n if (typeof predicate !== 'function') {\n throw new TypeError('predicate must be a function');\n }\n var thisArg = arguments[1];\n var k = 0;\n while (k < len) {\n var kValue = o[k];\n if (predicate.call(thisArg, kValue, k, o)) {\n return kValue;\n }\n k++;\n }\n return undefined;\n }\n });\n }\n\n var pbjs = pbjs || {};\n pbjs.que = pbjs.que || [];\n\n (function() {\n var pbjsEl = document.createElement(\"script\"); pbjsEl.type = \"text/javascript\";\n pbjsEl.async = true; var isHttps = 'https:' === document.location.protocol;\n pbjsEl.src = (isHttps ? \"https\" : \"http\") + \"://acdn.adnxs.com/prebid/not-for-prod/prebid.js\";\n var pbjsTargetEl = document.getElementsByTagName(\"head\")[0];\n pbjsTargetEl.insertBefore(pbjsEl, pbjsTargetEl.firstChild);\n })();\n\n pbjs.que.push(function() {\n var adUnits = [{\n code: '" + conf.adUnitCode + "',\n sizes: " + conf.adUnitSizes + ",\n bids: " + conf.adUnitBids + "\n }];\n\n pbjs.addAdUnits(adUnits);\n\n pbjs.requestBids({\n timeout: " + conf.timout + ",\n bidsBackHandler: function() {\n var iframe = document.getElementById('postbid_if_3');\n\n var iframeDoc = iframe.contentWindow.document;\n\n var params = pbjs.getAdserverTargetingForAdUnitCode('" + conf.adUnitCode + "');\n\n // If any bidders return any creatives\n var bid;\n if(params && params['hb_adid']){\n bid = pbjs._bidsReceived.find(function(bid) {\n return bid.adId === params['hb_adid'];\n });\n pbjs.renderAd(iframeDoc, params['hb_adid']);\n } else {\n // If no bidder return any creatives,\n // Passback 3rd party tag in Javascript\n\n iframe.width = '" + conf.adUnitSizes[0] + "';\n iframe.height = '" + conf.adUnitSizes[1] + "';\n\n iframeDoc.write('" + conf.passbackTagHtml + "');\n }\n\n var iframeResize = window.parent.document.getElementById('" + conf.targetId + "');\n iframeResize.height = (bid.height) ? bid.height+'px' : '" + conf.adUnitSizes[1] + "px';\n iframeResize.width = (bid.width) ? bid.width+'px' : '" + conf.adUnitSizes[0] + "px';\n }\n });\n });\n <"+ '' +"/script>\n <iframe id='postbid_if_3' FRAMEBORDER=\"0\" SCROLLING=\"no\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" ALLOWTRANSPARENCY=\"true\" WIDTH=\"0\" HEIGHT=\"0\"></iframe>";
var sizes = JSON.parse(conf.adUnitSizes);
var timeout = conf.timeout;
var adUnitCode = conf.adUnitCode;
var adUnitBids = conf.adUnitBids;
var targetId = conf.targetId;
var passbackTagHtml = conf.passbackTagHtml;

var content = [%%postbid%%];
content = content.replace(/\[%%targetId%%\]/g, targetId);
content = content.replace(/\[%%adUnitCode%%\]/g, adUnitCode);
content = content.replace(/\[%%timeout%%\]/g, timeout);
content = content.replace(/\[%%adUnitBids%%\]/g, adUnitBids);
content = content.replace(/\[%%passbackTagHtml%%\]/g, passbackTagHtml);
content = content.replace(/\[%%sizes%%\]/g, conf.adUnitSizes);
content = content.replace(/\[%%size0%%\]/g, sizes[0]);
content = content.replace(/\[%%size1%%\]/g, sizes[1]);

var iframe = createIframe(conf.targetId);
var div = document.getElementById(conf.divId);
Expand All @@ -116,3 +132,4 @@
window.processQue = processQue;

})(window);
/* eslint-enable */
Loading

0 comments on commit 4273734

Please sign in to comment.