Merge pull request #4 from there4/master

Merge 2.0.10 changes from markdown-resume project
This commit is contained in:
Erik Waibel 2017-04-09 15:13:47 -07:00 committed by GitHub
commit 70e72345ae
13 changed files with 111 additions and 47 deletions

View File

@ -1,14 +1,13 @@
# Markdown Resume Generator # Markdown Resume Generator [![Build Status](https://travis-ci.org/there4/markdown-resume.png?branch=master)](https://travis-ci.org/there4/markdown-resume)
> Convert markdown to HTML and PDF resumes
Turn a simple Markdown document into an elegant resume with both a perfect Turn a simple Markdown document into an elegant resume with both a perfect
pdf printable format, and a responsive css3 html5 file. You can view a sample pdf printable format, and a responsive css3 html5 file. You can view a sample
at the [blog post for the project][blog]. at the [blog post for the project][blog].
[![Build Status](https://travis-ci.org/there4/markdown-resume.png?branch=master)](https://travis-ci.org/there4/markdown-resume)
## Features ## Features
* Three styles to choose from: modern, blockish, unstyled (Fork and add more!) * Multiple styles to choose from: `modern`, `blockish`, `unstyled`, `readable`, `swissen` _(Fork and add more!)_
* PDF generation via [wkhtmltopdf][wkhtmltopdf] * PDF generation via [wkhtmltopdf][wkhtmltopdf]
* Responsive design for multiple device viewport sizes * Responsive design for multiple device viewport sizes
* Simple Markdown formatting * Simple Markdown formatting
@ -17,14 +16,16 @@ at the [blog post for the project][blog].
## Quickstart ## Quickstart
There is no installation or need to run composer. Just run the phar file: There is no installation or need to run composer. Just download and [run the phar file](https://github.com/there4/markdown-resume/raw/master/bin/md2resume):
```
./bin/md2resume html examples/source/sample.md examples/output/ ./bin/md2resume html examples/source/sample.md examples/output/
./bin/md2resume pdf examples/source/sample.md examples/output/ ./bin/md2resume pdf examples/source/sample.md examples/output/
```
## Help ## Help
``` ```
Markdown Resume Generator version 2.0.8 by Craig Davis Markdown Resume Generator version 2.0.10 by Craig Davis
Usage: Usage:
[options] command [arguments] [options] command [arguments]
@ -53,18 +54,21 @@ Available commands:
Choose a template with the -t option. Choose a template with the -t option.
./bin/md2resume html --template blockish examples/source/sample.md examples/output/ `./bin/md2resume html --template blockish examples/source/sample.md examples/output/`
If you want to edit your markdown resume in your editor while watching it If you want to edit your markdown resume in your editor while watching it
update in your browser, run this command: update in your browser, run this command:
watch ./bin/md2resume html --refresh examples/source/sample.md examples/output/ `watch ./bin/md2resume html --refresh yes --template modern examples/source/sample.md examples/output/`
This makes the build script run periodically, and html document will refresh This makes the build script run periodically, and html document will refresh
every two seconds via a meta tag. Open the `./examples/ouput/sample.html` file every two seconds via a meta tag. Open the `./examples/ouput/sample.html` file
in your browser, and then just save your markdown document when you want to see in your browser, and then just save your markdown document when you want to see
a fresh preview. a fresh preview.
For information about running this inside a Docker container, please read [Issue 46](https://github.com/there4/markdown-resume/issues/46#issuecomment-126520792)
where [Sebastian Klose](https://github.com/sklose) has shared his approach.
## Authoring Your Resume ## Authoring Your Resume
Markdown is limited to basic html markup. Follow the `examples/source/sample.md` Markdown is limited to basic html markup. Follow the `examples/source/sample.md`
@ -87,6 +91,15 @@ commands, you'll need to first install the dependencies:
* `composer install` * `composer install`
After that, you can run the `md2resume_dev.php` file from the command line. After that, you can run the `md2resume_dev.php` file from the command line.
## Building a Release
1. Tag the repo with the new build number. This will be picked up for both
the `version` file used by the self update command and placed into the
phar file.
2. Run `pake build`.
3. Push both the tag and the code.
Check out the pake tooling for more information about the build. Pake will be Check out the pake tooling for more information about the build. Pake will be
installed to `./vendor/bin/pake`. So for instance a complete phar file build installed to `./vendor/bin/pake`. So for instance a complete phar file build
looks like `./vendor/bin/pake build`. looks like `./vendor/bin/pake build`.
@ -100,25 +113,28 @@ are a more comfortable with html than markdown, you should use it.
## Changelog ## Changelog
* __2.0.10__ : Updated spacing in moder template with commites from [@501st-alpha1](https://github.com/501st-alpha1)
* __2.0.9__ : Updated Modern template with improved spacing. Update parsing of
`--template` option to close [issue #7](https://github.com/there4/markdown-resume/issues/7)
* __2.0.8__ : New `readable` theme contributed by @ahmadnazir, minor refactor * __2.0.8__ : New `readable` theme contributed by @ahmadnazir, minor refactor
to support a /links directory to support a /links directory
* __2.0.7__ : Update composer to use `sunra/php-simple-html-dom-parser` this * __2.0.7__ : Update composer to use `sunra/php-simple-html-dom-parser` this
appears to be better maintained and more popular to close #27 appears to be better maintained and more popular to [close #27](https://github.com/there4/markdown-resume/issues/27)
* __2.0.6__ : Fix empty template list from phar file to close #24 * __2.0.6__ : Fix empty template list from phar file to [close #24](https://github.com/there4/markdown-resume/issues/24)
* __2.0.5__ : Remove default value for the `--refresh` option to close #22 * __2.0.5__ : Remove default value for the `--refresh` option to [close #22](https://github.com/there4/markdown-resume/issues/22)
* __2.0.4__ : Fix path resolution problem with absolute paths to close #16 * __2.0.4__ : Fix path resolution problem with absolute paths to [close #16](https://github.com/there4/markdown-resume/issues/16)
* __2.0.3__ : Add optional duration to the `--refresh` option to close #15 * __2.0.3__ : Add optional duration to the `--refresh` option to [close #15](https://github.com/there4/markdown-resume/issues/15)
* __2.0.2__ : Add new dependency check for `mbstring` to close #20 * __2.0.2__ : Add new dependency check for `mbstring` to [close #20](https://github.com/there4/markdown-resume/issues/20)
* __2.0.1__ : Add new `swissen` template with Helvetica styling (@beautifulcode) * __2.0.1__ : Add new `swissen` template with Helvetica styling [@beautifulcode](https://github.com/beautifulcode)
* __2.0.0__ : Complete rewrite with the [symfony console component][console]. * __2.0.0__ : Complete rewrite with the [symfony console component][console].
Deployment is now done with a compiled phar file, and development dependencies Deployment is now done with a compiled phar file, and development dependencies
are managed with composer. are managed with composer.
* __0.9.0__ : Add composer and update README with new changelog * __0.9.0__ : Add composer and update README with new changelog
* __0.8.8__ : Add Chinese text example (@ishitcno1) * __0.8.8__ : Add Chinese text example [@ishitcno1](https://github.com/ishitcno1)
* __0.8.7__ : Update pdf formatting of the modern template (@roleary) * __0.8.7__ : Update pdf formatting of the modern template [@roleary](https://github.com/roleary)
* __0.8.6__ : Fix output path (@abhikandoi2000) * __0.8.6__ : Fix output path [@abhikandoi2000](https://github.com/abhikandoi2000)
* __0.8.5__ : Fix issue #2 * __0.8.5__ : Fix [issue #2](https://github.com/there4/markdown-resume/issues/2)
* __0.8.4__ : Correct chmod and add parameter for output directory (@kevinxucs) * __0.8.4__ : Correct chmod and add parameter for output directory [@kevinxucs](https://github.com/kevinxucs)
* __0.8.2__ : Update build script and add refresh command option * __0.8.2__ : Update build script and add refresh command option
* __0.8.1__ : Updating formatting of initial templates * __0.8.1__ : Updating formatting of initial templates
* __0.8__ : Initial Release to Public * __0.8__ : Initial Release to Public

Binary file not shown.

View File

@ -8,7 +8,7 @@
"html5" "html5"
], ],
"license": "MIT", "license": "MIT",
"version": "2.0.8", "version": "2.0.10",
"selfupdatepath": "://github.com/there4/markdown-resume/raw/master/bin/md2resume", "selfupdatepath": "://github.com/there4/markdown-resume/raw/master/bin/md2resume",
"selfupdateversion": "://github.com/there4/markdown-resume/raw/master/version", "selfupdateversion": "://github.com/there4/markdown-resume/raw/master/version",
"authors": [ "authors": [

View File

@ -32,7 +32,10 @@ pake_task('build', 'version', 'version_file', 'readme', 'lint', 'fixer', 'sniff'
pake_alias('default', 'build'); pake_alias('default', 'build');
function run_build() {} function run_build()
{
// Used only for naming a string of dependencies.
}
function run_test() function run_test()
{ {
@ -112,7 +115,7 @@ function run_readme()
function run_mv() function run_mv()
{ {
pake_sh('cp ./bin/md2resume ~/bin/md2resume', true); pake_sh('cp ./bin/md2resume ~/bin/md2resume', true);
} }
/* End of pakefile */ /* End of pakefile */

View File

@ -35,7 +35,7 @@ class HtmlCommand extends Command
'template', 'template',
't', 't',
InputOption::VALUE_REQUIRED, InputOption::VALUE_REQUIRED,
'Which of the templates to use' 'Which of the templates to use. Use an absolute path for a custom template.'
) )
->addOption( ->addOption(
'refresh', 'refresh',
@ -43,6 +43,12 @@ class HtmlCommand extends Command
InputOption::VALUE_REQUIRED, InputOption::VALUE_REQUIRED,
'Regenerate the html and include a meta command to refresh the ' . 'Regenerate the html and include a meta command to refresh the ' .
'document every periodically. Measured in seconds.' 'document every periodically. Measured in seconds.'
)
->addOption(
'output',
'o',
InputOption::VALUE_REQUIRED,
'The optional override of default filename to output to'
); );
} }
@ -50,10 +56,18 @@ class HtmlCommand extends Command
{ {
$this->app = $this->getApplication(); $this->app = $this->getApplication();
$source = $input->getArgument('source'); $source = $input->getArgument('source');
$sourceName = pathinfo($source, PATHINFO_FILENAME);
$destination = rtrim($input->getArgument('destination'), DIRECTORY_SEPARATOR); $destination = rtrim($input->getArgument('destination'), DIRECTORY_SEPARATOR);
$template = $input->getOption('template'); $template = $input->getOption('template');
$refresh = $input->getOption('refresh'); $refresh = $input->getOption('refresh');
$destFilename = join(DIRECTORY_SEPARATOR, array($destination, pathinfo($source, PATHINFO_FILENAME) . '.html')); $optFilename = $input->getOption('output');
$destFilename = "";
if ($optFilename) {
$destFilename = $destination . DIRECTORY_SEPARATOR . $optFilename . '.html';
} else {
$destFilename = $destination . DIRECTORY_SEPARATOR . $sourceName . '.html';
}
$rendered = $this->generateHtml($source, $template, $refresh); $rendered = $this->generateHtml($source, $template, $refresh);
file_put_contents($destFilename, $rendered); file_put_contents($destFilename, $rendered);
@ -88,6 +102,10 @@ class HtmlCommand extends Command
array_push($assets, new FileAsset($fileInfo->getPathname())); array_push($assets, new FileAsset($fileInfo->getPathname()));
} }
usort($assets, function (FileAsset $a, FileAsset $b) {
return strcmp($a->getSourcePath(), $b->getSourcePath());
});
$collection = new AssetCollection( $collection = new AssetCollection(
$assets $assets
); );
@ -112,7 +130,13 @@ class HtmlCommand extends Command
if (!$template) { if (!$template) {
$template = $this->app->defaultTemplate; $template = $this->app->defaultTemplate;
} }
$templatePath = join(DIRECTORY_SEPARATOR, array($this->app->templatePath, basename($template)));
if (strpos($template, DIRECTORY_SEPARATOR) !== false) {
$templatePath = realpath($template);
} else {
$templatePath = join(DIRECTORY_SEPARATOR, array($this->app->templatePath, basename($template)));
}
$templateIndexPath = join(DIRECTORY_SEPARATOR, array($templatePath, 'index.html')); $templateIndexPath = join(DIRECTORY_SEPARATOR, array($templatePath, 'index.html'));
if (!file_exists($templateIndexPath)) { if (!file_exists($templateIndexPath)) {
@ -151,6 +175,11 @@ class HtmlCommand extends Command
return $rendered; return $rendered;
} }
protected function determineOutfile($outputFilename)
{
return join(DIRECTORY_SEPARATOR, array($destination, pathinfo($source, PATHINFO_FILENAME) . '.html'));
}
} }
/* End of file HtmlCommand.php */ /* End of file HtmlCommand.php */

View File

@ -30,6 +30,12 @@ class PdfCommand extends HtmlCommand
't', 't',
InputOption::VALUE_REQUIRED, InputOption::VALUE_REQUIRED,
'Which of the templates to use' 'Which of the templates to use'
)
->addOption(
'output',
'o',
InputOption::VALUE_REQUIRED,
'The optional override of default filename to output to'
); );
} }
@ -37,11 +43,19 @@ class PdfCommand extends HtmlCommand
{ {
$this->app = $this->getApplication(); $this->app = $this->getApplication();
$source = $input->getArgument('source'); $source = $input->getArgument('source');
$sourceName = pathinfo($source, PATHINFO_FILENAME);
$destination = rtrim($input->getArgument('destination'), DIRECTORY_SEPARATOR); $destination = rtrim($input->getArgument('destination'), DIRECTORY_SEPARATOR);
$template = $input->getOption('template'); $template = $input->getOption('template');
$pdfSource = join(DIRECTORY_SEPARATOR, array($destination, '.tmp_pdf_source.html')); $pdfSource = join(DIRECTORY_SEPARATOR, array($destination, '.tmp_pdf_source.html'));
$optFilename = $input->getOption('output');
$destFilename = join(DIRECTORY_SEPARATOR, array($destination, pathinfo($source, PATHINFO_FILENAME) . '.pdf')); $destFilename = join(DIRECTORY_SEPARATOR, array($destination, pathinfo($source, PATHINFO_FILENAME) . '.pdf'));
if ($optFilename) {
$destFilename = $destination . DIRECTORY_SEPARATOR . $optFilename . '.pdf';
} else {
$destFilename = $destination . DIRECTORY_SEPARATOR . $sourceName . '.pdf';
}
// Make sure we've got out converter available // Make sure we've got out converter available
exec('wkhtmltopdf -V', $results, $returnVal); exec('wkhtmltopdf -V', $results, $returnVal);
if ($returnVal) { if ($returnVal) {

View File

@ -44,7 +44,7 @@ body.pdf {
} }
h3+p { h3+p {
float: left; float: left;
width: 84%; width: 78%;
} }
blockquote { blockquote {
@ -54,7 +54,7 @@ body.pdf {
} }
ul li { ul li {
width: 28%; width: 33%;
float: left; float: left;
} }
ul dl { ul dl {
@ -66,13 +66,13 @@ body.pdf {
margin: 0 0 .75em; margin: 0 0 .75em;
} }
dd { dd {
padding: 0 4em 0 0; padding: 0 2em 0 0;
} }
} }
ol { ol {
float: left; float: left;
width: 84%; width: 79%;
margin: .7em 0 0; margin: .7em 0 0;
} }
@ -91,7 +91,7 @@ body.pdf {
margin: .7em 0 0; margin: .7em 0 0;
page-break-inside: avoid !important; page-break-inside: avoid !important;
display: block; display: block;
width:84%; width:79%;
float: left; float: left;
dt {} dt {}
dd { dd {

View File

@ -82,7 +82,7 @@ h2 {
} }
h3 { h3 {
margin: 0; margin: 0px 20px;
padding: 0 0 .5em; padding: 0 0 .5em;
font-size: 150%; font-size: 150%;
font-style: italic; font-style: italic;
@ -102,6 +102,7 @@ ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
display: table;
} }
ul li { ul li {
margin: 0; margin: 0;
@ -146,7 +147,7 @@ ol li:nth-child(1) {
dl { dl {
display: inline-block; display: inline-block;
width: 75%; width: 78%;
margin: 0; margin: 0;
padding: 0; padding: 0;
dt { dt {

View File

@ -91,11 +91,11 @@
h3+p { h3+p {
float: left; float: left;
width: 84%; width: 78%;
} }
ul li { ul li {
width: 28%; width: 33%;
float: left; float: left;
} }
ul dl { ul dl {
@ -105,13 +105,13 @@
margin-bottom: .75em; margin-bottom: .75em;
} }
dd { dd {
padding: 0 4em 0 0; padding: 0 2em 0 0;
} }
} }
ol { ol {
float: left; float: left;
width: 84%; width: 79%;
margin: .6em 0 0; margin: .6em 0 0;
} }

View File

@ -37,12 +37,12 @@ body.pdf {
} }
h3 { h3 {
float: left; float: left;
width: 16%; width: 20%;
font-style: normal; font-style: normal;
} }
h3+p { h3+p {
float: left; float: left;
width: 84%; width: 80%;
} }
blockquote { blockquote {
@ -52,7 +52,7 @@ body.pdf {
} }
ul li { ul li {
width: 28%; width: 33.33%;
float: left; float: left;
} }
ul dl { ul dl {
@ -70,7 +70,7 @@ body.pdf {
ol { ol {
float: left; float: left;
width: 84%; width: 80%;
margin: .7em 0 0; margin: .7em 0 0;
} }

View File

@ -109,6 +109,7 @@ ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
display: table;
} }
ul li { ul li {
margin: 0; margin: 0;
@ -133,7 +134,7 @@ ul dl {
ol { ol {
margin: 0; margin: 0;
padding: 0 0 .75em; padding: 0 0 .75em;
width: 84%; width: 80%;
display: inline-block; display: inline-block;
} }

View File

@ -82,16 +82,16 @@
h3 { h3 {
float: left; float: left;
width: 16%; width: 20%;
} }
h3+p { h3+p {
float: left; float: left;
width: 84%; width: 80%;
} }
ul li { ul li {
width: 28%; width: 33.33%;
float: left; float: left;
} }
ul dl { ul dl {
@ -107,7 +107,7 @@
ol { ol {
float: left; float: left;
width: 84%; width: 80%;
margin: .6em 0 0; margin: .6em 0 0;
} }

View File

@ -1 +1 @@
2.0.8 2.0.10