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
Provenance
- Commit
f4818b2- Tree
1a3582f- Author
Kenneth Reitz <me@kennethreitz.org>- Committer
Kenneth Reitz <me@kennethreitz.org>- Parent
33b41c7
5 files changed+222 added−1 removed
added:docs/_static/native.js+131 added
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+12 added
12345678910111213141516171850 unmodified lines<!-- Alabaster (krTheme++) Hacks -->
<script src="{{ pathto('_static/', 1) }}/native.js"></script><script src="https://codepen.io/sayzlim/pen/geOONP.js" type="text/javascript"></script>
<script> _native.init("CK7D62JU", { targetClass: 'native-js', display: 'flex', visibleClass: 'native-show' });</script>
<!-- CSS Adjustments (I'm very picky.) --><style type="text/css">
/* Rezzy requires precise alignment. */50 unmodified linesmodified:docs/_templates/sidebarintro.html+39 added
67 unmodified lines686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911067 unmodified lines <li><a href="http://pt.python-requests.org/">Portuguese</a></li> <li><a href="http://it.python-requests.org/">Italian</a></li> <li><a href="http://es.python-requests.org/">Spanish</a></li></ul>
<div class="native-js"> <div class="native-sponsor">Sponsored by #native_company# — Learn More</div> <a href="#native_link#" class="native-flex"> <style> .native-js { background: linear-gradient(-30deg, #native_bg_color#E5, #native_bg_color#E5 45%, #native_bg_color# 45%) #fff; }
.native-details, .native-sponsor, .native-bsa { color: #native_color# !important; }
.native-details:hover { color: #native_color_hover# !important; }
.native-cta { color: #native_cta_color#; background-color: #native_cta_bg_color#; }
.native-cta:hover { color: #native_cta_color_hover; background-color: #native_cta_bg_color_hover#; } </style> <div class="native-main"> <img class="native-img" src="#native_logo#"> <div class="native-details"> <span class="native-company">#native_title#</span> <span class="native-desc">#native_desc#</span> </div> </div> <span class="native-cta">#native_cta#</span> </a></div>modified:docs/_templates/sidebarlogo.html+39 added
61 unmodified lines62 <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>66+67+<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+ }74+75+ .native-details,76+ .native-sponsor,77+ .native-bsa {78+ color: #native_color# !important;79+ }80+81+ .native-details:hover {82+ color: #native_color_hover# !important;83+ }84+85+ .native-cta {86+ color: #native_cta_color#;87+ background-color: #native_cta_bg_color#;88+ }89+90+ .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 lines82 83 Requests is one of the most downloaded Python packages of all time, pulling in84 over 400,000 downloads **each day**. Join the party!85 86-If your organization uses Requests internally, consider `supporting the development of 3.0 <https://www.kennethreitz.org/requests3>`_. Your86+If your organization uses Requests internally, consider `supporting the development of 3.0 <http://docs.python-requests.org/en/master/community/sponsors/>`_. Your87 generosity will be greatly appreciated, and help drive the project forward88 into the future.89 90 Beloved Features86 unmodified lines