Fixed Issues and added a UI

This commit is contained in:
imfunny 2019-08-13 15:24:14 +05:30 committed by GitHub
parent 39ffee2944
commit 870758aa69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 614 additions and 580 deletions

View File

@ -14,22 +14,22 @@ 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
advances
* 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
professional setting
- 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
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities

View File

@ -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
View 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
};

View File

@ -1 +1 @@
[]
[]

View File

@ -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:${

View File

@ -1,547 +1,547 @@
@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%;
padding: 0%;
width: 100vw;
background: var(--bg-color);
color: var(--text-color);
max-width: 100vw;
overflow-x: hidden;
align-items: center;
font-family: 'Poppins', sans-serif;
margin: 0%;
padding: 0%;
width: 100vw;
background: var(--bg-color);
color: var(--text-color);
max-width: 100vw;
overflow-x: hidden;
align-items: center;
font-family: "Poppins", sans-serif;
}
#loading {
width: 100vw;
height: 100vh;
position: fixed;
background: var(--bg-color);
z-index: 999;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100vw;
height: 100vh;
position: fixed;
background: var(--bg-color);
z-index: 999;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
#spinner {
animation: rotate 0.5s infinite linear;
width: 50px;
height: 50px;
border: 2px solid var(--bg-color);
border-bottom: 2px solid var(--text-color);
border-radius: 50%;
margin: 0;
animation: rotate 0.5s infinite linear;
width: 50px;
height: 50px;
border: 2px solid var(--bg-color);
border-bottom: 2px solid var(--text-color);
border-radius: 50%;
margin: 0;
}
@keyframes rotate {
0% {
transform: rotate(0deg);
}
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
100% {
transform: rotate(360deg);
}
}
#profile {
width: 24vw;
padding: 4vh 3vw;
height: 92vh;
display: flex;
flex-direction: column;
justify-content: center;
text-align: left;
background: var(--background-image) center center;
background-size: cover !important;
background-repeat: no-repeat;
position: fixed;
color: #fff !important;
width: 24vw;
padding: 4vh 3vw;
height: 92vh;
display: flex;
flex-direction: column;
justify-content: center;
text-align: left;
background: var(--background-image) center center;
background-size: cover !important;
background-repeat: no-repeat;
position: fixed;
color: #fff !important;
}
#display {
width: 64vw;
padding: 4vh 3vw;
height: 92vh;
display: inline-block;
padding-left: 33vw;
width: 64vw;
padding: 4vh 3vw;
height: 92vh;
display: inline-block;
padding-left: 33vw;
}
#display h1 {
font-size: 50px;
color: var(--text-color);
font-weight: bold;
font-family: 'Questrial', sans-serif;
font-size: 50px;
color: var(--text-color);
font-weight: bold;
font-family: "Questrial", sans-serif;
}
.emoji {
width: 18px;
height: 18px;
width: 18px;
height: 18px;
}
#profile_img_blog {
border-radius: 50%;
width: 90px;
height: 90px;
background-size: cover !important;
background-repeat: no-repeat;
border-radius: 50%;
width: 90px;
height: 90px;
background-size: cover !important;
background-repeat: no-repeat;
}
#username_blog {
font-size: 18px;
color: var(--text-color);
font-family: 'Poppins', sans-serif;
font-weight: bold;
font-size: 18px;
color: var(--text-color);
font-family: "Poppins", sans-serif;
font-weight: bold;
}
#username_blog span {
font-size: 24px;
font-family: 'Questrial', sans-serif !important;
font-size: 24px;
font-family: "Questrial", sans-serif !important;
}
#username_blog b {
font-size: 12px;
font-family: 'Poppins', sans-serif;
font-weight: bold;
font-size: 12px;
font-family: "Poppins", sans-serif;
font-weight: bold;
}
#blog-display {
width: 60vw;
margin: 0px 20vw;
text-align: left;
margin-top: 3vh;
z-index: 1;
width: 60vw;
margin: 0px 20vw;
text-align: left;
margin-top: 3vh;
z-index: 1;
}
#profile_blog {
width: 60vw;
margin: 0px 20vw;
margin-top: 34vh;
text-align: left;
z-index: 1;
width: 60vw;
margin: 0px 20vw;
margin-top: 34vh;
text-align: left;
z-index: 1;
}
#background_overlay {
width: 100vw;
height: 55vh;
position: absolute;
z-index: -1;
top: 0;
left: 0;
width: 100vw;
height: 55vh;
position: absolute;
z-index: -1;
top: 0;
left: 0;
}
#background {
width: 100vw;
height: 55vh;
background-size: cover !important;
background-repeat: no-repeat !important;
position: absolute;
z-index: -2;
top: 0;
left: 0;
width: 100vw;
height: 55vh;
background-size: cover !important;
background-repeat: no-repeat !important;
position: absolute;
z-index: -2;
top: 0;
left: 0;
}
#blog-display h1 {
font-size: 50px;
color: var(--text-color);
font-weight: bold;
font-family: 'Questrial', sans-serif;
font-size: 50px;
color: var(--text-color);
font-weight: bold;
font-family: "Questrial", sans-serif;
}
#blog-display h2 {
color: var(--blog-gray-color);
color: var(--blog-gray-color);
}
#blog-display {
padding: 1vh 0px;
font-family: 'Questrial', sans-serif;
padding: 1vh 0px;
font-family: "Questrial", sans-serif;
}
#blog p {
font-size: 17px;
line-height: 25px;
word-spacing: 1.2px;
margin: 5vh 0px;
font-size: 17px;
line-height: 25px;
word-spacing: 1.2px;
margin: 5vh 0px;
}
#blog p span {
padding: 2px 4px;
background: var(--text-color);
color: var(--bg-color) !important;
padding: 2px 4px;
background: var(--text-color);
color: var(--bg-color) !important;
}
#blog img {
width: 100%;
margin: 2vh 0px;
border-radius: 5px;
border: 1px solid rgb(0, 0, 0, 0.08);
width: 100%;
margin: 2vh 0px;
border-radius: 5px;
border: 1px solid rgb(0, 0, 0, 0.08);
}
#header {
width: 63vw;
text-align: right;
padding: 3vh 0px;
position: absolute;
width: 63vw;
text-align: right;
padding: 3vh 0px;
position: absolute;
}
#header a {
color: var(--text-color);
text-decoration: none;
margin-left: 4vw;
font-weight: bold;
color: var(--text-color);
text-decoration: none;
margin-left: 4vw;
font-weight: bold;
}
#footer_blog {
width: 90vw;
padding: 8vh 5vw;
text-align: center;
width: 90vw;
padding: 8vh 5vw;
text-align: center;
}
#footer_blog a {
color: var(--text-color) !important;
text-decoration: none;
font-family: 'Questrial', sans-serif;
font-weight: bold;
color: var(--text-color) !important;
text-decoration: none;
font-family: "Questrial", sans-serif;
font-weight: bold;
}
#footer {
width: 100%;
padding: 8vh 0px;
text-align: center;
width: 100%;
padding: 8vh 0px;
text-align: center;
}
#footer a {
color: var(--text-color) !important;
text-decoration: none;
font-family: 'Questrial', sans-serif;
font-weight: bold;
color: var(--text-color) !important;
text-decoration: none;
font-family: "Questrial", sans-serif;
font-weight: bold;
}
#profile_img {
width: 180px;
height: 180px;
min-width: 180px;
min-height: 180px;
max-width: 180px;
max-height: 180px;
border-radius: 5px;
background-size: cover !important;
background-repeat: no-repeat !important;
width: 180px;
height: 180px;
min-width: 180px;
min-height: 180px;
max-width: 180px;
max-height: 180px;
border-radius: 5px;
background-size: cover !important;
background-repeat: no-repeat !important;
}
#profile div {
font-weight: bold;
margin: 1.5vh 0px;
font-weight: bold;
margin: 1.5vh 0px;
}
#username {
font-size: 18px;
font-weight: bold;
font-size: 18px;
font-weight: bold;
}
#username span {
font-size: 24px;
font-size: 24px;
}
#userbio {
font-size: 26px;
font-family: 'Questrial', sans-serif;
width: 100%;
font-size: 26px;
font-family: "Questrial", sans-serif;
width: 100%;
}
#about {
font-size: 18px;
font-family: 'Questrial', sans-serif;
font-size: 18px;
font-family: "Questrial", sans-serif;
}
#about a,
#username a {
color: #fff !important;
text-decoration: none;
font-weight: bold;
color: #fff !important;
text-decoration: none;
font-weight: bold;
}
#about a:hover,
#username a:hover {
text-decoration: underline;
text-decoration: underline;
}
#about span {
margin: 1vh 0px;
display: block;
margin: 1vh 0px;
display: block;
}
#about span i {
font-size: 16px;
font-size: 16px;
}
#work {
margin: 2vh 0px;
padding: 4vh 0px !important;
margin: 2vh 0px;
padding: 4vh 0px !important;
}
#forks {
margin: 2vh 0px;
padding: 4vh 0px !important;
margin: 2vh 0px;
padding: 4vh 0px !important;
}
.projects {
margin-left: -15px;
/* align section w/ heading above */
margin-left: -15px;
/* align section w/ heading above */
}
.projects a {
/* 30px is the gutter size in magic grid */
width: calc(49% - 30px);
/* 49% avoids a weird single column on some wide screens */
display: flex;
text-decoration: none;
/* 30px is the gutter size in magic grid */
width: calc(49% - 30px);
/* 49% avoids a weird single column on some wide screens */
display: flex;
text-decoration: none;
}
.projects section {
width: 100%;
padding: 2.5vh 5%;
margin: 1vh 0px;
display: inline-block;
border-radius: 5px;
color: var(--text-color);
border: 1px solid rgb(0, 0, 0, 0.08);
box-shadow: 0px 0px 0px rgb(0, 0, 0, 0);
transition: 0.4s ease-in-out;
transform: scale(1);
width: 100%;
padding: 2.5vh 5%;
margin: 1vh 0px;
display: inline-block;
border-radius: 5px;
color: var(--text-color);
border: 1px solid rgb(0, 0, 0, 0.08);
box-shadow: 0px 0px 0px rgb(0, 0, 0, 0);
transition: 0.4s ease-in-out;
transform: scale(1);
}
.projects section:hover {
cursor: pointer;
border: 1px solid rgb(0, 0, 0, 0);
box-shadow: 0px 15px 35px rgb(0, 0, 0, 0.06);
transform: scale(1.03);
cursor: pointer;
border: 1px solid rgb(0, 0, 0, 0);
box-shadow: 0px 15px 35px rgb(0, 0, 0, 0.06);
transform: scale(1.03);
}
.section_title {
font-size: 24px;
font-weight: bold;
margin: 1vh 0px;
padding: 0px 1px;
word-wrap: break-word;
font-size: 24px;
font-weight: bold;
margin: 1vh 0px;
padding: 0px 1px;
word-wrap: break-word;
}
.about_section {
font-size: 18px;
font-family: 'Questrial', sans-serif;
margin: 2vh 0px;
font-weight: bold;
word-wrap: break-word;
font-size: 18px;
font-family: "Questrial", sans-serif;
margin: 2vh 0px;
font-weight: bold;
word-wrap: break-word;
}
.bottom_section {
margin: 1vh 0px;
font-size: 14px;
word-wrap: break-word;
margin: 1vh 0px;
font-size: 14px;
word-wrap: break-word;
}
.bottom_section span {
margin-right: 20px;
font-weight: bold;
margin-right: 20px;
font-weight: bold;
}
.bottom_section span i {
font-size: 15px;
font-size: 15px;
}
.socials {
color: #fff;
text-decoration: none;
margin: 3vh 0px !important;
color: #fff;
text-decoration: none;
margin: 3vh 0px !important;
}
.socials span {
display: inline-block !important;
margin-right: 2vw !important;
font-weight: normal !important;
display: inline-block !important;
margin-right: 2vw !important;
font-weight: normal !important;
}
.socials span a {
font-weight: normal !important;
font-weight: normal !important;
}
#blog_section {
margin: 2vh 0px;
padding: 2vh 0px !important;
margin: 2vh 0px;
padding: 2vh 0px !important;
}
#blogs {
columns: 2;
columns: 2;
}
#blog_title {
font-size: 50px;
font-size: 50px;
}
#blog_sub_title {
font-size: 36px;
margin-top: -2vh;
font-size: 36px;
margin-top: -2vh;
}
#blogs section {
width: 100%;
display: inline-block;
border-radius: 5px;
color: var(--text-color);
border: 1px solid rgb(0, 0, 0, 0.04);
box-shadow: 0px 0px 0px rgb(0, 0, 0, 0);
transition: 0.4s ease-in-out;
transform: scale(1);
padding: 0px;
margin: 2vh 0px;
width: 100%;
display: inline-block;
border-radius: 5px;
color: var(--text-color);
border: 1px solid rgb(0, 0, 0, 0.04);
box-shadow: 0px 0px 0px rgb(0, 0, 0, 0);
transition: 0.4s ease-in-out;
transform: scale(1);
padding: 0px;
margin: 2vh 0px;
}
#blogs section img {
width: 100%;
border-radius: 5px 5px 0px 0px;
width: 100%;
border-radius: 5px 5px 0px 0px;
}
.blog_container {
padding: 2.5vh 5%;
padding: 2.5vh 5%;
}
#blogs section:hover {
cursor: pointer;
border: 1px solid rgb(0, 0, 0, 0);
box-shadow: 0px 15px 35px rgb(0, 0, 0, 0.06);
transform: scale(1.03);
cursor: pointer;
border: 1px solid rgb(0, 0, 0, 0);
box-shadow: 0px 15px 35px rgb(0, 0, 0, 0.06);
transform: scale(1.03);
}
.go_back {
position: absolute;
color: var(--text-color);
font-size: 26px;
margin-left: 5vw;
margin-top: 4vh;
position: absolute;
color: var(--text-color);
font-size: 26px;
margin-left: 5vw;
margin-top: 4vh;
}
::selection {
color: var(--bg-color);
background: var(--text-color);
color: var(--bg-color);
background: var(--text-color);
}
@media (max-width: 800px) {
#profile {
width: 90vw;
padding: 4vh 5vw;
height: 60vh;
text-align: center;
position: relative;
}
#profile {
width: 90vw;
padding: 4vh 5vw;
height: 60vh;
text-align: center;
position: relative;
}
#display {
width: 90vw;
padding: 4vh 5vw;
height: auto;
display: inline-block;
padding-left: 5vw;
}
#display {
width: 90vw;
padding: 4vh 5vw;
height: auto;
display: inline-block;
padding-left: 5vw;
}
#profile_img {
width: 120px;
height: 120px;
min-width: 120px;
min-height: 120px;
max-width: 120px;
max-height: 120px;
margin: 0px auto !important;
}
#profile_img {
width: 120px;
height: 120px;
min-width: 120px;
min-height: 120px;
max-width: 120px;
max-height: 120px;
margin: 0px auto !important;
}
#work {
margin: 0px;
}
#work {
margin: 0px;
}
.projects {
margin-left: 0;
/* remove neg margin to align w/ header */
}
.projects {
margin-left: 0;
/* remove neg margin to align w/ header */
}
.projects a {
width: 100%;
}
.projects a {
width: 100%;
}
.projects section {
width: 88%;
}
.projects section {
width: 88%;
}
#blogs {
columns: 1;
}
#blogs {
columns: 1;
}
#blogs section {
width: 98%;
}
#blogs section {
width: 98%;
}
#blog_section {
margin: 0px;
}
#blog_section {
margin: 0px;
}
#blog-display {
width: 90vw;
margin: 0px 5vw;
text-align: left;
margin-top: 0vh;
z-index: 1;
}
#blog-display {
width: 90vw;
margin: 0px 5vw;
text-align: left;
margin-top: 0vh;
z-index: 1;
}
#blog_title {
font-size: 32px !important;
}
#blog_title {
font-size: 32px !important;
}
#blog_sub_title {
font-size: 24px;
margin-top: -1vh;
}
#blog_sub_title {
font-size: 24px;
margin-top: -1vh;
}
#profile_blog {
width: 90vw;
margin: 0px 5vw;
margin-top: 36vh;
text-align: left;
z-index: 1;
}
#profile_blog {
width: 90vw;
margin: 0px 5vw;
margin-top: 36vh;
text-align: left;
z-index: 1;
}
#profile_img_blog {
width: 65px;
height: 65px;
}
#profile_img_blog {
width: 65px;
height: 65px;
}
.go_back {
position: relative;
color: var(--text-color);
font-size: 26px;
margin-left: 5vw;
top: 5vh;
}
.go_back {
position: relative;
color: var(--text-color);
font-size: 26px;
margin-left: 5vw;
top: 5vh;
}
#blog img {
margin: 1vh 0px !important;
}
#blog img {
margin: 1vh 0px !important;
}
#blog p {
margin: 2vh 0px;
}
#blog p {
margin: 2vh 0px;
}
}
::-webkit-scrollbar {
width: 5px;
height: 5px;
width: 5px;
height: 5px;
}
::-webkit-scrollbar-track {
background: var(--bg-color);
background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
background: var(--text-color);
}
background: var(--text-color);
}

