Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/comments/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "js/vendor"
}
3 changes: 3 additions & 0 deletions apps/comments/.l10nignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# compiled vue templates
src/templates.js
js/
4 changes: 3 additions & 1 deletion apps/comments/lib/Listener/LoadAdditionalScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function handle(Event $event): void {
return;
}

// Adding init script for file list inline actions
// TODO: make sure to only include the sidebar script when
// we properly split it between files list and sidebar
Util::addScript(Application::APP_ID, 'comments');
Util::addInitScript(Application::APP_ID, 'init');
}
}
5 changes: 4 additions & 1 deletion apps/comments/lib/Listener/LoadSidebarScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public function handle(Event $event): void {
$this->commentsManager->load();

$this->initialState->provideInitialState('activityEnabled', $this->appManager->isEnabledForUser('activity'));
// Add comments sidebar tab script

// TODO: make sure to only include the sidebar script when
// we properly split it between files list and sidebar
Util::addScript(Application::APP_ID, 'comments');
Util::addScript(Application::APP_ID, 'comments-tab', 'files');
}
}
73 changes: 73 additions & 0 deletions apps/comments/src/activitytabviewplugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* Copyright (c) 2016
*
* @author Joas Schilling <[email protected]>
* @author John Molakvoæ <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/** @typedef {import('jquery')} jQuery */

(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 displays this activity
*/
prepareModelForDisplay(model, $el, view) {
if (model.get('app') !== 'comments' || model.get('type') !== 'comments') {
return
}

if (view === 'ActivityTabView') {
$el.addClass('comment')
if (model.get('message') && this._isLong(model.get('message'))) {
$el.addClass('collapsed')
const $overlay = $('<div>').addClass('message-overlay')
$el.find('.activitymessage').after($overlay)
$el.on('click', this._onClickCollapsedComment)
}
}
},

/*
* Copy of CommentsTabView._onClickComment()
*/
_onClickCollapsedComment(ev) {
let $row = $(ev.target)
if (!$row.is('.comment')) {
$row = $row.closest('.comment')
}
$row.removeClass('collapsed')
},

/*
* Copy of CommentsTabView._isLong()
*/
_isLong(message) {
return message.length > 250 || (message.match(/\n/g) || []).length > 1
},
}

})()

OC.Plugins.register('OCA.Activity.RenderingPlugins', OCA.Comments.ActivityTabViewPlugin)
32 changes: 32 additions & 0 deletions apps/comments/src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2016 Vincent Petry <[email protected]>
*
* @author John Molakvoæ <[email protected]>
* @author Vincent Petry <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

(function() {
if (!OCA.Comments) {
/**
* @namespace
*/
OCA.Comments = {}
}

})()
28 changes: 28 additions & 0 deletions apps/comments/src/comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @copyright Copyright (c) 2016 Roeland Jago Douma <[email protected]>
*
* @author John Molakvoæ <[email protected]>
* @author Roeland Jago Douma <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

import './app.js'
import './templates.js'
import './activitytabviewplugin.js'

window.OCA.Comments = OCA.Comments
17 changes: 17 additions & 0 deletions apps/comments/src/templates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(function() {
var template = Handlebars.template, templates = OCA.Comments.Templates = OCA.Comments.Templates || {};
templates['filesplugin'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
return parent[propertyName];
}
return undefined
};

return "<a class=\"action action-comment permanent\" title=\""
+ alias4(((helper = (helper = lookupProperty(helpers,"countMessage") || (depth0 != null ? lookupProperty(depth0,"countMessage") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"countMessage","hash":{},"data":data,"loc":{"start":{"line":1,"column":50},"end":{"line":1,"column":66}}}) : helper)))
+ "\" href=\"#\">\n <img class=\"svg\" src=\""
+ alias4(((helper = (helper = lookupProperty(helpers,"iconUrl") || (depth0 != null ? lookupProperty(depth0,"iconUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"iconUrl","hash":{},"data":data,"loc":{"start":{"line":2,"column":23},"end":{"line":2,"column":34}}}) : helper)))
+ "\"/>\n</a>\n";
},"useData":true});
})();
3 changes: 3 additions & 0 deletions apps/comments/src/templates/filesplugin.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a class="action action-comment permanent" title="{{countMessage}}" href="#">
<img class="svg" src="{{iconUrl}}"/>
</a>
30 changes: 30 additions & 0 deletions apps/comments/src/utils/numberUtil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @copyright Copyright (c) 2020 John Molakvoæ <[email protected]>
*
* @author John Molakvoæ <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

const isNumber = function(num) {
if (!num) {
return false
}
return Number(num).toString() === num.toString()
}

export { isNumber }
3 changes: 3 additions & 0 deletions dist/comments-comments.js

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

45 changes: 45 additions & 0 deletions dist/comments-comments.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @copyright Copyright (c) 2016 Roeland Jago Douma <[email protected]>
*
* @author John Molakvoæ <[email protected]>
* @author Roeland Jago Douma <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* Copyright (c) 2016 Vincent Petry <[email protected]>
*
* @author John Molakvoæ <[email protected]>
* @author Vincent Petry <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
Loading