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.
|
// Test properties that are displayed in both teaser and full mode.
|
||||||
$this->assertRdfaArticleProperties($graph, "Teaser");
|
$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
|
// @todo Once the image points to the original instead of the processed
|
||||||
// image, move this to testArticleProperties().
|
// image, move this to testArticleProperties().
|
||||||
$image_file = file_load($this->article->get('field_image')->offsetGet(0)->get('target_id')->getValue());
|
$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.
|
// Test the comment properties displayed on articles.
|
||||||
$this->assertRdfaNodeCommentProperties($graph);
|
$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
|
// @todo Once the image points to the original instead of the processed
|
||||||
// image, move this to testArticleProperties().
|
// image, move this to testArticleProperties().
|
||||||
$expected_value = array(
|
$expected_value = array(
|
||||||
|
@ -320,16 +296,6 @@ class StandardProfileTest extends WebTestBase {
|
||||||
|
|
||||||
// Test the properties that are common between pages and articles.
|
// Test the properties that are common between pages and articles.
|
||||||
$this->assertRdfaCommonNodeProperties($graph, $this->page, "Page");
|
$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_info = $node->uri();
|
||||||
$uri = url($uri_info['path'], array('absolute' => TRUE));
|
$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.
|
// Created date.
|
||||||
$expected_value = array(
|
$expected_value = array(
|
||||||
'type' => 'literal',
|
'type' => 'literal',
|
||||||
|
|
|
@ -254,28 +254,17 @@ function rdf_preprocess_node(&$variables) {
|
||||||
$variables['attributes']['about'] = empty($variables['node_url']) ? NULL: $variables['node_url'];
|
$variables['attributes']['about'] = empty($variables['node_url']) ? NULL: $variables['node_url'];
|
||||||
$variables['attributes']['typeof'] = empty($bundle_mapping['types']) ? NULL : $bundle_mapping['types'];
|
$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
|
// Adds RDFa markup for the node title as metadata because wrapping the title
|
||||||
// added to the <h2> tag which might contain HTML code, we specify an empty
|
// with markup is not reliable and the title output is different depdending on
|
||||||
// datatype to ensure the value of the title read by the RDFa parsers is a
|
// the view mode (e.g. full vs. teaser).
|
||||||
// literal.
|
|
||||||
$title_mapping = $mapping->getPreparedFieldMapping('title');
|
$title_mapping = $mapping->getPreparedFieldMapping('title');
|
||||||
$variables['title_attributes']['property'] = empty($title_mapping['properties']) ? NULL : $title_mapping['properties'];
|
if ($title_mapping) {
|
||||||
$variables['title_attributes']['datatype'] = '';
|
$title_attributes['property'] = empty($title_mapping['properties']) ? NULL : $title_mapping['properties'];
|
||||||
|
$title_attributes['content'] = $variables['label'];
|
||||||
// In full node mode, the title is not displayed by node.html.twig so it is
|
$variables['title_suffix']['rdf_meta_title'] = array(
|
||||||
// added in the <head> tag of the HTML page.
|
'#theme' => 'rdf_metadata',
|
||||||
if ($variables['page']) {
|
'#metadata' => array($title_attributes),
|
||||||
$element = array(
|
|
||||||
'#tag' => 'meta',
|
|
||||||
'#attributes' => array(
|
|
||||||
'content' => $variables['label'],
|
|
||||||
'about' => $variables['node_url'],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
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.
|
// Adds RDFa markup for the relation between the node and its author.
|
||||||
|
|
Loading…
Reference in New Issue