mirror of
https://github.com/dilllxd/gitfolio.git
synced 2024-08-14 22:28:09 +00:00
Repos to pull from list like Blogs (#11)
* Reimplimented Repos pulling from list. * added repos.json back in
This commit is contained in:
parent
8b432362cf
commit
ee230e3a1a
4 changed files with 94 additions and 20 deletions
|
@ -62,6 +62,25 @@
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$.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> ${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>
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
50
build.js
50
build.js
|
@ -76,26 +76,6 @@ jsdom.fromFile("./assets/index.html", options).then(function (dom) {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
console.log("Building HTML/CSS...");
|
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> ${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}`);
|
var user = await got(`https://api.github.com/users/${username}`);
|
||||||
user = JSON.parse(user.body);
|
user = JSON.parse(user.body);
|
||||||
document.title = user.login;
|
document.title = user.login;
|
||||||
|
@ -155,8 +135,38 @@ 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 repos folder.');
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
if (program.name) {
|
if (program.name) {
|
||||||
populateHTML(('%s', program.name));
|
populateHTML(('%s', program.name));
|
||||||
|
PopulateRepos(('%s', program.name));
|
||||||
} else {
|
} else {
|
||||||
console.log("Provide a username");
|
console.log("Provide a username");
|
||||||
}
|
}
|
45
repos.js
Normal file
45
repos.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
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/repos.json', JSON.stringify(repoData), function(err){
|
||||||
|
if (err) throw err;
|
||||||
|
console.log('Repos Created Successfully in repos folder.');
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
if (program.name) {
|
||||||
|
PopulateRepos(('%s', program.name));
|
||||||
|
} else {
|
||||||
|
console.log("provide a name to scrape repos");
|
||||||
|
}
|
0
repos/repos.json
Normal file
0
repos/repos.json
Normal file
Loading…
Reference in a new issue