Merge pull request #3 from there4/master

Merge changes from markdown-resume project into my forked version
This commit is contained in:
Erik Waibel 2014-05-18 10:06:37 -07:00
commit e8ba899812
11 changed files with 176 additions and 109 deletions

View File

@ -24,7 +24,7 @@ at the [blog post for the project][blog].
## Help
```
Markdown Resume Generator version 2.0.6 by Craig Davis
Markdown Resume Generator version 2.0.8 by Craig Davis
Usage:
[options] command [arguments]
@ -100,6 +100,10 @@ are a more comfortable with html than markdown, you should use it.
## Changelog
* __2.0.8__ : New `readable` theme contributed by @ahmadnazir, minor refactor
to support a /links directory
* __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
* __2.0.6__ : Fix empty template list from phar file to close #24
* __2.0.5__ : Remove default value for the `--refresh` option to close #22
* __2.0.4__ : Fix path resolution problem with absolute paths to close #16

Binary file not shown.

View File

@ -8,7 +8,7 @@
"html5"
],
"license": "MIT",
"version": "2.0.6",
"version": "2.0.8",
"selfupdatepath": "://github.com/there4/markdown-resume/raw/master/bin/md2resume",
"selfupdateversion": "://github.com/there4/markdown-resume/raw/master/version",
"authors": [
@ -49,18 +49,13 @@
"michelf/php-smartypants": "1.6.0-beta1",
"mustache/mustache": "2.5.1",
"phpunit/phpunit": "3.7.*",
"simple-html-dom/simple-html-dom": "1.5.0",
"squizlabs/php_codesniffer": "1.*",
"sunra/php-simple-html-dom-parser": "v1.5.0",
"symfony/config": "v2.3.4",
"symfony/console": "v2.3.4",
"symfony/yaml": "v2.3.4",
"twig/twig": "v1.13.2"
},
"autoload": {
"classmap": [
"vendor/simple-html-dom/simple-html-dom/"
]
},
"bin": [
"bin/md2resume"
]

178
composer.lock generated
View File

@ -3,7 +3,7 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "87e1f659b849bce922f4a0bffa38d61f",
"hash": "5f42fb6da16a9d26eb5a44694e6123a6",
"packages": [
{
"name": "fabpot/php-cs-fixer",
@ -384,22 +384,22 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "1.2.13",
"version": "1.2.x-dev",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94"
"reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/466e7cd2554b4e264c9e3f31216d25ac0e5f3d94",
"reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ef2bf3a1c47eca07ea95f0d8a902a6340390b34",
"reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"phpunit/php-file-iterator": ">=1.3.0@stable",
"phpunit/php-text-template": ">=1.1.1@stable",
"phpunit/php-text-template": ">=1.2.0@stable",
"phpunit/php-token-stream": ">=1.1.3@stable"
},
"require-dev": {
@ -441,7 +441,7 @@
"testing",
"xunit"
],
"time": "2013-09-10 08:14:32"
"time": "2014-03-28 10:53:45"
},
{
"name": "phpunit/php-file-iterator",
@ -490,16 +490,16 @@
},
{
"name": "phpunit/php-text-template",
"version": "1.1.4",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
"reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23"
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5180896f51c5b3648ac946b05f9ec02be78a0b23",
"reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
"shasum": ""
},
"require": {
@ -530,7 +530,7 @@
"keywords": [
"template"
],
"time": "2012-10-31 18:15:28"
"time": "2014-01-30 17:20:04"
},
{
"name": "phpunit/php-timer",
@ -582,12 +582,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32"
"reference": "955c24b708f8bfd6a05f303217a8dac3a443d531"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32",
"reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/955c24b708f8bfd6a05f303217a8dac3a443d531",
"reference": "955c24b708f8bfd6a05f303217a8dac3a443d531",
"shasum": ""
},
"require": {
@ -624,7 +624,7 @@
"keywords": [
"tokenizer"
],
"time": "2014-03-03 05:10:30"
"time": "2014-05-12 05:34:42"
},
{
"name": "phpunit/phpunit",
@ -632,34 +632,33 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "4dbc3ab5de25a9ffd07796519f9f7f4aaddc37e0"
"reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4dbc3ab5de25a9ffd07796519f9f7f4aaddc37e0",
"reference": "4dbc3ab5de25a9ffd07796519f9f7f4aaddc37e0",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ae6cefd7cc84586a5ef27e04bae11ee940ec63dc",
"reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.3.3",
"phpunit/php-code-coverage": "~1.2.1",
"phpunit/php-file-iterator": "~1.3.1",
"phpunit/php-text-template": "~1.1.1",
"phpunit/php-timer": "~1.0.4",
"phpunit/phpunit-mock-objects": "~1.2.0",
"phpunit/php-code-coverage": "~1.2",
"phpunit/php-file-iterator": "~1.3",
"phpunit/php-text-template": "~1.1",
"phpunit/php-timer": "~1.0",
"phpunit/phpunit-mock-objects": "~1.2",
"symfony/yaml": "~2.0"
},
"require-dev": {
"pear-pear.php.net/pear": "1.9.4"
},
"suggest": {
"ext-json": "*",
"ext-simplexml": "*",
"ext-tokenizer": "*",
"phpunit/php-invoker": "~1.1"
},
"bin": [
@ -698,7 +697,7 @@
"testing",
"xunit"
],
"time": "2014-03-05 12:52:24"
"time": "2014-04-30 12:24:19"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -763,12 +762,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "ecc923996545d4e4395c0759b6c538f085233f62"
"reference": "ac84cfdec593945f36f24074d6ea17d296e86f76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ecc923996545d4e4395c0759b6c538f085233f62",
"reference": "ecc923996545d4e4395c0759b6c538f085233f62",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ac84cfdec593945f36f24074d6ea17d296e86f76",
"reference": "ac84cfdec593945f36f24074d6ea17d296e86f76",
"shasum": ""
},
"require": {
@ -805,49 +804,20 @@
"keywords": [
"diff"
],
"time": "2014-02-16 12:08:10"
},
{
"name": "simple-html-dom/simple-html-dom",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/Youpie/simple-html-dom.git",
"reference": "961610576c460546677a635062e9d3d7b6dab745"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Youpie/simple-html-dom/zipball/961610576c460546677a635062e9d3d7b6dab745",
"reference": "961610576c460546677a635062e9d3d7b6dab745",
"shasum": ""
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "S.C. Chen",
"email": "me578022@gmail.com",
"homepage": "http://simplehtmldom.sourceforge.net/"
}
],
"description": "A copy of the PHP Simple HTML DOM Parser project.",
"time": "2013-05-14 22:27:35"
"time": "2014-05-12 05:21:40"
},
{
"name": "squizlabs/php_codesniffer",
"version": "1.5.2",
"version": "1.5.3",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "a76a39b317ce8106abe6264daa505e24e1731860"
"reference": "396178ada8499ec492363587f037125bf7b07fcc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/a76a39b317ce8106abe6264daa505e24e1731860",
"reference": "a76a39b317ce8106abe6264daa505e24e1731860",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/396178ada8499ec492363587f037125bf7b07fcc",
"reference": "396178ada8499ec492363587f037125bf7b07fcc",
"shasum": ""
},
"require": {
@ -861,6 +831,11 @@
"scripts/phpcs"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-phpcs-fixer": "2.0.x-dev"
}
},
"autoload": {
"classmap": [
"CodeSniffer.php",
@ -904,7 +879,50 @@
"phpcs",
"standards"
],
"time": "2014-02-04 23:49:58"
"time": "2014-05-01 03:07:07"
},
{
"name": "sunra/php-simple-html-dom-parser",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/sunra/php-simple-html-dom-parser.git",
"reference": "a0b80ace086c7e09085669205e1b3c2c9c7a453c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sunra/php-simple-html-dom-parser/zipball/a0b80ace086c7e09085669205e1b3c2c9c7a453c",
"reference": "a0b80ace086c7e09085669205e1b3c2c9c7a453c",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"type": "library",
"autoload": {
"psr-0": {
"Sunra\\PhpSimple\\HtmlDomParser": "Src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sunra",
"email": "sunra@yandex.ru",
"homepage": "https://github.com/sunra"
}
],
"description": "Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.",
"homepage": "https://github.com/sunra/php-simple-html-dom-parser",
"keywords": [
"dom",
"html",
"parser"
],
"time": "2013-05-04 14:32:03"
},
{
"name": "symfony/config",
@ -1014,12 +1032,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Filesystem.git",
"reference": "e81f1b30eb9748c3f8e0de3a92ea210845cff0a9"
"reference": "98e831eac836a0a5911626ce82684155f21d0e4d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/e81f1b30eb9748c3f8e0de3a92ea210845cff0a9",
"reference": "e81f1b30eb9748c3f8e0de3a92ea210845cff0a9",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/98e831eac836a0a5911626ce82684155f21d0e4d",
"reference": "98e831eac836a0a5911626ce82684155f21d0e4d",
"shasum": ""
},
"require": {
@ -1043,7 +1061,9 @@
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Symfony Community",
@ -1052,7 +1072,7 @@
],
"description": "Symfony Filesystem Component",
"homepage": "http://symfony.com",
"time": "2014-01-07 13:29:57"
"time": "2014-04-16 10:36:21"
},
{
"name": "symfony/finder",
@ -1061,12 +1081,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Finder.git",
"reference": "d45faef922df8438cce99b5ee226bf06c32d145e"
"reference": "1343b576d1401f4a5117cab4e250201ae348143a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Finder/zipball/d45faef922df8438cce99b5ee226bf06c32d145e",
"reference": "d45faef922df8438cce99b5ee226bf06c32d145e",
"url": "https://api.github.com/repos/symfony/Finder/zipball/1343b576d1401f4a5117cab4e250201ae348143a",
"reference": "1343b576d1401f4a5117cab4e250201ae348143a",
"shasum": ""
},
"require": {
@ -1101,7 +1121,7 @@
],
"description": "Symfony Finder Component",
"homepage": "http://symfony.com",
"time": "2014-03-03 12:53:01"
"time": "2014-05-12 09:28:39"
},
{
"name": "symfony/process",
@ -1110,12 +1130,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"reference": "0ae3bf5ff90edbe6e30e645221646479c2f1ef54"
"reference": "8a3edace8e8aabed8992b993bfc13df3b1e836f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/0ae3bf5ff90edbe6e30e645221646479c2f1ef54",
"reference": "0ae3bf5ff90edbe6e30e645221646479c2f1ef54",
"url": "https://api.github.com/repos/symfony/Process/zipball/8a3edace8e8aabed8992b993bfc13df3b1e836f2",
"reference": "8a3edace8e8aabed8992b993bfc13df3b1e836f2",
"shasum": ""
},
"require": {
@ -1150,7 +1170,7 @@
],
"description": "Symfony Process Component",
"homepage": "http://symfony.com",
"time": "2014-02-24 16:21:51"
"time": "2014-04-28 05:15:04"
},
{
"name": "symfony/yaml",

View File

@ -11,6 +11,7 @@ use Assetic\Asset\FileAsset;
use Assetic\Filter;
use Michelf\MarkdownExtra;
use Michelf\SmartyPants;
use Sunra\PhpSimple\HtmlDomParser;
class HtmlCommand extends Command
{
@ -67,6 +68,39 @@ class HtmlCommand extends Command
return true;
}
protected function generateContent($templatePath, $contentType)
{
// We build these into a single string so that we can deploy this resume as a
// single file.
$assetPath = join(DIRECTORY_SEPARATOR, array($templatePath, $contentType));
if (!file_exists($assetPath)) {
return '';
}
$assets = array();
// Our PHAR deployment can't handle the GlobAsset typically used here
foreach (new \DirectoryIterator($assetPath) as $fileInfo) {
if ($fileInfo->isDot() || !$fileInfo->isFile()) {
continue;
}
array_push($assets, new FileAsset($fileInfo->getPathname()));
}
$collection = new AssetCollection(
$assets
);
switch ($contentType) {
case 'css':
$collection->ensureFilter(new Filter\LessphpFilter());
break;
}
return $collection->dump();
}
protected function generateHtml($source, $template, $refresh)
{
// Check that the source file is sane
@ -85,25 +119,9 @@ class HtmlCommand extends Command
throw new \Exception("Unable to open template file: $templateIndexPath");
}
// We build these into a single string so that we can deploy this resume as a
// single file.
$cssAssetPath = join(DIRECTORY_SEPARATOR, array($templatePath, '/css'));
$cssAssets = array();
$style = $this->generateContent($templatePath, 'css');
// Our PHAR deployment can't handle the GlobAsset typically used here
foreach (new \DirectoryIterator($cssAssetPath) as $fileInfo) {
if ($fileInfo->isDot() || !$fileInfo->isFile()) {
continue;
}
array_push($cssAssets, new FileAsset($fileInfo->getPathname()));
}
$css = new AssetCollection(
$cssAssets,
array(new Filter\LessphpFilter())
);
$style = $css->dump();
$links = $this->generateContent($templatePath, 'links');
$templateContent = file_get_contents($templateIndexPath);
$resumeContent = file_get_contents($source);
@ -113,8 +131,7 @@ class HtmlCommand extends Command
$resumeHtml = SmartyPants::defaultTransform($resumeHtml);
// Construct the title for the html document from the h1 and h2 tags
$simpleDom = new \simple_html_dom();
$simpleDom->load($resumeHtml);
$simpleDom = HtmlDomParser::str_get_html($resumeHtml);
$title = sprintf(
'%s | %s',
$simpleDom->find('h1', 0)->innertext,
@ -126,6 +143,7 @@ class HtmlCommand extends Command
$rendered = $m->render($templateContent, array(
'title' => $title,
'style' => $style,
'links' => $links,
'resume' => $resumeHtml,
'reload' => (bool) $refresh,
'refresh_rate' => $refresh

View File

@ -6,6 +6,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Sunra\PhpSimple\HtmlDomParser;
class PdfCommand extends HtmlCommand
{
@ -59,7 +60,7 @@ class PdfCommand extends HtmlCommand
// The pdf needs some extra css rules, and so we'll add them here
// to our html document
$simpleDom = new \simple_html_dom($rendered);
$simpleDom = HtmlDomParser::str_get_html($rendered);
$body = $simpleDom->find('body', 0);
$body->class = $body->class . ' pdf';
$rendered = (string) $simpleDom;

View File

@ -0,0 +1,8 @@
#footer {
display: none;
}
#footer + p {
width: 100%;
font-size: 11px;
}

View File

@ -0,0 +1 @@
Bootswatch 'readable' theme

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
{{#reload}}
<meta http-equiv="refresh" content="{{refresh_rate}}">
{{/reload}}
<title>{{title}}</title>
{{{links}}}
<style type="text/css">
{{{style}}}
</style>
</head>
<body>
<div class="container">
{{{resume}}}
</div>
</body>
</html>

View File

@ -0,0 +1 @@
<link href="http://netdna.bootstrapcdn.com/bootswatch/3.1.1/readable/bootstrap.min.css" rel="stylesheet">

View File

@ -1 +1 @@
2.0.6
2.0.8