Add composer file to manage some dev dependencies

This commit is contained in:
Magnus Walbeck 2021-08-10 21:39:53 +02:00
parent 23517ad52d
commit d95e9c0cf4
No known key found for this signature in database
GPG Key ID: CCB78CFF3F950769
11 changed files with 2245 additions and 113 deletions

8
.gitignore vendored
View File

@ -1,4 +1,4 @@
build
node_modules
translationfiles
translationtool.phar
/build
/node_modules
/vendor
/.php_cs.cache

View File

@ -1,26 +1,26 @@
<?php
/**
* Breeze Dark theme for Nextcloud
*
*
* @copyright Copyright (C) 2020 Magnus Walbeck <mw@mwalbeck.org>
*
*
* @author Magnus Walbeck <mw@mwalbeck.org>
*
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/

13
composer.json Normal file
View File

@ -0,0 +1,13 @@
{
"autoload-dev": {
"psr-4": {
"OCP\\": "vendor/christophwurst/nextcloud/OCP",
"OCA\\Talked\\": "lib/"
}
},
"require": {},
"require-dev": {
"nextcloud/coding-standard": "^0.5.0",
"christophwurst/nextcloud": "^21.0"
}
}

2093
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,26 +4,26 @@ declare(strict_types=1);
/**
* Breeze Dark theme for Nextcloud
*
*
* @copyright Copyright (C) 2020 Magnus Walbeck <mw@mwalbeck.org>
*
*
* @author Magnus Walbeck <mw@mwalbeck.org>
*
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\BreezeDark\AppInfo;
@ -37,7 +37,8 @@ use OCP\IUserSession;
use OCP\Util;
use OCP\IURLGenerator;
class Application extends App implements IBootstrap {
class Application extends App implements IBootstrap
{
/** @var string */
public const APP_NAME = 'breezedark';
@ -45,48 +46,53 @@ class Application extends App implements IBootstrap {
/** @var string */
protected $appName;
public function __construct() {
public function __construct()
{
parent::__construct(self::APP_NAME);
$this->appName = self::APP_NAME;
}
public function register(IRegistrationContext $context): void {
}
public function register(IRegistrationContext $context): void
{
}
public function boot(IBootContext $context): void {
$context->injectFn([$this, 'doTheming']);
}
public function boot(IBootContext $context): void
{
$context->injectFn([$this, 'doTheming']);
}
/**
* Check if the theme should be applied
*
*
* @param IConfig $config
* @param IUserSession $userSession
* @param IURLGenerator $urlGenerator
*/
public function doTheming(IConfig $config, IUserSession $userSession, IURLGenerator $urlGenerator): void {
public function doTheming(IConfig $config, IUserSession $userSession, IURLGenerator $urlGenerator): void
{
$user = $userSession->getUser();
$default = $config->getAppValue($this->appName, "theme_enabled", "0");
$loginPage = $config->getAppValue($this->appName, "theme_login_page", "1");
$cachebuster = $config->getAppValue($this->appName, "theme_cachebuster", "0");
if (!is_null($user) AND $config->getUserValue($user->getUID(), $this->appName, "theme_enabled", $default)) {
// When shown the 2FA login page you are logged in while also being on a login page,
if (!is_null($user) and $config->getUserValue($user->getUID(), $this->appName, "theme_enabled", $default)) {
// When shown the 2FA login page you are logged in while also being on a login page,
// so a logged in user still needs the guests.css stylesheet
$this->addStyling($urlGenerator, $loginPage, $cachebuster);
} else if (is_null($user) AND $default) {
} elseif (is_null($user) and $default) {
$this->addStyling($urlGenerator, $loginPage, $cachebuster);
}
}
/**
* Add stylesheet(s) to nextcloud
*
*
* @param IURLGenerator $urlGenerator
* @param string $loginPage
* @param string $cachebuster
*/
public function addStyling(IURLGenerator $urlGenerator, string $loginPage, string $cachebuster): void {
public function addStyling(IURLGenerator $urlGenerator, string $loginPage, string $cachebuster): void
{
Util::addStyle($this->appName, 'server');
Util::addScript($this->appName, 'breezedark');
@ -98,7 +104,7 @@ class Application extends App implements IBootstrap {
// Only request the stylesheet if there is any styling to request
if ($cachebuster) {
$linkToCustomStyling = $urlGenerator->linkToRoute(
'breezedark.Theming.getCustomStyling',
'breezedark.Theming.getCustomStyling',
['v' => $cachebuster,]
);
Util::addHeader(

View File

@ -4,38 +4,37 @@ declare(strict_types=1);
/**
* Breeze Dark theme for Nextcloud
*
*
* @copyright Copyright (C) 2020 Magnus Walbeck <mw@mwalbeck.org>
*
*
* @author Magnus Walbeck <mw@mwalbeck.org>
*
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\BreezeDark\Controller;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
class SettingsController extends Controller {
class SettingsController extends Controller
{
/** @var string */
protected $appName;
@ -52,10 +51,12 @@ class SettingsController extends Controller {
* @param IUserSession $userSession
* @param IRequest $request
*/
public function __construct(string $appName,
IConfig $config,
IUserSession $userSession,
IRequest $request) {
public function __construct(
string $appName,
IConfig $config,
IUserSession $userSession,
IRequest $request
) {
parent::__construct($appName, $request);
$this->config = $config;
$this->userId = $userSession->getUser()->getUID();
@ -63,10 +64,11 @@ class SettingsController extends Controller {
/**
* @NoAdminRequired
*
*
* Set user theme option
*/
public function personal(): void {
public function personal(): void
{
if ($this->request->getParam("theme_enabled")) {
$this->config->setUserValue($this->userId, $this->appName, "theme_enabled", "1");
} else {
@ -77,7 +79,8 @@ class SettingsController extends Controller {
/**
* Set global theme option
*/
public function admin(): void {
public function admin(): void
{
if ($this->request->getParam("theme_enabled")) {
$this->config->setAppValue($this->appName, "theme_enabled", "1");
} else {
@ -94,7 +97,8 @@ class SettingsController extends Controller {
/**
* Set custom styling option
*/
public function customStyling(): void {
public function customStyling(): void
{
if ($this->request->getParam("theme_custom_styling")) {
$this->config->setAppValue($this->appName, "theme_custom_styling", $this->request->getParam("theme_custom_styling"));
$this->config->setAppValue($this->appName, "theme_cachebuster", time());

View File

@ -4,26 +4,26 @@ declare(strict_types=1);
/**
* Breeze Dark theme for Nextcloud
*
*
* @copyright Copyright (C) 2021 Magnus Walbeck <mw@mwalbeck.org>
*
*
* @author Magnus Walbeck <mw@mwalbeck.org>
*
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\BreezeDark\Controller;
@ -34,7 +34,8 @@ use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\IConfig;
use OCP\IRequest;
class ThemingController extends Controller {
class ThemingController extends Controller
{
/** @var string */
protected $appName;
@ -47,24 +48,27 @@ class ThemingController extends Controller {
* @param IConfig $config
* @param IRequest $request
*/
public function __construct(string $appName,
IConfig $config,
IRequest $request) {
public function __construct(
string $appName,
IConfig $config,
IRequest $request
) {
parent::__construct($appName, $request);
$this->config = $config;
}
/**
* @NoCSRFRequired
* @PublicPage
* @NoSameSiteCookieRequired
*
* @return DataDisplayResponse|NotFoundResponse
*/
public function getCustomStyling(): DataDisplayResponse {
* @NoCSRFRequired
* @PublicPage
* @NoSameSiteCookieRequired
*
* @return DataDisplayResponse|NotFoundResponse
*/
public function getCustomStyling(): DataDisplayResponse
{
$customStyling = $this->config->getAppValue($this->appName, 'theme_custom_styling', '');
$response = new DataDisplayResponse($customStyling, Http::STATUS_OK, ['Content-Type' => 'text/css']);
$response->cacheFor(86400);
$response->cacheFor(86400);
return $response;
}
}

View File

@ -4,26 +4,26 @@ declare(strict_types=1);
/**
* Breeze Dark theme for Nextcloud
*
*
* @copyright Copyright (C) 2020 Magnus Walbeck <mw@mwalbeck.org>
*
*
* @author Magnus Walbeck <mw@mwalbeck.org>
*
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\BreezeDark\Settings;
@ -32,7 +32,8 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;
class Admin implements ISettings {
class Admin implements ISettings
{
/** @var string */
protected $appName;
@ -44,8 +45,11 @@ class Admin implements ISettings {
* @param string $appName
* @param IConfig $config
*/
public function __construct(string $appName,
IConfig $config) {
public function __construct(
string $appName,
IConfig $config
)
{
$this->appName = $appName;
$this->config = $config;
}
@ -53,11 +57,12 @@ class Admin implements ISettings {
/**
* @return TemplateResponse
*/
public function getForm(): TemplateResponse {
public function getForm(): TemplateResponse
{
$themeEnabled = $this->config->getAppValue($this->appName, 'theme_enabled', "0");
$themeLoginPage = $this->config->getAppValue($this->appName, 'theme_login_page', "1");
$themeCustomStyling = $this->config->getAppValue($this->appName, 'theme_custom_styling', "");
return new TemplateResponse('breezedark', 'admin', [
return new TemplateResponse('breezedark', 'admin', [
"themeEnabled" => $themeEnabled,
"themeLoginPage" => $themeLoginPage,
"themeCustomStyling" => $themeCustomStyling
@ -67,14 +72,16 @@ class Admin implements ISettings {
/**
* @return string
*/
public function getSection(): string {
public function getSection(): string
{
return 'theming';
}
/**
* @return int
*/
public function getPriority(): int {
public function getPriority(): int
{
return 50;
}
}

View File

@ -4,26 +4,26 @@ declare(strict_types=1);
/**
* Breeze Dark theme for Nextcloud
*
*
* @copyright Copyright (C) 2020 Magnus Walbeck <mw@mwalbeck.org>
*
*
* @author Magnus Walbeck <mw@mwalbeck.org>
*
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\BreezeDark\Settings;
@ -34,7 +34,8 @@ use OCP\IConfig;
use OCP\Settings\ISettings;
use OCP\IUserSession;
class Personal implements ISettings {
class Personal implements ISettings
{
/** @var string */
protected $appName;
@ -54,10 +55,12 @@ class Personal implements ISettings {
* @param IUserSession $userSession
* @param IAppManager $appManager
*/
public function __construct(string $appName,
IConfig $config,
IUserSession $userSession,
IAppManager $appManager) {
public function __construct(
string $appName,
IConfig $config,
IUserSession $userSession,
IAppManager $appManager
) {
$this->appName = $appName;
$this->config = $config;
$this->userId = $userSession->getUser()->getUID();
@ -67,10 +70,11 @@ class Personal implements ISettings {
/**
* @return TemplateResponse
*/
public function getForm(): TemplateResponse {
public function getForm(): TemplateResponse
{
$default = $this->config->getAppValue($this->appName, 'theme_enabled', "0");
$themeEnabled = $this->config->getUserValue($this->userId, $this->appName, 'theme_enabled', $default);
return new TemplateResponse('breezedark', 'personal', [
return new TemplateResponse('breezedark', 'personal', [
"themeEnabled" => $themeEnabled,
"appWebPath" => $this->appWebPath
]);
@ -79,15 +83,16 @@ class Personal implements ISettings {
/**
* @return string
*/
public function getSection(): string {
public function getSection(): string
{
return 'accessibility';
}
/**
* @return int
*/
public function getPriority(): int {
public function getPriority(): int
{
return 50;
}
}

View File

@ -1,26 +1,26 @@
<?php
/**
* Breeze Dark theme for Nextcloud
*
*
* @copyright Copyright (C) 2020 Magnus Walbeck <mw@mwalbeck.org>
*
* @author Magnus Walbeck <mw@mwalbeck.org>
*
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/

View File

@ -1,26 +1,26 @@
<?php
/**
* Breeze Dark theme for Nextcloud
*
*
* @copyright Copyright (C) 2020 Magnus Walbeck <mw@mwalbeck.org>
*
* @author Magnus Walbeck <mw@mwalbeck.org>
*
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/