diff options
author | David Rothstein <drothstein@gmail.com> | 2014-11-01 12:49:00 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2014-11-01 12:49:00 -0400 |
commit | 3a4f085dfbf48a12d364b3aa80d0ecd336eb23e9 (patch) | |
tree | 874ad2e61b07f447b71af91614cd99e82839d18f | |
parent | 4d5a0ad301544ad3ba4dcc6d7f29c513e29d884e (diff) | |
download | brdo-3a4f085dfbf48a12d364b3aa80d0ecd336eb23e9.tar.gz brdo-3a4f085dfbf48a12d364b3aa80d0ecd336eb23e9.tar.bz2 |
Issue #2130673 by lokapujya, cwells | scor: Place number of comments metadata inside node template.
-rw-r--r-- | CHANGELOG.txt | 6 | ||||
-rw-r--r-- | modules/rdf/rdf.module | 35 | ||||
-rw-r--r-- | modules/rdf/rdf.test | 8 |
3 files changed, 16 insertions, 33 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0d475bc8d..46096d302 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,9 +1,9 @@ Drupal 7.33, xxxx-xx-xx (development version) ----------------------- -- Changed the RDF module to consistently output RDF metadata for nodes near - where the node is rendered in the HTML (minor markup and data structure - change). +- Changed the RDF module to consistently output RDF metadata for nodes and + comments near where the node is rendered in the HTML (minor markup and data + structure change). - Added an HTML class to RDFa metatags throughout Drupal to prevent them from accidentally affecting the site appearance (minor markup change). - Fixed a bug in the Unicode requirements check which prevented installing diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module index ce3f97bcf..88665812f 100644 --- a/modules/rdf/rdf.module +++ b/modules/rdf/rdf.module @@ -501,35 +501,20 @@ function rdf_preprocess_node(&$variables) { } // Adds RDFa markup annotating the number of comments a node has. - if (isset($variables['node']->comment_count) && !empty($variables['node']->rdf_mapping['comment_count']['predicates'])) { - // Annotates the 'x comments' link in teaser view. - if (isset($variables['content']['links']['comment']['#links']['comment-comments'])) { - $comment_count_attributes['property'] = $variables['node']->rdf_mapping['comment_count']['predicates']; - $comment_count_attributes['content'] = $variables['node']->comment_count; - $comment_count_attributes['datatype'] = $variables['node']->rdf_mapping['comment_count']['datatype']; - // According to RDFa parsing rule number 4, a new subject URI is created - // from the href attribute if no rel/rev attribute is present. To get the - // original node URL from the about attribute of the parent container we - // set an empty rel attribute which triggers rule number 5. See - // http://www.w3.org/TR/rdfa-syntax/#sec_5.5. - $comment_count_attributes['rel'] = ''; - $variables['content']['links']['comment']['#links']['comment-comments']['attributes'] += $comment_count_attributes; - } - // In full node view, the number of comments is not displayed by - // node.tpl.php so it is expressed in RDFa in the <head> tag of the HTML - // page. - if ($variables['page'] && user_access('access comments')) { - $element = array( - '#tag' => 'meta', - '#attributes' => array( - 'about' => $variables['node_url'], + if (isset($variables['node']->comment_count) && + !empty($variables['node']->rdf_mapping['comment_count']['predicates']) && + user_access('access comments')) { + // Adds RDFa markup for the comment count near the node title as metadata. + $variables['title_suffix']['rdf_meta_comment_count'] = array( + '#theme' => 'rdf_metadata', + '#metadata' => array( + array( 'property' => $variables['node']->rdf_mapping['comment_count']['predicates'], 'content' => $variables['node']->comment_count, 'datatype' => $variables['node']->rdf_mapping['comment_count']['datatype'], ), - ); - drupal_add_html_head($element, 'rdf_node_comment_count'); - } + ), + ); } } diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test index 4eeef4620..22c41f1f8 100644 --- a/modules/rdf/rdf.test +++ b/modules/rdf/rdf.test @@ -461,15 +461,13 @@ class RdfCommentAttributesTestCase extends CommentHelperCase { // Tests number of comments in teaser view. $this->drupalGet('node'); - $comment_count_teaser = $this->xpath('//div[contains(@typeof, "sioc:Item")]//li[contains(@class, "comment-comments")]/a[contains(@property, "sioc:num_replies") and contains(@content, "2") and @datatype="xsd:integer"]'); + $node_url = url('node/' . $this->node1->nid); + $comment_count_teaser = $this->xpath('//div[@about=:node-url]/span[@property="sioc:num_replies" and @content="2" and @datatype="xsd:integer"]', array(':node-url' => $node_url)); $this->assertTrue(!empty($comment_count_teaser), 'RDFa markup for the number of comments found on teaser view.'); - $comment_count_link = $this->xpath('//div[@about=:url]//a[contains(@property, "sioc:num_replies") and @rel=""]', array(':url' => url("node/{$this->node1->nid}"))); - $this->assertTrue(!empty($comment_count_link), 'Empty rel attribute found in comment count link.'); // Tests number of comments in full node view. $this->drupalGet('node/' . $this->node1->nid); - $node_url = url('node/' . $this->node1->nid); - $comment_count_teaser = $this->xpath('/html/head/meta[@about=:node-url and @property="sioc:num_replies" and @content="2" and @datatype="xsd:integer"]', array(':node-url' => $node_url)); + $comment_count_teaser = $this->xpath('//div[@about=:node-url]/span[@property="sioc:num_replies" and @content="2" and @datatype="xsd:integer"]', array(':node-url' => $node_url)); $this->assertTrue(!empty($comment_count_teaser), 'RDFa markup for the number of comments found on full node view.'); } |