Skip to content
This repository was archived by the owner on Sep 20, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="//platform.linkedin.com/in.js">

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any special reason to have this in the head? It would block page rendering until it loads.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the way it's stated in the documentation: https://developer.linkedin.com/docs/getting-started-js-sdk (in the "Initialize the SDK in your webpage" section).

api_key: <your_api_key>
onLoad: onLinkedInLoad
</script>
<title>CV Maker</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="./style.css"/>
<script type="text/javascript" src="https://rawgit.com/gwendall/way.js/master/way.min.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/gwendall/way.js/master/way.min.js"></script>
</head>
<body>
<div id="wrapper">
<div id="left-wrapper" class="container">
<h2>Markdown CV Maker</h2>
<script type="in/Login"></script>
<form id="inputData" way-data="inputData" way-persistent class="form-group">
<fieldset class="form-group">
<label>Full Name</label>
Expand Down Expand Up @@ -112,13 +117,14 @@ <h3>Favorites</h3>
<div class="container">
<button class="btn btn-default" id="btnMd">Markdown</button>
<button class="btn btn-default" id="btnLive">Live Preview</button>
<button class="btn btn-success" id="btnExport">Export JSON</button>
<button class="btn btn-success" id="btnDownload">Download Raw Markdown</button>
</div>
<pre id="previewer"></pre>
<div id="live-preview" class="hidden"></div>
</div>
</div>
<script src="./src.es5.js"></script>
<script src="https://rawgit.com/chjj/marked/master/lib/marked.js"></script>
<script src="https://cdn.rawgit.com/chjj/marked/master/lib/marked.js"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ this app makes a markdown only resume that looks elegant and simple everywhere

try it out here: http://awal.js.org/cv-maker/

# Example

[Source](https://gist.githubusercontent.com/awalGarg/a8e97b27b249f2c94f8e/raw/09e63fd69f2288cd631a492d392e8d114af7a432/res.md)
Renders in various markdown renderers:
- [Github Gist](https://gist.github.com/awalGarg/a8e97b27b249f2c94f8e)
- [StackEdit](https://stackedit.io/viewer#!url=https://gist.githubusercontent.com/awalGarg/a8e97b27b249f2c94f8e/raw/09e63fd69f2288cd631a492d392e8d114af7a432/res.md)
- [Notehub](https://notehub.org/tvpb6)
- [Draft.sx](http://draft.sx/a8e97b27b249f2c94f8e)
- [Markdownshare](https://markdownshare.com/view/6dfe5d69-36f7-4708-b9b8-d3ce7ffc1b77)
- [Plain HTML](https://html.house/5hkj6wf5.html)

This just illustrates how versatile markdown (and thus this app) is!

# philosophy

Stackoverflow had a side project called "Careers Stackoverflow". They had a very decent resume builder. The output it produced was elegant, and easy on eyes. It wasn't bloated with ads and didn't look shit on small screens. Unfortunately, it seems that they are converting it to some Facebook timeline like [story thing](http://meta.stackoverflow.com/questions/313960/introducing-the-developer-story). The community there doesn't like that decision either.
Expand Down
48 changes: 40 additions & 8 deletions src.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ var config = {
divider: '\n---'
};

function onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}

// Handle the successful return from the API call
function onSuccess(data) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the on* naming for these functions are too generic to be in global scope. We'd need to move these into a closure or as object methods

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awalgarg OK, you are right. I will be happy to improve my PR.
Can you give me more details on how I can implement this?

console.log(data);
}

// Handle an error response from the API call
function onError(error) {
console.log(error);
}

// Use the API call wrapper to request the member's basic profile data
function getProfileData() {
IN.API.Raw("/people/~").result(onSuccess).error(onError);
}

var reducers = [[function avatar(u) {
return u.avatar ? ' ![avatar][]' : '';
}, function fullName(u) {
Expand Down Expand Up @@ -173,6 +192,20 @@ var utils = {
return since + ' - ' + till;
}
return '';
},
downloadFromData: function downloadFromData(data, type, filename) {
var blob = new Blob([data], { type: type });
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.download = filename;
a.href = url;
a.classList.add('hidden');
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
setTimeout(function () {
return URL.revokeObjectURL(url);
}, 0);
}
};

Expand All @@ -183,16 +216,14 @@ way.watch('inputData', function (val) {
});

document.getElementById('btnDownload').addEventListener('click', downloadRaw);
document.getElementById('btnExport').addEventListener('click', downloadJSON);

function downloadJSON() {
utils.downloadFromData(JSON.stringify(way.get('inputData'), null, ' '), 'application/json', 'cv.json');
}

function downloadRaw() {
var a = document.createElement('a');
a.download = 'cv.md';
var blob = new Blob([renderer(way.get('inputData'), reducers)], { type: 'text/plain' });
var url = URL.createObjectURL(blob);
a.href = url;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
utils.downloadFromData(renderer(way.get('inputData'), reducers), 'text/plain', 'cv.md');
}

document.getElementById('btnMd').addEventListener('click', function () {
Expand All @@ -213,3 +244,4 @@ function switchTab(to) {
prev.classList.add('hidden');
}
}

26 changes: 18 additions & 8 deletions src.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ var utils = {
return `${since} - ${till}`;
}
return '';
},
downloadFromData(data, type, filename) {
var blob = new Blob([data], {type});
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.download = filename;
a.href = url;
a.classList.add('hidden');
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
setTimeout(() => URL.revokeObjectURL(url), 0);
}
};

Expand All @@ -192,16 +204,14 @@ way.watch('inputData', function (val) {
});

document.getElementById('btnDownload').addEventListener('click', downloadRaw);
document.getElementById('btnExport').addEventListener('click', downloadJSON);

function downloadJSON() {
utils.downloadFromData(JSON.stringify(way.get('inputData'), null, ' '), 'application/json', 'cv.json');
}

function downloadRaw () {
var a = document.createElement('a');
a.download = 'cv.md';
var blob = new Blob([renderer(way.get('inputData'), reducers)], {type: 'text/plain'});
var url = URL.createObjectURL(blob);
a.href = url;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
utils.downloadFromData(renderer(way.get('inputData'), reducers), 'text/plain', 'cv.md');
}

document.getElementById('btnMd').addEventListener('click', function () {
Expand Down