Merge pull request #405 from nextcloud/theming-fixes

Theming fixes
This commit is contained in:
Björn Schießle 2016-07-18 15:59:47 +02:00 committed by GitHub
commit ea470f8777
19 changed files with 87 additions and 25 deletions

View File

@ -65,7 +65,7 @@ class PublicAuth extends AbstractBasic {
$this->session = $session;
// setup realm
$defaults = new \OC_Defaults();
$defaults = new \OCP\Defaults();
$this->realm = $defaults->getName();
}

View File

@ -78,7 +78,7 @@ class Auth extends AbstractBasic {
$this->principalPrefix = $principalPrefix;
// setup realm
$defaults = new \OC_Defaults();
$defaults = new \OCP\Defaults();
$this->realm = $defaults->getName();
}

View File

@ -38,7 +38,7 @@ class FedAuth extends AbstractBasic {
$this->principalPrefix = 'principals/system/';
// setup realm
$defaults = new \OC_Defaults();
$defaults = new \OCP\Defaults();
$this->realm = $defaults->getName();
}

View File

@ -5,11 +5,17 @@
<description>Adjust the Nextcloud theme</description>
<licence>AGPL</licence>
<author>Nextcloud</author>
<version>0.1.0</version>
<version>0.2.0</version>
<namespace>Theming</namespace>
<category>other</category>
<dependencies>
<owncloud min-version="9.0" max-version="9.1" />
</dependencies>
<types>
<logging/>
</types>
<default_enable/>
</info>

View File

