Svg from app
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
84e90e26c0
commit
98a0113d40
|
@ -59,8 +59,39 @@ class SvgController extends Controller {
|
||||||
* @param string $color
|
* @param string $color
|
||||||
* @return DataDisplayResponse|NotFoundException
|
* @return DataDisplayResponse|NotFoundException
|
||||||
*/
|
*/
|
||||||
public function getSvg(string $fileName, $color = 'ffffff') {
|
public function getSvgFromCore(string $fileName, string $color = 'ffffff') {
|
||||||
$path = $this->serverRoot . "/core/img/actions/$fileName.svg";
|
$path = $this->serverRoot . "/core/img/actions/$fileName.svg";
|
||||||
|
return $this->getSvg($path, $color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*
|
||||||
|
* Generate svg from filename with the requested color
|
||||||
|
*
|
||||||
|
* @param string $fileName
|
||||||
|
* @param string $color
|
||||||
|
* @return DataDisplayResponse|NotFoundException
|
||||||
|
*/
|
||||||
|
public function getSvgFromApp(string $app, string $fileName, string $color = 'ffffff') {
|
||||||
|
$appPath = \OC_App::getAppWebPath($app);
|
||||||
|
if (!$appPath) {
|
||||||
|
return new NotFoundResponse();
|
||||||
|
}
|
||||||
|
$path = $this->serverRoot . $appPath ."/img/$fileName.svg";
|
||||||
|
return $this->getSvg($path, $color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate svg from filename with the requested color
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param string $color
|
||||||
|
* @return DataDisplayResponse|NotFoundException
|
||||||
|
*/
|
||||||
|
private function getSvg(string $path, string $color) {
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
return new NotFoundResponse();
|
return new NotFoundResponse();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,8 @@ $application->registerRoutes($this, [
|
||||||
['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
|
['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
|
||||||
['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
|
['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
|
||||||
['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
|
['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
|
||||||
['name' => 'Svg#getSvg', 'url' => '/svg/{fileName}/{color}', 'verb' => 'GET'],
|
['name' => 'Svg#getSvgFromCore', 'url' => '/svg/{fileName}/{color}', 'verb' => 'GET'],
|
||||||
|
['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}/{color}', 'verb' => 'GET'],
|
||||||
['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
|
['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
|
||||||
['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
|
['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
|
||||||
['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
|
['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
|
||||||
|
|
Loading…
Reference in New Issue