View File

@ -2,10 +2,18 @@
--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)),
url("{{{background}}}");
--background-background: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0.6)),
url("{{{background}}}") center center fixed;
--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)
),
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)),
url("{{{background}}}") !important;
--background-image: linear-gradient(
0deg,
rgba(10, 10, 10, 1),
rgba(10, 10, 10, 0)
),
url("{{{background}}}") !important;
}
}
}

View File

@ -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;
}

View File

@ -1,4 +1,4 @@
#! /usr/bin/env node
#! /usr/bin/env node
/* Argument parser */
const program = require("commander");
@ -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(

View File

@ -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 = {

View File

@ -1 +1 @@
[]
[]

View File

@ -1,11 +1,11 @@
[
{
"username": null,
"name": null,
"userimg": null,
"sort": null,
"order": null,
"includeFork": null,
"theme": "light.css"
}
]
{
"username": null,
"name": null,
"userimg": null,
"sort": null,
"order": null,
"includeFork": null,
"theme": "light.css"
}
]

38
package-lock.json generated
View File

@ -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",

View File

@ -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"
}
}

View File

@ -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>
@ -102,8 +75,8 @@ module.exports.updateHTML = (
? "none"
: "inline-block"
};"><i class="fas fa-code"></i>&nbsp; ${
repos[i].language
}</span>
repos[i].language
}</span>
<span><i class="fas fa-star"></i>&nbsp; ${
repos[i].stargazers_count
}</span>
@ -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>&nbsp; ${
repos[i].language
}</span>
<span><i class="fas fa-star"></i>&nbsp; ${
repos[i].stargazers_count
}</span>
<span><i class="fas fa-code-branch"></i>&nbsp; ${
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
View File

@ -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)
});
});
});

