Design fixes and preview check
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
Родитель
5e589bacfe
Коммит
45ecbbf62c
|
@ -46,8 +46,10 @@
|
|||
}
|
||||
ul {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
li {
|
||||
$size: 150px;
|
||||
$sizeY: $size / 210 * 297;
|
||||
$space: 10px;
|
||||
border-radius: var(--border-radius);
|
||||
border: 1px solid var(--color-border);
|
||||
|
@ -60,7 +62,7 @@
|
|||
margin: $space;
|
||||
img {
|
||||
width: $size;
|
||||
height: $size;
|
||||
height: $sizeY;
|
||||
background-color: var(--color-background-dark);
|
||||
}
|
||||
figcaption {
|
||||
|
@ -70,7 +72,7 @@
|
|||
.delete-cover,
|
||||
.delete-template {
|
||||
width: $size;
|
||||
height: $size;
|
||||
height: $sizeY;
|
||||
top: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
|
@ -78,7 +80,7 @@
|
|||
opacity: 0;
|
||||
transition: opacity 250ms ease-in-out;
|
||||
z-index: 3;
|
||||
line-height: $size;
|
||||
line-height: $sizeY;
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
background-size: 24px;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
|
@ -27,6 +28,7 @@ use OCA\Richdocuments\TemplateManager;
|
|||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\FileDisplayResponse;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
use OCP\Files\Node;
|
||||
|
@ -189,7 +191,7 @@ class TemplatesController extends Controller {
|
|||
bool $forceIcon = true,
|
||||
string $mode): Http\Response {
|
||||
|
||||
if (!($node instanceof File) || (!$forceIcon && !$this->preview->isAvailable($node))) {
|
||||
if (!($node instanceof Node) || (!$forceIcon && !$this->preview->isAvailable($node))) {
|
||||
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
if (!$node->isReadable()) {
|
||||
|
|
|
@ -61,7 +61,7 @@ class Admin implements ISettings {
|
|||
'doc_format' => $this->config->getAppValue('richdocuments', 'doc_format'),
|
||||
'external_apps' => $this->config->getAppValue('richdocuments', 'external_apps'),
|
||||
'canonical_webroot' => $this->config->getAppValue('richdocuments', 'canonical_webroot'),
|
||||
'templates' => $this->manager->getGlobals()
|
||||
'templates' => $this->manager->getUser()
|
||||
],
|
||||
'blank'
|
||||
);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare (strict_types = 1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
|
@ -23,7 +24,6 @@
|
|||
|
||||
namespace OCA\Richdocuments;
|
||||
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\Files\IAppData;
|
||||
use OCP\Files\IRootFolder;
|
||||
|
@ -92,12 +92,12 @@ class TemplateManager {
|
|||
* @param IPreview $previewManager
|
||||
*/
|
||||
public function __construct(string $appName,
|
||||
string $userId,
|
||||
IConfig $config,
|
||||
Factory $appDataFactory,
|
||||
IURLGenerator $urlGenerator,
|
||||
IRootFolder $rootFolder,
|
||||
IPreview $previewManager) {
|
||||
string $userId,
|
||||
IConfig $config,
|
||||
Factory $appDataFactory,
|
||||
IURLGenerator $urlGenerator,
|
||||
IRootFolder $rootFolder,
|
||||
IPreview $previewManager) {
|
||||
$this->appName = $appName;
|
||||
$this->userId = $userId;
|
||||
$this->config = $config;
|
||||
|
@ -114,7 +114,7 @@ class TemplateManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get template file/node
|
||||
* Get template ISimpleFile|Node
|
||||
*
|
||||
* @param string $templateName
|
||||
* @return ISimpleFile|Node
|
||||
|
@ -129,18 +129,19 @@ class TemplateManager {
|
|||
try {
|
||||
$templateFile = $templateDir->get($templateName);
|
||||
} catch (NotFoundException $e) {
|
||||
throw new NotFoundException($e);
|
||||
throw new NotFoundException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $templateFile;
|
||||
// return $this->formatNodeReturn($templateFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all global templates
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGlobals() {
|
||||
public function getSystem(): array{
|
||||
$templateFiles = $this->folder->getDirectoryListing();
|
||||
|
||||
return array_map(function (ISimpleFile $templateFile) {
|
||||
|
@ -148,14 +149,28 @@ class TemplateManager {
|
|||
}, $templateFiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all user templates
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUser(): array{
|
||||
$templateDir = $this->getUserTemplateDir();
|
||||
$templateFiles = $templateDir->getDirectoryListing();
|
||||
|
||||
return array_map(function (Node $templateFile) {
|
||||
return $this->formatNodeReturn($templateFile);
|
||||
}, $templateFiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a template to the global template folder
|
||||
*
|
||||
* @param string $templateName
|
||||
* @param string $templateFile
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
public function add(string $templateName, string $templateFile) {
|
||||
public function add(string $templateName, string $templateFile): array{
|
||||
try {
|
||||
$template = $this->folder->getFile($templateName);
|
||||
} catch (NotFoundException $e) {
|
||||
|
@ -170,15 +185,17 @@ class TemplateManager {
|
|||
* Delete a template to the global template folder
|
||||
*
|
||||
* @param string $templateName
|
||||
* @return void
|
||||
* @return boolean
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
public function delete(string $templateName) {
|
||||
public function delete(string $templateName): bool {
|
||||
try {
|
||||
$template = $this->get($templateName);
|
||||
$template->delete();
|
||||
} catch (NotFoundException $e) {
|
||||
throw new NotFoundException($e);
|
||||
throw new NotFoundException($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -214,7 +231,7 @@ class TemplateManager {
|
|||
try {
|
||||
$templateDir = $this->userFolder->get('Templates');
|
||||
} catch (NotFoundException $e) {
|
||||
throw new NotFoundException($e);
|
||||
throw new NotFoundException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +250,7 @@ class TemplateManager {
|
|||
'preview' => $this->urlGenerator->linkToRoute('richdocuments.templates.getPreview', ['templateName' => $template->getName()]),
|
||||
'ext' => $this->flipTypes[$template->getMimeType()],
|
||||
'etag' => $template->getETag(),
|
||||
'delete' => $this->urlGenerator->linkToRoute('richdocuments.templates.delete', ['templateName' => $template->getName()]),
|
||||
'delete' => $this->urlGenerator->linkToRoute('richdocuments.templates.delete', ['templateName' => $template->getName()])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче