I'd like create a sub-module for this project for the 7.x version that integrates with nodejs through the Node.js Integration module: http://drupal.org/project/nodejs

The goal would be a scalable, real-time comment updates.

This sub-module would not add any other functionality in itself and would rely on the ajax_comments and nodejs modules.

This will take some time and there is a lot of other work do to on the 7.x version, but I'm opening this up now for anyone who wants to work on this, sub, or share ideas.

Comments

acouch’s picture

I created a stub for this that folks can patch against.

Fidelix’s picture

Seems really interesting, man. Really.

SeanBannister’s picture

Really interested in this functionality, was actually just searching to see if anyone else was working on it.

I got thinking, should this just be limited to comments? Or is their a use to add this to any fieldable entity.

My original BIG thought was implementing something like Google Wave so multiple people could simultaneously edit an entity or see it updating in real time. But I realise this would be a nightmare to implement and certainly takes this away from the original proposal.

inolen’s picture

I actually have the node.js integration nearly 100% complete.

I started slacking on it while working on this http://drupal.org/node/1278186.

If we could get that committed I'll wrap it up.

inolen’s picture

Question @acouch, I saw the stub folder in the source, should this module stay inside of ajax comments or go up as a new project? Is there some general rule of thumb here for when to/when not to separate?

acouch’s picture

@inolen This could definitely be its own project. It is up to you really. If you want to create a separate project I would support that. Otherwise send patches for what you have and I'll start committing.

SeanBannister’s picture

Totally up to you guys, but I'm thinking a separate module might be useful so we have the ability to expand this past comments for real time collaboration in Drupal? I noticed the project name realtime is also available. But thats just me thinking about my own needs ;)

inolen’s picture

StatusFileSize
new7.9 KB

@acouch,

Sorry for taking so long on this one.

The patch attached contains the modifications to the ajax_comments module in order to accommodate the nodejs_ajax_comments module.

The new ajax_comments_get_thread() function is kind of unpleasant, but it let me get rid of the shoddy functionality that was involved to just update the comment's content, now it updates the entire wrapper since on update it now renders the comment and every comment beneath it (if threaded).

Aside from that, nothing is actually changed, the ajax_comments_create_ajax_response() function has been added to allow the ajax_comments_nodejs module to use the same functionality as ajax_comments for adding/updating/deleting comments.

Patch attached, I'll work on setting up a sandbox for nodejs_ajax_comments next.

inolen’s picture

StatusFileSize
new12.76 KB

Actually, after thinking about it I don't think it makes much sense for this functionality to go in a new module.

New patch contains the last patch + ajax_comments_nodejs module.

If anyone has the time to test this, it would be great :)

inolen’s picture

Status:Active» Needs review
acouch’s picture

awesome. will start testing. what version of nodejs are you using? beta6 or the dev branch?

inolen’s picture

I'm running a hacked up dev version from before the beta6 release. I believe the beta6 release has the changes required for this to work smoothly (http://drupal.org/node/1282464 and http://drupal.org/node/1280748).

asilva1312’s picture

Hi guys!

I started looking at this as well. I have the nodejs server working fine and I tested with Drupal Chat. All looked good.

I got this module to send the message and I can see in nodejs log that the message is sent via the channel. However, the page div isn't updating on the other user's browser. I looked at FireBug and noticed that the ajax_comments_node.js file is there and linked fine however it doesn't load up in the FireBug script debugger so I could see how the jquery stuff is working. Any idea why?

Did anyone get this to work?

Thank you for the awesome work!

asilva1312’s picture

Actually, I got this to work today. Great work! It didn't work due to an error on my end. I had an error in the JavaScript code.

acouch’s picture

I'll be committing this soon. Got sidetracked on some other projects but working on this again.

typhonius’s picture

Didn't manage to get this patch to apply to the latest git release of the module so I manually applied and rerolled the patch.

I'm going to have to look into it though because for some reason the comments aren't showing up after submission. They submit successfully yet do not show.

typhonius’s picture

StatusFileSize
new12.04 KB

and here's that patch I mentioned

acouch’s picture

I'd be very excited to commit a working patch. Sorry I have fallen out of touch with this project.

typhonius’s picture

I'm going to have a go at fixing any brokenness. I have a vested interest in making this work!

typhonius’s picture

StatusFileSize
new12.36 KB

Not really finished and there are a couple of things I'd rather not use in there but this one works for me.

There are still things that are unresolved but for me this works (best practice would be to disable the module prior to applying the patch).

I haven't gone through all usecases but with anonymous comments on, comment form displayed at bottom of comments and enabled for all node types I've received the expected results.

Be interested to see if there are issues with this and other people's opinions on how this should be written.

typhonius’s picture

Here's a link to a page where nodejs comments is demonstrably working using the above patch.

acouch’s picture

Exciting progress. Will review soon.

Jody Lynn’s picture

StatusFileSize
new14.46 KB

The last patches were missing the js file. Same code, better patch.

