1
0
Fork 0
mirror of https://github.com/dilllxd/gitfolio.git synced 2024-08-14 22:28:09 +00:00

Merge pull request #9 from imfunniee/revert-8-master

Revert "Repo list now pulls from a JSON list like Blogs"
This commit is contained in:
imfunny 2019-05-11 14:12:31 +05:30 committed by GitHub
commit 8b432362cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 101 deletions

View file

@ -60,18 +60,13 @@ You could also add in your custom CSS inside `index.css` to give it a more perso
### Let's Publish
You can host your website using github pages and use a custom domain as well or simply use `username.github.io`.
You can host your website using github pages and use a custom domain aswell or simply use `username.github.io`.
### Updating
To update your info, follow the same steps shown in `Let's build` part
The repo list can be updated independently with the following command:
```
$ node repos --name username
```
### Add a Blog

View file

@ -62,25 +62,6 @@
`)
}
});
$.getJSON("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>

View file

@ -76,7 +76,26 @@ jsdom.fromFile("./assets/index.html", options).then(function (dom) {
(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;
@ -136,38 +155,8 @@ jsdom.fromFile("./blog/blog_template.html", options).then(function (dom) {
});
}
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){
if (err) throw err;
console.log('Repos Created Successfully in root folder.');
});
} catch (error) {
console.log(error);
}
})();
}
if (program.name) {
populateHTML(('%s', program.name));
populateRepos(('%s', program.name));
} else {
console.log("Provide a username");
}

View file

@ -1,45 +0,0 @@
const program = require('commander');
const fs = require('fs');
const got = require('got');
options = {
resources: "usable"
};
program
.version('0.1.0')
.option('-n, --name [username]', 'get username')
.parse(process.argv);
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.json', JSON.stringify(repoData), function(err){
if (err) throw err;
console.log('Repos Created Successfully in root folder.');
});
} catch (error) {
console.log(error);
}
})();
}
if (program.name) {
populateRepos(('%s', program.name));
} else {
console.log("provide a name to scrape repos");
}

View file