From b28c8aaa767c9f3a2c63734156837ff5d3746013 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Wed, 11 Oct 2023 08:09:47 +0200 Subject: [PATCH] Fix Star/Fork button sometimes not showing [why] The Star and Fork buttons sometime show nicely, sometimes they are just plain linked tect with no count and no icon and nothing. [how] The reason is not completely clear, sometimes it works and without any change after a complete reload it does not work anymore. The most likely candidate is the Github rate limit that we run into for cross repo access. To avoid that we just copy the button script into our repository. The rate limit will now not apply anymore. But of course we will also not get any updates. That needs to be checked from time to time manually - as with the Github actions. Strange is already that the current script from github.io is version 2.27.0 while the latest release on the repo is 4.2.2. The date is the same (Dec 2022). Signed-off-by: Fini Jastrow --- _includes/header.html | 2 +- _includes/scripts.html | 4 ++-- buttons.js | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 buttons.js diff --git a/_includes/header.html b/_includes/header.html index 8a66d09d8..c8c0fb656 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -25,4 +25,4 @@ }); {% endif %} - \ No newline at end of file + diff --git a/_includes/scripts.html b/_includes/scripts.html index 9943f0def..11288ee85 100644 --- a/_includes/scripts.html +++ b/_includes/scripts.html @@ -1,4 +1,4 @@ - + \ No newline at end of file + diff --git a/buttons.js b/buttons.js new file mode 100644 index 000000000..3e2427534 --- /dev/null +++ b/buttons.js @@ -0,0 +1,6 @@ +/*! + * 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-c.length)!=="."+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)}))}))}))}();