Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#38 | ajax_comments_nodejs-1159196-38.patch | 18.23 KB | adammalone |
#30 | ajax_comments-1159196-30_do-not-test.patch | 16.72 KB | adammalone |
#26 | ajax_comments-1159196-26.patch | 14.69 KB | Jody Lynn |
#25 | ajax_comments-1159196-24.patch | 14.47 KB | Jody Lynn |
#24 | ajax_comments-1159196-24.patch | 0 bytes | Jody Lynn |
Comments
Comment #1
acouch CreditAttribution: acouch commentedI created a stub for this that folks can patch against.
Comment #2
Fidelix CreditAttribution: Fidelix commentedSeems really interesting, man. Really.
Comment #3
SeanBannister CreditAttribution: SeanBannister commentedReally 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.
Comment #4
inolen CreditAttribution: inolen commentedI 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.
Comment #5
inolen CreditAttribution: inolen commentedQuestion @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?
Comment #6
acouch CreditAttribution: acouch commented@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.
Comment #7
SeanBannister CreditAttribution: SeanBannister commentedTotally 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 ;)
Comment #8
inolen CreditAttribution: inolen commented@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.
Comment #9
inolen CreditAttribution: inolen commentedActually, 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 :)
Comment #10
inolen CreditAttribution: inolen commentedComment #11
acouch CreditAttribution: acouch commentedawesome. will start testing. what version of nodejs are you using? beta6 or the dev branch?
Comment #12
inolen CreditAttribution: inolen commentedI'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).
Comment #13
asilva1312 CreditAttribution: asilva1312 commentedHi 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!
Comment #14
asilva1312 CreditAttribution: asilva1312 commentedActually, 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.
Comment #15
acouch CreditAttribution: acouch commentedI'll be committing this soon. Got sidetracked on some other projects but working on this again.
Comment #16
adammaloneDidn'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.
Comment #17
adammaloneand here's that patch I mentioned
Comment #18
acouch CreditAttribution: acouch commentedI'd be very excited to commit a working patch. Sorry I have fallen out of touch with this project.
Comment #19
adammaloneI'm going to have a go at fixing any brokenness. I have a vested interest in making this work!
Comment #20
adammaloneNot 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.
Comment #21
adammaloneHere's a link to a page where nodejs comments is demonstrably working using the above patch.
Comment #22
acouch CreditAttribution: acouch commentedExciting progress. Will review soon.
Comment #23
Jody LynnThe last patches were missing the js file. Same code, better patch.
Comment #24
Jody LynnI 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.
Comment #25
Jody LynnNon-empty patch
Comment #26
Jody LynnFixing the update comment functionality.
Comment #27
adammalonePatch in #26 works for me.
Comment #28
First.Middle.Last.1024 CreditAttribution: First.Middle.Last.1024 commentedI applied the patch in #26 and it didn't work for me. Anyone able to point me in the right direction?
Comment #29
_Tareq_ CreditAttribution: _Tareq_ commentedSame 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?
Comment #30
adammaloneThere 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:
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.
Comment #31
_Tareq_ CreditAttribution: _Tareq_ commentedThanks 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
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?
Comment #32
adammaloneFrom:
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!
Comment #33
_Tareq_ CreditAttribution: _Tareq_ commentedOkay, I installed the latest dev version and applied the patch, and there are no rejects:
(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.
Comment #34
adammaloneInstead of using patch, try using git apply -v
Comment #35
_Tareq_ CreditAttribution: _Tareq_ commentedIt 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. =)
Comment #36
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedthis patch no longer applies to the latest dev version
Edit; the patch does apply right. it was just another patch that interfered.
Comment #37
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedIt no longer applies to the July 28 dev version of ajax_comments
Comment #38
adammaloneI'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.
Comment #39
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedthe 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
Comment #40
muschpusch CreditAttribution: muschpusch commentedOk setting this to needs work
Comment #41
adammaloneI've made some more alterations to the module and will upload another patch when they're done.
Comment #42
SocialNicheGuru CreditAttribution: SocialNicheGuru commented@typhonius how are the updates? I'd like to help you test it.
Comment #43
formatC'vt CreditAttribution: formatC'vt commentedsub-module with this integration added in latest dev
Comment #44
tr33m4n CreditAttribution: tr33m4n commentedNice