@ -77,6 +77,10 @@ class Template extends \OC_Defaults {
return $this->config->getAppValue('theming', 'name', $this->name);
}
public function getHTMLName() {
return $this->config->getAppValue('theming', 'name', $this->name);
}
public function getTitle() {
return $this->config->getAppValue('theming', 'name', $this->name);
}
@ -93,6 +97,15 @@ class Template extends \OC_Defaults {
return $this->config->getAppValue('theming', 'slogan', $this->slogan);
}
public function getShortFooter() {
$slogan = $this->getSlogan();
$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
' rel="noreferrer">' .$this->getEntity() . '</a>'.
($slogan !== '' ? ' ' . $slogan : '');
return $footer;
}
/**
* Color that is used for the header as well as for mail headers
*

View File

@ -91,6 +91,26 @@ class TemplateTest extends TestCase {
$this->assertEquals('MyCustomCloud', $this->template->getName());
}
public function testGetHTMLNameWithDefault() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('theming', 'name', 'Nextcloud')
->willReturn('Nextcloud');
$this->assertEquals('Nextcloud', $this->template->getHTMLName());
}
public function testGetHTMLNameWithCustom() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('theming', 'name', 'Nextcloud')
->willReturn('MyCustomCloud');
$this->assertEquals('MyCustomCloud', $this->template->getHTMLName());
}
public function testGetTitleWithDefault() {
$this->config
->expects($this->once())
@ -172,6 +192,32 @@ class TemplateTest extends TestCase {
$this->assertEquals('My custom Slogan', $this->template->getSlogan());
}
public function testGetShortFooter() {
$this->config
->expects($this->exactly(3))
->method('getAppValue')
->willReturnMap([
['theming', 'url', 'https://nextcloud.com/', 'url'],
['theming', 'name', 'Nextcloud', 'Name'],
['theming', 'slogan', 'Safe Data', 'Slogan'],
]);
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a> Slogan', $this->template->getShortFooter());
}
public function testGetShortFooterEmptySlogan() {
$this->config
->expects($this->exactly(3))
->method('getAppValue')
->willReturnMap([
['theming', 'url', 'https://nextcloud.com/', 'url'],
['theming', 'name', 'Nextcloud', 'Name'],
['theming', 'slogan', 'Safe Data', ''],
]);
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a>', $this->template->getShortFooter());
}
public function testGetMailHeaderColorWithDefault() {
$this->config
->expects($this->once())

View File

@ -35,7 +35,7 @@ use OC\Core\Controller\LostController;
use OC\Core\Controller\TokenController;
use OC\Core\Controller\TwoFactorChallengeController;
use OC\Core\Controller\UserController;
use OC_Defaults;
use OCP\Defaults;
use OCP\AppFramework\App;
use OCP\Util;
@ -165,8 +165,8 @@ class Application extends App {
$container->registerService('UserFolder', function(SimpleContainer $c) {
return $c->query('ServerContainer')->getUserFolder();
});
$container->registerService('Defaults', function() {
return new OC_Defaults;
$container->registerService('Defaults', function(SimpleContainer $c) {
return $c->query('ServerContainer')->getThemingDefaults();
});
$container->registerService('Mailer', function(SimpleContainer $c) {
return $c->query('ServerContainer')->getMailer();

View File

@ -64,7 +64,7 @@ class Install extends Command {
// validate the environment
$server = \OC::$server;
$setupHelper = new Setup($this->config, $server->getIniWrapper(),
$server->getL10N('lib'), new \OC_Defaults(), $server->getLogger(),
$server->getL10N('lib'), $server->getThemingDefaults(), $server->getLogger(),
$server->getSecureRandom());
$sysInfo = $setupHelper->getSystemInfo(true);
$errors = $sysInfo['errors'];

View File

@ -38,7 +38,6 @@ use \OCP\IConfig;
use OCP\IUserManager;
use OCP\Mail\IMailer;
use OCP\Security\ISecureRandom;
use \OC_Defaults;
use OCP\Security\StringUtils;
/**
@ -54,8 +53,7 @@ class LostController extends Controller {
protected $urlGenerator;
/** @var IUserManager */
protected $userManager;
// FIXME: Inject a non-static factory of OC_Defaults for better unit-testing
/** @var OC_Defaults */
/** @var \OC_Defaults */
protected $defaults;
/** @var IL10N */
protected $l10n;
@ -77,7 +75,7 @@ class LostController extends Controller {
* @param IRequest $request
* @param IURLGenerator $urlGenerator
* @param IUserManager $userManager
* @param OC_Defaults $defaults
* @param \OC_Defaults $defaults
* @param IL10N $l10n
* @param IConfig $config
* @param ISecureRandom $secureRandom
@ -90,7 +88,7 @@ class LostController extends Controller {
IRequest $request,
IURLGenerator $urlGenerator,
IUserManager $userManager,
OC_Defaults $defaults,
\OC_Defaults $defaults,
IL10N $l10n,
IConfig $config,
ISecureRandom $secureRandom,

View File

@ -812,7 +812,7 @@ class OC {
if (!$systemConfig->getValue('installed', false)) {
\OC::$server->getSession()->clear();
$setupHelper = new OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(),
\OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(),
\OC::$server->getL10N('lib'), \OC::$server->getThemingDefaults(), \OC::$server->getLogger(),
\OC::$server->getSecureRandom());
$controller = new OC\Core\Controller\SetupController($setupHelper);
$controller->run($_POST);

View File

@ -26,8 +26,8 @@
namespace OC\Console;
use OC_App;
use OC_Defaults;
use OCP\Console\ConsoleEvent;
use OCP\Defaults;
use OCP\IConfig;
use OCP\IRequest;
use Symfony\Component\Console\Application as SymfonyApplication;
@ -51,7 +51,7 @@ class Application {
* @param IRequest $request
*/
public function __construct(IConfig $config, EventDispatcherInterface $dispatcher, IRequest $request) {
$defaults = new OC_Defaults;
$defaults = \OC::$server->getThemingDefaults();
$this->config = $config;
$this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString());
$this->dispatcher = $dispatcher;

View File

@ -562,7 +562,7 @@ class Server extends ServerContainer implements IServerContainer {
return new Mailer(
$c->getConfig(),
$c->getLogger(),
new \OC_Defaults()
$c->getThemingDefaults()
);
});
$this->registerService('OcsClient', function (Server $c) {

View File

@ -426,7 +426,7 @@ class Setup {
}
$setupHelper = new \OC\Setup($config, \OC::$server->getIniWrapper(),
\OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(),
\OC::$server->getL10N('lib'), \OC::$server->getThemingDefaults(), \OC::$server->getLogger(),
\OC::$server->getSecureRandom());
$htaccessContent = file_get_contents($setupHelper->pathToHtaccess());

View File

@ -29,7 +29,7 @@
*/
namespace OC;
use OC_Defaults;
use OCP\Defaults;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IURLGenerator;
@ -222,7 +222,7 @@ class URLGenerator implements IURLGenerator {
* @return string url to the online documentation
*/
public function linkToDocs($key) {
$theme = new OC_Defaults();
$theme = \OC::$server->getThemingDefaults();
return $theme->buildDocLinkToKey($key);
}
}

View File

@ -631,7 +631,7 @@ class OC_Util {
$webServerRestart = false;
$setup = new \OC\Setup($config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'),
new \OC_Defaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom());
\OC::$server->getThemingDefaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom());
$urlGenerator = \OC::$server->getURLGenerator();

View File

@ -51,7 +51,7 @@ class Defaults {
* @since 6.0.0
*/
function __construct() {
$this->defaults = new \OC_Defaults();
$this->defaults = \OC::$server->getThemingDefaults();
}
/**

View File

@ -227,7 +227,7 @@ class Application extends App {
return $c->query('ServerContainer')->getMailer();
});
$container->registerService('Defaults', function(IContainer $c) {
return new \OC_Defaults;
return $c->query('ServerContainer')->getThemingDefaults();
});
$container->registerService('DefaultMailAddress', function(IContainer $c) {
return Util::getDefaultEmailAddress('no-reply');

View File

@ -29,7 +29,6 @@ use OCP\IRequest;
use OCP\IL10N;
use OCP\IConfig;
use OCP\Mail\IMailer;
use OCP\Mail\IMessage;
/**
* @package OC\Settings\Controller

View File

@ -37,7 +37,7 @@
OC_Util::checkLoggedIn();
$defaults = new OC_Defaults(); // initialize themable default strings and urls
$defaults = \OC::$server->getThemingDefaults();
$certificateManager = \OC::$server->getCertificateManager();
$config = \OC::$server->getConfig();
$urlGenerator = \OC::$server->getURLGenerator();