Merge branch 'in-reply-to-uf2' into 'master'

Add direct link to parent notice

This is partly for usability, and partly to make Linkbacks for replies work (when the plugin is enabled).

See merge request !37
This commit is contained in:
mmn 2015-11-06 12:39:02 +00:00
commit dbdac9cfbe
2 changed files with 32 additions and 11 deletions

View File

@ -64,6 +64,7 @@ class NoticeListItem extends Widget
protected $options = true; protected $options = true;
protected $maxchars = 0; // if <= 0 it means use full posts protected $maxchars = 0; // if <= 0 it means use full posts
protected $item_tag = 'li'; protected $item_tag = 'li';
protected $pa = null;
/** /**
* constructor * constructor
@ -150,7 +151,13 @@ class NoticeListItem extends Widget
$this->elementStart('section', array('class'=>'notice-headers')); $this->elementStart('section', array('class'=>'notice-headers'));
$this->showNoticeTitle(); $this->showNoticeTitle();
$this->showAuthor(); $this->showAuthor();
if (!empty($this->notice->reply_to) || count($this->getProfileAddressees()) > 0) {
$this->elementStart('div', array('class' => 'parents'));
if (!empty($this->notice->reply_to)) { $this->showParent(); }
if ($this->addressees) { $this->showAddressees(); } if ($this->addressees) { $this->showAddressees(); }
$this->elementEnd('div');
}
$this->elementEnd('section'); $this->elementEnd('section');
} }
@ -248,6 +255,19 @@ class NoticeListItem extends Widget
} }
} }
function showParent()
{
$this->out->element(
'a',
array(
'href' => $this->notice->getParent()->getUrl(),
'class' => 'u-in-reply-to',
'rel' => 'in-reply-to'
),
'in reply to'
);
}
function showAddressees() function showAddressees()
{ {
$pa = $this->getProfileAddressees(); $pa = $this->getProfileAddressees();
@ -268,19 +288,20 @@ class NoticeListItem extends Widget
function getProfileAddressees() function getProfileAddressees()
{ {
$pa = array(); if($this->pa) { return $this->pa; }
$this->pa = array();
$attentions = $this->getReplyProfiles(); $attentions = $this->getReplyProfiles();
foreach ($attentions as $attn) { foreach ($attentions as $attn) {
$class = $attn->isGroup() ? 'group' : 'account'; $class = $attn->isGroup() ? 'group' : 'account';
$pa[] = array('href' => $attn->profileurl, $this->pa[] = array('href' => $attn->profileurl,
'title' => $attn->getNickname(), 'title' => $attn->getNickname(),
'class' => "addressee {$class}", 'class' => "addressee {$class}",
'text' => $attn->getStreamName()); 'text' => $attn->getStreamName());
} }
return $pa; return $this->pa;
} }
function getReplyProfiles() function getReplyProfiles()

View File

@ -648,11 +648,11 @@ address .poweredby {
width:100%; width:100%;
} }
.notice .p-author { .notice .parents {
margin-right: 8px; display: inline;
} }
.notice .addressees::before { .notice .parents::before {
content: '\25B8 '; content: '\25B8 ';
} }
.notice .addressees, .notice .addressees li { .notice .addressees, .notice .addressees li {