diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Authentication/Token/Manager.php | 8 | ||||
-rw-r--r-- | lib/private/Avatar.php | 33 | ||||
-rw-r--r-- | lib/private/Preview/TXT.php | 2 | ||||
-rw-r--r-- | lib/private/Template/JSResourceLocator.php | 1 |
4 files changed, 27 insertions, 17 deletions
diff --git a/lib/private/Authentication/Token/Manager.php b/lib/private/Authentication/Token/Manager.php index 7c991eadea9..98a48f41523 100644 --- a/lib/private/Authentication/Token/Manager.php +++ b/lib/private/Authentication/Token/Manager.php @@ -112,7 +112,9 @@ class Manager implements IProvider { public function getToken(string $tokenId): IToken { try { return $this->publicKeyTokenProvider->getToken($tokenId); - } catch (InvalidTokenException $e) { + } catch (ExpiredTokenException $e) { + throw $e; + } catch(InvalidTokenException $e) { // No worries we try to convert it to a PublicKey Token } @@ -138,6 +140,8 @@ class Manager implements IProvider { public function getTokenById(int $tokenId): IToken { try { return $this->publicKeyTokenProvider->getTokenById($tokenId); + } catch (ExpiredTokenException $e) { + throw $e; } catch (InvalidTokenException $e) { return $this->defaultTokenProvider->getTokenById($tokenId); } @@ -151,6 +155,8 @@ class Manager implements IProvider { public function renewSessionToken(string $oldSessionId, string $sessionId) { try { $this->publicKeyTokenProvider->renewSessionToken($oldSessionId, $sessionId); + } catch (ExpiredTokenException $e) { + throw $e; } catch (InvalidTokenException $e) { $this->defaultTokenProvider->renewSessionToken($oldSessionId, $sessionId); } diff --git a/lib/private/Avatar.php b/lib/private/Avatar.php index d107bb47c52..97e1c0535a4 100644 --- a/lib/private/Avatar.php +++ b/lib/private/Avatar.php @@ -62,15 +62,18 @@ class Avatar implements IAvatar { /** * https://github.com/sebdesign/cap-height -- for 500px height - * Open Sans cap-height is 0.72 and we want a 200px caps height size (0.4 letter-to-total-height ratio, 500*0.4=200). 200/0.72 = 278px. - * Since we start from the baseline (text-anchor) we need to shift the y axis by 100px (half the caps height): 500/2+100=350 - * - * @var string + * Automated check: https://codepen.io/skjnldsv/pen/PydLBK/ + * Nunito cap-height is 0.716 and we want a 200px caps height size + * (0.4 letter-to-total-height ratio, 500*0.4=200), so: 200/0.716 = 279px. + * Since we start from the baseline (text-anchor) we need to + * shift the y axis by 100px (half the caps height): 500/2+100=350 + * + * @var string */ private $svgTemplate = '<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg width="{size}" height="{size}" version="1.1" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"> <rect width="100%" height="100%" fill="#{fill}"></rect> - <text x="50%" y="350" style="font-weight:600;font-size:278px;font-family:\'Open Sans\';text-anchor:middle;fill:#fff">{letter}</text> + <text x="50%" y="350" style="font-weight:normal;font-size:279px;font-family:\'Nunito\';text-anchor:middle;fill:#fff">{letter}</text> </svg>'; /** @@ -189,7 +192,7 @@ class Avatar implements IAvatar { // } $this->user->triggerChange('avatar', $file); - } + } /** * remove the users avatar @@ -285,15 +288,15 @@ class Avatar implements IAvatar { } throw new NotFoundException; } - + /** * {size} = 500 * {fill} = hex color to fill * {letter} = Letter to display - * + * * Generate SVG avatar * @return string - * + * */ private function getAvatarVector(int $size): string { $userDisplayName = $this->user->getDisplayName(); @@ -301,14 +304,14 @@ class Avatar implements IAvatar { $bgRGB = $this->avatarBackgroundColor($userDisplayName); $bgHEX = sprintf("%02x%02x%02x", $bgRGB->r, $bgRGB->g, $bgRGB->b); $letter = mb_strtoupper(mb_substr($userDisplayName, 0, 1), 'UTF-8'); - + $toReplace = ['{size}', '{fill}', '{letter}']; return str_replace($toReplace, [$size, $bgHEX, $letter], $this->svgTemplate); } /** * Generate png avatar from svg with Imagick - * + * * @param int $size * @return string|boolean */ @@ -317,7 +320,7 @@ class Avatar implements IAvatar { return false; } try { - $font = __DIR__ . '/../../core/fonts/OpenSans-Semibold.ttf'; + $font = __DIR__ . '/../../core/fonts/Nunito-Regular.ttf'; $svg = $this->getAvatarVector($size); $avatar = new Imagick(); $avatar->setFont($font); @@ -333,7 +336,7 @@ class Avatar implements IAvatar { /** * Generate png avatar with GD - * + * * @param string $userDisplayName * @param int $size * @return string @@ -347,7 +350,7 @@ class Avatar implements IAvatar { $white = imagecolorallocate($im, 255, 255, 255); imagefilledrectangle($im, 0, 0, $size, $size, $background); - $font = __DIR__ . '/../../core/fonts/OpenSans-Semibold.ttf'; + $font = __DIR__ . '/../../core/fonts/Nunito-Regular.ttf'; $fontSize = $size * 0.4; @@ -455,7 +458,7 @@ class Avatar implements IAvatar { public function avatarBackgroundColor(string $hash) { // Normalize hash $hash = strtolower($hash); - + // Already a md5 hash? if( preg_match('/^([0-9a-f]{4}-?){8}$/', $hash, $matches) !== 1 ) { $hash = md5($hash); diff --git a/lib/private/Preview/TXT.php b/lib/private/Preview/TXT.php index 2925e5bd537..a5efb73010c 100644 --- a/lib/private/Preview/TXT.php +++ b/lib/private/Preview/TXT.php @@ -69,7 +69,7 @@ class TXT extends Provider { $fontFile = __DIR__; $fontFile .= '/../../../core'; - $fontFile .= '/fonts/OpenSans-Regular.ttf'; + $fontFile .= '/fonts/Nunito-Regular.ttf'; $canUseTTF = function_exists('imagettftext'); diff --git a/lib/private/Template/JSResourceLocator.php b/lib/private/Template/JSResourceLocator.php index d38488e4618..8b23a8d1486 100644 --- a/lib/private/Template/JSResourceLocator.php +++ b/lib/private/Template/JSResourceLocator.php @@ -55,6 +55,7 @@ class JSResourceLocator extends ResourceLocator { $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); $found += $this->appendIfExist($this->serverroot, $script.'.js'); $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); + $found += $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js'); $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); if ($found) { |