Jody Lynn’s picture

StatusFileSize
new0 bytes

I was having trouble on a site using this getting "Requested page not found errors". I traced it down to comment_save running a database transaction. Sometimes that transaction is not complete when this module tries to do a comment_load, which makes it fail. To get around that problem I switched form using hook_comment_insert/update to adding a new submit handler on comment_form, which runs after the database transaction.

I guess node and transactions don't always play so well together.

Jody Lynn’s picture

StatusFileSize
new14.47 KB

Non-empty patch

Jody Lynn’s picture

StatusFileSize
new14.69 KB

Fixing the update comment functionality.

typhonius’s picture

Patch in #26 works for me.

First.Middle.Last.1024’s picture

Category:feature» support

I applied the patch in #26 and it didn't work for me. Anyone able to point me in the right direction?

_Tareq_’s picture

Same here.

Although With some debugging, I found that it does fire the AjaxCommentInsert callback, but it doesn't 'get' anything from 'ajax_comments_nodejs/insert/' (I assumed that because the alert I put inside the function doesn't show).

Does anyone know what's wrong?

typhonius’s picture

StatusFileSize
new16.72 KB

There are a few changes I've made locally to patch in #26 that are currently verified as working on my node.js demo site.

Just a few checks:

  • Is nodejs definitely running and connecting (latest dev of nodejs includes a check on the status report)
  • Are you working with the latest dev of ajax_comments and is the patch applying without any rejections

If the patch I'm using doesn't work on your install my guess is that the issue is not with the patch but rather with your node.js connection perhaps.

_Tareq_’s picture

Thanks for your reply typhonius, and sorry for my late reply.

About the Nodejs, I have tested it with other modules and it's working perfectly.
It might be something about patching, I'm not experienced with patches, but I remember there were some rejects, but when I checked the rejected functions where in the patched module, I wasn't sure what was going on.

Anyway, I tried it again on a fresh copy of ajax_comments-7.x-1.0-alpha1

[root@t2test ajax_comments]# patch < ajax_comments-1159196-26.patch
patching file ajax_comments.module
Hunk #2 FAILED at 210.
Hunk #3 succeeded at 269 with fuzz 2 (offset -24 lines).
1 out of 3 hunks FAILED -- saving rejects to file ajax_comments.module.rej
can't find file to patch at input line 244
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/ajax_comments_nodejs/ajax_comments_nodejs.info b/ajax_comments_nodejs/ajax_comments_nodejs.info
|index 092284a..4266584 100644
|--- a/ajax_comments_nodejs/ajax_comments_nodejs.info
|+++ b/ajax_comments_nodejs/ajax_comments_nodejs.info
--------------------------
File to patch: ajax_comments_nodejs/ajax_comments_nodejs.info
patching file ajax_comments_nodejs/ajax_comments_nodejs.info
Hunk #1 succeeded at 3 with fuzz 2.
patching file ajax_comments_nodejs.js
can't find file to patch at input line 300
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/ajax_comments_nodejs/ajax_comments_nodejs.module b/ajax_comments_nodejs/ajax_comments_nodejs.module
|index 7f83b7b..935d135 100644
|--- a/ajax_comments_nodejs/ajax_comments_nodejs.module
|+++ b/ajax_comments_nodejs/ajax_comments_nodejs.module
--------------------------
File to patch: ajax_comments_nodejs/ajax_comments_nodejs.module
patching file ajax_comments_nodejs/ajax_comments_nodejs.module

When I tried it this time, I got this error when I submitted a comment:

An error occurred while attempting to proccess /dr7/commons/system/ajax: Object #<Object> has no method 'ipeReplacedBeforeSerialize'

Another thing is that, when I first enabled the module, and tried to insert a comment, it acts as if the module isn't there, I had to go to Ajax Comments configuration and check the Content Types manually so that Ajax Comments is enabled there.

Although it says "Select node types you want to activate ajax comments on. If you select nothing, AJAX Comments will be enabled everywhere." but this doesn't work.

Any idea what's wrong?

typhonius’s picture

From:

Hunk #2 FAILED at 210.
1 out of 3 hunks FAILED -- saving rejects to file ajax_comments.module.rej

it looks like the patch isn't applying correctly. Are you patching against ajax comments dev or the stable release? The patch should apply against dev which you can get from the version control tab on the project page. Select 7.x-1.x and clone it to your local machine!

_Tareq_’s picture

Okay, I installed the latest dev version and applied the patch, and there are no rejects:

[root@t2test ajax_comments]# patch < ajax_comments-1159196-26.patch
patching file ajax_comments.module
can't find file to patch at input line 244
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/ajax_comments_nodejs/ajax_comments_nodejs.info b/ajax_comments_nodejs/ajax_comments_nodejs.info
|index 092284a..4266584 100644
|--- a/ajax_comments_nodejs/ajax_comments_nodejs.info
|+++ b/ajax_comments_nodejs/ajax_comments_nodejs.info
--------------------------
File to patch: ajax_comments_nodejs/ajax_comments_nodejs.info
patching file ajax_comments_nodejs/ajax_comments_nodejs.info
Hunk #1 succeeded at 3 with fuzz 2.
patching file ajax_comments_nodejs.js
can't find file to patch at input line 300
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/ajax_comments_nodejs/ajax_comments_nodejs.module b/ajax_comments_nodejs/ajax_comments_nodejs.module
|index 7f83b7b..935d135 100644
|--- a/ajax_comments_nodejs/ajax_comments_nodejs.module
|+++ b/ajax_comments_nodejs/ajax_comments_nodejs.module
--------------------------
File to patch: ajax_comments_nodejs/ajax_comments_nodejs.module
patching file ajax_comments_nodejs/ajax_comments_nodejs.module

(Note: The ajax_comments_nodejs.js file was patched in the ajax_comments directory though, I moved it to ajax_comments_nodejs folder)

I enabled the module, and when I write a comment and press save, I get this error:

An error occurred while attempting to proccess /dr7/commons/system/ajax: Object #<Object> has no method 'ipeReplacedBeforeSerialize'

I just also noticed this, when I click on "Customize this page" at the bottom, (from the panels module that is used by commons) I get this:

An error occurred while attempting to process /dr7/commons/panels/ajax/ipe/save_form/panel_context%3Anode_view%3Anode_view_panel_context: Object #<Object> has no method 'ipeReplacedBeforeSerialize'

So it's something general in ajax? This error only shows in the commons though.

I tried this successfully patched ajax_comments module in my /dr7/ installation of drupal (not commons) and I don't get this error but when I insert a comment, all what happens is the "Add new comment" fades out and in again, as if a new comment was added but no new comment is added even in the same page I'm commenting on, I have to refresh the page to see the comment I inserted.

On the other page that I opened on the same node, nothing happens at all.

What's going on? =( Nodejs is working, I tried broadcasting and swapIt demo and other things.

typhonius’s picture

Instead of using patch, try using git apply -v

_Tareq_’s picture

It works!

Here's what happened:

I patched it using git apply -v, and enabled it, and it was the same; posting a comment does nothing. Then I noticed that there is an error in the browser console, something like: can't find http://10.2.10.37/ajax_comments_nodejs/insert/45 But I have drupal set up in a sub folder, not at the roo7, so it should be http://10.2.10.37/dr7/ajax_comments_nodejs/insert/45 so I found that in ajax_comments_nodejs.js there is a line:

$.get('/ajax_comments_nodejs/insert/' + message.cid, function (data)

and another one for "update". I added /dr7/at the beginning so it became:

$.get('/dr7/ajax_comments_nodejs/insert/' + message.cid, function (data)

Then everything worked =) I'm not sure why it didn't take the sub folder since I run the drupal from dr7.

As for the 'ipeReplacedBeforeSerialize' error, it's still there when I try the module in commons. It seems something is wrong with ajax there, not sure what. But it's working on another copy of drupal, so yeah, it's working!

Thanks a lot for your help, typhonius. =)

SocialNicheGuru’s picture

this patch no longer applies to the latest dev version

Edit; the patch does apply right. it was just another patch that interfered.

SocialNicheGuru’s picture

It no longer applies to the July 28 dev version of ajax_comments

typhonius’s picture

StatusFileSize
new18.23 KB

I've rerolled this for the latest HEAD but there may be a couple of changes to come. Important things to note are that while it works, there are still a few things to do to ensure it's aesthetically pleasing.

SocialNicheGuru’s picture

the patch places ajax_comments_nodejs.js in the wrong place. (another comment above mentioned it).

I can add comments without ajax_comments_nodejs enabled but I cannot with it enabled.

nodejs is enabled and configured correctly.

Here is what I see in watchdog when I have ajax_comments_nodejs:

241 25/Sep 16:02 warning php Warning: Invalid argument supplied for foreach() in ajax_comments_remove_status() (line 680 of /modules/all/ajax_comments/ajax_comments.module).

240 25/Sep 16:02 notice php Notice: Undefined index: messages in ajax_comments_remove_status() (line 680 of /modules/all/ajax_comments/ajax_comments.module).

the above does NOT show up if ajax_comments_nodejs is disabled

muschpusch’s picture

Assigned:acouch» Unassigned
Status:Needs review» Needs work

Ok setting this to needs work

typhonius’s picture

I've made some more alterations to the module and will upload another patch when they're done.

SocialNicheGuru’s picture

@typhonius how are the updates? I'd like to help you test it.

formatC&#039;vt’s picture

Issue summary:View changes
Status:Needs work» Fixed

sub-module with this integration added in latest dev

tr33m4n’s picture

Nice

  • acouch committed c954f37 on 8.x-1.x
    #1159196 by acouch: create a submodule for nodejs integration. this is...

Status:Fixed» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.