-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bc4d167
Showing
15 changed files
with
714 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.git* | ||
docs/ | ||
examples/ | ||
support/ | ||
test/ | ||
testing.js | ||
.DS_Store | ||
.ep_initialized |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
var db = require('ep_etherpad-lite/node/db/DB').db; | ||
var ERR = require("ep_etherpad-lite/node_modules/async-stacktrace"); | ||
var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; | ||
|
||
exports.getComments = function (padId, callback) | ||
{ | ||
//get the globalComments | ||
db.get("comments:" + padId, function(err, comments) | ||
{ | ||
if(ERR(err, callback)) return; | ||
|
||
//comment does not exists | ||
if(comments == null) comments = {}; | ||
|
||
/*var comments = []; | ||
var jsonComments = globalComments.comments; | ||
for (var commentId in jsonComments) | ||
{ | ||
comments[commentId] = jsonComments; | ||
}*/ | ||
|
||
callback(null, { comments: comments }); | ||
}); | ||
}; | ||
|
||
exports.addComment = function(padId, data, callback) | ||
{ | ||
//create the new comment | ||
var commentId = "c-" + randomString(16); | ||
|
||
//get the entry | ||
db.get("comments:" + padId, function(err, comments){ | ||
|
||
if(ERR(err, callback)) return; | ||
|
||
// the entry doesn't exist so far, let's create it | ||
if(comments == null) comments = {}; | ||
|
||
var comment = { | ||
"author": data.author, | ||
"name": data.name, | ||
"text": data.text, | ||
"timestamp": new Date().getTime() | ||
}; | ||
|
||
//add the entry for this pad | ||
comments[commentId] = comment; | ||
|
||
//save the new element back | ||
db.set("comments:" + padId, comments); | ||
|
||
callback(null, commentId, comment); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
var commentManager = require('./commentManager'); | ||
var padManager = require("ep_etherpad-lite/node/db/PadManager"); | ||
var ERR = require("ep_etherpad-lite/node_modules/async-stacktrace"); | ||
|
||
function padExists(padID){ | ||
padManager.doesPadExists(padID, function(err, exists){ | ||
return exists; | ||
}); | ||
} | ||
|
||
exports.getPadComments = function(padID, callback) | ||
{ | ||
commentManager.getComments(padID, function (err, padComments) | ||
{ | ||
if(ERR(err, callback)) return; | ||
|
||
if(padComments !== null) callback(null, padComments); | ||
}); | ||
}; | ||
|
||
exports.addPadComment = function(padID, data, callback) | ||
{ | ||
commentManager.addComment(padID, data, function (err, commentID) | ||
{ | ||
if(ERR(err, callback)) return; | ||
|
||
if(commentID !== null) callback(null, commentID); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"parts": [ | ||
{ | ||
"name": "main", | ||
"pre": ["ep_etherpad-lite/webaccess"], | ||
"client_hooks": { | ||
"postAceInit": "ep_comments/static/js/index", | ||
"aceAttribsToClasses": "ep_comments/static/js/index", | ||
"aceEditorCSS": "ep_comments/static/js/index" | ||
}, | ||
"hooks": { | ||
"socketio": "ep_comments/index", | ||
"eejsBlock_editbarMenuLeft": "ep_comments/index", | ||
"eejsBlock_scripts": "ep_comments/index", | ||
"eejsBlock_styles": "ep_comments/index" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
var eejs = require('ep_etherpad-lite/node/eejs/'); | ||
var commentManager = require('./commentManager'); | ||
|
||
exports.socketio = function (hook_name, args, cb){ | ||
var app = args.app; | ||
var io = args.io; | ||
var pushComment; | ||
var padComment = io; | ||
|
||
var commentSocket = io | ||
.of('/comment') | ||
.on('connection', function (socket) { | ||
|
||
socket.on('getComments', function (data, callback) { | ||
var padId = data.padId; | ||
|
||
socket.join(padId); | ||
|
||
commentManager.getComments(padId, function (err, comments){ | ||
callback(comments); | ||
}); | ||
}); | ||
|
||
socket.on('addComment', function (data, callback) { | ||
var padId = data.padId; | ||
var content = data.comment; | ||
|
||
commentManager.addComment(padId, content, function (err, commentId, comment){ | ||
socket.broadcast.to(padId).emit('pushAddComment', commentId, comment); | ||
callback(commentId, comment); | ||
}); | ||
}); | ||
|
||
}); | ||
}; | ||
|
||
exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) { | ||
args.content = args.content + eejs.require("ep_comments/templates/commentBarButtons.ejs"); | ||
return cb(); | ||
}; | ||
|
||
exports.eejsBlock_scripts = function (hook_name, args, cb) { | ||
args.content = args.content + eejs.require("ep_comments/templates/comments.html", {}, module); | ||
return cb(); | ||
}; | ||
|
||
exports.eejsBlock_styles = function (hook_name, args, cb) { | ||
args.content = args.content + eejs.require("ep_comments/templates/styles.html", {}, module); | ||
return cb(); | ||
}; | ||
|
||
/* | ||
exports.expressCreateServer = function (hook_name, args, cb) { | ||
var app = args.app; | ||
app.get('/p/:pad/:rev?/comments', function(req, res, next) { | ||
var padId = req.params.pad; | ||
var revision = req.params.rev ? req.params.rev : null; | ||
comments.getPadComments(padId, revision, function(err, padComments) { | ||
res.render('comments.ejs', { locals: { comments: padComments } }); | ||
}); | ||
}); | ||
app.get('/p/:pad/:rev?/add/comment/:name/:text', function(req, res, next) { | ||
var padId = req.params.pad; | ||
var revision = req.params.rev ? req.params.rev : null; | ||
var data = { | ||
author: "empty", | ||
selection: "empty", | ||
name: req.params.name, | ||
text: req.params.text | ||
}; | ||
comments.addPadComment(padId, data, revision, function(err, commentId) { | ||
res.contentType('text/x-json'); | ||
res.send('{ "commentId": "'+ commentId +'" }'); | ||
}); | ||
}); | ||
app.configure(function(){ | ||
args.app.set('views', __dirname + '/views'); | ||
args.app.set('view options', {layout: false}); | ||
args.app.engine('ejs', require('ejs').renderFile); | ||
} | ||
};*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"description": "Adds comments on sidebar and link it to the text.", | ||
"name": "ep_comments", | ||
"version": "0.0.1", | ||
"author": { | ||
"name": "Nicolas Lescop", | ||
"email": "[email protected]" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Nicolas Lescop", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"dependencies": {}, | ||
"engines": { | ||
"node": "*" | ||
}, | ||
"homepage": "https://github.com/nicolas-lescop/etherpad-plugins", | ||
"devDependencies": {}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/nicolas-lescop/etherpad-plugins.git" | ||
}, | ||
"_id": "[email protected]", | ||
"_from": "etherpad-plugins/ep_comments", | ||
"readme": "ERROR: No README.md file found!", | ||
"dist": { | ||
"shasum": "99884ed7ddab0e5b74f57d7d59cc618e8cf681f3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
.comment { | ||
background: #FFCC91 !important; | ||
border-radius: 2px; | ||
} | ||
|
||
#comments { | ||
width: 180px; | ||
font-family: Helvetica, Arial, sans-serif; | ||
} | ||
|
||
.sidebar-comment { | ||
margin-left: 10px; | ||
padding: 8px 5px; | ||
margin-top: 10px; | ||
background: white; | ||
width: 167px; | ||
border-top-left-radius: 2px; | ||
border-bottom-left-radius: 2px; | ||
-moz-box-shadow: 0 0 2px #888; | ||
-webkit-box-shadow: 0 0 2px #888; | ||
box-shadow: 0 0 2px #888; | ||
} | ||
|
||
.sidebar-comment.mouseover { | ||
margin: 8px 0 0 14px; | ||
/*-moz-box-shadow: 0 0 2px #EB5C2E; | ||
-webkit-box-shadow: 0 0 2px #EB5C2E; | ||
box-shadow: 0 0 2px #EB5C2E;*/ | ||
background: #FFF9F7; | ||
-webkit-transition: margin 300ms ease-in, background 300ms ease-in; | ||
-moz-transition: margin 300ms ease-in, background 300ms ease-in; | ||
-ms-transition: margin 300ms ease-in, background 300ms ease-in; | ||
-o-transition: margin 300ms ease-in, background 300ms ease-in; | ||
transition: margin 300ms ease-in, background 300ms ease-in; | ||
} | ||
|
||
.comment-author-name { | ||
color: #555; | ||
font-weight:bold; | ||
font-size: 1.2em; | ||
} | ||
|
||
.comment-date { | ||
line-height: 0.9em; | ||
font-size: 0.9em; | ||
} | ||
|
||
.comment-text { | ||
margin-top: 5px; | ||
font-size: 1em; | ||
color: #333; | ||
width: 160px; | ||
word-wrap: break-word; | ||
white-space : normal; | ||
} | ||
|
||
.comment-content { | ||
border: 2px solid #DDD; | ||
background: #fff; | ||
width: 160px; | ||
height: 60px; | ||
padding: 2px; | ||
} | ||
|
||
.comment-content:focus { | ||
border: 2px solid #ccc; | ||
} | ||
|
||
.comment-buttons input { | ||
color: #666; | ||
border: 2px solid #DDD; | ||
background: #EEE; | ||
width: 81px; | ||
height: 30px; | ||
} | ||
|
||
.comment-buttons input[type="submit"] { | ||
margin-right: 5px; | ||
} | ||
|
||
.comment-buttons input:hover { | ||
color: #333; | ||
cursor: pointer; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.