Skip to content

Commit

Permalink
Issue DrupalRU#1234: Fix node urls, display of comments and dates
Browse files Browse the repository at this point in the history
  • Loading branch information
avakorin committed Nov 1, 2018
1 parent 06fd797 commit c68477b
Show file tree
Hide file tree
Showing 42 changed files with 113 additions and 3,204 deletions.
32 changes: 18 additions & 14 deletions profiles/drupalru/themes/druru/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 22 additions & 12 deletions profiles/drupalru/themes/druru/less/drupal/components/_tracker.less
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,31 @@
}

&:focus,
&:hover{
&:hover {
background-color: @little-darker;
color: @gray;
}
}

.node-item__comments-stat {
.node-item__comments {
color: inherit;
font-size: @font-size-small;
margin-left: @padding-large-horizontal;
margin-left: @padding-small-horizontal; // @todo Replace with proper variable
order: 3;
transition: color @transition-speed @transition-func;

&:before {
content: @fa-var-commenting-o;
font-family: FontAwesome;
content: @fa-var-comment-o;
margin-right: .3333em;

.is-updated & {
content: @fa-var-commenting;
.has-new-comments & {
color: @brand-success;
content: @fa-var-commenting;
}

.zero-comments & {
content: @fa-var-comment-o;
}
}
}
Expand All @@ -59,7 +64,7 @@
}

.node-item__title {
.text-emphasis-variant(@brand-primary);
color: @brand-primary;
font-size: @font-size-large;
font-weight: @headings-font-weight;
line-height: @headings-line-height;
Expand All @@ -74,6 +79,11 @@
order: 2;
transition: color @transition-speed @transition-func;
margin-left: auto;

.is-new &,
.is-updated & {
color: @brand-success;
}
}

.node-item__author {
Expand All @@ -93,15 +103,15 @@ aside.first {
padding: @padding-base-vertical @padding-large-horizontal; // @todo Replace with proper variable
}

.node-item__comments-stat {
.node-item__comments {
margin-left: auto;
}

.node-item__date {
display: none;
}

.node-item__title {
font-size: @font-size-base;
}

.node-item__date {
display: none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
* @ingroup views_templates
*/
?>
<span class="node-item__comments-stat">
<?php print $fields['comment_count']->content; ?>
<?php print $fields['new_comments']->content; ?>
</span>
<span class="node-item__comments"><?php print $fields['comment_count']->content; ?></span>
<span class="node-item__title"><?php print $fields['title']->content; ?></span>
<span class="node-item__author"><?php print $fields['name']->content; ?></span>
<span class="node-item__date"><?php print $fields['display_date']; ?></span>
<span class="node-item__date"><?php print $fields['created']->content; ?></span>
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
* @ingroup views_templates
*/
?>
<span class="node-item__comments-stat">
<?php print $fields['comment_count']->content; ?>
<?php print $fields['new_comments']->content; ?>
</span>
<span class="node-item__comments"><?php print $fields['comment_count']->content; ?></span>
<span class="node-item__title"><?php print $fields['title']->content; ?></span>
<span class="node-item__author"><?php print $fields['name']->content; ?></span>
<span class="node-item__date"><?php print $fields['display_date']; ?></span>
<span class="node-item__date"><?php print $fields['created']->content; ?></span>
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
* @ingroup views_templates
*/
?>
<span class="node-item__comments-stat">
<?php print $fields['comment_count']->content; ?>
<?php print $fields['new_comments']->content; ?>
</span>
<span class="node-item__comments"><?php print $fields['comment_count']->content; ?></span>
<span class="node-item__title"><?php print $fields['title']->content; ?></span>
<span class="node-item__author"><?php print $fields['name']->content; ?></span>
<span class="node-item__date"><?php print $fields['display_date']; ?></span>
<span class="node-item__date"><?php print $fields['created']->content; ?></span>
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
* @ingroup views_templates
*/
?>
<span class="node-item__comments-stat">
<?php print $fields['comment_count']->content; ?>
<?php print $fields['new_comments']->content; ?>
</span>
<span class="node-item__comments"><?php print $fields['comment_count']->content; ?></span>
<span class="node-item__title"><?php print $fields['title']->content; ?></span>
<span class="node-item__author"><?php print $fields['name']->content; ?></span>
<span class="node-item__date"><?php print $fields['display_date']; ?></span>
<span class="node-item__date"><?php print $fields['created']->content; ?></span>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
?>
<?php foreach ($rows as $id => $row): ?>
<a href="<?php print "/node/" . $result[$id]->nid; ?>" class="node-item<?php print $classes_array[$id]; ?>">
<a href="<?php print $node_hrefs[$id]; ?>"<?php if ($classes_array[$id]): ?> class="<?php print $classes_array[$id]; ?>"<?php endif; ?>>
<?php print $row; ?>
</a>
<?php endforeach; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
?>
<?php foreach ($rows as $id => $row): ?>
<a href="<?php print "/node/" . $result[$id]->nid; ?>" class="node-item<?php print $classes_array[$id]; ?>">
<a href="<?php print $node_hrefs[$id]; ?>"<?php if ($classes_array[$id]): ?> class="<?php print $classes_array[$id]; ?>"<?php endif; ?>>
<?php print $row; ?>
</a>
<?php endforeach; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
?>
<?php foreach ($rows as $id => $row): ?>
<a href="<?php print "/node/" . $result[$id]->nid; ?>" class="node-item<?php print $classes_array[$id]; ?>">
<a href="<?php print $node_hrefs[$id]; ?>"<?php if ($classes_array[$id]): ?> class="<?php print $classes_array[$id]; ?>"<?php endif; ?>>
<?php print $row; ?>
</a>
<?php endforeach; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
?>
<?php foreach ($rows as $id => $row): ?>
<a href="<?php print "/node/" . $result[$id]->nid; ?>" class="node-item<?php print $classes_array[$id]; ?>">
<a href="<?php print $node_hrefs[$id]; ?>"<?php if ($classes_array[$id]): ?> class="<?php print $classes_array[$id]; ?>"<?php endif; ?>>
<?php print $row; ?>
</a>
<?php endforeach; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function druru_preprocess_views_view_unformatted(&$vars) {
$view = $vars['view'];
$rows = $vars['rows'];
$result = $vars['view']->result;

// Populate $result to be used in view tpl files
$vars['result'] = $view->result;
$vars['classes_array'] = [];
$vars['classes'] = [];
$vars['node_hrefs'] = [];

if ($view->name == 'events_upcoming_block') {
foreach ($rows as $id => $row) {
Expand All @@ -22,7 +22,32 @@ function druru_preprocess_views_view_unformatted(&$vars) {

if (in_array($view->name, ['tracker', 'tracker_new', 'tracker_my', 'featured'])) {
foreach ($rows as $id => $row) {
$vars['classes_array'][$id] = $result[$id]->node_new_comments ? ' is-updated' : '';
$vars['classes'][$id][] = 'node-item';
$vars['node_hrefs'][$id] = '/node/' . $result[$id]->nid;

$node_mark = node_mark($result[$id]->nid, $result[$id]->node_changed);

if ($node_mark != MARK_NEW && $result[$id]->node_new_comments > 0) {
$vars['node_hrefs'][$id] .= '#new';
}

if ($node_mark == MARK_NEW) {
$vars['classes'][$id][] = 'is-new';
}

if ($node_mark == MARK_UPDATED) {
$vars['classes'][$id][] = 'is-updated';
}

if ($result[$id]->node_new_comments > 0) {
$vars['classes'][$id][] = 'has-new-comments';
}

if ($result[$id]->node_comment_statistics_comment_count == 0) {
$vars['classes'][$id][] = 'zero-comments';
}

$vars['classes_array'][$id] = isset($vars['classes'][$id]) ? implode(' ', $vars['classes'][$id]) : '';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,38 @@ function druru_preprocess_views_view_field(&$vars) {
}

if (in_array($view->name, ['tracker', 'tracker_new', 'tracker_my', 'featured'])) {
if ($field->field == 'new_comments') {
$vars['output'] = $row->node_new_comments ? '<span class="node-item__new-comments">+' . $row->node_new_comments . '</span>' : '';
if ($field->field == 'created') {
$timestamp = $row->node_created;

$today = new DateTime();
$today->setTime(0, 0, 0); // Reset time part, to prevent partial comparison

$match_date = new DateTime('@' . $timestamp);
$match_date->setTime(0, 0, 0); // Reset time part, to prevent partial comparison

$diff = $today->diff($match_date);
$diff_days = (integer)$diff->format('%R%a'); // Extract days count in interval
$diff_years = (integer)$diff->format('%R%y'); // Extract years count in interval

if ($diff_days == 0) {
$vars['output'] = format_date($row->node_created, 'current_day');
}
elseif ($diff_years == 0) {
$vars['output'] = format_date($row->node_created, 'current_year');
}
else {
$vars['output'] = format_date($row->node_created, 'years');
}
}

if ($field->field == 'comment_count') {
$node_mark = node_mark($row->nid, $row->node_changed);
if ($node_mark == MARK_NEW || $row->node_new_comments == $row->node_comment_statistics_comment_count) {
$vars['output'] = $row->node_new_comments ? '<span class="node-item__new-comments">' . $row->node_new_comments . '</span>' : 0;
}
else {
$vars['output'] = $row->node_comment_statistics_comment_count . ($row->node_new_comments ? ' / <span class="node-item__new-comments">' . $row->node_new_comments . '</span>' : '');
}
}
}

Expand Down

This file was deleted.

19 changes: 0 additions & 19 deletions sites/all/modules/github/altpager/.zenci.yml

This file was deleted.

Loading

0 comments on commit c68477b

Please sign in to comment.