From b8cf2fb58b7114cf20e73554c9c73908a1e8a6a9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 26 Apr 2016 12:46:25 +0200 Subject: [PATCH 1/7] Do not shorten comments in the activity sidebar Signed-off-by: Lukas Reschke --- apps/comments/lib/Activity/Extension.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/apps/comments/lib/Activity/Extension.php b/apps/comments/lib/Activity/Extension.php index 0a7503c1915..2bb9d6428e2 100644 --- a/apps/comments/lib/Activity/Extension.php +++ b/apps/comments/lib/Activity/Extension.php @@ -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; @@ -300,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('/^\(\d*)\<\/parameter\>$/', $parameter, $matches)) { try { $comment = $this->commentsManager->get((int) $matches[1]); $message = $comment->getMessage(); $message = str_replace("\n", '
', str_replace(['<', '>'], ['<', '>'], $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 ''; From fe6c9f7f47681a06409fa2efae2a57044b7fef29 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 26 Apr 2016 12:47:33 +0200 Subject: [PATCH 2/7] Remove resolved FIXME Signed-off-by: Lukas Reschke --- apps/comments/lib/Activity/Extension.php | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/comments/lib/Activity/Extension.php b/apps/comments/lib/Activity/Extension.php index 2bb9d6428e2..3bdb267358b 100644 --- a/apps/comments/lib/Activity/Extension.php +++ b/apps/comments/lib/Activity/Extension.php @@ -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; } } From 724cd50e523f10a9b732c72dc77306a75a0c5e0c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 26 Apr 2016 12:47:57 +0200 Subject: [PATCH 3/7] Register a ActivityTabView plugin Signed-off-by: Lukas Reschke --- apps/comments/appinfo/app.php | 1 + apps/comments/js/activitytabviewplugin.js | 57 +++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 apps/comments/js/activitytabviewplugin.js diff --git a/apps/comments/appinfo/app.php b/apps/comments/appinfo/app.php index 00085cf9148..df41bdfa32d 100644 --- a/apps/comments/appinfo/app.php +++ b/apps/comments/appinfo/app.php @@ -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'); } ); diff --git a/apps/comments/js/activitytabviewplugin.js b/apps/comments/js/activitytabviewplugin.js new file mode 100644 index 00000000000..a087bf1279f --- /dev/null +++ b/apps/comments/js/activitytabviewplugin.js @@ -0,0 +1,57 @@ +/* + * @author Joas Schilling + * Copyright (c) 2016 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + */ + +(function() { + OCA.Comments.ActivityTabViewPlugin = { + + /** + * Prepare activity for display + * + * @param {OCA.Activity.ActivityModel} model for this activity + * @param {jQuery} $el jQuery handle for this activity + * @param {string} view The view that displayes this activity + */ + prepareModelForDisplay: function (model, $el, view) { + if (model.get('app') !== 'comments' || model.get('type') !== 'comments') { + return; + } + + if (view === 'ActivityTabView') { + $el.addClass('comment'); + if (this._isLong(model.get('message_prepared'))) { + $el.addClass('collapsed'); + var $overlay = $('
').addClass('message-overlay'); + $el.find('.activitymessage').after($overlay); + $el.on('click', this._onClickCollapsedComment); + } + } + }, + + _onClickCollapsedComment: function(ev) { + var $row = $(ev.target); + if (!$row.is('.comment')) { + $row = $row.closest('.comment'); + } + $row.removeClass('collapsed'); + }, + + /** + * Returns whether the given message is long and needs + * collapsing + */ + _isLong: function(message) { + return message.length > 250 || (message.match(/\n/g) || []).length > 1; + } + }; + + +})(); + +OC.Plugins.register('OCA.Activity.Plugins', OCA.Comments.ActivityTabViewPlugin); From bd0c9489f683b9638842cb7ab197c0f6438df917 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 26 Apr 2016 12:48:22 +0200 Subject: [PATCH 4/7] Make sure the CSS rules apply to the activityTabView as well Signed-off-by: Lukas Reschke --- apps/comments/css/comments.css | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index 7f64f1cf7db..103564c5faf 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -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 { From ed70d4a2dcf5218fe48b22d31e4ceb2968a46ef7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 26 Apr 2016 15:18:55 +0200 Subject: [PATCH 5/7] Mark the methods as copied Signed-off-by: Lukas Reschke --- apps/comments/js/activitytabviewplugin.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/comments/js/activitytabviewplugin.js b/apps/comments/js/activitytabviewplugin.js index a087bf1279f..6ea5a3610ef 100644 --- a/apps/comments/js/activitytabviewplugin.js +++ b/apps/comments/js/activitytabviewplugin.js @@ -34,6 +34,9 @@ } }, + /* + * Copy of CommentsTabView._onClickComment() + */ _onClickCollapsedComment: function(ev) { var $row = $(ev.target); if (!$row.is('.comment')) { @@ -42,9 +45,8 @@ $row.removeClass('collapsed'); }, - /** - * Returns whether the given message is long and needs - * collapsing + /* + * Copy of CommentsTabView._isLong() */ _isLong: function(message) { return message.length > 250 || (message.match(/\n/g) || []).length > 1; From dba72a48cd8a2105540669ef380ec0537e656153 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 12 Sep 2016 11:44:38 +0200 Subject: [PATCH 6/7] Fix activity rendering plugin name Signed-off-by: Lukas Reschke --- apps/comments/js/activitytabviewplugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/comments/js/activitytabviewplugin.js b/apps/comments/js/activitytabviewplugin.js index 6ea5a3610ef..321e3392e35 100644 --- a/apps/comments/js/activitytabviewplugin.js +++ b/apps/comments/js/activitytabviewplugin.js @@ -56,4 +56,4 @@ })(); -OC.Plugins.register('OCA.Activity.Plugins', OCA.Comments.ActivityTabViewPlugin); +OC.Plugins.register('OCA.Activity.RenderingPlugins', OCA.Comments.ActivityTabViewPlugin); From 43265befac637d09c71e4f639c317e423e3bbfd6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 5 Oct 2016 14:33:54 +0200 Subject: [PATCH 7/7] Update file header Signed-off-by: Joas Schilling --- apps/comments/js/activitytabviewplugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/comments/js/activitytabviewplugin.js b/apps/comments/js/activitytabviewplugin.js index 321e3392e35..ca3253bd137 100644 --- a/apps/comments/js/activitytabviewplugin.js +++ b/apps/comments/js/activitytabviewplugin.js @@ -1,5 +1,5 @@ /* - * @author Joas Schilling + * @author Joas Schilling * Copyright (c) 2016 * * This file is licensed under the Affero General Public License version 3