-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#67] Add option to overwrite dashboard background
- Loading branch information
Showing
17 changed files
with
201 additions
and
61 deletions.
There are no files selected for viewing
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#app-dashboard { | ||
background-image : url("https://source.unsplash.com/featured/?nature") !important; | ||
} |
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
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
45 changes: 45 additions & 0 deletions
45
lib/EventListener/AddContentSecurityPolicyEventListener.php
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,45 @@ | ||
<?php | ||
/** | ||
* This file is part of the Unpslash App | ||
* and licensed under the AGPL. | ||
*/ | ||
|
||
namespace OCA\Unsplash\EventListener; | ||
|
||
use OC\Security\CSP\ContentSecurityPolicy; | ||
use OCA\Unsplash\Services\SettingsService; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\Security\CSP\AddContentSecurityPolicyEvent; | ||
|
||
class AddContentSecurityPolicyEventListener implements IEventListener { | ||
/** | ||
* @var SettingsService | ||
*/ | ||
protected $settingsService; | ||
|
||
/** | ||
* BeforeTemplateRenderedEventListener constructor. | ||
* | ||
* @param SettingsService $settingsService | ||
*/ | ||
public function __construct(SettingsService $settingsService) { | ||
$this->settingsService = $settingsService; | ||
} | ||
|
||
/** | ||
* @param Event $event | ||
*/ | ||
public function handle(Event $event): void { | ||
if(!($event instanceof AddContentSecurityPolicyEvent)) { | ||
return; | ||
} | ||
|
||
if($this->settingsService->getUserStyleHeaderEnabled() || $this->settingsService->getServerStyleLoginEnabled() || $this->settingsService->getUserStyleDashboardEnabled()) { | ||
$policy = new ContentSecurityPolicy(); | ||
$policy->addAllowedImageDomain('https://source.unsplash.com'); | ||
$policy->addAllowedImageDomain('https://images.unsplash.com'); | ||
$event->addPolicy($policy); | ||
} | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
/** | ||
* This file is part of the Unpslash App | ||
* and licensed under the AGPL. | ||
*/ | ||
|
||
namespace OCA\Unsplash\EventListener; | ||
|
||
use OCA\Unsplash\Services\SettingsService; | ||
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\IRequest; | ||
use OCP\Util; | ||
|
||
class BeforeTemplateRenderedEventListener implements IEventListener { | ||
/** | ||
* @var SettingsService | ||
*/ | ||
protected $settingsService; | ||
|
||
/** | ||
* @var IRequest | ||
*/ | ||
protected $request; | ||
|
||
/** | ||
* BeforeTemplateRenderedEventListener constructor. | ||
* | ||
* @param SettingsService $settingsService | ||
* @param IRequest $request | ||
*/ | ||
public function __construct(SettingsService $settingsService, IRequest $request) { | ||
$this->settingsService = $settingsService; | ||
$this->request = $request; | ||
} | ||
|
||
/** | ||
* @param Event $event | ||
*/ | ||
public function handle(Event $event): void { | ||
if(!($event instanceof BeforeTemplateRenderedEvent)) { | ||
return; | ||
} | ||
|
||
if($event->isLoggedIn()) { | ||
if($this->settingsService->getUserStyleHeaderEnabled() && $this->request->getParam('_route') !== 'dashboard.dashboard.index') { | ||
Util::addStyle('unsplash', 'header'); | ||
} | ||
|
||
if($this->settingsService->getUserStyleDashboardEnabled() && $this->request->getParam('_route') === 'dashboard.dashboard.index') { | ||
Util::addStyle('unsplash', 'dashboard'); | ||
} | ||
} | ||
|
||
if(!$event->isLoggedIn() && $this->settingsService->getServerStyleLoginEnabled()) { | ||
Util::addStyle('unsplash', 'login'); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.