summaryrefslogtreecommitdiffstats
path: root/apps/accessibility/lib
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-06-14 15:27:57 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-06-25 17:12:27 +0200
commitc972e3dc31ffb2de1e583ab0328ec1b424af57b1 (patch)
tree4d17eed21c61078ffbf1df73ff59882db7fa592f /apps/accessibility/lib
parent77817797707238746490e069e789abf4c2327bc3 (diff)
downloadnextcloud-server-c972e3dc31ffb2de1e583ab0328ec1b424af57b1.tar.gz
nextcloud-server-c972e3dc31ffb2de1e583ab0328ec1b424af57b1.zip
Live css update, cache fix, design updates and various stuff
+ AppName fixes and compile bump + Bump dark theme and added highcontrast + various fixes Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/accessibility/lib')
-rw-r--r--apps/accessibility/lib/AppInfo/Application.php22
-rw-r--r--apps/accessibility/lib/Controller/AccessibilityController.php41
-rw-r--r--apps/accessibility/lib/Settings/Personal.php10
-rw-r--r--apps/accessibility/lib/Settings/PersonalSection.php12
4 files changed, 56 insertions, 29 deletions
diff --git a/apps/accessibility/lib/AppInfo/Application.php b/apps/accessibility/lib/AppInfo/Application.php
index 1c5e4b5cec1..dda2fd60698 100644
--- a/apps/accessibility/lib/AppInfo/Application.php
+++ b/apps/accessibility/lib/AppInfo/Application.php
@@ -24,16 +24,32 @@
namespace OCA\Accessibility\AppInfo;
use OCP\AppFramework\App;
+use OCP\IConfig;
+use OCP\IUserSession;
class Application extends App {
/** @var string */
protected $appName = 'accessibility';
+ /** @var IConfig */
+ private $config;
+
+ /** @var IUserSession */
+ private $userSession;
+
public function __construct() {
parent::__construct($this->appName);
-
- // Inject the fake css on all pages
- \OCP\Util::addStyle('accessibility', 'user', true);
+ $this->config = \OC::$server->getConfig();
+ $this->userSession = \OC::$server->getUserSession();
+
+ // 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);
+ }
+ }
}
}
diff --git a/apps/accessibility/lib/Controller/AccessibilityController.php b/apps/accessibility/lib/Controller/AccessibilityController.php
index ee1f42dfebb..ff5da9c0827 100644
--- a/apps/accessibility/lib/Controller/AccessibilityController.php
+++ b/apps/accessibility/lib/Controller/AccessibilityController.php
@@ -29,6 +29,7 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IRequest;
@@ -62,6 +63,9 @@ class AccessibilityController extends Controller {
/** @var IUserSession */
private $userSession;
+ /** @var IAppManager */
+ private $appManager;
+
/**
* Account constructor.
*
@@ -73,39 +77,43 @@ class AccessibilityController extends Controller {
* @param IURLGenerator $urlGenerator
* @param ITimeFactory $timeFactory
* @param IUserSession $userSession
+ * @param IAppManager $appManager
*/
public function __construct(string $appName,
- IRequest $request,
- IConfig $config,
- IUserManager $userManager,
- ILogger $logger,
- IURLGenerator $urlGenerator,
- ITimeFactory $timeFactory,
- IUserSession $userSession) {
+ IRequest $request,
+ IConfig $config,
+ IUserManager $userManager,
+ ILogger $logger,
+ IURLGenerator $urlGenerator,
+ ITimeFactory $timeFactory,
+ IUserSession $userSession,
+ IAppManager $appManager) {
parent::__construct($appName, $request);
+ $this->appName = $appName;
$this->config = $config;
$this->userManager = $userManager;
$this->logger = $logger;
$this->urlGenerator = $urlGenerator;
$this->timeFactory = $timeFactory;
$this->userSession = $userSession;
+ $this->appManager = $appManager;
$this->serverRoot = \OC::$SERVERROOT;
- $this->appRoot = \OC_App::getAppPath($this->appName);
+ $this->appRoot = $this->appManager->getAppPath($this->appName);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
- * @return DataResponse
+ * @return DataDisplayResponse
*/
public function getCss(): DataDisplayResponse {
$css = '';
$imports = '';
- foreach ($this->getUserValues() as $scssFile) {
+ foreach ($this->getUserValues() as $key => $scssFile) {
if ($scssFile !== false) {
$imports .= '@import "' . $scssFile . '";';
}
@@ -122,7 +130,7 @@ class AccessibilityController extends Controller {
$scss->setIgnoreErrors(true);
$scss->setFormatter(Crunched::class);
- // Compile
+ // Import theme, variables and compile css4 variables
try {
$css .= $scss->compile(
$imports .
@@ -139,9 +147,9 @@ class AccessibilityController extends Controller {
$response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']);
+ // Set cache control
$ttl = 31536000;
$response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable');
-
$expires = new \DateTime();
$expires->setTimestamp($this->timeFactory->getTime());
$expires->add(new \DateInterval('PT' . $ttl . 'S'));
@@ -152,13 +160,10 @@ class AccessibilityController extends Controller {
}
private function getUserValues() {
- $userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'accessibility', 'theme', false);
- $userFont = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'accessibility', 'font', false);
+ $userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false);
+ $userFont = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false);
- return [
- 'theme' => $userTheme,
- 'font' => $userFont
- ];
+ return [$userTheme, $userFont];
}
private function filterOutRule(string $rule, string $css) {
diff --git a/apps/accessibility/lib/Settings/Personal.php b/apps/accessibility/lib/Settings/Personal.php
index d28625449a7..6bce287e6e1 100644
--- a/apps/accessibility/lib/Settings/Personal.php
+++ b/apps/accessibility/lib/Settings/Personal.php
@@ -83,12 +83,12 @@ class Personal implements ISettings {
$serverData = [
'themes' => $this->accessibilityProvider->getThemes(),
- 'fonts' => $this->accessibilityProvider->getFonts(),
- 'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), 'accessibility', 'theme', 'dark'),
- 'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), 'accessibility', 'font', false)
+ 'fonts' => $this->accessibilityProvider->getFonts(),
+ 'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false),
+ 'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false)
];
- return new TemplateResponse('accessibility', 'settings-personal', ['serverData' => $serverData]);
+ return new TemplateResponse($this->appName, 'settings-personal', ['serverData' => $serverData]);
}
/**
@@ -96,7 +96,7 @@ class Personal implements ISettings {
* @since 9.1
*/
public function getSection() {
- return 'accessibility';
+ return $this->appName;
}
/**
diff --git a/apps/accessibility/lib/Settings/PersonalSection.php b/apps/accessibility/lib/Settings/PersonalSection.php
index bd3afa79355..3e89635c7bb 100644
--- a/apps/accessibility/lib/Settings/PersonalSection.php
+++ b/apps/accessibility/lib/Settings/PersonalSection.php
@@ -29,6 +29,9 @@ use OCP\Settings\IIconSection;
class PersonalSection implements IIconSection {
+ /** @var string */
+ protected $appName;
+
/** @var IURLGenerator */
private $urlGenerator;
@@ -38,11 +41,14 @@ class PersonalSection implements IIconSection {
/**
* Personal Section constructor.
*
+ * @param string $appName
* @param IURLGenerator $urlGenerator
* @param IL10N $l
*/
- public function __construct(IURLGenerator $urlGenerator,
+ public function __construct(string $appName,
+ IURLGenerator $urlGenerator,
IL10N $l) {
+ $this->appName = $appName;
$this->urlGenerator = $urlGenerator;
$this->l = $l;
}
@@ -55,7 +61,7 @@ class PersonalSection implements IIconSection {
* @since 13.0.0
*/
public function getIcon() {
- return $this->urlGenerator->imagePath('accessibility', 'app-dark.svg');
+ return $this->urlGenerator->imagePath($this->appName, 'app-dark.svg');
}
/**
@@ -66,7 +72,7 @@ class PersonalSection implements IIconSection {
* @since 9.1
*/
public function getID() {
- return 'accessibility';
+ return $this->appName;
}
/**