Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
1d2de462
Commit
1d2de462
authored
11 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1323830
by scor: Place title RDFa metadata inside entity HTML element.
parent
b2dc8aa5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php
+8
-34
8 additions, 34 deletions
.../modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php
core/modules/rdf/rdf.module
+9
-20
9 additions, 20 deletions
core/modules/rdf/rdf.module
with
17 additions
and
54 deletions
core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php
+
8
−
34
View file @
1d2de462
...
...
@@ -231,20 +231,6 @@ protected function doFrontPageRdfaTests() {
// 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 @@ protected function doArticleRdfaTests() {
// 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 @@ protected function doPageRdfaTests() {
// 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 @@ protected function assertRdfaCommonNodeProperties($graph, NodeInterface $node, $
$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'
,
...
...
This diff is collapsed.
Click to expand it.
core/modules/rdf/rdf.module
+
9
−
20
View file @
1d2de462
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment