mirror of
https://github.com/dilllxd/gitfolio.git
synced 2024-08-14 22:28:09 +00:00
Fixed Issues and added a UI
This commit is contained in:
parent
39ffee2944
commit
870758aa69
19 changed files with 614 additions and 580 deletions
|
@ -14,21 +14,21 @@ appearance, race, religion, or sexual identity and orientation.
|
|||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
- Using welcoming and inclusive language
|
||||
- Being respectful of differing viewpoints and experiences
|
||||
- Gracefully accepting constructive criticism
|
||||
- Focusing on what is best for the community
|
||||
- Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
- The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
- Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
- Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<img src="https://i.imgur.com/eA6clZr.png">
|
||||
|
||||
# Gitfolio [![Tweet](https://img.shields.io/twitter/url/https/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=personal%20website%20and%20a%20blog%20for%20every%20github%20user%20@imfunnieee%20&url=https://github.com/imfunniee/gitfolio) ![GitHub release](https://img.shields.io/github/release/imfunniee/gitfolio.svg?style=popout-square) ![npm](https://img.shields.io/npm/dm/gitfolio.svg?style=popout-square) ![GitHub top language](https://img.shields.io/github/languages/top/imfunniee/gitfolio.svg?style=popout-square) ![GitHub last commit](https://img.shields.io/github/last-commit/imfunniee/gitfolio.svg?style=popout-square) ![GitHub](https://img.shields.io/github/license/imfunniee/gitfolio.svg?style=popout-square)
|
||||
# Gitfolio [![Tweet](https://img.shields.io/twitter/url/https/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=personal%20website%20and%20a%20blog%20for%20every%20github%20user%20@imfunnieee%20&url=https://github.com/imfunniee/gitfolio) ![GitHub release](https://img.shields.io/github/release/imfunniee/gitfolio.svg?style=popout-square) ![npm](https://img.shields.io/npm/dm/gitfolio.svg?style=popout-square) ![GitHub top language](https://img.shields.io/github/languages/top/imfunniee/gitfolio.svg?style=popout-square) ![GitHub last commit](https://img.shields.io/github/last-commit/imfunniee/gitfolio.svg?style=popout-square) ![GitHub](https://img.shields.io/github/license/imfunniee/gitfolio.svg?style=popout-square) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
|
||||
|
||||
### personal website + blog for every github user
|
||||
|
||||
|
|
66
api.js
Normal file
66
api.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
const got = require("got");
|
||||
|
||||
/**
|
||||
* The defaults here are the same as the API
|
||||
* @see https://developer.github.com/v3/repos/#list-user-repositories
|
||||
* @param {string} username
|
||||
* @param {Object} opts
|
||||
* @param {('all' | 'owner' | 'member')[]} [opts.types]
|
||||
* @param {'created' | 'updated' | 'pushed' | 'full_name' | 'star'} [opts.sort]
|
||||
* @param {'desc' | 'asc'} [opts.order]
|
||||
*/
|
||||
async function getRepos(username, opts = {}) {
|
||||
let tempRepos;
|
||||
let page = 1;
|
||||
let repos = [];
|
||||
|
||||
const sort = opts.sort;
|
||||
const order = opts.order || (sort === "full_name" ? "asc" : "desc");
|
||||
const types = opts.types || [];
|
||||
let type = "all";
|
||||
|
||||
if (
|
||||
types.includes("all") ||
|
||||
(types.includes("owner") && types.includes("member"))
|
||||
) {
|
||||
type = "all";
|
||||
} else if (types.includes("member")) {
|
||||
type = "member";
|
||||
}
|
||||
|
||||
do {
|
||||
let requestUrl = `https://api.github.com/users/${username}/repos?per_page=100&page=${page++}&type=${type}`;
|
||||
if (sort && sort !== "star") {
|
||||
requestUrl += `&sort=${sort}&direction=${order}`;
|
||||
}
|
||||
tempRepos = await got(requestUrl);
|
||||
tempRepos = JSON.parse(tempRepos.body);
|
||||
repos = repos.concat(tempRepos);
|
||||
} while (tempRepos.length == 100);
|
||||
|
||||
if (sort == "star") {
|
||||
repos = repos.sort(function(a, b) {
|
||||
if (order == "desc") {
|
||||
return b.stargazers_count - a.stargazers_count;
|
||||
} else {
|
||||
return a.stargazers_count - b.stargazers_count;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return repos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://developer.github.com/v3/users/#get-a-single-user
|
||||
* @param {string} username
|
||||
*/
|
||||
async function getUser(username) {
|
||||
const res = await got(`https://api.github.com/users/${username}`);
|
||||
return JSON.parse(res.body);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getRepos,
|
||||
getUser
|
||||
};
|
|
@ -103,9 +103,9 @@
|
|||
icon.setAttribute("href", user[0].userimg);
|
||||
icon.setAttribute("type", "image/png");
|
||||
document.getElementsByTagName("head")[0].appendChild(icon);
|
||||
document.getElementById("profile_img_blog").style.background = `url('${
|
||||
user[0].userimg
|
||||
}') center center`;
|
||||
document.getElementById(
|
||||
"profile_img_blog"
|
||||
).style.background = `url('${user[0].userimg}') center center`;
|
||||
document.getElementById(
|
||||
"username_blog"
|
||||
).innerHTML = `<span style="display:${
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
@import url('https://fonts.googleapis.com/css?family=Poppins');
|
||||
@import url('https://fonts.googleapis.com/css?family=Questrial');
|
||||
@import url("https://fonts.googleapis.com/css?family=Poppins");
|
||||
@import url("https://fonts.googleapis.com/css?family=Questrial");
|
||||
|
||||
body {
|
||||
margin: 0%;
|
||||
|
@ -10,7 +10,7 @@ body {
|
|||
max-width: 100vw;
|
||||
overflow-x: hidden;
|
||||
align-items: center;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-family: "Poppins", sans-serif;
|
||||
}
|
||||
|
||||
#loading {
|
||||
|
@ -76,7 +76,7 @@ body {
|
|||
font-size: 50px;
|
||||
color: var(--text-color);
|
||||
font-weight: bold;
|
||||
font-family: 'Questrial', sans-serif;
|
||||
font-family: "Questrial", sans-serif;
|
||||
}
|
||||
|
||||
.emoji {
|
||||
|
@ -95,18 +95,18 @@ body {
|
|||
#username_blog {
|
||||
font-size: 18px;
|
||||
color: var(--text-color);
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-family: "Poppins", sans-serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#username_blog span {
|
||||
font-size: 24px;
|
||||
font-family: 'Questrial', sans-serif !important;
|
||||
font-family: "Questrial", sans-serif !important;
|
||||
}
|
||||
|
||||
#username_blog b {
|
||||
font-size: 12px;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-family: "Poppins", sans-serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ body {
|
|||
font-size: 50px;
|
||||
color: var(--text-color);
|
||||
font-weight: bold;
|
||||
font-family: 'Questrial', sans-serif;
|
||||
font-family: "Questrial", sans-serif;
|
||||
}
|
||||
|
||||
#blog-display h2 {
|
||||
|
@ -159,7 +159,7 @@ body {
|
|||
|
||||
#blog-display {
|
||||
padding: 1vh 0px;
|
||||
font-family: 'Questrial', sans-serif;
|
||||
font-family: "Questrial", sans-serif;
|
||||
}
|
||||
|
||||
#blog p {
|
||||
|
@ -205,7 +205,7 @@ body {
|
|||
#footer_blog a {
|
||||
color: var(--text-color) !important;
|
||||
text-decoration: none;
|
||||
font-family: 'Questrial', sans-serif;
|
||||
font-family: "Questrial", sans-serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ body {
|
|||
#footer a {
|
||||
color: var(--text-color) !important;
|
||||
text-decoration: none;
|
||||
font-family: 'Questrial', sans-serif;
|
||||
font-family: "Questrial", sans-serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
@ -250,13 +250,13 @@ body {
|
|||
|
||||
#userbio {
|
||||
font-size: 26px;
|
||||
font-family: 'Questrial', sans-serif;
|
||||
font-family: "Questrial", sans-serif;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#about {
|
||||
font-size: 18px;
|
||||
font-family: 'Questrial', sans-serif;
|
||||
font-family: "Questrial", sans-serif;
|
||||
}
|
||||
|
||||
#about a,
|
||||
|
@ -333,7 +333,7 @@ body {
|
|||
|
||||
.about_section {
|
||||
font-size: 18px;
|
||||
font-family: 'Questrial', sans-serif;
|
||||
font-family: "Questrial", sans-serif;
|
||||
margin: 2vh 0px;
|
||||
font-weight: bold;
|
||||
word-wrap: break-word;
|
||||
|
|
|
@ -2,9 +2,17 @@
|
|||
--bg-color: rgb(10, 10, 10);
|
||||
--text-color: #fff;
|
||||
--blog-gray-color: rgb(180, 180, 180);
|
||||
--background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.3), rgb(10, 10, 10, 1)),
|
||||
--background-image: linear-gradient(
|
||||
90deg,
|
||||
rgba(10, 10, 10, 0.3),
|
||||
rgb(10, 10, 10, 1)
|
||||
),
|
||||
url("{{{background}}}");
|
||||
--background-background: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0.6)),
|
||||
--background-background: linear-gradient(
|
||||
0deg,
|
||||
rgba(10, 10, 10, 1),
|
||||
rgba(10, 10, 10, 0.6)
|
||||
),
|
||||
url("{{{background}}}") center center fixed;
|
||||
--height: 50vh;
|
||||
}
|
||||
|
@ -31,7 +39,11 @@
|
|||
|
||||
@media (max-width: 800px) {
|
||||
:root {
|
||||
--background-image: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0)),
|
||||
--background-image: linear-gradient(
|
||||
0deg,
|
||||
rgba(10, 10, 10, 1),
|
||||
rgba(10, 10, 10, 0)
|
||||
),
|
||||
url("{{{background}}}") !important;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,11 @@
|
|||
--bg-color: #fff;
|
||||
--text-color: rgb(10, 10, 10);
|
||||
--blog-gray-color: rgb(80, 80, 80);
|
||||
--background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.4), rgb(10, 10, 10, 0.4)), url("{{{background}}}");
|
||||
--background-image: linear-gradient(
|
||||
90deg,
|
||||
rgba(10, 10, 10, 0.4),
|
||||
rgb(10, 10, 10, 0.4)
|
||||
),
|
||||
url("{{{background}}}");
|
||||
--background-background: #fff;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,11 @@ const { uiCommand } = require("../ui");
|
|||
const { runCommand } = require("../run");
|
||||
const { version } = require("../package.json");
|
||||
|
||||
function collect(val, memo) {
|
||||
memo.push(val);
|
||||
return memo;
|
||||
}
|
||||
|
||||
program
|
||||
.command("build <username>")
|
||||
.description(
|
||||
|
|
63
build.js
63
build.js
|
@ -58,54 +58,33 @@ async function populateCSS({
|
|||
await fs.writeFileAsync(config, JSON.stringify(data, null, " "));
|
||||
}
|
||||
|
||||
async function populateConfig(
|
||||
sort,
|
||||
order,
|
||||
includeFork,
|
||||
twitter,
|
||||
linkedin,
|
||||
medium,
|
||||
dribbble
|
||||
) {
|
||||
async function populateConfig(opts) {
|
||||
const data = await getConfig();
|
||||
data[0].sort = sort;
|
||||
data[0].order = order;
|
||||
data[0].includeFork = includeFork;
|
||||
data[0].twitter = twitter; // added twitter
|
||||
data[0].linkedin = linkedin; // added linkedin
|
||||
data[0].medium = medium; // added medium
|
||||
data[0].dribbble = dribbble; // added dribbble
|
||||
Object.assign(data[0], opts);
|
||||
await fs.writeFileAsync(config, JSON.stringify(data, null, " "));
|
||||
}
|
||||
|
||||
async function buildCommand(username, program) {
|
||||
await populateCSS(program);
|
||||
let sort = program.sort ? program.sort : "created";
|
||||
let order = program.order ? program.order : "asc";
|
||||
let includeFork = program.fork ? true : false;
|
||||
let twitter = program.twitter ? program.twitter : null;
|
||||
let linkedin = program.linkedin ? program.linkedin : null;
|
||||
let medium = program.medium ? program.medium : null;
|
||||
let dribbble = program.dribbble ? program.dribbble : null;
|
||||
await populateConfig(
|
||||
sort,
|
||||
order,
|
||||
includeFork,
|
||||
twitter,
|
||||
linkedin,
|
||||
medium,
|
||||
dribbble
|
||||
);
|
||||
updateHTML(
|
||||
("%s", username),
|
||||
sort,
|
||||
order,
|
||||
includeFork,
|
||||
twitter,
|
||||
linkedin,
|
||||
medium,
|
||||
dribbble
|
||||
);
|
||||
let types;
|
||||
if (!program.include || !program.include.length) {
|
||||
types = ["all"];
|
||||
} else {
|
||||
types = program.include;
|
||||
}
|
||||
const opts = {
|
||||
sort: program.sort,
|
||||
order: program.order,
|
||||
includeFork: program.fork ? true : false,
|
||||
types,
|
||||
twitter: program.twitter,
|
||||
linkedin: program.linkedin,
|
||||
medium: program.medium,
|
||||
dribbble: program.dribbble
|
||||
};
|
||||
|
||||
await populateConfig(opts);
|
||||
updateHTML(("%s", username), opts);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
38
package-lock.json
generated
38
package-lock.json
generated
|
@ -152,17 +152,32 @@
|
|||
"integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
|
||||
},
|
||||
"cacheable-request": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.0.0.tgz",
|
||||
"integrity": "sha512-2N7AmszH/WPPpl5Z3XMw1HAP+8d+xugnKQAeKvxFZ/04dbT/CAznqwbl+7eSr3HkwdepNwtb2yx3CAMQWvG01Q==",
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz",
|
||||
"integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==",
|
||||
"requires": {
|
||||
"clone-response": "^1.0.2",
|
||||
"get-stream": "^4.0.0",
|
||||
"get-stream": "^5.1.0",
|
||||
"http-cache-semantics": "^4.0.0",
|
||||
"keyv": "^3.0.0",
|
||||
"lowercase-keys": "^1.0.1",
|
||||
"normalize-url": "^3.1.0",
|
||||
"lowercase-keys": "^2.0.0",
|
||||
"normalize-url": "^4.1.0",
|
||||
"responselike": "^1.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"get-stream": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz",
|
||||
"integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==",
|
||||
"requires": {
|
||||
"pump": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"lowercase-keys": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
|
||||
"integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"caseless": {
|
||||
|
@ -773,9 +788,9 @@
|
|||
"integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw=="
|
||||
},
|
||||
"normalize-url": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-3.3.0.tgz",
|
||||
"integrity": "sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg=="
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.3.0.tgz",
|
||||
"integrity": "sha512-0NLtR71o4k6GLP+mr6Ty34c5GA6CMoEsncKJxvQd8NzPxaHRJNnb5gZE8R1XF4CPIS7QPHLJ74IFszwtNVAHVQ=="
|
||||
},
|
||||
"nwsapi": {
|
||||
"version": "2.1.4",
|
||||
|
@ -872,6 +887,11 @@
|
|||
"resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz",
|
||||
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
|
||||
},
|
||||
"prettier": {
|
||||
"version": "1.18.2",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz",
|
||||
"integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw=="
|
||||
},
|
||||
"proxy-addr": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz",
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
"scripts": {
|
||||
"cli": "OUT_DIR='./dist' node bin/gitfolio.js",
|
||||
"clean": "rm -rf ./dist/*",
|
||||
"prettier": "prettier --write \"./**/*.{js,jsx,json,html,css,md}\"",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": {
|
||||
"name": "imfunny and community",
|
||||
"name": "@imfunniee and community",
|
||||
"email": "imfunny@wybemf.com",
|
||||
"url": "https://imfunniee.github.io"
|
||||
},
|
||||
|
@ -41,6 +42,7 @@
|
|||
"got": "^9.6.0",
|
||||
"handlebars": "^4.1.2",
|
||||
"jsdom": "^15.1.0",
|
||||
"ncp": "^2.0.0"
|
||||
"ncp": "^2.0.0",
|
||||
"prettier": "^1.18.2"
|
||||
}
|
||||
}
|
||||
|
|
109
populate.js
109
populate.js
|
@ -1,11 +1,11 @@
|
|||
const fs = require("fs");
|
||||
const got = require("got");
|
||||
const emoji = require("github-emoji");
|
||||
const jsdom = require("jsdom").JSDOM,
|
||||
options = {
|
||||
resources: "usable"
|
||||
};
|
||||
const { getConfig, outDir } = require("./utils");
|
||||
const { getRepos, getUser } = require("./api");
|
||||
|
||||
function convertToEmoji(text) {
|
||||
if (text == null) return;
|
||||
|
@ -35,16 +35,8 @@ function convertToEmoji(text) {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports.updateHTML = (
|
||||
username,
|
||||
sort,
|
||||
order,
|
||||
includeFork,
|
||||
twitter,
|
||||
linkedin,
|
||||
medium,
|
||||
dribbble
|
||||
) => {
|
||||
module.exports.updateHTML = (username, opts) => {
|
||||
const { includeFork, twitter, linkedin, medium, dribbble } = opts;
|
||||
//add data to assets/index.html
|
||||
jsdom
|
||||
.fromFile(`${__dirname}/assets/index.html`, options)
|
||||
|
@ -54,38 +46,19 @@ module.exports.updateHTML = (
|
|||
(async () => {
|
||||
try {
|
||||
console.log("Building HTML/CSS...");
|
||||
var repos = [];
|
||||
var tempRepos;
|
||||
var page = 1;
|
||||
if (sort == "star") {
|
||||
do {
|
||||
tempRepos = await got(
|
||||
`https://api.github.com/users/${username}/repos?per_page=100&page=${page++}`
|
||||
);
|
||||
tempRepos = JSON.parse(tempRepos.body);
|
||||
repos = repos.concat(tempRepos);
|
||||
} while (tempRepos.length == 100);
|
||||
if (order == "desc") {
|
||||
repos = repos.sort(function(a, b) {
|
||||
return b.stargazers_count - a.stargazers_count;
|
||||
});
|
||||
} else {
|
||||
repos = repos.sort(function(a, b) {
|
||||
return a.stargazers_count - b.stargazers_count;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
tempRepos = await got(
|
||||
`https://api.github.com/users/${username}/repos?sort=${sort}&order=${order}&per_page=100&page=${page++}`
|
||||
);
|
||||
tempRepos = JSON.parse(tempRepos.body);
|
||||
repos = repos.concat(tempRepos);
|
||||
} while (tempRepos.length == 100);
|
||||
}
|
||||
const repos = await getRepos(username, opts);
|
||||
|
||||
for (var i = 0; i < repos.length; i++) {
|
||||
let element;
|
||||
if (repos[i].fork == false) {
|
||||
document.getElementById("work_section").innerHTML += `
|
||||
element = document.getElementById("work_section");
|
||||
} else if (includeFork == true) {
|
||||
document.getElementById("forks").style.display = "block";
|
||||
element = document.getElementById("forks_section");
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
element.innerHTML += `
|
||||
<a href="${repos[i].html_url}" target="_blank">
|
||||
<section>
|
||||
<div class="section_title">${repos[i].name}</div>
|
||||
|
@ -113,55 +86,18 @@ module.exports.updateHTML = (
|
|||
</div>
|
||||
</section>
|
||||
</a>`;
|
||||
} else {
|
||||
if (includeFork == true) {
|
||||
document.getElementById("forks").style.display = "block";
|
||||
document.getElementById("forks_section").innerHTML += `
|
||||
<a href="${repos[i].html_url}" target="_blank">
|
||||
<section>
|
||||
<div class="section_title">${
|
||||
repos[i].name
|
||||
}</div>
|
||||
<div class="about_section">
|
||||
<span style="display:${
|
||||
repos[i].description == undefined
|
||||
? "none"
|
||||
: "block"
|
||||
};">${convertToEmoji(
|
||||
repos[i].description
|
||||
)}</span>
|
||||
</div>
|
||||
<div class="bottom_section">
|
||||
<span style="display:${
|
||||
repos[i].language == null
|
||||
? "none"
|
||||
: "inline-block"
|
||||
};"><i class="fas fa-code"></i> ${
|
||||
repos[i].language
|
||||
}</span>
|
||||
<span><i class="fas fa-star"></i> ${
|
||||
repos[i].stargazers_count
|
||||
}</span>
|
||||
<span><i class="fas fa-code-branch"></i> ${
|
||||
repos[i].forks_count
|
||||
}</span>
|
||||
</div>
|
||||
</section>
|
||||
</a>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
var user = await got(`https://api.github.com/users/${username}`);
|
||||
user = JSON.parse(user.body);
|
||||
const user = await getUser(username);
|
||||
document.title = user.login;
|
||||
var icon = document.createElement("link");
|
||||
icon.setAttribute("rel", "icon");
|
||||
icon.setAttribute("href", user.avatar_url);
|
||||
icon.setAttribute("type", "image/png");
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(icon);
|
||||
document.getElementById("profile_img").style.background = `url('${
|
||||
user.avatar_url
|
||||
}') center center`;
|
||||
document.getElementById(
|
||||
"profile_img"
|
||||
).style.background = `url('${user.avatar_url}') center center`;
|
||||
document.getElementById(
|
||||
"username"
|
||||
).innerHTML = `<span style="display:${
|
||||
|
@ -206,19 +142,20 @@ module.exports.updateHTML = (
|
|||
<span style="display:${
|
||||
medium == null ? "none !important" : "block"
|
||||
};"><a href="https://www.medium.com/@${medium}/" target="_blank" class="socials"><i class="fab fa-medium-m"></i></a></span>
|
||||
</div>`;
|
||||
|
||||
</div>
|
||||
`;
|
||||
//add data to config.json
|
||||
const data = await getConfig();
|
||||
data[0].username = user.login;
|
||||
data[0].name = user.name;
|
||||
data[0].userimg = user.avatar_url;
|
||||
|
||||
await fs.writeFile(
|
||||
`${outDir}/config.json`,
|
||||
JSON.stringify(data, null, " "),
|
||||
function(err) {
|
||||
if (err) throw err;
|
||||
console.log("Config file updated.\n");
|
||||
console.log("Config file updated.");
|
||||
}
|
||||
);
|
||||
await fs.writeFile(
|
||||
|
|
75
ui.js
75
ui.js
|
@ -1,6 +1,5 @@
|
|||
const fs = require("fs");
|
||||
const express = require("express");
|
||||
let bodyParser = require("body-parser");
|
||||
const { updateHTML } = require("./populate");
|
||||
const { populateCSS, populateConfig } = require("./build");
|
||||
const { updateCommand } = require("./update");
|
||||
|
@ -8,8 +7,17 @@ const app = express();
|
|||
app.set("view engine", "ejs");
|
||||
app.use(express.static(__dirname + "/views"));
|
||||
app.set("views", __dirname + "/views");
|
||||
app.use(express.json({ limit: "50mb" }));
|
||||
app.use(express.urlencoded({ limit: "50mb", extended: true }));
|
||||
app.use(
|
||||
express.json({
|
||||
limit: "50mb"
|
||||
})
|
||||
);
|
||||
app.use(
|
||||
express.urlencoded({
|
||||
limit: "50mb",
|
||||
extended: true
|
||||
})
|
||||
);
|
||||
|
||||
const port = 3000;
|
||||
|
||||
|
@ -24,11 +32,19 @@ function createBlog(title, subtitle, folder, topImage, images, content) {
|
|||
// Checks to make sure this directory actually exists
|
||||
// and creates it if it doesn't
|
||||
if (!fs.existsSync(`${outDir}/blog/`)) {
|
||||
fs.mkdirSync(`${outDir}/blog/`, { recursive: true }, err => {});
|
||||
fs.mkdirSync(
|
||||
`${outDir}/blog/`,
|
||||
{
|
||||
recursive: true
|
||||
},
|
||||
err => {}
|
||||
);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(`${outDir}/blog/${folder}`)) {
|
||||
fs.mkdirSync(`${outDir}/blog/${folder}`, { recursive: true });
|
||||
fs.mkdirSync(`${outDir}/blog/${folder}`, {
|
||||
recursive: true
|
||||
});
|
||||
}
|
||||
|
||||
fs.copyFile(
|
||||
|
@ -70,7 +86,9 @@ function createBlog(title, subtitle, folder, topImage, images, content) {
|
|||
item.split("/")[1].split(";")[0]
|
||||
}`,
|
||||
base64Image,
|
||||
{ encoding: "base64" },
|
||||
{
|
||||
encoding: "base64"
|
||||
},
|
||||
function(err) {
|
||||
if (err) throw err;
|
||||
}
|
||||
|
@ -89,7 +107,9 @@ function createBlog(title, subtitle, folder, topImage, images, content) {
|
|||
topImage.split("/")[1].split(";")[0]
|
||||
}`,
|
||||
base64ImageTop,
|
||||
{ encoding: "base64" },
|
||||
{
|
||||
encoding: "base64"
|
||||
},
|
||||
function(err) {
|
||||
if (err) throw err;
|
||||
}
|
||||
|
@ -147,6 +167,7 @@ function uiCommand() {
|
|||
let sort = req.body.sort ? req.body.sort : "created";
|
||||
let order = req.body.order ? req.body.order : "asc";
|
||||
let includeFork = req.body.fork == "true" ? true : false;
|
||||
let types = ["owner"];
|
||||
let twitter = req.body.twitter ? req.body.twitter : null;
|
||||
let linkedin = req.body.linkedin ? req.body.linkedin : null;
|
||||
let medium = req.body.medium ? req.body.medium : null;
|
||||
|
@ -155,27 +176,23 @@ function uiCommand() {
|
|||
? req.body.background
|
||||
: "https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1500&q=80";
|
||||
let theme = req.body.theme == "on" ? "dark" : "light";
|
||||
const opts = {
|
||||
sort: sort,
|
||||
order: order,
|
||||
includeFork: includeFork,
|
||||
types,
|
||||
twitter: twitter,
|
||||
linkedin: linkedin,
|
||||
medium: medium,
|
||||
dribbble: dribbble
|
||||
};
|
||||
|
||||
updateHTML(
|
||||
username,
|
||||
sort,
|
||||
order,
|
||||
includeFork,
|
||||
twitter,
|
||||
linkedin,
|
||||
medium,
|
||||
dribbble
|
||||
);
|
||||
populateCSS({ background: background, theme: theme });
|
||||
populateConfig(
|
||||
sort,
|
||||
order,
|
||||
includeFork,
|
||||
twitter,
|
||||
linkedin,
|
||||
medium,
|
||||
dribbble
|
||||
);
|
||||
updateHTML(username, opts);
|
||||
populateCSS({
|
||||
background: background,
|
||||
theme: theme
|
||||
});
|
||||
populateConfig(opts);
|
||||
res.redirect("/");
|
||||
});
|
||||
|
||||
|
@ -186,7 +203,9 @@ function uiCommand() {
|
|||
);
|
||||
}
|
||||
fs.readFile(`${outDir}/config.json`, function(err, data) {
|
||||
res.render("blog.ejs", { profile: JSON.parse(data) });
|
||||
res.render("blog.ejs", {
|
||||
profile: JSON.parse(data)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
35
update.js
35
update.js
|
@ -4,34 +4,23 @@ const { updateHTML } = require("./populate");
|
|||
async function updateCommand() {
|
||||
const data = await getConfig();
|
||||
var username = data[0].username;
|
||||
var sort = data[0].sort;
|
||||
var order = data[0].order;
|
||||
var includeFork = data[0].includeFork;
|
||||
var twitter = data[0].twitter;
|
||||
var linkedin = data[0].linkedin;
|
||||
var medium = data[0].medium;
|
||||
var dribbble = data[0].dribbble;
|
||||
if (
|
||||
username == null ||
|
||||
sort == null ||
|
||||
order == null ||
|
||||
includeFork == null
|
||||
) {
|
||||
if (username == null) {
|
||||
console.log(
|
||||
"username not found in config.json, please run build command before using update"
|
||||
);
|
||||
return;
|
||||
}
|
||||
updateHTML(
|
||||
username,
|
||||
sort,
|
||||
order,
|
||||
includeFork,
|
||||
twitter,
|
||||
linkedin,
|
||||
medium,
|
||||
dribbble
|
||||
);
|
||||
const opts = {
|
||||
sort: data[0].sort,
|
||||
order: data[0].order,
|
||||
includeFork: data[0].includeFork,
|
||||
types: data[0].types,
|
||||
twitter: data[0].twitter,
|
||||
linkedin: data[0].linkedin,
|
||||
medium: data[0].medium,
|
||||
dribbble: data[0].dribbble
|
||||
};
|
||||
updateHTML(username, opts);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
12
utils.js
12
utils.js
|
@ -1,10 +1,10 @@
|
|||
const path = require('path');
|
||||
const bluebird = require('bluebird');
|
||||
const fs = bluebird.promisifyAll(require('fs'));
|
||||
const path = require("path");
|
||||
const bluebird = require("bluebird");
|
||||
const fs = bluebird.promisifyAll(require("fs"));
|
||||
|
||||
const outDir = path.resolve('./dist/' || process.env.OUT_DIR);
|
||||
const configPath = path.join(outDir, 'config.json');
|
||||
const blogPath = path.join(outDir, 'blog.json');
|
||||
const outDir = path.resolve("./dist/" || process.env.OUT_DIR);
|
||||
const configPath = path.join(outDir, "config.json");
|
||||
const blogPath = path.join(outDir, "blog.json");
|
||||
|
||||
const defaultConfigPath = path.resolve(`${__dirname}/default/config.json`);
|
||||
const defaultBlogPath = path.resolve(`${__dirname}/default/blog.json`);
|
||||
|
|
Loading…
Reference in a new issue