made it even better

we got v0.1.1 bois
Changes made :
-added update command
-added emojis 👌🙌👀
-added company and hire thingy in user profile section
-fixed issues and bugs

let's add more features bois v0.1.2 soon
This commit is contained in:
imfunny 2019-05-12 19:14:03 +05:30 committed by GitHub
parent 59b441a6d6
commit e61d0846d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 231 additions and 162 deletions

View File

@ -62,25 +62,6 @@
`)
}
});
$.getJSON("./repos/repos.json", function(repos){
for(var i = 0; i < repos.length; i++){
$("#projects").append(`
<a href="${repos[i].html_url}" target="_blank">
<section>
<div class="section_title">${repos[i].name}</div>
<div class="about_section">
${repos[i].description}
</div>
<div class="bottom_section">
<span><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>
`)
}
});
</script>
</body>
</html>

17
blog.js
View File

@ -6,18 +6,18 @@ options = {
};
program
.version('0.1.2')
.version('0.1.1')
.option('-t, --title [title]', 'give blog a title')
.option('-s, --subtitle [subtitle]', 'give blog a subtitle', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
.option('-p, --pagetitle [pagetitle]', 'give page a title')
.option('-f, --folder [folder]', 'give folder a title')
.option('-p, --pagetitle [pagetitle]', 'give blog page a title')
.option('-f, --folder [folder]', 'give folder a title (use "-" instead of spaces)')
.parse(process.argv);
function createBlog(title, subtitle, pagetitle, folder) {
if (!fs.existsSync(`./blog/${folder}`)){
fs.mkdirSync(`./blog/${folder}`);
}
fs.copyFile('./blog/blog_template.html', `./blog/${folder}/index.html`, (err) => {
fs.copyFile('./blog/blogTemplate.html', `./blog/${folder}/index.html`, (err) => {
if (err) throw err;
jsdom.fromFile(`./blog/${folder}/index.html`, options).then(function (dom) {
let window = dom.window, document = window.document;
@ -46,7 +46,7 @@ function createBlog(title, subtitle, pagetitle, folder) {
if (err) throw err;
console.log('Blog Created Successfully in "blog" folder.');
});
})
});
});
}).catch(function(error){
console.log(error);
@ -58,15 +58,10 @@ if (program.title) {
if (!program.pagetitle) {
program.pagetitle = program.title;
}
if (!program.folder) {
program.folder = program.title;
}
program.folder = program.folder.replace(/[^A-Za-z0-9_-\s]/g, "").trim();
program.folder = program.folder.replace(/\s/g, "-");
createBlog(program.title, program.subtitle, program.pagetitle, program.folder);
} else {
console.log("provide a title to create a new blog");
console.log("Provide a title to create a new blog");
}

View File

@ -1 +1 @@
[]
[]

64
blog/blogTemplate.html Normal file
View File

@ -0,0 +1,64 @@
<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Lorem ipsum dolor</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
</head>
<body>
<div id="loading">
<div id="spinner"></div>
</div>
<a href="/" class="go_back"><i class="fas fa-arrow-left"></i></a>
<div id="background"></div>
<table id="profile_blog">
<tbody><tr>
<td style="width:8vw;"><div id="profile_img_blog"></div></td>
<td style="width:52vw;">
<div id="username_blog"></div>
</td>
</tr>
</tbody></table>
<div id="blog-display">
<h1 id="blog_title">Lorem ipsum dolor</h1>
<h2 id="blog_sub_title">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</h2>
<div id="blog">
<img src="https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut placerat pretium sem, ac maximus dui sodales a. Nunc aliquet hendrerit turpis ac egestas. Phasellus volutpat tristique maximus. <b>Pellentesque feugiat eget nisi et dignissim.</b> Nam nibh erat, sollicitudin non facilisis nec, scelerisque nec ipsum. Sed accumsan velit condimentum, pharetra felis vitae, commodo tellus. <u><i>Mauris consequat luctus orci.</i></u></p>
<p>
Vivamus pharetra lobortis dui non tincidunt. Mauris vitae nisi vestibulum, mollis magna a, maximus mi. Suspendisse dictum eget augue quis sodales. Quisque rutrum ligula nec dapibus tincidunt. <span>Proin hendrerit massa a tellus vestibulum, a hendrerit ipsum iaculis. Suspendisse potenti.</span> Praesent eget erat blandit, finibus sapien vitae, ullamcorper erat. Integer blandit, felis at ullamcorper maximus, odio lectus pretium mauris, vel consequat lectus quam eu risus. Pellentesque gravida nec diam eget vehicula.
</p>
<img src="https://images.unsplash.com/photo-1556814278-8906c7d3a05f?w=1050">
<p>
Donec hendrerit turpis non libero eleifend dignissim. Mauris non tempor metus, et tristique massa. Integer consequat justo quam, vitae aliquam arcu vestibulum at. Donec porttitor quam in tempus convallis. Praesent feugiat eget eros vitae accumsan. Duis ultricies odio quis nisl volutpat, consectetur imperdiet sem laoreet. Quisque maximus semper ligula at tincidunt. Pellentesque accumsan varius vehicula.
</p>
</div>
</div>
<div id="footer_blog">
<a href="https://github.com/imfunniee" target="_blank">made on earth by a human</a>
</div>
<script type="text/javascript">
setTimeout(function(){
document.getElementById("loading").classList.add("animated");
document.getElementById("loading").classList.add("fadeOut");
setTimeout(function(){
document.getElementById("loading").classList.remove("animated");
document.getElementById("loading").classList.remove("fadeOut");
document.getElementById("loading").style.display = "none";
},800);
},1500);
$.getJSON("../../config.json", function(user){
var icon = document.createElement("link");
icon.setAttribute("rel", "icon");
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("username_blog").innerHTML = `<spanstyle="display:${user[0].name == null || !user[0].name ? 'none' : 'block'};">${user[0].name}</span><br>@${user[0].username}<b id="blog_time"></b>`;
});
</script>
</body></html>

166
build.js
View File

@ -1,14 +1,9 @@
const program = require('commander');
const fs = require('fs');
const got = require('got');
const emoji = require('github-emoji');
const jsdom = require('jsdom').JSDOM,
options = {
resources: "usable"
};
const {updateHTML} = require('./populate')
program
.version('0.1.2')
.version('0.1.1')
.option('-n, --name [username]', 'get username')
.option('-d, --dark', 'enable dark mode')
.option('-b, --background [background]', 'set background image')
@ -23,6 +18,14 @@ function populateCSS(){
if (err) throw err;
fs.appendFile('index.css', dark, function (err) {
if (err) throw err;
fs.readFile("config.json", function (err , data) {
if (err) throw err;
data = JSON.parse(data);
data[0].theme = "dark";
fs.writeFile('config.json', JSON.stringify(data, null, ' '), function(err){
if (err) throw err;
});
});
});
});
}else{
@ -30,6 +33,14 @@ function populateCSS(){
if (err) throw err;
fs.appendFile('index.css', light, function (err) {
if (err) throw err;
fs.readFile("config.json", function (err , data) {
if (err) throw err;
data = JSON.parse(data);
data[0].theme = "light";
fs.writeFile('config.json', JSON.stringify(data, null, ' '), function(err){
if (err) throw err;
});
});
});
});
}
@ -38,135 +49,32 @@ function populateCSS(){
if (program.background) {
dark = `:root {--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.6), rgb(10, 10, 10, 1)), url('${('%s', program.background)}');--background-background: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0.6)),url('${('%s', program.background)}') center center fixed;--height:50vh;} #display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;} #blog-display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;}#projects section {background:rgb(20, 20, 20);}#blog_section section {background:rgb(20, 20, 20);}@media (max-width: 800px){ --background-image: linear-gradient(0deg, rgba(10, 10, 10, 1), rgb(10, 10, 10, 0)), url('${('%s', program.background)}') !important;}`;
light = `:root {--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('${('%s', program.background)}');--background-background: #fff;}`
light = `:root {--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('${('%s', program.background)}');--background-background: #fff;}`;
fs.readFile("config.json", function (err , data) {
if (err) throw err;
data = JSON.parse(data);
data[0].background = ('%s', program.background);
fs.writeFile('config.json', JSON.stringify(data, null, ' '), function(err){
if (err) throw err;
});
});
populateCSS();
}else{
dark = `:root {--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.6), rgb(10, 10, 10, 1)), url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450');--background-background: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0.6)),url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450') center center fixed;--height:50vh;} #display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;} #blog-display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;}#projects section {background:rgb(20, 20, 20);}#blog_section section {background:rgb(20, 20, 20);}@media (max-width: 800px){ --background-image: linear-gradient(0deg, rgba(10, 10, 10, 1), rgb(10, 10, 10, 0)), url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450') !important;}`;
dark = `:root {--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.6), rgb(10, 10, 10, 1)), url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450');--background-background: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0.6)),url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450') center center fixed;--height:50vh;} #display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;} #blog-display h1 {-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color: #fff;}#projects section {background:rgb(20, 20, 20);}#blog_section section {background:rgb(20, 20, 20);}@media (max-width: 800px){ :root {--background-image: linear-gradient(0deg, rgba(10, 10, 10, 1), rgb(10, 10, 10, 0)), url('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450') !important;}}`;
light = `:root {--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('https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450');--background-background: #fff;}`;
populateCSS();
}
function convertToEmoji(text){
if (text == null) return;
text = text.toString();
if(text.match(/(?<=:\s*).*?(?=\s*:)/gs) != null){
var str = text.match(/(?<=:\s*).*?(?=\s*:)/gs);
str = str.filter(function(arr) {
return /\S/.test(arr);
});
for(i=0;i<str.length;i++){
if(emoji.URLS[str[i]] != undefined){
var output = emoji.of(str[i]);
var emojiImage = output.url.replace("assets-cdn.github", "github.githubassets");
text = text.replace(`:${str[i]}:`, `<img src="${emojiImage}" class="emoji">`);
}
}
return text;
}else{
return text;
}
}
function populateHTML(username){
//add data to assets/index.html
jsdom.fromFile("./assets/index.html", options).then(function (dom) {
let window = dom.window, document = window.document;
(async () => {
try {
console.log("Building HTML/CSS...");
var user = await got(`https://api.github.com/users/${username}`);
user = JSON.parse(user.body);
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("username").innerHTML = `<span>${user.name}</span><br>@${user.login}`;
//document.getElementById("github_link").href = `https://github.com/${user.login}`;
document.getElementById("userbio").innerHTML = convertToEmoji(user.bio);
document.getElementById("userbio").style.display = user.bio == null || !user.bio ? 'none' : 'block';
document.getElementById("about").innerHTML = `
<span style="display:${user.company == null || !user.company ? 'none' : 'block'};"><i class="fas fa-users"></i> &nbsp; ${user.company}</span>
<span style="display:${user.email == null || !user.email ? 'none' : 'block'};"><i class="fas fa-envelope"></i> &nbsp; ${user.email}</span>
<span style="display:${user.blog == null || !user.blog ? 'none' : 'block'};"><i class="fas fa-link"></i> &nbsp; ${user.blog}</span>
<span style="display:${user.location == null || !user.location ? 'none' : 'block'};"><i class="fas fa-map-marker-alt"></i> &nbsp;&nbsp; ${user.location}</span>`;
fs.writeFile('index.html', '<!DOCTYPE html>'+window.document.documentElement.outerHTML, function (error){
if (error) throw error;
});
} catch (error) {
console.log(error);
}
})();
}).catch(function(error){
console.log(error);
});
//copy blog.html from assets to blog
fs.copyFile('./assets/blog_template.html', './blog/blog_template.html', (err) => {
if (err) throw err;
//add data to assets/blog.html
jsdom.fromFile("./blog/blog_template.html", options).then(function (dom) {
let window = dom.window, document = window.document;
(async () => {
try {
var user = await got(`https://api.github.com/users/${username}`);
user = JSON.parse(user.body);
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_blog").style.background = `url('${user.avatar_url}') center center`;
document.getElementById("username_blog").innerHTML = `<span>${user.name}</span><br>@${user.login}<br><b id="blog_time"></b>`;
fs.writeFile('./blog/blog_template.html', '<!DOCTYPE html>'+window.document.documentElement.outerHTML, function (error){
if (error) throw error;
});
} catch (error) {
console.log(error);
}
})();
}).catch(function(error){
console.log(error);
});
});
}
function PopulateRepos(username){
var repoData = [];
(async () => {
try {
var repos = await got(`https://api.github.com/users/${username}/repos?sort=created`);
repos = JSON.parse(repos.body);
for(var i = 0;i < repos.length;i++){
if(repos[i].fork == false){
repoData.push({
"html_url": repos[i].html_url,
"name": repos[i].name,
"description": repos[i].description,
"language": repos[i].language,
"stargazers_count": repos[i].stargazers_count,
"forks_count" :repos[i].forks_count
});
}
}
fs.writeFile('./repos/repos.json', JSON.stringify(repoData), function(err){
fs.readFile("config.json", function (err , data) {
if (err) throw err;
console.log('Repos Created Successfully in repos folder.');
});
} catch (error) {
console.log(error);
}
})();
data = JSON.parse(data);
data[0].background = "https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450";
fs.writeFile('config.json', JSON.stringify(data, null, ' '), function(err){
if (err) throw err;
});
});
populateCSS();
}
if (program.name) {
populateHTML(('%s', program.name));
PopulateRepos(('%s', program.name));
updateHTML(('%s', program.name));
} else {
console.log("Provide a username");
}

9
config.json Normal file
View File

@ -0,0 +1,9 @@
[
{
"username": null,
"name": null,
"userimg": null,
"background": null,
"theme": "light"
}
]

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "gitfolio",
"version": "0.1.2",
"version": "0.1.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "gitfolio",
"version": "0.1.2",
"version": "0.1.1",
"description": "portfolio website for showcasing your work",
"main": "build.js",
"scripts": {

99
populate.js Normal file
View File

@ -0,0 +1,99 @@
const fs = require('fs');
const got = require('got');
const emoji = require('github-emoji');
const jsdom = require('jsdom').JSDOM,
options = {
resources: "usable"
};
function convertToEmoji(text){
if (text == null) return;
text = text.toString();
if(text.match(/(?<=:\s*).*?(?=\s*:)/gs) != null){
var str = text.match(/(?<=:\s*).*?(?=\s*:)/gs);
str = str.filter(function(arr) {
return /\S/.test(arr);
});
for(i=0;i<str.length;i++){
if(emoji.URLS[str[i]] != undefined){
var output = emoji.of(str[i]);
var emojiImage = output.url.replace("assets-cdn.github", "github.githubassets");
text = text.replace(`:${str[i]}:`, `<img src="${emojiImage}" class="emoji">`);
}
}
return text;
}else{
return text;
}
}
module.exports.updateHTML = (username) => {
//add data to assets/index.html
jsdom.fromFile("./assets/index.html", options).then(function (dom) {
let window = dom.window, document = window.document;
(async () => {
try {
console.log("Building HTML/CSS...");
var repos = await got(`https://api.github.com/users/${username}/repos?sort=created`);
repos = JSON.parse(repos.body);
for(var i = 0;i < repos.length;i++){
if(repos[i].fork == false){
document.getElementById("projects").innerHTML += `
<a href="${repos[i].html_url}" target="_blank">
<section>
<div class="section_title">${repos[i].name}</div>
<div class="about_section">
${convertToEmoji(repos[i].description)}
</div>
<div class="bottom_section">
<span><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);
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("username").innerHTML = `<span style="display:${user.name == null || !user.name ? 'none' : 'block'};">${user.name}</span>@${user.login}`;
//document.getElementById("github_link").href = `https://github.com/${user.login}`;
document.getElementById("userbio").innerHTML = convertToEmoji(user.bio);
document.getElementById("userbio").style.display = user.bio == null || !user.bio ? 'none' : 'block';
document.getElementById("about").innerHTML = `
<span style="display:${user.company == null || !user.company ? 'none' : 'block'};"><i class="fas fa-users"></i> &nbsp; ${user.company}</span>
<span style="display:${user.email == null || !user.email ? 'none' : 'block'};"><i class="fas fa-envelope"></i> &nbsp; ${user.email}</span>
<span style="display:${user.blog == null || !user.blog ? 'none' : 'block'};"><i class="fas fa-link"></i> &nbsp; ${user.blog}</span>
<span style="display:${user.location == null || !user.location ? 'none' : 'block'};"><i class="fas fa-map-marker-alt"></i> &nbsp;&nbsp; ${user.location}</span>
<span style="display:${user.hireable == false || !user.hireable ? 'none' : 'block'};"><i class="fas fa-user-tie"></i> &nbsp;&nbsp; Available for hire</span>`;
//add data to config.json
fs.readFile("config.json", function (err , data) {
if (err) throw err;
data = JSON.parse(data);
data[0].username = user.login;
data[0].name = user.name;
data[0].userimg = user.avatar_url;
fs.writeFile('config.json', JSON.stringify(data, null, ' '), function(err){
if (err) throw err;
});
});
fs.writeFile('index.html', '<!DOCTYPE html>'+window.document.documentElement.outerHTML, function (error){
if (error) throw error;
console.log("Build Complete");
process.exit(0)
});
} catch (error) {
console.log(error);
}
})();
}).catch(function(error){
console.log(error);
});
}

13
update.js Normal file
View File

@ -0,0 +1,13 @@
const fs = require('fs');
const {updateHTML} = require('./populate');
fs.readFile("config.json", function (err , data) {
if (err) throw err;
data = JSON.parse(data);
var username = data[0].username;
if(!username || username == null){
console.log("username not found in config.json, please run build command before using update");
return;
}
updateHTML(username);
});