Skip to content

Commit c1b21e8

Browse files
committed
update
1 parent 1eb0e2e commit c1b21e8

File tree

89 files changed

+95983
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+95983
-37
lines changed

package.json

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11
{
2-
"name": "github-readme-stats",
3-
"version": "1.0.0",
4-
"description": "Dynamically generate stats for your github readmes",
5-
"main": "index.js",
6-
"scripts": {
7-
"test": "jest --coverage",
8-
"test:watch": "jest --watch",
9-
"theme-readme-gen": "node scripts/generate-theme-doc",
10-
"preview-theme": "node scripts/preview-theme"
11-
},
12-
"author": "Anurag Hazra",
13-
"license": "MIT",
14-
"devDependencies": {
15-
"@actions/core": "^1.2.4",
16-
"@actions/github": "^4.0.0",
17-
"@testing-library/dom": "^7.20.0",
18-
"@testing-library/jest-dom": "^5.11.0",
19-
"axios": "^0.19.2",
20-
"axios-mock-adapter": "^1.18.1",
21-
"css-to-object": "^1.1.0",
22-
"husky": "^4.2.5",
23-
"jest": "^26.1.0",
24-
"parse-diff": "^0.7.0"
25-
},
26-
"dependencies": {
27-
"dotenv": "^8.2.0",
28-
"emoji-name-map": "^1.2.8",
29-
"github-username-regex": "^1.0.0",
30-
"prettier": "^2.1.2",
31-
"web-dev-utils": "^1.0.4",
32-
"word-wrap": "^1.2.3"
33-
},
34-
"husky": {
35-
"hooks": {
36-
"pre-commit": "npm test"
2+
"name": "github-readme-stats",
3+
"version": "1.0.0",
4+
"description": "my version of the https://github.com/anuraghazra/github-readme-stats generate stats for your github readmes",
5+
"main": "index.js",
6+
"scripts": {
7+
8+
"theme-readme-gen": "node scripts/generate-theme-doc",
9+
"preview-theme": "node scripts/preview-theme"
10+
},
11+
"author": "Bryan Guner",
12+
"license": "MIT",
13+
"devDependencies": {
14+
"@actions/core": "^1.2.4",
15+
"@actions/github": "^4.0.0",
16+
"@testing-library/dom": "^7.20.0",
17+
"@testing-library/jest-dom": "^5.11.0",
18+
"axios": "^0.19.2",
19+
"axios-mock-adapter": "^1.18.1",
20+
"css-to-object": "^1.1.0",
21+
"husky": "^4.2.5",
22+
"jest": "^26.1.0",
23+
"parse-diff": "^0.7.0",
24+
"web-dev-utils": "^1.0.4"
25+
},
26+
"dependencies": {
27+
"dotenv": "^8.2.0",
28+
"emoji-name-map": "^1.2.8",
29+
"github-username-regex": "^1.0.0",
30+
"prettier": "^2.1.2",
31+
"word-wrap": "^1.2.3"
32+
},
33+
"husky": {
34+
"hooks": {
35+
"pre-commit": "npm test"
36+
}
3737
}
38-
}
39-
}
38+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
body {
2+
background: linear-gradient(-45deg, #da0000, #0008ffe5, #23d5a2d8, #2f2fbce5);
3+
background-size: 400% 400%;
4+
-webkit-animation: gradient 15s ease infinite;
5+
animation: gradient 15s ease infinite;
6+
}
7+
8+
@-webkit-keyframes gradient {
9+
0% {
10+
background-position: 0% 50%;
11+
}
12+
50% {
13+
background-position: 100% 50%;
14+
}
15+
100% {
16+
background-position: 0% 50%;
17+
}
18+
}
19+
20+
@keyframes gradient {
21+
0% {
22+
background-position: 0% 50%;
23+
}
24+
50% {
25+
background-position: 100% 50%;
26+
}
27+
100% {
28+
background-position: 0% 50%;
29+
}
30+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
(() => {
2+
3+
const previewForm = document.getElementById('previewform');
4+
5+
const url = location.search.substring(1).replace(/\/\/github\.com/, '//raw.githubusercontent.com').replace(/\/blob\//, '/'); //Get URL of the raw file
6+
7+
const replaceAssets = () => {
8+
let frame;
9+
let a;
10+
let link;
11+
const links = [];
12+
let script;
13+
const scripts = [];
14+
let i;
15+
let href;
16+
let src;
17+
//Framesets
18+
if (document.querySelectorAll('frameset').length)
19+
return; //Don't replace CSS/JS if it's a frameset, because it will be erased by document.write()
20+
//Frames
21+
frame = document.querySelectorAll('iframe[src],frame[src]');
22+
for (i = 0; i < frame.length; ++i) {
23+
src = frame[i].src; //Get absolute URL
24+
if (src.indexOf('//raw.githubusercontent.com') > 0 || src.indexOf('//bitbucket.org') > 0) { //Check if it's from raw.github.com or bitbucket.org
25+
frame[i].src = '//' + location.hostname + location.pathname + '?' + src; //Then rewrite URL so it can be loaded using CORS proxy
26+
}
27+
}
28+
//Links
29+
a = document.querySelectorAll('a[href]');
30+
for (i = 0; i < a.length; ++i) {
31+
href = a[i].href; //Get absolute URL
32+
if (href.indexOf('#') > 0) { //Check if it's an anchor
33+
a[i].href = '//' + location.hostname + location.pathname + location.search + '#' + a[i].hash.substring(1); //Then rewrite URL with support for empty anchor
34+
} else if ((href.indexOf('//raw.githubusercontent.com') > 0 || href.indexOf('//bitbucket.org') > 0) && (href.indexOf('.html') > 0 || href.indexOf('.htm') > 0)) { //Check if it's from raw.github.com or bitbucket.org and to HTML files
35+
a[i].href = '//' + location.hostname + location.pathname + '?' + href; //Then rewrite URL so it can be loaded using CORS proxy
36+
}
37+
}
38+
//Stylesheets
39+
link = document.querySelectorAll('link[rel=stylesheet]');
40+
for (i = 0; i < link.length; ++i) {
41+
href = link[i].href; //Get absolute URL
42+
if (href.indexOf('//raw.githubusercontent.com') > 0 || href.indexOf('//bitbucket.org') > 0) { //Check if it's from raw.github.com or bitbucket.org
43+
links.push(fetchProxy(href, null, 0)); //Then add it to links queue and fetch using CORS proxy
44+
}
45+
}
46+
Promise.all(links).then(res => {
47+
for (i = 0; i < res.length; ++i) {
48+
loadCSS(res[i]);
49+
}
50+
});
51+
//Scripts
52+
script = document.querySelectorAll('script[type="text/htmlpreview"]');
53+
for (i = 0; i < script.length; ++i) {
54+
src = script[i].src; //Get absolute URL
55+
if (src.indexOf('//raw.githubusercontent.com') > 0 || src.indexOf('//bitbucket.org') > 0) { //Check if it's from raw.github.com or bitbucket.org
56+
scripts.push(fetchProxy(src, null, 0)); //Then add it to scripts queue and fetch using CORS proxy
57+
} else {
58+
script[i].removeAttribute('type');
59+
scripts.push(script[i].innerHTML); //Add inline script to queue to eval in order
60+
}
61+
}
62+
Promise.all(scripts).then(res => {
63+
for (i = 0; i < res.length; ++i) {
64+
loadJS(res[i]);
65+
}
66+
document.dispatchEvent(new Event('DOMContentLoaded', {bubbles: true, cancelable: true})); //Dispatch DOMContentLoaded event after loading all scripts
67+
});
68+
};
69+
70+
const loadHTML = data => {
71+
if (data) {
72+
data = data.replace(/<head([^>]*)>/i, '<head$1><base href="' + url + '">').replace(/<script(\s*src=["'][^"']*["'])?(\s*type=["'](text|application)\/javascript["'])?/gi, '<script type="text/htmlpreview"$1'); //Add <base> just after <head> and replace <script type="text/javascript"> with <script type="text/htmlpreview">
73+
setTimeout(() => {
74+
document.open();
75+
document.write(data);
76+
document.close();
77+
replaceAssets();
78+
}, 10); //Delay updating document to have it cleared before
79+
}
80+
};
81+
82+
var loadCSS = data => {
83+
if (data) {
84+
const style = document.createElement('style');
85+
style.innerHTML = data;
86+
document.head.appendChild(style);
87+
}
88+
};
89+
90+
var loadJS = data => {
91+
if (data) {
92+
const script = document.createElement('script');
93+
script.innerHTML = data;
94+
document.body.appendChild(script);
95+
}
96+
};
97+
98+
var fetchProxy = (url, options, i) => {
99+
const proxy = [
100+
'https://cors-anywhere.herokuapp.com/',
101+
'https://yacdn.org/proxy/',
102+
'https://api.codetabs.com/v1/proxy/?quest='
103+
];
104+
return fetch(proxy[i] + url, options).then(res => {
105+
if (!res.ok) throw new Error('Cannot load ' + url + ': ' + res.status + ' ' + res.statusText);
106+
return res.text();
107+
}).catch(error => {
108+
if (i === proxy.length - 1)
109+
throw error;
110+
return fetchProxy(url, options, i + 1);
111+
});
112+
};
113+
114+
if (url && url.indexOf(location.hostname) < 0)
115+
fetch(url).then(res => {
116+
if (!res.ok) throw new Error('Cannot load ' + url + ': ' + res.status + ' ' + res.statusText);
117+
return res.text();
118+
}).then(loadHTML).catch(error => {
119+
console.error(error);
120+
previewForm.style.display = 'block';
121+
previewForm.innerText = error;
122+
});
123+
else
124+
previewForm.style.display = 'block';
125+
126+
})();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy