diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2017-09-04 12:02:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-04 12:02:33 +0200 |
commit | 57b74c921be3f7b9f9e35e04263a995f9e572157 (patch) | |
tree | d00bc2bdff744e865448a845c9e983b40cb63071 | |
parent | 139f9bd3cae2dc3805fa90135778160801d3ebdd (diff) | |
parent | 46229a00f39e507249dbe3ceb7507277da3fa4f8 (diff) | |
download | nextcloud-server-57b74c921be3f7b9f9e35e04263a995f9e572157.tar.gz nextcloud-server-57b74c921be3f7b9f9e35e04263a995f9e572157.zip |
Merge pull request #6342 from nextcloud/rich-link-preview
Add rich link preview to the login page
-rw-r--r-- | core/Controller/LoginController.php | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php index 12431571256..3a294ce855c 100644 --- a/core/Controller/LoginController.php +++ b/core/Controller/LoginController.php @@ -38,6 +38,7 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\Authentication\TwoFactorAuth\IProvider; +use OCP\Defaults; use OCP\IConfig; use OCP\ILogger; use OCP\IRequest; @@ -47,6 +48,7 @@ use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; use OC\Hooks\PublicEmitter; +use OCP\Util; class LoginController extends Controller { /** @var IUserManager */ @@ -63,6 +65,8 @@ class LoginController extends Controller { private $logger; /** @var Manager */ private $twoFactorManager; + /** @var Defaults */ + private $defaults; /** * @param string $appName @@ -76,14 +80,15 @@ class LoginController extends Controller { * @param Manager $twoFactorManager */ public function __construct($appName, - IRequest $request, - IUserManager $userManager, - IConfig $config, - ISession $session, - IUserSession $userSession, - IURLGenerator $urlGenerator, - ILogger $logger, - Manager $twoFactorManager) { + IRequest $request, + IUserManager $userManager, + IConfig $config, + ISession $session, + IUserSession $userSession, + IURLGenerator $urlGenerator, + ILogger $logger, + Manager $twoFactorManager, + Defaults $defaults) { parent::__construct($appName, $request); $this->userManager = $userManager; $this->config = $config; @@ -92,6 +97,7 @@ class LoginController extends Controller { $this->urlGenerator = $urlGenerator; $this->logger = $logger; $this->twoFactorManager = $twoFactorManager; + $this->defaults = $defaults; } /** @@ -176,6 +182,14 @@ class LoginController extends Controller { $parameters['user_autofocus'] = true; } + // OpenGraph Support: http://ogp.me/ + Util::addHeader('meta', ['property' => "og:title", 'content' => Util::sanitizeHTML($this->defaults->getName())]); + Util::addHeader('meta', ['property' => "og:description", 'content' => Util::sanitizeHTML($this->defaults->getSlogan())]); + Util::addHeader('meta', ['property' => "og:site_name", 'content' => Util::sanitizeHTML($this->defaults->getName())]); + Util::addHeader('meta', ['property' => "og:url", 'content' => $this->urlGenerator->getAbsoluteURL('')]); + Util::addHeader('meta', ['property' => "og:type", 'content' => "website"]); + Util::addHeader('meta', ['property' => "og:image", 'content' => $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core','favicon-touch.png'))]); + return new TemplateResponse( $this->appName, 'login', $parameters, 'guest' ); |