commit 6d3e93f3b705cf095f2e0d61ac2021f0ce4449f1 Author: Joel Pittet Date: Sun Apr 27 12:14:19 2014 -0700 move submitted to the template and fix margin around submitted to match p diff --git a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php index 0282c93..7cfaa7e 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php @@ -45,7 +45,7 @@ function testPagePostInfo() { // Check that the post information is displayed. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); - $elements = $this->xpath('//*[contains(@class, :class)]', array(':class' => 'node__meta')); + $elements = $this->xpath('//div[contains(@class, :class)]', array(':class' => 'node__submitted')); $this->assertEqual(count($elements), 1, 'Post information is displayed.'); $node->delete(); @@ -61,7 +61,7 @@ function testPagePostInfo() { $this->drupalPostForm('node/add/page', $edit, t('Save')); // Check that the post information is displayed. - $elements = $this->xpath('//*[contains(@class, :class)]', array(':class' => 'node__meta')); + $elements = $this->xpath('//div[contains(@class, :class)]', array(':class' => 'node__submitted')); $this->assertEqual(count($elements), 0, 'Post information is not displayed.'); } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 764abf4..c094b91 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -645,7 +645,7 @@ function template_preprocess_node(&$variables) { '#account' => $node->getOwner(), '#link_options' => array('attributes' => array('rel' => 'author')), ); - $variables['name'] = drupal_render($username); + $variables['author_name'] = drupal_render($username); $variables['url'] = $node->url('canonical', array( 'language' => $node->language(), @@ -666,20 +666,14 @@ function template_preprocess_node(&$variables) { // Display submitted by default. $variables['display_submitted'] = $node_type_config->isNew() || $node_type_config->get('settings.node.submitted'); if ($variables['display_submitted']) { - $variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date'])); + // Used by RDF to add attributes around the author and date submitted. + $variables['author_attributes'] = new Attribute(); if (theme_get_setting('features.node_user_picture')) { // To change user picture settings (e.g. image style), edit the 'compact' // view mode on the User entity. Note that the 'compact' view mode might // not be configured, so remember to always check the theme setting first. - $variables['author'] = user_view($node->getOwner(), 'compact'); + $variables['author_picture'] = user_view($node->getOwner(), 'compact'); } - else { - $variables['author'] = array(); - } - } - else { - $variables['submitted'] = ''; - $variables['author'] = ''; } // Add article ARIA role. diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index fb0e8e5..99f1d34 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -20,16 +20,14 @@ * or print a subset such as {{ content.field_example }}. Use * {{ content|without('field_example') %} to temporarily suppress the printing * of a given child element. - * - author: The node author user entity, rendered using the "compact" view - * mode. + * - author_picture: The node author user entity, rendered using the "compact" + * view mode. * - date: Formatted creation date. Preprocess functions can reformat it by * calling format_date() with the desired parameters on * $variables['created']. - * - name: Themed username of node author output from theme_username(). + * - author_name: Themed username of node author output from theme_username(). * - url: Direct URL of the current node. * - display_submitted: Whether submission information should be displayed. - * - submitted: Submission information created from name and date during - * template_preprocess_node(). * - attributes: HTML attributes for the containing element. * The attributes.class element may contain one or more of the following * classes: @@ -91,7 +89,10 @@ {% if display_submitted %} {% endif %} diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 0d7ae2c..c17dbb7 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -296,20 +296,19 @@ function rdf_preprocess_node(&$variables) { // Adds RDFa markup for the relation between the node and its author. $author_mapping = $mapping->getPreparedFieldMapping('uid'); - if (!empty($author_mapping['properties']) && $variables['submitted']) { - $author_attributes = array('rel' => $author_mapping['properties']); - $variables['submitted'] = '' . $variables['submitted'] . ''; + if (!empty($author_mapping['properties']) && $variables['author_attributes']) { + $variables['author_attributes']['rel'] = $author_mapping['properties']; } // Adds RDFa markup for the date. $created_mapping = $mapping->getPreparedFieldMapping('created'); - if (!empty($created_mapping) && $variables['submitted']) { + if (!empty($created_mapping) && $variables['author_attributes']) { $date_attributes = rdf_rdfa_attributes($created_mapping, $variables['node']->getCreatedTime()); $rdf_metadata = array( '#theme' => 'rdf_metadata', '#metadata' => array($date_attributes), ); - $variables['submitted'] .= drupal_render($rdf_metadata); + $variables['metadata'] = drupal_render($rdf_metadata); } // Adds RDFa markup annotating the number of comments a node has. diff --git a/core/themes/bartik/templates/node.html.twig b/core/themes/bartik/templates/node.html.twig index 42e33bf..d6373cb 100644 --- a/core/themes/bartik/templates/node.html.twig +++ b/core/themes/bartik/templates/node.html.twig @@ -20,15 +20,13 @@ * or print a subset such as {{ content.field_example }}. Use * {{ content|without('field_example') }} to exclude the printing of a * given child element. - * - author: The author of this node. + * - author_picture: The author of this node. * - date: Formatted creation date. Preprocess functions can reformat it by * calling format_date() with the desired parameters on * $variables['created']. - * - name: Themed username of node author output from theme_username(). + * - author_name: Themed username of node author output from theme_username(). * - url: Direct URL of the current node. * - display_submitted: Whether submission information should be displayed. - * - submitted: Submission information created from name and date during - * template_preprocess_node(). * - attributes: HTML attributes for the containing element. * The attributes.class element may contain one or more of the following * classes: @@ -84,8 +82,11 @@ {% if display_submitted %}
- {{ author }} - {{ submitted }} + {{ author_picture }} + + {% trans %}Submitted by {{ author_name|passthrough }} on {{ date }}{% endtrans %} + {{ metadata }} +
{% endif %} diff --git a/core/themes/seven/style.css b/core/themes/seven/style.css index 7bd88fd..c5db28e 100644 --- a/core/themes/seven/style.css +++ b/core/themes/seven/style.css @@ -515,9 +515,12 @@ ul.admin-list { .admin-list li a:active .label { text-decoration: underline; } -.node__meta { +div.submitted { color: #898989; } +.node__submitted { + margin: 1em 0; +} /** * Pagination.