-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from LibreCodeCoop/feature/customize-theme
Feature/customize theme
- Loading branch information
Showing
21 changed files
with
386 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#header .app-menu, #contactsmenu/*, #header .unified-search*/ { | ||
display: none; | ||
} | ||
|
||
:root { | ||
--image-logo: 'fake-path' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\MyCompany\Middleware; | ||
|
||
use OCA\Theming\Controller\ThemingController; | ||
use OCP\AppFramework\Controller; | ||
use OCP\AppFramework\Http\ContentSecurityPolicy; | ||
use OCP\AppFramework\Http\FileDisplayResponse; | ||
use OCP\AppFramework\Http\Response; | ||
use OCP\AppFramework\Middleware; | ||
use OCP\Files\IAppData; | ||
use OCP\Files\NotFoundException; | ||
use OCP\Files\SimpleFS\ISimpleFolder; | ||
use OCP\IRequest; | ||
|
||
class InjectionMiddleware extends Middleware { | ||
public function __construct( | ||
private IAppData $appData, | ||
private IRequest $request | ||
) { | ||
} | ||
|
||
public function afterController(Controller $controller, string $methodName, Response $response): Response { | ||
if ($controller instanceof ThemingController && $methodName === 'getImage') { | ||
return $this->getImageFromDomain($response); | ||
} | ||
return $response; | ||
} | ||
|
||
private function getImageFromDomain(Response $response): Response { | ||
$headers = $response->getHeaders(); | ||
if (str_contains($headers['Content-Disposition'], '"background"')) { | ||
return $this->getBackgroundOfDomain($response); | ||
} | ||
return $response; | ||
} | ||
|
||
private function getBackgroundOfDomain(Response $response): Response { | ||
try { | ||
$folder = $this->getRootFolder('themes')->getFolder($this->request->getServerHost()); | ||
$file = $folder->getFile('background.jpg'); | ||
} catch (NotFoundException $e) { | ||
return $response; | ||
} | ||
|
||
$response = new FileDisplayResponse($file); | ||
$csp = new ContentSecurityPolicy(); | ||
$csp->allowInlineStyle(); | ||
$response->setContentSecurityPolicy($csp); | ||
$response->cacheFor(3600); | ||
$response->addHeader('Content-Disposition', 'attachment; filename="background.jpg"'); | ||
$response->addHeader('Content-Type', 'image/jpeg'); | ||
return $response; | ||
} | ||
|
||
private function getRootFolder(string $folder): ISimpleFolder { | ||
try { | ||
return $this->appData->getFolder($folder); | ||
} catch (NotFoundException $e) { | ||
return $this->appData->newFolder($folder); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
<template> | ||
<NcContent app-name="my_company"> | ||
<LeftSidebar /> | ||
<NcAppContent> | ||
<router-view /> | ||
</NcAppContent> | ||
</NcContent> | ||
</template> | ||
|
||
<script> | ||
import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js' | ||
import NcContent from '@nextcloud/vue/dist/Components/NcContent.js' | ||
import LeftSidebar from './components/LeftSidebar.vue' | ||
export default { | ||
name: 'App', | ||
components: { | ||
NcContent | ||
LeftSidebar, | ||
NcAppContent, | ||
NcContent, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<template> | ||
<NcAppNavigation :aria-label="t('my_company', 'Main menu')"> | ||
<template #list> | ||
<NcAppNavigationItem :to="{name: 'home'}" | ||
:title="t('my_company', 'Home')" | ||
icon="icon-home" | ||
:exact="true" /> | ||
<NcAppNavigationItem :to="{name: 'profile'}" | ||
:title="t('my_company', 'Profile')" | ||
:open="false" | ||
:allow-collapse="true" | ||
icon="icon-user"> | ||
<template> | ||
<NcAppNavigationItem :to="{name: 'security'}" | ||
:title="t('my_company', 'Security')" | ||
icon="icon-password" /> | ||
</template> | ||
</NcAppNavigationItem> | ||
</template> | ||
</NcAppNavigation> | ||
</template> | ||
|
||
<script> | ||
import NcAppNavigation from '@nextcloud/vue/dist/Components/NcAppNavigation.js' | ||
import NcAppNavigationItem from '@nextcloud/vue/dist/Components/NcAppNavigationItem.js' | ||
export default { | ||
name: 'LeftSidebar', | ||
components: { | ||
NcAppNavigation, | ||
NcAppNavigationItem, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.