Skip to content

Commit

Permalink
Merge pull request #11 from cetinerhalil/develop
Browse files Browse the repository at this point in the history
release version bump to v0.2.0
  • Loading branch information
bayneri authored Nov 30, 2018
2 parents bc479a0 + a259e00 commit e93d7fd
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 65 deletions.
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ You need `node` in order to build the project. If it's not installed, install no
"name": "li/cetinerhalil",
"link": "https://linkedin.com/in/cetinerhalil"
},
"dribble": {
"name": "dr/cetinerhalil",
"link": "https://dribble.com/cetinerhalil"
},
"blog": {
"name": "md/@cetiner",
"link": "https://medium.com/@cetiner"
Expand All @@ -49,7 +45,7 @@ You need `node` in order to build the project. If it's not installed, install no
"link": "https://twitter.com/cetinerhalil"
},
"instagram": {
"name": "in/cetinerhalil",
"name": "ig/cetinerhalil",
"link": "https://instagram.com/cetinerhalil"
},
"facebook": {
Expand Down Expand Up @@ -96,6 +92,29 @@ Well, after filling the json, you are almost all set.
```
npm run-script adapt
```

## Platform Icons

If you add the name of the profiles you add like `gh/cetinerhalil`, adapt will automatically parse it and replace the `gh` with GitHub icon. Here are the supported icons:

| Platform | Shortened |
|:-----------|:-----------|
| Behance | be |
| Blogger | bl |
| Discord | dc |
| Dribbble | dr |
| Facebook | fb |
| GitHub | gh |
| Instagram | ig |
| LinkedIn | li |
| Medium | md |
| Pinterest | pt |
| Skype | sk |
| Spotify | sp|
| Telegram | tg |
| Twitter | tw |
| Vimeo | vi |
| YouTube | yt |
## Result

After editing the json file and running the script, your personal website is ready. From then on, all you need are `index.html` file and `assets` folder.
Expand Down
92 changes: 53 additions & 39 deletions adapt.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const fs = require('fs');
const platforms = require('./platforms');

fs.readFile('./data.json', 'utf8', (err, data) => {
if (err) throw err;
data = JSON.parse(data);
if (err) throw err;
data = JSON.parse(data);

const head = `
const head = `
<!DOCTYPE html>
<html>
Expand All @@ -28,24 +30,24 @@ fs.readFile('./data.json', 'utf8', (err, data) => {
</head>`;


let nav = `
let nav = `
<div id="sidenav" class="span2">
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<li class="nav-header active" data-group="User"><a href="#api-User">User</a></li>
<li data-group="User" data-name="GetUser">`;

for (let i in data.endpoints) {
nav += `
<a href="#endpoint-${i}">${data.endpoints[i].name}</a>`
}
for (let i in data.endpoints) {
nav += `
<a href="#endpoint-${i}">${data.endpoints[i].name}</a>`
}
nav += `
</li>
</ul>
</nav>
</div>`

const header = `
const header = `
<div id="header">
<div class="pull-left">
<h1>${data.user.firstname} ${data.user.lastname}</h1>
Expand All @@ -54,13 +56,13 @@ fs.readFile('./data.json', 'utf8', (err, data) => {
<div class="clearfix"></div>
</div>`;

let sections = `
let sections = `
<div id="sections">
<section id="api-User" data-name="User">
<h1>User</h1>`

for (let i in data.endpoints) {
sections += `
for (let i in data.endpoints) {
sections += `
<div id="endpoint-${i}">
<article>
<div class="pull-left">
Expand All @@ -69,8 +71,8 @@ fs.readFile('./data.json', 'utf8', (err, data) => {
<div class="clearfix"></div>
<pre class="prettyprint language-html prettyprinted" data-type="get"><code><span class="pln">${data.endpoints[i].path}</span></code></pre>`;
if (data.endpoints[i].success) {
sections += `
if (data.endpoints[i].success) {
sections += `
<h2>Success 200</h2>
<table>
<thead>
Expand All @@ -82,18 +84,30 @@ fs.readFile('./data.json', 'utf8', (err, data) => {
</thead>
<tbody>`;

for (let x in data.user) {
const sample_response = typeof data.user[x] == 'string' ? data.user[x] : `<a href="${data.user[x].link}" target="_blank">${data.user[x].name}</a>`
sections += `
for (let x in data.user) {
let sample_response;
if (typeof data.user[x] == 'string') {
sample_response = data.user[x];
} else {
const propertyName = data.user[x].name;
const platformIndex = platforms.shortened.indexOf(propertyName.substr(0, 3));
if (platformIndex != -1) {
sample_response = `<a href="${data.user[x].link}" target="_blank"><i class="fab fa-${platforms.icons[platformIndex]}"></i>/${propertyName.substring(3)}</a>`;
} else {
sample_response = `<a href="${data.user[x].link}" target="_blank">${propertyName}</a>`
}
}

sections += `
<tr>
<td class="code">${x}</td>
<td>String</td>
<td>
<p>${sample_response}</p>
</td>
</tr>`;
}
sections += `
}
sections += `
</tbody>
</table>
Expand All @@ -108,21 +122,21 @@ fs.readFile('./data.json', 'utf8', (err, data) => {
<pre class="prettyprint language-json prettyprinted" data-type="json"><code><span class="pln"> HTTP</span><span class="pun">/</span><span class="lit">1.1</span><span class="pln"> </span><span class="lit">200</span><span class="pln"> OK
</span><span class="pun">{</span>`;

for (let x in data.user) {
const value = typeof data.user[x] == 'string' ? data.user[x] : data.user[x].name;
sections += `<span class="pln">
for (let x in data.user) {
const value = typeof data.user[x] == 'string' ? data.user[x] : data.user[x].name;
sections += `<span class="pln">
</span><span class="str">"${x}"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"${value}"</span><span class="pun">,</span>`;
}
}

sections += `<span class="pln">
sections += `<span class="pln">
</span><span class="pun">}</span></code></pre>
</div>
</div>`
}
}

if (data.endpoints[i].error) {
let error = data.endpoints[i].error;
sections += `
if (data.endpoints[i].error) {
let error = data.endpoints[i].error;
sections += `
<h2>Error 4xx</h2>
<table>
<thead>
Expand Down Expand Up @@ -155,10 +169,10 @@ fs.readFile('./data.json', 'utf8', (err, data) => {
</span><span class="pun">}</span></code></pre>
</div>
</div>`;
}

}
sections += `

}
sections += `
</article>
</div>
<div id="generator">
Expand All @@ -169,7 +183,7 @@ fs.readFile('./data.json', 'utf8', (err, data) => {
</div>
</div>`;

const body = `<body>
const body = `<body>
<div class="container-fluid">
<div class="row-fluid">
${nav}
Expand All @@ -181,17 +195,17 @@ fs.readFile('./data.json', 'utf8', (err, data) => {
</div>
</body>`;

const html = `
const html = `
${head}
${body}
</html>`

fs.writeFile("./index.html", html, function (err) {
if (err) {
return console.log(err);
}
fs.writeFile("./index.html", html, function (err) {
if (err) {
return console.log(err);
}

console.log("The file was saved!");
});
console.log("The file was saved!");
});
});
6 changes: 1 addition & 5 deletions data.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"name": "li/cetinerhalil",
"link": "https://linkedin.com/in/cetinerhalil"
},
"dribble": {
"name": "dr/cetinerhalil",
"link": "https://dribble.com/cetinerhalil"
},
"blog": {
"name": "md/@cetiner",
"link": "https://medium.com/@cetiner"
Expand All @@ -32,7 +28,7 @@
"link": "https://twitter.com/cetinerhalil"
},
"instagram": {
"name": "in/cetinerhalil",
"name": "ig/cetinerhalil",
"link": "https://instagram.com/cetinerhalil"
},
"facebook": {
Expand Down
22 changes: 7 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,49 +107,42 @@ <h2>Success 200</h2>
<td class="code">github</td>
<td>String</td>
<td>
<p><a href="undefined" target="_blank">gh/cetinerhalil</a></p>
<p><a href="undefined" target="_blank"><i class="fab fa-github"></i>/cetinerhalil</a></p>
</td>
</tr>
<tr>
<td class="code">linkedin</td>
<td>String</td>
<td>
<p><a href="https://linkedin.com/in/cetinerhalil" target="_blank">li/cetinerhalil</a></p>
</td>
</tr>
<tr>
<td class="code">dribble</td>
<td>String</td>
<td>
<p><a href="https://dribble.com/cetinerhalil" target="_blank">dr/cetinerhalil</a></p>
<p><a href="https://linkedin.com/in/cetinerhalil" target="_blank"><i class="fab fa-linkedin"></i>/cetinerhalil</a></p>
</td>
</tr>
<tr>
<td class="code">blog</td>
<td>String</td>
<td>
<p><a href="https://medium.com/@cetiner" target="_blank">md/@cetiner</a></p>
<p><a href="https://medium.com/@cetiner" target="_blank"><i class="fab fa-medium"></i>/@cetiner</a></p>
</td>
</tr>
<tr>
<td class="code">twitter</td>
<td>String</td>
<td>
<p><a href="https://twitter.com/cetinerhalil" target="_blank">tw/cetinerhalil</a></p>
<p><a href="https://twitter.com/cetinerhalil" target="_blank"><i class="fab fa-twitter"></i>/cetinerhalil</a></p>
</td>
</tr>
<tr>
<td class="code">instagram</td>
<td>String</td>
<td>
<p><a href="https://instagram.com/cetinerhalil" target="_blank">in/cetinerhalil</a></p>
<p><a href="https://instagram.com/cetinerhalil" target="_blank"><i class="fab fa-instagram"></i>/cetinerhalil</a></p>
</td>
</tr>
<tr>
<td class="code">facebook</td>
<td>String</td>
<td>
<p><a href="https://facebook.com/cetinerhalil" target="_blank">fb/cetinerhalil</a></p>
<p><a href="https://facebook.com/cetinerhalil" target="_blank"><i class="fab fa-facebook"></i>/cetinerhalil</a></p>
</td>
</tr>
</tbody>
Expand All @@ -172,10 +165,9 @@ <h2>Success 200</h2>
</span><span class="str">"university"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"Bogazici University"</span><span class="pun">,</span><span class="pln">
</span><span class="str">"github"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"gh/cetinerhalil"</span><span class="pun">,</span><span class="pln">
</span><span class="str">"linkedin"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"li/cetinerhalil"</span><span class="pun">,</span><span class="pln">
</span><span class="str">"dribble"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"dr/cetinerhalil"</span><span class="pun">,</span><span class="pln">
</span><span class="str">"blog"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"md/@cetiner"</span><span class="pun">,</span><span class="pln">
</span><span class="str">"twitter"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"tw/cetinerhalil"</span><span class="pun">,</span><span class="pln">
</span><span class="str">"instagram"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"in/cetinerhalil"</span><span class="pun">,</span><span class="pln">
</span><span class="str">"instagram"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"ig/cetinerhalil"</span><span class="pun">,</span><span class="pln">
</span><span class="str">"facebook"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"fb/cetinerhalil"</span><span class="pun">,</span><span class="pln">
</span><span class="pun">}</span></code></pre>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adapt",
"version": "0.1.0",
"version": "0.2.0",
"description": "adapt - apiDoc as personal website template",
"author": "Halil Cetiner (@cetinerhalil)",
"scripts": {
Expand Down
21 changes: 21 additions & 0 deletions platforms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
shortened: ['be/', 'bl/', 'dc/', 'dr/', 'fb/', 'gh/', 'ig/', 'li/', 'md/', 'pt/', 'sk/', 'sp/', 'tg/', 'tw/', 'vi/', 'yt/'],
icons: [
'behance',
'blogger',
'discord',
'dribbble',
'facebook',
'github',
'instagram',
'linkedin',
'medium',
'pinterest',
'skype',
'spotify',
'telegram',
'twitter',
'vimeo',
'youtube'
]
};
Binary file modified screenshots/ss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e93d7fd

Please sign in to comment.