1
0
Fork 0
mirror of https://github.com/dilllxd/gitfolio.git synced 2024-08-14 22:28:09 +00:00
-added cli support (thanks @rohit-smpx)
-arguments for fork
-you can now sort and order repos
-fixed bugs
This commit is contained in:
imfunny 2019-05-23 15:27:23 +05:30 committed by GitHub
parent 81e8302b22
commit 6fb6408534
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 1853 additions and 1056 deletions

View file

@ -11,31 +11,29 @@ Check out this [live demo](https://imfunniee.github.io/gitfolio/) to see gitfoli
# Getting Started # Getting Started
### Let's Install
Install gitfolio
```sh
npm i -g gitfolio
```
### Let's Build ### Let's Build
a. Clone this repo or simply download it.
```sh ```sh
git clone https://github.com/imfunniee/gitfolio.git gitfolio build <username>
``` ```
This will build your website using your GitHub username and put it in the `/dist` folder.
b. `cd` into the repo you just cloned or downloaded. To run your website use `run` command
```sh
cd gitfolio # Navigate into the project folder
npm i # Install the required dependencies
```
c. Gitfolio is now ready to be used. The command
```sh ```sh
node build --name [username] gitfolio build <username>
``` ```
Will build your website using your GitHub username and put it in the `dist/` folder.
d. To run your website navigate to `./dist/index.html` in your browser. [you won't see blogs until you are on localhost]
🎉 Congrats, you just made yourself a personal website! 🎉 Congrats, you just made yourself a personal website!
> if you get stuck somewhere or get an error, please create an issue
### Let's Customize ### Let's Customize
@ -44,7 +42,7 @@ d. To run your website navigate to `./dist/index.html` in your browser. [you won
To include forks on your personal website just provide `-f` or `--fork` argument while building To include forks on your personal website just provide `-f` or `--fork` argument while building
``` ```
$ node build --name username -f $ gitfolio build username -f
``` ```
#### Sorting Repos #### Sorting Repos
@ -52,7 +50,7 @@ $ node build --name username -f
To sort repos provide `--sort [sortBy]` argument while building. Where `[sortBy]` can be `star`, `created`, `updated`, `pushed`,`full_name`. Default: `created` To sort repos provide `--sort [sortBy]` argument while building. Where `[sortBy]` can be `star`, `created`, `updated`, `pushed`,`full_name`. Default: `created`
``` ```
$ node build --name username --sort star $ gitfolio build username --sort star
``` ```
#### Ordering Repos #### Ordering Repos
@ -60,7 +58,7 @@ $ node build --name username --sort star
To order the sorted repos provide `--order [orderBy]` argument while building. Where `[orderBy]` can be `asc` or `desc`. Default: `asc` To order the sorted repos provide `--order [orderBy]` argument while building. Where `[orderBy]` can be `asc` or `desc`. Default: `asc`
``` ```
$ node build --name username --sort star --order desc $ gitfolio build username --sort star --order desc
``` ```
#### Customize Themes #### Customize Themes
@ -73,7 +71,7 @@ Themes are specified using the `--theme [theme-name]` flag when running the `bui
For example, the following command will build the website with the dark theme For example, the following command will build the website with the dark theme
``` ```
$ node build --name username --theme dark $ gitfolio build username --theme dark
``` ```
#### Customize background image #### Customize background image
@ -81,7 +79,7 @@ $ node build --name username --theme dark
To customize the background image just provide `--background [url]` argument while building To customize the background image just provide `--background [url]` argument while building
``` ```
$ node build --name username --background https://images.unsplash.com/photo-1557277770-baf0ca74f908?w=1634 $ gitfolio build username --background https://images.unsplash.com/photo-1557277770-baf0ca74f908?w=1634
``` ```
You could also add in your custom CSS inside `index.css` to give it a more personal feel. You could also add in your custom CSS inside `index.css` to give it a more personal feel.
@ -99,7 +97,7 @@ Go To `username.github.io` your site should be up!!
To update your info, simply run To update your info, simply run
``` ```
$ node update $ gitfolio update
``` ```
This will update your info and your repository info. This will update your info and your repository info.
@ -111,7 +109,7 @@ To Update background or theme you need to run `build` command again.
To add your first blog run this command. To add your first blog run this command.
``` ```
$ node blog --title my-first-blog $ gitfolio blog my-first-blog
``` ```
> (use "-" instead of spaces) > (use "-" instead of spaces)
@ -142,11 +140,12 @@ More Arguments for Blog
> (use "-" instead of spaces) > (use "-" instead of spaces)
## Support ## Support
Support me by buying me a coffee ☕ Support me to make more projects like this by Buying me a Coffee ☕
<a href="https://www.buymeacoffee.com/imfunniee" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a> <a href="https://www.buymeacoffee.com/imfunniee" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;"></a>
## License ## License
![GitHub](https://img.shields.io/github/license/imfunniee/gitfolio.svg) ![GitHub](https://img.shields.io/github/license/imfunniee/gitfolio.svg)

View file

@ -1,9 +1,9 @@
[ [
{ {
"url_title": "FooBar", "url_title": "FooBar",
"title": "FooBar", "title": "FooBar",
"sub_title": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "sub_title": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"top_image": "https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450", "top_image": "https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450",
"visible": true "visible": true
} }
] ]

View file

@ -287,6 +287,7 @@ body{
font-size:24px; font-size:24px;
font-weight:bold; font-weight:bold;
margin:1vh 0px; margin:1vh 0px;
padding:0px 1px;
word-wrap: break-word; word-wrap: break-word;
} }

View file

@ -1,44 +1,51 @@
#! /usr/bin/env node #! /usr/bin/env node
/* Argument parser */ /* Argument parser */
const program = require('commander'); const program = require('commander');
process.env.OUT_DIR = process.env.OUT_DIR || process.cwd(); process.env.OUT_DIR = process.env.OUT_DIR || process.cwd();
const {buildCommand} = require('../build'); const {buildCommand} = require('../build');
const {updateCommand} = require('../update'); const {updateCommand} = require('../update');
const {blogCommand} = require('../blog'); const {blogCommand} = require('../blog');
const {version} = require('../package.json'); const {runCommand} = require('../run');
const {version} = require('../package.json');
program
.command('build <username>') program
.description('Build site with your GitHub username. This will be used to customize your site') .command('build <username>')
.option('-t, --theme [theme]', 'specify a theme to use', 'light') .description('Build site with your GitHub username. This will be used to customize your site')
.option('-b, --background [background]', 'set the background image') .option('-t, --theme [theme]', 'specify a theme to use', 'light')
.option('-f, --fork', 'includes forks with repos') .option('-b, --background [background]', 'set the background image')
.option('-s, --sort [sort]', 'set default sort for repository', 'created') .option('-f, --fork', 'includes forks with repos')
.option('-o, --order [order]', 'set default order on sort', 'asc') .option('-s, --sort [sort]', 'set default sort for repository', 'created')
.action(buildCommand) .option('-o, --order [order]', 'set default order on sort', 'asc')
.action(buildCommand)
program
.command('update') program
.action(updateCommand); .command('update')
.description('Update user and repository data')
program .action(updateCommand);
.command('blog <title>')
.description('Create blog with specified title') program
.option('-s, --subtitle [subtitle]', 'give blog a subtitle', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.') .command('blog <title>')
.option('-p, --pagetitle [pagetitle]', 'give blog page a title') .description('Create blog with specified title')
.option('-f, --folder [folder]', 'give folder a title (use "-" instead of spaces)') .option('-s, --subtitle [subtitle]', 'give blog a subtitle', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
.action(blogCommand); .option('-p, --pagetitle [pagetitle]', 'give blog page a title')
.option('-f, --folder [folder]', 'give folder a title (use "-" instead of spaces)')
program.on('command:*', () => { .action(blogCommand);
console.log('Unknown Command: ' + program.args.join(' '))
program.help() program
}); .command('run')
.description('Run build files')
program .action(runCommand);
.version(version, '-v --version')
.usage('<command> [options]') program.on('command:*', () => {
.parse(process.argv); console.log('Unknown Command: ' + program.args.join(' '))
program.help()
if (program.args.length === 0) program.help(); });
program
.version(version, '-v --version')
.usage('<command> [options]')
.parse(process.argv);
if (program.args.length === 0) program.help();

View file

@ -64,5 +64,5 @@ function blogCommand(title, program) {
} }
module.exports = { module.exports = {
blogCommand, blogCommand
}; };

View file

@ -83,5 +83,5 @@ async function buildCommand(username, program) {
} }
module.exports = { module.exports = {
buildCommand, buildCommand
}; };

View file

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

2610
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
{ {
"name": "gitfolio", "name": "gitfolio",
"version": "0.1.2", "version": "0.1.3",
"description": "portfolio website for showcasing your work", "description": "a portfolio website for everyone to showcase your work",
"main": "build.js", "main": "build.js",
"bin": "bin/gitfolio.js", "bin": "bin/gitfolio.js",
"scripts": { "scripts": {
@ -34,9 +34,13 @@
"dependencies": { "dependencies": {
"bluebird": "^3.5.4", "bluebird": "^3.5.4",
"commander": "^2.20.0", "commander": "^2.20.0",
"express": "^4.17.0",
"github-emoji": "^1.1.0", "github-emoji": "^1.1.0",
"got": "^9.6.0", "got": "^9.6.0",
"handlebars": "^4.1.2", "handlebars": "^4.1.2",
"jsdom": "^15.1.0" "jsdom": "^15.1.0",
"ncp": "^2.0.0",
"open": "^6.3.0",
"x-default-browser": "^0.4.0"
} }
} }

View file

@ -126,7 +126,7 @@ module.exports.updateHTML = (username, sort, order, includeFork) => {
}); });
fs.writeFile(`${outDir}/index.html`, '<!DOCTYPE html>' + window.document.documentElement.outerHTML, function (error) { fs.writeFile(`${outDir}/index.html`, '<!DOCTYPE html>' + window.document.documentElement.outerHTML, function (error) {
if (error) throw error; if (error) throw error;
console.log("Build Complete"); console.log(`Build Complete, Files can be Found @ ${outDir}`);
}); });
} catch (error) { } catch (error) {
console.log(error); console.log(error);

25
run.js Normal file
View file

@ -0,0 +1,25 @@
const express = require('express');
const open = require('open');
const defaultBrowser = require('x-default-browser');
const app = express();
app.use(express.static(__dirname + '/dist'));
function runCommand(){
app.get('/',function(req,res){
res.sendFile('/index.html');
});
app.listen(3000);
defaultBrowser(function (err, res) {
if(err) throw err;
(async () => {
await open('http://localhost:3000', {app: res.commonName});
console.log("ctrl + c to exit");
})();
});
}
module.exports = {
runCommand
};

View file

@ -1,5 +1,4 @@
const fs = require('fs'); const {getConfig} = require('./utils');
const {getConfig, outDir} = require('./utils');
const {updateHTML} = require('./populate'); const {updateHTML} = require('./populate');
async function updateCommand() { async function updateCommand() {
@ -16,5 +15,5 @@ async function updateCommand() {
} }
module.exports = { module.exports = {
updateCommand, updateCommand
}; };

View file

@ -1,39 +1,39 @@
const path = require('path'); const path = require('path');
const bluebird = require('bluebird'); const bluebird = require('bluebird');
const fs = bluebird.promisifyAll(require('fs')); const fs = bluebird.promisifyAll(require('fs'));
const outDir = path.resolve('./dist/' || process.env.OUT_DIR); const outDir = path.resolve('./dist/' || process.env.OUT_DIR);
const configPath = path.join(outDir, 'config.json'); const configPath = path.join(outDir, 'config.json');
const blogPath = path.join(outDir, 'blog.json'); const blogPath = path.join(outDir, 'blog.json');
const defaultConfigPath = path.resolve(`${__dirname}/default/config.json`); const defaultConfigPath = path.resolve(`${__dirname}/default/config.json`);
const defaultBlogPath = path.resolve(`${__dirname}/default/blog.json`); const defaultBlogPath = path.resolve(`${__dirname}/default/blog.json`);
/** /**
* Tries to read file from out dir, * Tries to read file from out dir,
* if not present returns default file contents * if not present returns default file contents
*/ */
async function getFileWithDefaults(file, defaultFile) { async function getFileWithDefaults(file, defaultFile) {
try { try {
await fs.accessAsync(file, fs.constants.F_OK); await fs.accessAsync(file, fs.constants.F_OK);
} catch (err) { } catch (err) {
const defaultData = await fs.readFileAsync(defaultFile); const defaultData = await fs.readFileAsync(defaultFile);
return JSON.parse(defaultData); return JSON.parse(defaultData);
} }
const data = await fs.readFileAsync(file); const data = await fs.readFileAsync(file);
return JSON.parse(data); return JSON.parse(data);
} }
async function getConfig() { async function getConfig() {
return getFileWithDefaults(configPath, defaultConfigPath); return getFileWithDefaults(configPath, defaultConfigPath);
} }
async function getBlog() { async function getBlog() {
return getFileWithDefaults(blogPath, defaultBlogPath); return getFileWithDefaults(blogPath, defaultBlogPath);
} }
module.exports = { module.exports = {
outDir, outDir,
getConfig, getConfig,
getBlog, getBlog
}; };