Skip to content

Commit

Permalink
Add optional value to the --refresh option. Closes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
craig-davis committed Mar 24, 2014
1 parent 6e4e08a commit 738f5b2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
34 changes: 17 additions & 17 deletions src/Resume/Command/HtmlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ protected function configure()
->addOption(
'refresh',
'r',
InputOption::VALUE_NONE,
'If set, the html will include a meta command to refresh the ' .
'document every 5 seconds.'
InputOption::VALUE_OPTIONAL,
'Regenerate the html and include a meta command to refresh the ' .
'document every periodically. Measured in seconds. Defaults to' .
'5 seconds',
5
);
}

Expand All @@ -58,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
file_put_contents($destFilename, $rendered);
$output->writeln(
sprintf(
"Wrote resume to: <info>%s</info>",
'Wrote resume to: <info>%s</info>',
$destFilename
),
$this->app->outputFormat
Expand All @@ -73,7 +75,7 @@ protected function generateHtml($source, $template, $refresh)
if (!file_exists($source)) {
$output->writeln(
sprintf(
"<error>Unable to open source file: %s</error>",
'<error>Unable to open source file: %s</error>',
$source
),
$this->app->outputFormat
Expand All @@ -91,7 +93,7 @@ protected function generateHtml($source, $template, $refresh)
if (!file_exists($templateIndexPath)) {
$output->writeln(
sprintf(
"<error>Unable to open template file: %s</error>",
'<error>Unable to open template file: %s</error>',
$templateIndexPath
),
$this->app->outputFormat
Expand Down Expand Up @@ -127,7 +129,7 @@ protected function generateHtml($source, $template, $refresh)
$resumeHtml = MarkdownExtra::defaultTransform($resumeContent);
$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->load($resumeHtml);
$title = sprintf(
Expand All @@ -136,17 +138,15 @@ protected function generateHtml($source, $template, $refresh)
$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;
$rendered = $m->render(
$templateContent,
array(
'title' => $title,
'style' => $style,
'resume' => $resumeHtml,
'reload' => $refresh
)
);
$rendered = $m->render($templateContent, array(
'title' => $title,
'style' => $style,
'resume' => $resumeHtml,
'reload' => (bool) $refresh,
'refresh_rate' => $refresh
));

return $rendered;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/blockish/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
{{#reload}}
<meta http-equiv="refresh" content="2">
<meta http-equiv="refresh" content="{{refresh_rate}}">
{{/reload}}

<title>{{title}}</title>
Expand Down
2 changes: 1 addition & 1 deletion templates/modern/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
{{#reload}}
<meta http-equiv="refresh" content="2">
<meta http-equiv="refresh" content="{{refresh_rate}}">
{{/reload}}

<title>{{title}}</title>
Expand Down
2 changes: 1 addition & 1 deletion templates/swissen/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
{{#reload}}
<meta http-equiv="refresh" content="2">
<meta http-equiv="refresh" content="{{refresh_rate}}">
{{/reload}}

<title>{{title}}</title>
Expand Down
2 changes: 1 addition & 1 deletion templates/unstyled/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
{{#reload}}
<meta http-equiv="refresh" content="2">
<meta http-equiv="refresh" content="{{refresh_rate}}">
{{/reload}}

<title>{{title}}</title>
Expand Down

0 comments on commit 738f5b2

Please sign in to comment.