Issue #1323830 by scor: Place title RDFa metadata inside entity HTML element.
parent
b2dc8aa53e
commit
1d2de46266
|
@ -231,20 +231,6 @@ class StandardProfileTest extends WebTestBase {
|
|||
// Test properties that are displayed in both teaser and full mode.
|
||||
$this->assertRdfaArticleProperties($graph, "Teaser");
|
||||
|
||||
// Title.
|
||||
// @todo Once the title data is output consistently between full and teaser
|
||||
// view modes, move this to _testCommonNodeProperties().
|
||||
$title = $this->article->get('title')->offsetGet(0)->get('value')->getValue();
|
||||
$expected_value = array(
|
||||
'type' => 'literal',
|
||||
// The teaser title parses with additional whitespace.
|
||||
'value' => "
|
||||
$title
|
||||
",
|
||||
'lang' => 'en',
|
||||
);
|
||||
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/name', $expected_value), "Teaser title was found (schema:name).");
|
||||
|
||||
// @todo Once the image points to the original instead of the processed
|
||||
// image, move this to testArticleProperties().
|
||||
$image_file = file_load($this->article->get('field_image')->offsetGet(0)->get('target_id')->getValue());
|
||||
|
@ -279,16 +265,6 @@ class StandardProfileTest extends WebTestBase {
|
|||
// Test the comment properties displayed on articles.
|
||||
$this->assertRdfaNodeCommentProperties($graph);
|
||||
|
||||
// Title.
|
||||
// @todo Once the title data is output consistently between full and teaser
|
||||
// view modes, move this to _testCommonNodeProperties().
|
||||
$expected_value = array(
|
||||
'type' => 'literal',
|
||||
'value' => $this->article->get('title')->offsetGet(0)->get('value')->getValue(),
|
||||
'lang' => 'en',
|
||||
);
|
||||
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/name', $expected_value), "Article title was found (schema:name).");
|
||||
|
||||
// @todo Once the image points to the original instead of the processed
|
||||
// image, move this to testArticleProperties().
|
||||
$expected_value = array(
|
||||
|
@ -320,16 +296,6 @@ class StandardProfileTest extends WebTestBase {
|
|||
|
||||
// Test the properties that are common between pages and articles.
|
||||
$this->assertRdfaCommonNodeProperties($graph, $this->page, "Page");
|
||||
|
||||
// Title.
|
||||
// @todo Once the title data is output consistently between full and teaser
|
||||
// view modes, move this to _testCommonNodeProperties().
|
||||
$expected_value = array(
|
||||
'type' => 'literal',
|
||||
'value' => $this->page->get('title')->offsetGet(0)->get('value')->getValue(),
|
||||
'lang' => 'en',
|
||||
);
|
||||
$this->assertTrue($graph->hasProperty($this->pageUri, 'http://schema.org/name', $expected_value), "Page title was found (schema:name).");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -394,6 +360,14 @@ class StandardProfileTest extends WebTestBase {
|
|||
$uri_info = $node->uri();
|
||||
$uri = url($uri_info['path'], array('absolute' => TRUE));
|
||||
|
||||
// Title.
|
||||
$expected_value = array(
|
||||
'type' => 'literal',
|
||||
'value' => $node->get('title')->offsetGet(0)->get('value')->getValue(),
|
||||
'lang' => 'en',
|
||||
);
|
||||
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/name', $expected_value), "$message_prefix title was found (schema:name).");
|
||||
|
||||
// Created date.
|
||||
$expected_value = array(
|
||||
'type' => 'literal',
|
||||
|
|
|
@ -254,28 +254,17 @@ function rdf_preprocess_node(&$variables) {
|
|||
$variables['attributes']['about'] = empty($variables['node_url']) ? NULL: $variables['node_url'];
|
||||
$variables['attributes']['typeof'] = empty($bundle_mapping['types']) ? NULL : $bundle_mapping['types'];
|
||||
|
||||
// Adds RDFa markup to the title of the node. Because the RDFa markup is
|
||||
// added to the <h2> tag which might contain HTML code, we specify an empty
|
||||
// datatype to ensure the value of the title read by the RDFa parsers is a
|
||||
// literal.
|
||||
// Adds RDFa markup for the node title as metadata because wrapping the title
|
||||
// with markup is not reliable and the title output is different depdending on
|
||||
// the view mode (e.g. full vs. teaser).
|
||||
$title_mapping = $mapping->getPreparedFieldMapping('title');
|
||||
$variables['title_attributes']['property'] = empty($title_mapping['properties']) ? NULL : $title_mapping['properties'];
|
||||
$variables['title_attributes']['datatype'] = '';
|
||||
|
||||
// In full node mode, the title is not displayed by node.html.twig so it is
|
||||
// added in the <head> tag of the HTML page.
|
||||
if ($variables['page']) {
|
||||
$element = array(
|
||||
'#tag' => 'meta',
|
||||
'#attributes' => array(
|
||||
'content' => $variables['label'],
|
||||
'about' => $variables['node_url'],
|
||||
),
|
||||
if ($title_mapping) {
|
||||
$title_attributes['property'] = empty($title_mapping['properties']) ? NULL : $title_mapping['properties'];
|
||||
$title_attributes['content'] = $variables['label'];
|
||||
$variables['title_suffix']['rdf_meta_title'] = array(
|
||||
'#theme' => 'rdf_metadata',
|
||||
'#metadata' => array($title_attributes),
|
||||
);
|
||||
if (!empty($title_mapping['properties'])) {
|
||||
$element['#attributes']['property'] = $title_mapping['properties'];
|
||||
}
|
||||
drupal_add_html_head($element, 'rdf_node_title');
|
||||
}
|
||||
|
||||
// Adds RDFa markup for the relation between the node and its author.
|
||||
|
|
Loading…
Reference in New Issue