diff --git a/exampleSite/layouts/partials/menu-footer.html b/exampleSite/layouts/partials/menu-footer.html index 40d77fe74b..a788036d49 100644 --- a/exampleSite/layouts/partials/menu-footer.html +++ b/exampleSite/layouts/partials/menu-footer.html @@ -14,8 +14,30 @@ margin: 0; } - Download - Star - Fork + +

Built with by Hugo

- \ No newline at end of file + + \ No newline at end of file diff --git a/exampleSite/static/js/buttons.js b/exampleSite/static/js/buttons.js deleted file mode 100644 index 7989f97707..0000000000 --- a/exampleSite/static/js/buttons.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * github-buttons v2.27.0 - * (c) 2023 なつき - * @license BSD-2-Clause - */ -!function(){"use strict";var o=window.document,e=o.location,t=window.Math,r=window.HTMLElement,a=window.XMLHttpRequest,n="github-button",i="https://buttons.github.io/buttons.html",c="github.com",l="https://api."+c,d=a&&"prototype"in a&&"withCredentials"in a.prototype,s=d&&r&&"attachShadow"in r.prototype&&!("prototype"in r.prototype.attachShadow),u=function(o,e){for(var t=0,r=o.length;t'}}},download:{heights:{16:{width:16,path:''}}},eye:{heights:{16:{width:16,path:''}}},heart:{heights:{16:{width:16,path:''}}},"issue-opened":{heights:{16:{width:16,path:''}}},"mark-github":{heights:{16:{width:16,path:''}}},package:{heights:{16:{width:16,path:''}}},play:{heights:{16:{width:16,path:''}}},"repo-forked":{heights:{16:{width:16,path:''}}},"repo-template":{heights:{16:{width:16,path:''}}},star:{heights:{16:{width:16,path:''}}}},Z=function(o,e){o=p(o).replace(/^octicon-/,""),b(M,o)||(o="mark-github");var t=e>=24&&24 in M[o].heights?24:16,r=M[o].heights[t];return'"},A={},F=function(o,e){var t=A[o]||(A[o]=[]);if(!(t.push(e)>1)){var r=g((function(){for(delete A[o];e=t.shift();)e.apply(null,arguments)}));if(d){var n=new a;m(n,"abort",r),m(n,"error",r),m(n,"load",(function(){var o;try{o=JSON.parse(this.responseText)}catch(o){return void r(o)}r(200!==this.status,o)})),n.open("GET",o),n.send()}else{var i=this||window;i._=function(o){i._=null,r(200!==o.meta.status,o.data)};var c=f(i.document)("script",{async:!0,src:o+(-1!==o.indexOf("?")?"&":"?")+"callback=_"}),l=function(){i._&&i._({meta:{}})};m(c,"load",l),m(c,"error",l),x(c,/de|m/,l),i.document.getElementsByTagName("head")[0].appendChild(c)}}},L=function(o,e,t){var r=f(o.ownerDocument),a=o.appendChild(r("style",{type:"text/css"})),n="body{margin:0}a{text-decoration:none;outline:0}.widget{display:inline-block;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;font-size:0;line-height:0;white-space:nowrap}.btn,.social-count{position:relative;display:inline-block;display:inline-flex;height:14px;padding:2px 5px;font-size:11px;font-weight:600;line-height:14px;vertical-align:bottom;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-repeat:repeat-x;background-position:-1px -1px;background-size:110% 110%;border:1px solid}.btn{border-radius:.25em}.btn:not(:last-child){border-radius:.25em 0 0 .25em}.social-count{border-left:0;border-radius:0 .25em .25em 0}.widget-lg .btn,.widget-lg .social-count{height:16px;padding:5px 10px;font-size:12px;line-height:16px}.octicon{display:inline-block;vertical-align:text-top;fill:currentColor;overflow:visible}"+function(o){if(null==o)return y.light;if(b(y,o))return y[o];var e=v(o,";",":",(function(o){return o.replace(/^[ \t\n\f\r]+|[ \t\n\f\r]+$/g,"")}));return y[b(y,e["no-preference"])?e["no-preference"]:"light"]+C("light",e.light)+C("dark",e.dark)}(e["data-color-scheme"]);a.styleSheet?a.styleSheet.cssText=n:a.appendChild(o.ownerDocument.createTextNode(n));var i="large"===p(e["data-size"]),d=r("a",{className:"btn",href:e.href,rel:"noopener",target:"_blank",title:e.title||void 0,"aria-label":e["aria-label"]||void 0,innerHTML:Z(e["data-icon"],i?16:14)+" "},[r("span",{},[e["data-text"]||""])]),s=o.appendChild(r("div",{className:"widget"+(i?" widget-lg":"")},[d])),u=d.hostname.replace(/\.$/,"");if(("."+u).substring(u.length-10)!=="."+c)return d.removeAttribute("href"),void t(s);var h=(" /"+d.pathname).split(/\/+/);if(((u===c||u==="gist."+c)&&"archive"===h[3]||u===c&&"releases"===h[3]&&("download"===h[4]||"latest"===h[4]&&"download"===h[5])||u==="codeload."+c)&&(d.target="_top"),"true"===p(e["data-show-count"])&&u===c&&"marketplace"!==h[1]&&"sponsors"!==h[1]&&"orgs"!==h[1]&&"users"!==h[1]&&"-"!==h[1]){var g,m;if(!h[2]&&h[1])m="followers",g="?tab=followers";else if(!h[3]&&h[2])m="stargazers_count",g="/stargazers";else if(h[4]||"subscription"!==h[3])if(h[4]||"fork"!==h[3]){if("issues"!==h[3])return void t(s);m="open_issues_count",g="/issues"}else m="forks_count",g="/forks";else m="subscribers_count",g="/watchers";var w=h[2]?"/repos/"+h[1]+"/"+h[2]:"/users/"+h[1];F.call(this,l+w,(function(o,e){if(!o){var a=e[m];s.appendChild(r("a",{className:"social-count",href:e.html_url+g,rel:"noopener",target:"_blank","aria-label":a+" "+m.replace(/_count$/,"").replace("_"," ").slice(0,a<2?-1:void 0)+" on GitHub"},[(""+a).replace(/\B(?=(\d{3})+(?!\d))/g,",")]))}t(s)}))}else t(s)},_=window.devicePixelRatio||1,E=function(o){return(_>1?t.ceil(t.round(o*_)/_*2)/2:t.ceil(o))||0},G=function(o,e){o.style.width=e[0]+"px",o.style.height=e[1]+"px"},T=function(e,r){if(null!=e&&null!=r)if(e.getAttribute&&(e=function(o){var e={href:o.href,title:o.title,"aria-label":o.getAttribute("aria-label")};return u(["icon","color-scheme","text","size","show-count"],(function(t){var r="data-"+t;e[r]=o.getAttribute(r)})),null==e["data-text"]&&(e["data-text"]=o.textContent||o.innerText),e}(e)),s){var a=h("span");L(a.attachShadow({mode:"closed"}),e,(function(){r(a)}))}else{var n=h("iframe",{src:"javascript:0",title:e.title||void 0,allowtransparency:!0,scrolling:"no",frameBorder:0});G(n,[0,0]),n.style.border="none";var c=function(){var a,l=n.contentWindow;try{a=l.document.body}catch(e){return void o.body.appendChild(n.parentNode.removeChild(n))}w(n,"load",c),L.call(l,a,e,(function(o){var a=function(o){var e=o.offsetWidth,r=o.offsetHeight;if(o.getBoundingClientRect){var a=o.getBoundingClientRect();e=t.max(e,E(a.width)),r=t.max(r,E(a.height))}return[e,r]}(o);n.parentNode.removeChild(n),k(n,"load",(function(){G(n,a)})),n.src=i+"#"+(n.name=function(o,e,t,r){null==e&&(e="&"),null==t&&(t="="),null==r&&(r=window.encodeURIComponent);var a=[];for(var n in o){var i=o[n];null!=i&&a.push(r(n)+t+r(i))}return a.join(e)}(e)),r(n)}))};m(n,"load",c),o.body.appendChild(n)}};e.protocol+"//"+e.host+e.pathname===i?L(o.body,v(window.name||e.hash.replace(/^#/,"")),(function(){})):function(e){if("complete"===o.readyState||"loading"!==o.readyState&&!o.documentElement.doScroll)setTimeout(e);else if(o.addEventListener){var t=g(e);k(o,"DOMContentLoaded",t),k(window,"load",t)}else x(o,/m/,e)}((function(){var e,t=o.querySelectorAll?o.querySelectorAll("a."+n):(e=[],u(o.getElementsByTagName("a"),(function(o){-1!==(" "+o.className+" ").replace(/[ \t\n\f\r]+/g," ").indexOf(" "+n+" ")&&e.push(o)})),e);u(t,(function(o){T(o,(function(e){o.parentNode.replaceChild(e,o)}))}))}))}(); diff --git a/exampleSite/static/js/github-buttons.js b/exampleSite/static/js/github-buttons.js new file mode 100644 index 0000000000..16dddbccee --- /dev/null +++ b/exampleSite/static/js/github-buttons.js @@ -0,0 +1,589 @@ +/*! + * github-buttons v2.27.0 + McShelby/hugo-theme-relearn#155 + - make render() available on window.githubButtons + * (c) 2023 なつき + * @license BSD-2-Clause + */ +(function () { + 'use strict'; + + var document = window.document; + + var location = document.location; + + var Math = window.Math; + + var HTMLElement = window.HTMLElement; + + var XMLHttpRequest = window.XMLHttpRequest; + + var buttonClass = 'github-button'; + + var iframeURL = 'https://' + (/* istanbul ignore next */ 'buttons.github.io') + '/buttons.html'; + + var domain = 'github.com'; + + var apiBaseURL = 'https://api.' + domain; + + var useXHR = XMLHttpRequest && 'prototype' in XMLHttpRequest && 'withCredentials' in XMLHttpRequest.prototype; + + var useShadowDOM = useXHR && HTMLElement && 'attachShadow' in HTMLElement.prototype && !('prototype' in HTMLElement.prototype.attachShadow); + + var forEach = function (obj, func) { + for (var i = 0, len = obj.length; i < len; i++) { + func(obj[i]); + } + }; + + var createElementInDocument = function (document) { + return function (tag, props, children) { + var el = document.createElement(tag); + if (props != null) { + for (var prop in props) { + var val = props[prop]; + if (val != null) { + if (el[prop] != null) { + el[prop] = val; + } else { + el.setAttribute(prop, val); + } + } + } + } + if (children != null) { + forEach(children, function (child) { + el.appendChild(typeof child === 'string' ? document.createTextNode(child) : child); + }); + } + return el + } + }; + + var createElement = createElementInDocument(document); + + var dispatchOnce = function (func) { + var onceToken; + return function () { + if (!onceToken) { + onceToken = 1; + func.apply(this, arguments); + } + } + }; + + var hasOwnProperty = function (obj, prop) { + return {}.hasOwnProperty.call(obj, prop) + }; + + var toLowerCase = function (obj) { + return ('' + obj).toLowerCase() + }; + + var stringify = function (obj, sep, eq, encodeURIComponent) { + if (sep == null) { + sep = '&'; + } + if (eq == null) { + eq = '='; + } + if (encodeURIComponent == null) { + encodeURIComponent = window.encodeURIComponent; + } + var params = []; + for (var name in obj) { + var value = obj[name]; + if (value != null) { + params.push(encodeURIComponent(name) + eq + encodeURIComponent(value)); + } + } + return params.join(sep) + }; + + var parse = function (str, sep, eq, decodeURIComponent) { + if (sep == null) { + sep = '&'; + } + if (eq == null) { + eq = '='; + } + if (decodeURIComponent == null) { + decodeURIComponent = window.decodeURIComponent; + } + var obj = {}; + forEach(str.split(sep), function (entry) { + if (entry !== '') { + var ref = entry.split(eq); + obj[decodeURIComponent(ref[0])] = (ref[1] != null ? decodeURIComponent(ref.slice(1).join(eq)) : undefined); + } + }); + return obj + }; + + var onEvent = function (target, eventName, func) { + /* istanbul ignore else: IE lt 9 */ + if (target.addEventListener) { + target.addEventListener(eventName, func, false); + } else { + target.attachEvent('on' + eventName, func); + } + }; + + var offEvent = function (target, eventName, func) { + /* istanbul ignore else: IE lt 9 */ + if (target.removeEventListener) { + target.removeEventListener(eventName, func, false); + } else { + target.detachEvent('on' + eventName, func); + } + }; + + var onceEvent = function (target, eventName, func) { + var callback = function () { + offEvent(target, eventName, callback); + return func.apply(this, arguments) + }; + onEvent(target, eventName, callback); + }; + + var onceReadyStateChange = /* istanbul ignore next: IE lt 9 */ function (target, regex, func) { + if (target.readyState != null) { + var eventName = 'readystatechange'; + var callback = function () { + if (regex.test(target.readyState)) { + offEvent(target, eventName, callback); + return func.apply(this, arguments) + } + }; + onEvent(target, eventName, callback); + } + }; + + var defer = /* istanbul ignore next */ function (func) { + if (document.readyState === 'complete' || (document.readyState !== 'loading' && !document.documentElement.doScroll)) { + setTimeout(func); + } else { + if (document.addEventListener) { + var callback = dispatchOnce(func); + onceEvent(document, 'DOMContentLoaded', callback); + onceEvent(window, 'load', callback); + } else { + onceReadyStateChange(document, /m/, func); + } + } + }; + + var buttonsCssText = "body{margin:0}a{text-decoration:none;outline:0}.widget{display:inline-block;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;font-size:0;line-height:0;white-space:nowrap}.btn,.social-count{position:relative;display:inline-block;display:inline-flex;height:14px;padding:2px 5px;font-size:11px;font-weight:600;line-height:14px;vertical-align:bottom;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-repeat:repeat-x;background-position:-1px -1px;background-size:110% 110%;border:1px solid}.btn{border-radius:.25em}.btn:not(:last-child){border-radius:.25em 0 0 .25em}.social-count{border-left:0;border-radius:0 .25em .25em 0}.widget-lg .btn,.widget-lg .social-count{height:16px;padding:5px 10px;font-size:12px;line-height:16px}.octicon{display:inline-block;vertical-align:text-top;fill:currentColor;overflow:visible}"; + + var light = ".btn:focus-visible,.social-count:focus-visible{outline:2px solid #0969da;outline-offset:-2px}.btn{color:#24292f;background-color:#ebf0f4;border-color:#ccd1d5;border-color:rgba(31,35,40,.15);background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg'%3e%3clinearGradient id='o' x2='0' y2='1'%3e%3cstop stop-color='%23f6f8fa'/%3e%3cstop offset='90%25' stop-color='%23ebf0f4'/%3e%3c/linearGradient%3e%3crect width='100%25' height='100%25' fill='url(%23o)'/%3e%3c/svg%3e\");background-image:-moz-linear-gradient(top, #f6f8fa, #ebf0f4 90%);background-image:linear-gradient(180deg, #f6f8fa, #ebf0f4 90%);filter:progid:DXImageTransform.Microsoft.Gradient(startColorstr='#FFF6F8FA', endColorstr='#FFEAEFF3')}:root .btn{filter:none}.btn:hover,.btn:focus{background-color:#e9ebef;background-position:0 -0.5em;border-color:#cbcdd1;border-color:rgba(31,35,40,.15);background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg'%3e%3clinearGradient id='o' x2='0' y2='1'%3e%3cstop stop-color='%23f3f4f6'/%3e%3cstop offset='90%25' stop-color='%23e9ebef'/%3e%3c/linearGradient%3e%3crect width='100%25' height='100%25' fill='url(%23o)'/%3e%3c/svg%3e\");background-image:-moz-linear-gradient(top, #f3f4f6, #e9ebef 90%);background-image:linear-gradient(180deg, #f3f4f6, #e9ebef 90%);filter:progid:DXImageTransform.Microsoft.Gradient(startColorstr='#FFF3F4F6', endColorstr='#FFE8EAEE')}:root .btn:hover,:root .btn:focus{filter:none}.btn:active{background-color:#e5e9ed;border-color:#c7cbcf;border-color:rgba(31,35,40,.15);background-image:none;filter:none}.social-count{color:#24292f;background-color:#fff;border-color:#dddedf;border-color:rgba(31,35,40,.15)}.social-count:hover,.social-count:focus{color:#0969da}.octicon-heart{color:#bf3989}"; + + var lightHighContrast = ".btn:focus-visible,.social-count:focus-visible{outline:2px solid #0349b4;outline-offset:-2px}.btn{color:#0e1116;background-color:#e7ecf0;border-color:#2f3237;border-color:rgba(1,4,9,.8);background-image:none;filter:none}.btn:hover,.btn:focus{background-color:#c4cdd5;background-position:0 -0.5em;border-color:#282c32;border-color:rgba(1,4,9,.8);background-image:none;filter:none}.btn:active{background-color:#d8dde1;border-color:#2c2f34;border-color:rgba(1,4,9,.8)}.social-count{color:#0e1116;background-color:#fff;border-color:#34363a;border-color:rgba(1,4,9,.8)}.social-count:hover,.social-count:focus{color:#0349b4}.octicon-heart{color:#971368}"; + + var dark = ".btn:focus-visible,.social-count:focus-visible{outline:2px solid #2f81f7;outline-offset:-2px}.btn{color:#c9d1d9;background-color:#1a1e23;border-color:#2f3439;border-color:rgba(240,246,252,.1);background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg'%3e%3clinearGradient id='o' x2='0' y2='1'%3e%3cstop stop-color='%2321262d'/%3e%3cstop offset='90%25' stop-color='%231a1e23'/%3e%3c/linearGradient%3e%3crect width='100%25' height='100%25' fill='url(%23o)'/%3e%3c/svg%3e\");background-image:-moz-linear-gradient(top, #21262d, #1a1e23 90%);background-image:linear-gradient(180deg, #21262d, #1a1e23 90%);filter:progid:DXImageTransform.Microsoft.Gradient(startColorstr='#FF21262D', endColorstr='#FF191D22')}:root .btn{filter:none}.btn:hover,.btn:focus{background-color:#292e33;background-position:0 -0.5em;border-color:#8b949e;background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg'%3e%3clinearGradient id='o' x2='0' y2='1'%3e%3cstop stop-color='%2330363d'/%3e%3cstop offset='90%25' stop-color='%23292e33'/%3e%3c/linearGradient%3e%3crect width='100%25' height='100%25' fill='url(%23o)'/%3e%3c/svg%3e\");background-image:-moz-linear-gradient(top, #30363d, #292e33 90%);background-image:linear-gradient(180deg, #30363d, #292e33 90%);filter:progid:DXImageTransform.Microsoft.Gradient(startColorstr='#FF30363D', endColorstr='#FF282D32')}:root .btn:hover,:root .btn:focus{filter:none}.btn:active{background-color:#161719;border-color:#8b949e;background-image:none;filter:none}.social-count{color:#c9d1d9;background-color:#0d1117;border-color:#24282e;border-color:rgba(240,246,252,.1)}.social-count:hover,.social-count:focus{color:#2f81f7}.octicon-heart{color:#db61a2}"; + + var darkDimmed = ".btn:focus-visible,.social-count:focus-visible{outline:2px solid #539bf5;outline-offset:-2px}.btn{color:#adbac7;background-color:#30363d;border-color:#40464e;border-color:rgba(205,217,229,.1);background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg'%3e%3clinearGradient id='o' x2='0' y2='1'%3e%3cstop stop-color='%23373e47'/%3e%3cstop offset='90%25' stop-color='%2330363d'/%3e%3c/linearGradient%3e%3crect width='100%25' height='100%25' fill='url(%23o)'/%3e%3c/svg%3e\");background-image:-moz-linear-gradient(top, #373e47, #30363d 90%);background-image:linear-gradient(180deg, #373e47, #30363d 90%);filter:progid:DXImageTransform.Microsoft.Gradient(startColorstr='#FF373E47', endColorstr='#FF2F353C')}:root .btn{filter:none}.btn:hover,.btn:focus{background-color:#3c444d;background-position:0 -0.5em;border-color:#768390;background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg'%3e%3clinearGradient id='o' x2='0' y2='1'%3e%3cstop stop-color='%23444c56'/%3e%3cstop offset='90%25' stop-color='%233c444d'/%3e%3c/linearGradient%3e%3crect width='100%25' height='100%25' fill='url(%23o)'/%3e%3c/svg%3e\");background-image:-moz-linear-gradient(top, #444c56, #3c444d 90%);background-image:linear-gradient(180deg, #444c56, #3c444d 90%);filter:progid:DXImageTransform.Microsoft.Gradient(startColorstr='#FF444C56', endColorstr='#FF3B434C')}:root .btn:hover,:root .btn:focus{filter:none}.btn:active{background-color:#2e3031;border-color:#768390;background-image:none;filter:none}.social-count{color:#adbac7;background-color:#22272e;border-color:#333940;border-color:rgba(205,217,229,.1)}.social-count:hover,.social-count:focus{color:#539bf5}.octicon-heart{color:#c96198}"; + + var darkHighContrast = ".btn:focus-visible,.social-count:focus-visible{outline:2px solid #71b7ff;outline-offset:-2px}.btn{color:#f0f3f6;background-color:#272b33;border-color:#7a828e;background-image:none;filter:none}.btn:hover,.btn:focus{background-color:#4a515b;background-position:0 -0.5em;border-color:#bdc4cc;background-image:none;filter:none}.btn:active{background-color:#1d1d1f;border-color:#bdc4cc}.social-count{color:#f0f3f6;background-color:#0a0c10;border-color:#7a828e}.social-count:hover,.social-count:focus{color:#71b7ff}.octicon-heart{color:#ef6eb1}"; + + var widgetColorSchemes = { + light: light, + light_high_contrast: lightHighContrast, + dark: dark, + dark_dimmed: darkDimmed, + dark_high_contrast: darkHighContrast + }; + + var getColorSchemeMediaQuery = function (systemColorScheme, widgetColorScheme) { + return '@media(prefers-color-scheme:' + systemColorScheme + '){' + widgetColorSchemes[hasOwnProperty(widgetColorSchemes, widgetColorScheme) ? widgetColorScheme : systemColorScheme] + '}' + }; + + var getColorScheme = function (declarations) { + if (declarations == null) { + return widgetColorSchemes.light + } + + if (hasOwnProperty(widgetColorSchemes, declarations)) { + return widgetColorSchemes[declarations] + } + + var colorSchemes = parse(declarations, ';', ':', function (str) { + return str.replace(/^[ \t\n\f\r]+|[ \t\n\f\r]+$/g, '') + }); + + return widgetColorSchemes[hasOwnProperty(widgetColorSchemes, colorSchemes['no-preference']) ? colorSchemes['no-preference'] : 'light'] + + getColorSchemeMediaQuery('light', colorSchemes.light) + + getColorSchemeMediaQuery('dark', colorSchemes.dark) + }; + + var data = { + "comment-discussion": { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + download: { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + eye: { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + heart: { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + "issue-opened": { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + "mark-github": { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + "package": { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + play: { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + "repo-forked": { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + "repo-template": { + heights: { + "16": { + width: 16, + path: "" + } + } + }, + star: { + heights: { + "16": { + width: 16, + path: "" + } + } + } + }; + + var octicon = function (icon, height) { + icon = toLowerCase(icon).replace(/^octicon-/, ''); + if (!hasOwnProperty(data, icon)) { + icon = 'mark-github'; + } + + var defaultHeight = height >= 24 && /* istanbul ignore next */ 24 in data[icon].heights ? /* istanbul ignore next */ 24 : 16; + + var svg = data[icon].heights[defaultHeight]; + + return '' + }; + + var queues = {}; + + var fetch = function (url, func) { + var queue = queues[url] || (queues[url] = []); + if (queue.push(func) > 1) { + return + } + + var callback = dispatchOnce(function () { + delete queues[url]; + while ((func = queue.shift())) { + func.apply(null, arguments); + } + }); + + if (useXHR) { + var xhr = new XMLHttpRequest(); + onEvent(xhr, 'abort', callback); + onEvent(xhr, 'error', callback); + onEvent(xhr, 'load', function () { + var data; + try { + data = JSON.parse(this.responseText); + } catch (error) { + callback(error); + return + } + callback(this.status !== 200, data); + }); + xhr.open('GET', url); + xhr.send(); + } else { + var contentWindow = this || window; + contentWindow._ = function (json) { + contentWindow._ = null; + callback(json.meta.status !== 200, json.data); + }; + var script = createElementInDocument(contentWindow.document)('script', { + async: true, + src: url + (url.indexOf('?') !== -1 ? '&' : '?') + 'callback=_' + }); + var onloadend = /* istanbul ignore next: IE lt 9 */ function () { + if (contentWindow._) { + contentWindow._({ + meta: {} + }); + } + }; + onEvent(script, 'load', onloadend); + onEvent(script, 'error', onloadend); + onceReadyStateChange(script, /de|m/, onloadend); + contentWindow.document.getElementsByTagName('head')[0].appendChild(script); + } + }; + + var render$1 = function (root, options, func) { + var createElement = createElementInDocument(root.ownerDocument); + + var style = root.appendChild(createElement('style', { + type: 'text/css' + })); + + var cssText = buttonsCssText + getColorScheme(options['data-color-scheme']); + + /* istanbul ignore if: IE lt 9 */ + if (style.styleSheet) { + style.styleSheet.cssText = cssText; + } else { + style.appendChild(root.ownerDocument.createTextNode(cssText)); + } + + var isLarge = toLowerCase(options['data-size']) === 'large'; + + var btn = createElement('a', { + className: 'btn', + href: options.href, + rel: 'noopener', + target: '_blank', + title: options.title || undefined, + 'aria-label': options['aria-label'] || undefined, + innerHTML: octicon(options['data-icon'], isLarge ? 16 : 14) + ' ' + }, [ + createElement('span', {}, [options['data-text'] || '']) + ]); + + var widget = root.appendChild(createElement('div', { + className: 'widget' + (isLarge ? ' widget-lg' : '') + }, [ + btn + ])); + + var hostname = btn.hostname.replace(/\.$/, ''); + if (('.' + hostname).substring(hostname.length - domain.length) !== ('.' + domain)) { + btn.removeAttribute('href'); + func(widget); + return + } + + var path = (' /' + btn.pathname).split(/\/+/); + if (((hostname === domain || hostname === 'gist.' + domain) && path[3] === 'archive') || + (hostname === domain && path[3] === 'releases' && (path[4] === 'download' || (path[4] === 'latest' && path[5] === 'download'))) || + (hostname === 'codeload.' + domain)) { + btn.target = '_top'; + } + + if (toLowerCase(options['data-show-count']) !== 'true' || + hostname !== domain || + path[1] === 'marketplace' || + path[1] === 'sponsors' || + path[1] === 'orgs' || + path[1] === 'users' || + path[1] === '-') { + func(widget); + return + } + + var href, property; + if (!path[2] && path[1]) { + property = 'followers'; + href = '?tab=followers'; + } else if (!path[3] && path[2]) { + property = 'stargazers_count'; + href = '/stargazers'; + } else if (!path[4] && path[3] === 'subscription') { + property = 'subscribers_count'; + href = '/watchers'; + } else if (!path[4] && path[3] === 'fork') { + property = 'forks_count'; + href = '/forks'; + } else if (path[3] === 'issues') { + property = 'open_issues_count'; + href = '/issues'; + } else { + func(widget); + return + } + + var api = path[2] ? '/repos/' + path[1] + '/' + path[2] : '/users/' + path[1]; + fetch.call(this, apiBaseURL + api, function (error, json) { + if (!error) { + var data = json[property]; + widget.appendChild(createElement('a', { + className: 'social-count', + href: json.html_url + href, + rel: 'noopener', + target: '_blank', + 'aria-label': data + ' ' + property.replace(/_count$/, '').replace('_', ' ').slice(0, data < 2 ? -1 : undefined) + ' on GitHub' + }, [ + ('' + data).replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ])); + } + func(widget); + }); + }; + + var parseOptions = function (anchor) { + var options = { + href: anchor.href, + title: anchor.title, + 'aria-label': anchor.getAttribute('aria-label') + }; + + forEach(['icon', 'color-scheme', 'text', 'size', 'show-count'], function (option) { + var attribute = 'data-' + option; + options[attribute] = anchor.getAttribute(attribute); + }); + + if (options['data-text'] == null) { + options['data-text'] = anchor.textContent || anchor.innerText; + } + + return options + }; + + var devicePixelRatio = window.devicePixelRatio || /* istanbul ignore next */ 1; + + var ceilPixel = function (px) { + return (devicePixelRatio > 1 ? Math.ceil(Math.round(px * devicePixelRatio) / devicePixelRatio * 2) / 2 : Math.ceil(px)) || 0 + }; + + var get = function (el) { + var width = el.offsetWidth; + var height = el.offsetHeight; + if (el.getBoundingClientRect) { + var boundingClientRect = el.getBoundingClientRect(); + width = Math.max(width, ceilPixel(boundingClientRect.width)); + height = Math.max(height, ceilPixel(boundingClientRect.height)); + } + return [width, height] + }; + + var set = function (el, size) { + el.style.width = size[0] + 'px'; + el.style.height = size[1] + 'px'; + }; + + var render = function (options, func) { + if (options == null || func == null) { + return + } + if (options.getAttribute) { + options = parseOptions(options); + } + if (useShadowDOM) { + var host = createElement('span'); + render$1(host.attachShadow({ mode: 'closed' }), options, function () { + func(host); + }); + } else { + var iframe = createElement('iframe', { + src: 'javascript:0', + title: options.title || undefined, + allowtransparency: true, + scrolling: 'no', + frameBorder: 0 + }); + set(iframe, [0, 0]); + iframe.style.border = 'none'; + var callback = function () { + var contentWindow = iframe.contentWindow; + var body; + try { + body = contentWindow.document.body; + } catch (_) /* istanbul ignore next: IE 11 */ { + document.body.appendChild(iframe.parentNode.removeChild(iframe)); + return + } + offEvent(iframe, 'load', callback); + render$1.call(contentWindow, body, options, function (widget) { + var size = get(widget); + iframe.parentNode.removeChild(iframe); + onceEvent(iframe, 'load', function () { + set(iframe, size); + }); + iframe.src = iframeURL + '#' + (iframe.name = stringify(options)); + func(iframe); + }); + }; + onEvent(iframe, 'load', callback); + document.body.appendChild(iframe); + } + }; + + if (location.protocol + '//' + location.host + location.pathname === iframeURL) { + render$1(document.body, parse(window.name || location.hash.replace(/^#/, '')), function () {}); + } else { + defer(function () { + var anchors = document.querySelectorAll + ? document.querySelectorAll('a.' + buttonClass) + : (function () { + var results = []; + forEach(document.getElementsByTagName('a'), function (a) { + if ((' ' + a.className + ' ').replace(/[ \t\n\f\r]+/g, ' ').indexOf(' ' + buttonClass + ' ') !== -1) { + results.push(a); + } + }); + return results + })(); + forEach(anchors, function (anchor) { + render(anchor, function (el) { + anchor.parentNode.replaceChild(el, anchor); + }); + }); + }); + } + + window.githubButtons = { render: render }; +})();