Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix css url
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Jun 25, 2018
commit 95f06d071decae789d0ce1beccabf59ad03d3eb6
6 changes: 6 additions & 0 deletions apps/accessibility/appinfo/app.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare (strict_types = 1);
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict :wink

* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
*
Expand All @@ -22,3 +23,8 @@
*/

$app = new \OCA\Accessibility\AppInfo\Application();

// Separate from the constructor since the route are not initialized before that
// 1. create the app
// 2. generate css route and inject
$app->injectCss();
16 changes: 12 additions & 4 deletions apps/accessibility/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use OCP\AppFramework\App;
use OCP\IConfig;
use OCP\IUserSession;
use OCP\IURLGenerator;

class Application extends App {

Expand All @@ -38,17 +39,24 @@ class Application extends App {
/** @var IUserSession */
private $userSession;

/** @var IURLGenerator */
private $urlGenerator;

public function __construct() {
parent::__construct($this->appName);
$this->config = \OC::$server->getConfig();
$this->userSession = \OC::$server->getUserSession();
$this->config = \OC::$server->getConfig();
$this->userSession = \OC::$server->getUserSession();
$this->urlGenerator = \OC::$server->getURLGenerator();
}

public function injectCss() {
// Inject the fake css on all pages if enabled and user is logged
$loggedUser = $this->userSession->getUser();
if (!is_null($loggedUser)) {
$userValues = $this->config->getUserKeys($loggedUser->getUID(), $this->appName);
if(count($userValues) > 0) {
\OCP\Util::addStyle($this->appName, 'user-' . md5(implode('-', $userValues)), true);
if (count($userValues) > 0) {
$linkToCSS = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => md5(implode('-', $userValues))]);
\OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public function __construct(string $appName,
* @return DataDisplayResponse
*/
public function getCss(): DataDisplayResponse {

$css = '';
$imports = '';

Expand Down