Add more attributes in app.blade.php and add a setDescription method. (#1105)

* Added `language` and `direction` properties to WebAppView

* Use properties `language` and `direction` in app.blade.php

* Added WebAppView::setDescription to set the meta description

* Whoops! Changed "ltr" to \'ltr\'. Thanks StyleCI :)

* Removed unnecessary `= null` for

* Changed `.. ? .. : ..` to `.. ?: ..`. Useful thing right there ;)
This commit is contained in:
David Sevilla Martín 2017-02-03 17:09:22 -05:00 committed by Franz Liedke
parent 82c84caf5a
commit 61da58cd1b
2 changed files with 48 additions and 2 deletions

View File

@ -41,6 +41,20 @@ class WebAppView
*/
protected $description;
/**
* The language of the document, displayed as the value of the attribute `dir` in the <html> tag.
*
* @var null|string
*/
protected $language;
/**
* The text direction of the document, displayed as the value of the attribute `dir` in the <html> tag.
*
* @var null|string
*/
protected $direction;
/**
* The path to the client layout view to display.
*
@ -188,6 +202,36 @@ class WebAppView
$this->title = $title;
}
/**
* The description of the document, displayed in a <meta> tag.
*
* @param null|string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* The language of the document, displayed as the value of the attribute `dir` in the <html> tag.
*
* @param null|string $language
*/
public function setLanguage($language)
{
$this->language = $language;
}
/**
* The language of the document, displayed as the value of the attribute `dir` in the <html> tag.
*
* @param null|string $direction
*/
public function setDirection($direction)
{
$this->direction = $direction;
}
/**
* Set the SEO content of the page, to be displayed in <noscript> tags.
*
@ -283,7 +327,9 @@ class WebAppView
$view = $this->view->file(__DIR__.'/../../../views/app.blade.php');
$view->title = $this->buildTitle(array_get($forum, 'data.attributes.title'));
$view->description = $this->description;
$view->description = $this->description ?: array_get($forum, 'data.attributes.description');
$view->language = $this->language ?: $this->locales->getLocale();
$view->direction = $this->direction ?: 'ltr';
$view->modules = $this->modules;
$view->payload = $this->buildPayload($request, $forum);

View File

@ -1,5 +1,5 @@
<!doctype html>
<html>
<html dir="{{ $direction }}" lang="{{ $language }}">
<head>
<meta charset="utf-8">
<title>{{ $title }}</title>