Code Style
This commit is contained in:
parent
27e0e8780c
commit
b1eaa506b2
@ -39,7 +39,8 @@ class Generate extends SymfonyCommand
|
|||||||
$daux->getGenerator()->generateAll($input, $output, $width);
|
$daux->getGenerator()->generateAll($input, $output, $width);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prepareDaux(InputInterface $input) {
|
protected function prepareDaux(InputInterface $input)
|
||||||
|
{
|
||||||
$daux = new Daux(Daux::STATIC_MODE);
|
$daux = new Daux(Daux::STATIC_MODE);
|
||||||
|
|
||||||
// Set the format if requested
|
// Set the format if requested
|
||||||
|
@ -193,14 +193,21 @@ class Api
|
|||||||
*/
|
*/
|
||||||
public function uploadAttachment($id, $attachment)
|
public function uploadAttachment($id, $attachment)
|
||||||
{
|
{
|
||||||
//get if attachment is uploaded
|
// Check if an attachment with
|
||||||
|
// this name is uploaded
|
||||||
try {
|
try {
|
||||||
$result = $this->getClient()->get("content/$id/child/attachment?filename=$attachment[filename]")->json();
|
$result = $this->getClient()->get("content/$id/child/attachment?filename=$attachment[filename]")->json();
|
||||||
} catch (BadResponseException $e) {
|
} catch (BadResponseException $e) {
|
||||||
throw $this->handleError($e);
|
throw $this->handleError($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = "content/$id/child/attachment" . (count($result['results']) ? "/{$result['results'][0]['id']}/data" : "");
|
$url = "content/$id/child/attachment";
|
||||||
|
|
||||||
|
// If the attachment is already uploaded,
|
||||||
|
// the update URL is different
|
||||||
|
if (count($result['results'])) {
|
||||||
|
$url .= "/{$result['results'][0]['id']}/data";
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->getClient()->post(
|
$this->getClient()->post(
|
||||||
|
@ -85,10 +85,12 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
|||||||
} elseif ($node instanceof Content) {
|
} elseif ($node instanceof Content) {
|
||||||
$params['request'] = $node->getUrl();
|
$params['request'] = $node->getUrl();
|
||||||
|
|
||||||
|
$contentType = $this->daux->getContentTypeHandler()->getType($node);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'title' => $this->prefix . $node->getTitle(),
|
'title' => $this->prefix . $node->getTitle(),
|
||||||
'file' => $node,
|
'file' => $node,
|
||||||
'page' => ContentPage::fromFile($node, $params, $this->daux->getContentTypeHandler()->getType($node)),
|
'page' => ContentPage::fromFile($node, $params, $contentType),
|
||||||
];
|
];
|
||||||
|
|
||||||
// As the page is lazily generated
|
// As the page is lazily generated
|
||||||
|
@ -82,7 +82,9 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
|||||||
$page['breadcrumb_separator'] = $params['html']['breadcrumb_separator'];
|
$page['breadcrumb_separator'] = $params['html']['breadcrumb_separator'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$context = ['page' => $page, 'params' => $params];
|
||||||
|
|
||||||
$template = new Template($params['templates'], $params['theme']['templates']);
|
$template = new Template($params['templates'], $params['theme']['templates']);
|
||||||
return $template->render($this->homepage ? 'theme::home' : 'theme::content', ['page' => $page, 'params' => $params]);
|
return $template->render($this->homepage ? 'theme::home' : 'theme::content', $context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,9 @@ class Builder
|
|||||||
$config = $parent->getConfig();
|
$config = $parent->getConfig();
|
||||||
|
|
||||||
if (!in_array(pathinfo($path, PATHINFO_EXTENSION), $config['valid_content_extensions'])) {
|
if (!in_array(pathinfo($path, PATHINFO_EXTENSION), $config['valid_content_extensions'])) {
|
||||||
$entry = new Raw($parent, static::removeSortingInformations(static::getFilename($path)), $path, filemtime($path));
|
$uri = static::removeSortingInformations(static::getFilename($path));
|
||||||
|
|
||||||
|
$entry = new Raw($parent, $uri, $path, filemtime($path));
|
||||||
$entry->setTitle(static::removeSortingInformations($name, ' '));
|
$entry->setTitle(static::removeSortingInformations($name, ' '));
|
||||||
$entry->setName($name);
|
$entry->setName($name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user