Fix double image request
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Use official framework for the "custom" ad design integration.
authored by Sayz Lim · committed by Sayz Lim · parent c9309e4 · Browse files · 4 files·+59 added−224 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+59 added−224 removed
- other:+59 added−224 removed
Provenance
- Commit
5add08f- Tree
b567f5a- Author
Sayz Lim <talk@sayzlim.net>- Committer
Sayz Lim <talk@sayzlim.net>- Parent
c9309e4
4 files changed+59 added−224 removed
modified:docs/_static/custom.css+20 added-25 removed
48 unmodified lines4950515253545556575853545556575859606162636465666566676869707172737475676869707111 unmodified lines83848586958788899091929394103959697989910010110211011111211310310410510616 unmodified lines12312412512612712812913013115 unmodified lines14714814915015115215315415515615715815916016116216316416516616717617716816917017117217317417517617748 unmodified lines
/* Native CPC by BuySellAds */
.native-js { visibility: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif; opacity: 0;#native-ribbon #_custom_ { position: fixed; right: 0; bottom: 0; left: 0; box-shadow: 0 -1px 4px 1px hsla(0, 0%, 0%, .15); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif; transition: all .25s ease-in-out; transform: translateY(calc(100% - 35px));
flex-flow: column nowrap;}
.native-js[data-state=visible] { position: fixed; bottom: 0; left: 0; right: 0; visibility: visible; box-shadow: 0 -1px 4px 1px hsla(0, 0%, 0%, .15); opacity: 1;}
.native-js[data-state=visible]:hover {#native-ribbon #_custom_:hover { transform: translateY(0);}
.native-img {11 unmodified lines transition: all .3s ease-in-out; transform-origin: left;}
.native-js[data-state=visible]:hover .native-sponsor {#native-ribbon #_custom_:hover .native-sponsor { margin: 0 20px; opacity: 0; transform: scaleY(0);}
.native-flex { display: flex; padding: 0 20px 30px; padding: 10px 20px 25px; text-decoration: none;
flex-flow: row nowrap; justify-content: center; align-items: center;}
.native-flex:hover { text-decoration: none;}
.native-main { display: flex;
flex-flow: row nowrap;16 unmodified lines
.native-desc { letter-spacing: 1px; font-weight: 300; font-size: 14px; line-height: 1.4;}
.native-cta {15 unmodified lines}
@media only screen and (min-width: 320px) and (max-width: 759px) { .native-flex { padding: 5px 5px 15px; flex-direction: column;
flex-wrap: wrap; }
.native-img { margin: 0; display: none; }
.native-details { margin: 0; }
.native-main { flex-direction: column; margin-bottom: 20px; text-align: center; text-align: left;
flex-wrap: wrap; align-content: center; }
.native-cta { display: none; }}deleted:docs/_static/native.js-131 removed
1-var _native = (function () {2- var _options = {}3- var _construct = function (e) {4- var defaultOptions = {5- carbonZoneKey: '',6- fallback: '',7- ignore: 'false',8- placement: '',9- prefix: 'native',10- targetClass: 'native-ad'11- }12-13- if (typeof e === 'undefined') return defaultOptions14- Object.keys(defaultOptions).forEach((key, index) => {15- if (typeof e[key] === 'undefined') {16- e[key] = defaultOptions[key]17- }18- })19- return e20- }21-22- var init = function (zone, options) {23- _options = _construct(options)24-25- let jsonUrl = `https://srv.buysellads.com/ads/${zone}.json?callback=_native_go`26- if (_options['placement'] !== '') {27- jsonUrl += '&segment=placement:' + _options['placement']28- }29- if (_options['ignore'] === 'true') {30- jsonUrl += '&ignore=yes'31- }32-33- let srv = document.createElement('script')34- srv.src = jsonUrl35- document.getElementsByTagName('head')[0].appendChild(srv)36- }37-38- var carbon = function (e) {39- let srv = document.createElement('script')40- srv.src = '//cdn.carbonads.com/carbon.js?serve=' + e['carbonZoneKey'] + '&placement=' + e['placement']41- srv.id = '_carbonads_js'42-43- return srv44- }45-46- var sanitize = function (ads) {47- return ads48- .filter(ad => {49- return Object.keys(ad).length > 050- })51- .filter(ad => {52- return ad.hasOwnProperty('statlink')53- })54- }55-56- var pixel = function (p, timestamp) {57- let c = ''58- if (p) {59- p.split('||').forEach((pixel, index) => {60- c += `<img src="${pixel.replace('[timestamp]', timestamp)}" style="display:none;" height="0" width="0" />`61- })62- }63- return c64- }65-66- var options = function () {67- return _options68- }69-70- return {71- carbon: carbon,72- init: init,73- options: options,74- pixel: pixel,75- sanitize: sanitize76- }77-})({})78-79-var _native_go = function (json) {80- let options = _native.options()81- let ads = _native.sanitize(json['ads'])82- let selectedClass = document.querySelectorAll('.' + options['targetClass'])83-84- if (ads.length < 1) {85- selectedClass.forEach((className, index) => {86- let selectedTarget = document.getElementsByClassName(options['targetClass'])[index]87-88- if (options['fallback'] !== '' || options['carbonZoneKey'] !== '') selectedTarget.setAttribute('data-state', 'visible')89- selectedTarget.innerHTML = options['fallback']90- if (options['carbonZoneKey'] !== '') selectedTarget.appendChild(_native.carbon(options))91- })92-93- // End at this line if no ads are found, avoiding unnecessary steps94- return95- }96-97- selectedClass.forEach((className, index) => {98- let selectedTarget = document.getElementsByClassName(options['targetClass'])[index]99- let adElement = selectedTarget.innerHTML100- let prefix = options['prefix']101- let ad = ads[index]102-103- if (ad && className) {104- let adInnerHtml = adElement105- .replace(new RegExp('#' + prefix + '_bg_color#', 'g'), ad['backgroundColor'])106- .replace(new RegExp('#' + prefix + '_bg_color_hover#', 'g'), ad['backgroundHoverColor'])107- .replace(new RegExp('#' + prefix + '_company#', 'g'), ad['company'])108- .replace(new RegExp('#' + prefix + '_cta#', 'g'), ad['callToAction'])109- .replace(new RegExp('#' + prefix + '_cta_bg_color#', 'g'), ad['ctaBackgroundColor'])110- .replace(new RegExp('#' + prefix + '_cta_bg_color_hover#', 'g'), ad['ctaBackgroundHoverColor'])111- .replace(new RegExp('#' + prefix + '_cta_color#', 'g'), ad['ctaTextColor'])112- .replace(new RegExp('#' + prefix + '_cta_color_hover#', 'g'), ad['ctaTextColorHover'])113- .replace(new RegExp('#' + prefix + '_desc#', 'g'), ad['description'])114- .replace(new RegExp('#' + prefix + '_index#', 'g'), prefix + '-' + ad['i'])115- .replace(new RegExp('#' + prefix + '_img#', 'g'), ad['image'])116- .replace(new RegExp('#' + prefix + '_small_img#', 'g'), ad['smallImage'])117- .replace(new RegExp('#' + prefix + '_link#', 'g'), ad['statlink'])118- .replace(new RegExp('#' + prefix + '_logo#', 'g'), ad['logo'])119- .replace(new RegExp('#' + prefix + '_color#', 'g'), ad['textColor'])120- .replace(new RegExp('#' + prefix + '_color_hover#', 'g'), ad['textColorHover'])121- .replace(new RegExp('#' + prefix + '_title#', 'g'), ad['title'])122-123- selectedTarget.innerHTML = null124- selectedTarget.innerHTML += adInnerHtml + _native.pixel(ad['pixel'], ad['timestamp'])125- selectedTarget.setAttribute('data-state', 'visible')126- } else {127- selectedTarget.innerHTML = null128- selectedTarget.style.display = 'none'129- }130- })131-}modified:docs/_templates/hacks.html+38 added-31 removed
55 unmodified lines56 <!-- That was not a hack. That was art. -->57 58 <!-- Native CPC by BuySellAds -->59 60-<script src="{{ pathto('_static/', 1) }}/native.js"></script>61-<script>62- _native.init("CK7D62JU", {63- targetClass: 'native-js'64- });65-</script>60+<script type="text/javascript" src="//m.servedby-buysellads.com/monetization.js"></script>61 67-<div class="native-js">68- <div class="native-sponsor">Sponsored Ad by #native_company# — Learn More</div>69- <a href="#native_link#" class="native-flex">62+<div id="native-ribbon">63+</div>64+65+<script>66+_bsa.init('custom', 'CK7D62JU', 'placement:pythonrequestsorg',67+ {68+ target: '#native-ribbon',69+ template: `70+<div class="native-sponsor">Sponsored by ##company## — Learn More</div>71+ <a href="##link##" class="native-flex">72 <style>71- .native-js {72- background: linear-gradient(-30deg, #native_bg_color#E5, #native_bg_color#E5 45%, #native_bg_color# 45%) #fff;73- }73+ #native-ribbon #_custom_ {74+ background: linear-gradient(-30deg, ##backgroundColor##E5, ##backgroundColor##E5 45%, ##backgroundColor## 45%) #fff;75+ }76 75- .native-details,76- .native-sponsor {77- color: #native_color# !important;78- }77+ .native-details,78+ .native-sponsor,79+ .native-bsa {80+ color: ##textColor## !important;81+ }82 80- .native-details:hover {81- color: #native_color_hover# !important;82- }83+ .native-details:hover {84+ color: ##textColorHover## !important;85+ }86 84- .native-cta {85- color: #native_cta_color#;86- background-color: #native_cta_bg_color#;87- }87+ .native-cta {88+ color: ##ctaTextColor##;89+ background-color: ##ctaBackgroundColor##;90+ }91 89- .native-cta:hover {90- color: #native_cta_color_hover;91- background-color: #native_cta_bg_color_hover#;92- }92+ .native-cta:hover {93+ color: ##ctaTextColorHover##;94+ background-color: ##ctaBackgroundColorHover##;95+ }96 </style>97 <div class="native-main">95- <img class="native-img" src="#native_logo#">98+ <img class="native-img" src="##logo##">99 <div class="native-details">97- <span class="native-company">#native_title#</span>98- <span class="native-desc">#native_desc#</span>100+ <span class="native-company">##title##</span>101+ <span class="native-desc">##description##</span>102 </div>100- <span class="native-cta">#native_cta#</span>103 </div>104+ <span class="native-cta">##callToAction##</span>105 </a>106 </div>107+`108+ }109+ );110+</script>modified:docs/_templates/sidebarintro.html+1 added-37 removed
67 unmodified lines68 <li><a href="http://it.python-requests.org/">Italian</a></li>69 <li><a href="http://es.python-requests.org/">Spanish</a></li>70 </ul>71 72-<div class="native-js">73- <div class="native-sponsor">Sponsored by #native_company# — Learn More</div>74- <a href="#native_link#" class="native-flex">75- <style>76- .native-js {77- background: linear-gradient(-30deg, #native_bg_color#E5, #native_bg_color#E5 45%, #native_bg_color# 45%) #fff;78- }79-80- .native-details,81- .native-sponsor,82- .native-bsa {83- color: #native_color# !important;84- }85-86- .native-details:hover {87- color: #native_color_hover# !important;88- }89-90- .native-cta {91- color: #native_cta_color#;92- background-color: #native_cta_bg_color#;93- }94-95- .native-cta:hover {96- color: #native_cta_color_hover;97- background-color: #native_cta_bg_color_hover#;98- }99- </style>100- <div class="native-main">101- <img class="native-img" src="#native_logo#">102- <div class="native-details">103- <span class="native-company">#native_title#</span>104- <span class="native-desc">#native_desc#</span>105- </div>106- </div>107- <span class="native-cta">#native_cta#</span>108- </a>72+<div id="native-ribbon">73 </div>