Merge pull request #1519 from nextcloud/better-comments-in-activity-sidebar

Better comments in activity sidebar
This commit is contained in:
Morris Jobke 2016-10-05 23:56:10 +02:00 committed by GitHub
commit fe2116ecf7
4 changed files with 12 additions and 17 deletions

View file

@ -32,6 +32,7 @@ $eventDispatcher->addListener(
\OCP\Util::addScript('comments', 'commentsummarymodel');
\OCP\Util::addScript('comments', 'commentstabview');
\OCP\Util::addScript('comments', 'filesplugin');
\OCP\Util::addScript('comments', 'activitytabviewplugin');
\OCP\Util::addStyle('comments', 'comments');
}
);

View file

@ -59,35 +59,39 @@
line-height: 32px;
}
#activityTabView li.comment.collapsed .activitymessage,
#commentsTabView .comment.collapsed .message {
white-space: pre-wrap;
}
#activityTabView li.comment.collapsed .activitymessage,
#commentsTabView .comment.collapsed .message {
max-height: 70px;
overflow: hidden;
}
#activityTabView li.comment .message-overlay,
#commentsTabView .comment .message-overlay {
display: none;
}
#activityTabView li.comment.collapsed .message-overlay,
#commentsTabView .comment.collapsed .message-overlay {
display: block;
position: absolute;
position: absolute;
z-index: 2;
height: 50px;
pointer-events: none;
height: 50px;
pointer-events: none;
left: 0;
right: 0;
bottom: 0;
bottom: 0;
background: -moz-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
background: -webkit-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
background: -o-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
background: -ms-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#00FFFFFF', endColorstr='#FFFFFFFF');
background-repeat: no-repeat;
background-repeat: no-repeat;
}
#commentsTabView .authorRow>div {

Binary file not shown.

View file

@ -159,7 +159,7 @@ class Extension implements IExtension {
}
return (string) $l->t('%1$s commented', $params);
case self::ADD_COMMENT_MESSAGE:
return $this->convertParameterToComment($params[0], 120);
return $this->convertParameterToComment($params[0]);
}
return false;
@ -196,7 +196,6 @@ class Extension implements IExtension {
try {
return strip_tags($user) === $this->activityManager->getCurrentUserId();
} catch (\UnexpectedValueException $e) {
// FIXME this is awkward, but we have no access to the current user in emails
return false;
}
}
@ -301,21 +300,12 @@ class Extension implements IExtension {
* @param string $parameter
* @return string
*/
protected function convertParameterToComment($parameter, $maxLength = 0) {
protected function convertParameterToComment($parameter) {
if (preg_match('/^\<parameter\>(\d*)\<\/parameter\>$/', $parameter, $matches)) {
try {
$comment = $this->commentsManager->get((int) $matches[1]);
$message = $comment->getMessage();
$message = str_replace("\n", '<br />', str_replace(['<', '>'], ['&lt;', '&gt;'], $message));
if ($maxLength && isset($message[$maxLength + 20])) {
$findSpace = strpos($message, ' ', $maxLength);
if ($findSpace !== false && $findSpace < $maxLength + 20) {
return substr($message, 0, $findSpace) . '…';
}
return substr($message, 0, $maxLength + 20) . '…';
}
return $message;
} catch (NotFoundException $e) {
return '';