Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Favicon support #40

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# jsonresume-theme-kendall
# jsonresume-theme-kendall-bushmanov

A theme for the [JSONResume](https://github.com/jsonresume/resume-schema) schema, that relies on Bootstrap and FontAwesome, added with some personal flair.

**NOTE**: This supports schema 1.0.0. Some things may be missing or broken if your resume.json is using the older schema.

## Usage

To first get started with this JSONResume theme, you'll need to have the JSONResume CLI installed. If you haven't already install it with `npm install -g resume-cli`. If this doesn't work, try `sudo npm install -g resume-cli`.
To first get started with this JSONResume theme, you'll need to have the JSONResume CLI installed. If you haven't already install it with `npm install -g resume-cli`. If this doesn't work, try `npm install -g resume-cli`.

After this, you can get your resume.json ready by typing `resume init`. After hitting enter, your resume will be initialized and you can edit it and fill in the neccessary fields. Check out [the official resume-schema repository](https://github.com/jsonresume/resume-schema) for more information on filling these fields.

When you are finished with your resume, you may test it by yet again opening the command line and typing `resume serve --theme kendall` to see how it looks with this theme. You can replace the word `kendall` with other theme names too.
When you are finished with your resume, you may test it by yet again opening the command line and typing `resume serve --theme kendall-bushmanov` to see how it looks with this theme. You can replace the word `kendall-bushmanov` with other theme names too.

### Install the command line

Expand All @@ -27,7 +27,7 @@ sudo npm install -g resume-cli
We need to install the dependencies. `cd` into the theme folder we just downloaded and run:

```bash
sudo npm install
npm install
```

This will read the local `package.json` and install the packages listed under `dependencies`.
Expand Down
106 changes: 64 additions & 42 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ var fs = require('fs');
var _ = require('lodash');
var gravatar = require('gravatar');
var Mustache = require('mustache');
var formatDuration = require('date-fns/formatDuration');
var differenceInMonths = require('date-fns/differenceInMonths');
var startOfMonth = require('date-fns/startOfMonth');
var endOfMonth = require('date-fns/endOfMonth');
var addDays = require('date-fns/addDays');

var d = new Date();
var curyear = d.getFullYear();
Expand Down Expand Up @@ -35,21 +40,34 @@ function getMonth(startDateStr) {
}
}

function getMimeType(url) {
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
return require('check-url-type').get_type(url) ;
}

function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function render(resumeObject) {

resumeObject.basics.capitalName = resumeObject.basics.name.toUpperCase();
resumeObject.basics.capitalName = _.upperCase(resumeObject.basics.name);
if(resumeObject.basics && resumeObject.basics.email) {
resumeObject.basics.gravatar = gravatar.url(resumeObject.basics.email, {
resumeObject.basics.gravatar = 'https:' + gravatar.url(resumeObject.basics.email, {
s: '200',
r: 'pg',
d: 'mm'
});
}
if (resumeObject.basics.image || resumeObject.basics.gravatar) {
resumeObject.photo = resumeObject.basics.image ? resumeObject.basics.image : resumeObject.basics.gravatar;
resumeObject.photoType = getMimeType(resumeObject.photo) ;
}

_.each(resumeObject.basics.profiles, function(p){
if(p.iconClass) {
return;
}
switch(p.network.toLowerCase()) {
// special cases
case "google-plus":
Expand Down Expand Up @@ -103,52 +121,54 @@ function render(resumeObject) {
}
});

if (resumeObject.work && resumeObject.work.length) {
resumeObject.workBool = true;
_.each(resumeObject.work, function(w){
if (w.startDate) {
w.startDateYear = (w.startDate || "").substr(0,4);
w.startDateMonth = getMonth(w.startDate || "");

}
if(w.endDate) {
w.endDateYear = (w.endDate || "").substr(0,4);
w.endDateMonth = getMonth(w.endDate || "");
} else {
w.endDateYear = 'Present'
}
if (w.highlights) {
if (w.highlights[0]) {
if (w.highlights[0] != "") {
w.boolHighlights = true;
function handleWorkplace(w) {
const { startDate, endDate } = w;
if (startDate) {
w.startDateYear = (startDate || "").substr(0,4);
w.startDateMonth = getMonth(startDate || "");
}
if(endDate) {
w.endDateYear = (endDate || "").substr(0,4);
w.endDateMonth = getMonth(endDate || "");
} else {
w.endDateYear = 'Present'
}
function handleStringArray(obj, fieldName) {
if (obj[fieldName]) {
if (obj[fieldName][0]) {
if (obj[fieldName][0] != "") {
obj['bool' + capitalizeFirstLetter(fieldName)] = true;
}
}
}
});
}
handleStringArray(w, 'highlights');
handleStringArray(w, 'keywords');
if (startDate) {
const months = differenceInMonths(
addDays(endOfMonth(new Date(endDate)), 1),
startOfMonth(new Date(startDate))
);
w.workExperience = formatDuration(
{
years: Math.floor(months / 12),
months: months % 12,
},
{
format: ["years", "months"],
}
);
}
}

if (resumeObject.work && resumeObject.work.length) {
resumeObject.workBool = true;
_.each(resumeObject.work, handleWorkplace);
}

if (resumeObject.volunteer && resumeObject.volunteer.length) {
resumeObject.volunteerBool = true;
_.each(resumeObject.volunteer, function(w){
if (w.startDate) {
w.startDateYear = (w.startDate || "").substr(0,4);
w.startDateMonth = getMonth(w.startDate || "");

}
if(w.endDate) {
w.endDateYear = (w.endDate || "").substr(0,4);
w.endDateMonth = getMonth(w.endDate || "");
} else {
w.endDateYear = 'Present'
}
if (w.highlights) {
if (w.highlights[0]) {
if (w.highlights[0] != "") {
w.boolHighlights = true;
}
}
}
});
_.each(resumeObject.volunteer, handleWorkplace);
}

if (resumeObject.projects && resumeObject.projects.length) {
Expand All @@ -161,6 +181,7 @@ function render(resumeObject) {
if (resumeObject.education[0].institution) {
resumeObject.educationBool = true;
_.each(resumeObject.education, function(e){
handleWorkplace(e);
if( !e.area || !e.studyType ){
e.educationDetail = (e.area == null ? '' : e.area) + (e.studyType == null ? '' : e.studyType);
} else {
Expand Down Expand Up @@ -242,7 +263,8 @@ function render(resumeObject) {

resumeObject.css = fs.readFileSync(__dirname + "/style.css", "utf-8");
resumeObject.printcss = fs.readFileSync(__dirname + "/print.css", "utf-8");
var theme = fs.readFileSync(__dirname + '/resume.template', 'utf8');
resumeObject.pdfcss = fs.readFileSync(__dirname + "/pdf.css", "utf-8");
var theme = fs.readFileSync(__dirname + '/resume.template.html', 'utf8');
var resumeHTML = Mustache.render(theme, resumeObject);


Expand Down
Loading