mirror of
https://github.com/there4/markdown-resume.git
synced 2024-12-03 08:59:35 -05:00
Add optional value to the --refresh option. Closes #15
This commit is contained in:
parent
6e4e08aea5
commit
738f5b2b76
@ -39,9 +39,11 @@ class HtmlCommand extends Command
|
|||||||
->addOption(
|
->addOption(
|
||||||
'refresh',
|
'refresh',
|
||||||
'r',
|
'r',
|
||||||
InputOption::VALUE_NONE,
|
InputOption::VALUE_OPTIONAL,
|
||||||
'If set, the html will include a meta command to refresh the ' .
|
'Regenerate the html and include a meta command to refresh the ' .
|
||||||
'document every 5 seconds.'
|
'document every periodically. Measured in seconds. Defaults to' .
|
||||||
|
'5 seconds',
|
||||||
|
5
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +60,7 @@ class HtmlCommand extends Command
|
|||||||
file_put_contents($destFilename, $rendered);
|
file_put_contents($destFilename, $rendered);
|
||||||
$output->writeln(
|
$output->writeln(
|
||||||
sprintf(
|
sprintf(
|
||||||
"Wrote resume to: <info>%s</info>",
|
'Wrote resume to: <info>%s</info>',
|
||||||
$destFilename
|
$destFilename
|
||||||
),
|
),
|
||||||
$this->app->outputFormat
|
$this->app->outputFormat
|
||||||
@ -73,7 +75,7 @@ class HtmlCommand extends Command
|
|||||||
if (!file_exists($source)) {
|
if (!file_exists($source)) {
|
||||||
$output->writeln(
|
$output->writeln(
|
||||||
sprintf(
|
sprintf(
|
||||||
"<error>Unable to open source file: %s</error>",
|
'<error>Unable to open source file: %s</error>',
|
||||||
$source
|
$source
|
||||||
),
|
),
|
||||||
$this->app->outputFormat
|
$this->app->outputFormat
|
||||||
@ -91,7 +93,7 @@ class HtmlCommand extends Command
|
|||||||
if (!file_exists($templateIndexPath)) {
|
if (!file_exists($templateIndexPath)) {
|
||||||
$output->writeln(
|
$output->writeln(
|
||||||
sprintf(
|
sprintf(
|
||||||
"<error>Unable to open template file: %s</error>",
|
'<error>Unable to open template file: %s</error>',
|
||||||
$templateIndexPath
|
$templateIndexPath
|
||||||
),
|
),
|
||||||
$this->app->outputFormat
|
$this->app->outputFormat
|
||||||
@ -127,7 +129,7 @@ class HtmlCommand extends Command
|
|||||||
$resumeHtml = MarkdownExtra::defaultTransform($resumeContent);
|
$resumeHtml = MarkdownExtra::defaultTransform($resumeContent);
|
||||||
$resumeHtml = SmartyPants::defaultTransform($resumeHtml);
|
$resumeHtml = SmartyPants::defaultTransform($resumeHtml);
|
||||||
|
|
||||||
// We'll construct the title for the html document from the h1 and h2 tags
|
// Construct the title for the html document from the h1 and h2 tags
|
||||||
$simpleDom = new \simple_html_dom();
|
$simpleDom = new \simple_html_dom();
|
||||||
$simpleDom->load($resumeHtml);
|
$simpleDom->load($resumeHtml);
|
||||||
$title = sprintf(
|
$title = sprintf(
|
||||||
@ -136,17 +138,15 @@ class HtmlCommand extends Command
|
|||||||
$simpleDom->find('h2', 0)->innertext
|
$simpleDom->find('h2', 0)->innertext
|
||||||
);
|
);
|
||||||
|
|
||||||
// We'll now render the Markdown into an html file with Mustache Templates
|
// Render the Markdown into an html file with Mustache Templates
|
||||||
$m = new \Mustache_Engine;
|
$m = new \Mustache_Engine;
|
||||||
$rendered = $m->render(
|
$rendered = $m->render($templateContent, array(
|
||||||
$templateContent,
|
'title' => $title,
|
||||||
array(
|
'style' => $style,
|
||||||
'title' => $title,
|
'resume' => $resumeHtml,
|
||||||
'style' => $style,
|
'reload' => (bool) $refresh,
|
||||||
'resume' => $resumeHtml,
|
'refresh_rate' => $refresh
|
||||||
'reload' => $refresh
|
));
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $rendered;
|
return $rendered;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
{{#reload}}
|
{{#reload}}
|
||||||
<meta http-equiv="refresh" content="2">
|
<meta http-equiv="refresh" content="{{refresh_rate}}">
|
||||||
{{/reload}}
|
{{/reload}}
|
||||||
|
|
||||||
<title>{{title}}</title>
|
<title>{{title}}</title>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
{{#reload}}
|
{{#reload}}
|
||||||
<meta http-equiv="refresh" content="2">
|
<meta http-equiv="refresh" content="{{refresh_rate}}">
|
||||||
{{/reload}}
|
{{/reload}}
|
||||||
|
|
||||||
<title>{{title}}</title>
|
<title>{{title}}</title>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
{{#reload}}
|
{{#reload}}
|
||||||
<meta http-equiv="refresh" content="2">
|
<meta http-equiv="refresh" content="{{refresh_rate}}">
|
||||||
{{/reload}}
|
{{/reload}}
|
||||||
|
|
||||||
<title>{{title}}</title>
|
<title>{{title}}</title>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
{{#reload}}
|
{{#reload}}
|
||||||
<meta http-equiv="refresh" content="2">
|
<meta http-equiv="refresh" content="{{refresh_rate}}">
|
||||||
{{/reload}}
|
{{/reload}}
|
||||||
|
|
||||||
<title>{{title}}</title>
|
<title>{{title}}</title>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user