Skip to content
Myr

updates to docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 33b41c7 · Browse files · 5 files+222 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+222 added−1 removed

  • other:+222 added−1 removed

5 files+222 added−1 removed

added:docs/_static/native.js+131 added
1var _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 }1213 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 }2122 var init = function (zone, options) {23 _options = _construct(options)2425 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 }3233 let srv = document.createElement('script')34 srv.src = jsonUrl35 document.getElementsByTagName('head')[0].appendChild(srv)36 }3738 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'4243 return srv44 }4546 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 }5556 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 }6566 var options = function () {67 return _options68 }6970 return {71 carbon: carbon,72 init: init,73 options: options,74 pixel: pixel,75 sanitize: sanitize76 }77})({})7879var _native_go = function (json) {80 let options = _native.options()81 let ads = _native.sanitize(json['ads'])82 let selectedClass = document.querySelectorAll('.' + options['targetClass'])8384 if (ads.length < 1) {85 selectedClass.forEach((className, index) => {86 let selectedTarget = document.getElementsByClassName(options['targetClass'])[index]8788 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 })9293 // End at this line if no ads are found, avoiding unnecessary steps94 return95 }9697 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]102103 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'])122123 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+12 added
modified:docs/_templates/sidebarintro.html+39 added
modified:docs/_templates/sidebarlogo.html+39 added
61 unmodified lines
62 <li><a href="http://pt.python-requests.org/">Portuguese</a></li>63 <li><a href="http://it.python-requests.org/">Italian</a></li>64 <li><a href="http://es.python-requests.org/">Spanish</a></li>65</ul>6667<div class="native-js">68 <div class="native-sponsor">Sponsored by #native_company# — Learn More</div>69 <a href="#native_link#" class="native-flex">70 <style>71 .native-js {72 background: linear-gradient(-30deg, #native_bg_color#E5, #native_bg_color#E5 45%, #native_bg_color# 45%) #fff;73 }7475 .native-details,76 .native-sponsor,77 .native-bsa {78 color: #native_color# !important;79 }8081 .native-details:hover {82 color: #native_color_hover# !important;83 }8485 .native-cta {86 color: #native_cta_color#;87 background-color: #native_cta_bg_color#;88 }8990 .native-cta:hover {91 color: #native_cta_color_hover;92 background-color: #native_cta_bg_color_hover#;93 }94 </style>95 <div class="native-main">96 <img class="native-img" src="#native_logo#">97 <div class="native-details">98 <span class="native-company">#native_title#</span>99 <span class="native-desc">#native_desc#</span>100 </div>101 </div>102 <span class="native-cta">#native_cta#</span>103 </a>104</div>
modified:docs/index.rst+1 added-1 removed
81 unmodified lines
8283Requests is one of the most downloaded Python packages of all time, pulling in84over 400,000 downloads **each day**. Join the party!8586If your organization uses Requests internally, consider `supporting the development of 3.0 <https://www.kennethreitz.org/requests3>`_. Your86If your organization uses Requests internally, consider `supporting the development of 3.0 <http://docs.python-requests.org/en/master/community/sponsors/>`_. Your87generosity will be greatly appreciated, and help drive the project forward88into the future.8990Beloved Features
86 unmodified lines