View File

@ -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 = {

View File

@ -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`);
@ -14,26 +14,26 @@ const defaultBlogPath = path.resolve(`${__dirname}/default/blog.json`);
* if not present returns default file contents
*/
async function getFileWithDefaults(file, defaultFile) {
try {
await fs.accessAsync(file, fs.constants.F_OK);
} catch (err) {
const defaultData = await fs.readFileAsync(defaultFile);
return JSON.parse(defaultData);
}
const data = await fs.readFileAsync(file);
return JSON.parse(data);
try {
await fs.accessAsync(file, fs.constants.F_OK);
} catch (err) {
const defaultData = await fs.readFileAsync(defaultFile);
return JSON.parse(defaultData);
}
const data = await fs.readFileAsync(file);
return JSON.parse(data);
}
async function getConfig() {
return getFileWithDefaults(configPath, defaultConfigPath);
return getFileWithDefaults(configPath, defaultConfigPath);
}
async function getBlog() {
return getFileWithDefaults(blogPath, defaultBlogPath);
return getFileWithDefaults(blogPath, defaultBlogPath);
}
module.exports = {
outDir,
getConfig,
getBlog
outDir,
getConfig,
getBlog
};

View File

@ -296,4 +296,4 @@ textarea:focus {
::placeholder {
color: #000;
}
}