mirror of
https://github.com/there4/markdown-resume.git
synced 2024-12-03 08:59:35 -05:00
Refactored the code so that any type of asset can be grouped and rendered.
This commit is contained in:
parent
0ac35d16a8
commit
cf6c1b0051
@ -67,6 +67,37 @@ class HtmlCommand extends Command
|
|||||||
return true;
|
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)
|
protected function generateHtml($source, $template, $refresh)
|
||||||
{
|
{
|
||||||
// Check that the source file is sane
|
// Check that the source file is sane
|
||||||
@ -85,25 +116,7 @@ class HtmlCommand extends Command
|
|||||||
throw new \Exception("Unable to open template file: $templateIndexPath");
|
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
|
$style = $this->generateContent($templatePath, 'css');
|
||||||
// single file.
|
|
||||||
$cssAssetPath = join(DIRECTORY_SEPARATOR, array($templatePath, '/css'));
|
|
||||||
$cssAssets = array();
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
|
|
||||||
$templateContent = file_get_contents($templateIndexPath);
|
$templateContent = file_get_contents($templateIndexPath);
|
||||||
$resumeContent = file_get_contents($source);
|
$resumeContent = file_get_contents($source);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user