Difference between revisions of "AjaxComments"

From Organic Design wiki
(Issues: The extension is now running on this site - you can test it below.)
(AjaxComments 2.0: and 2.5)
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
One of the clients I'm working for needs a new discussion component to replace the MediaWiki talk page system entirely. It needs to add an area at the bottom of the page (an area marked by a div element that can be positioned appropriately) that allows comments to be added or replies made to existing comments. Authors will be able to edit or delete any comments they've made as long as there are no replies, and sysops can edit or delete any comments (deleting a comment with replies will also remove all the replies). The system will be entirely JavaScript and all requests done via Ajax. The discussion data will still be stored in the article's talk by the server-side Ajax handler.
+
{{svn|extensions|MediaWiki/AjaxComments}}
 +
This extension replaces the normal MediaWiki talk page functionality by allowing comments to be added at the bottom of the page or replies made to existing comments. Authors can edit or delete any of their comments as long as no replies have been made to them, and sysops can edit or delete any comments at all (deleting a comment with replies will also remove all the replies). The system is mainly JavaScript and jQuery and all updates are done via Ajax. The discussion data is still stored in the article's talk page and is clearly delineated so that the talk page can still be used without interfering with the comment data if the extension is disabled. The comments are currently stored in a non-human readable format though, so although they can coexist with normal talk-page content, they can't be edited without the AjaxComments extension.
  
== Ajax requests ==
+
== AjaxComments 2.0 & 2.5 ==
*Retrieve all comments (used to initially populate the discussion area) - default command - no parameters.
+
In May 2015 version 2.0 was written which stores the comments in the database instead (it comes with a maintenance script to copy the existing comments over from talk pages into the new database table and reverts the talk pages back to how they were before comments were added). It logs the comment activity so it still shows up in the page history and recent changes. It also works with the [[Extension:WebSocket|WebSocket extension]] if it's installed and the server supports WebSockets so that polling the server using Ajax is no longer necessary.
*Add a comment - a single parameter, the content of the new comment
 
*Reply to a comment - two parameters, the id of the comment being replied to and the new comment content
 
*Edit a comment - two parameters, the id of the comment and the new content
 
*Delete a comment - a single parameter being the id of the comment
 
All these items can be passed to a single server-side Ajax handler method having the first parameter as the command and the other one or two being the id/comment data for the command. Each command returns the HTML required to populate the appropriate area.
 
  
== Discussion data ==
+
Version 2.5 is for MediaWiki 1.25 and above and uses the new JSON based [[MW:Manual:Extension registration|Extension registration]] methodology for loading the extension. If you're using a version of MediaWiki older than 1.25, then you should select the [https://github.com/OrganicDesign/extensions/tree/MediaWiki-1.24/MediaWiki/AjaxComments MediaWiki 1.24 branch] of the code.
The data stored in the talk page needs to be in a format that is easy to match a particular comment for editing or for inserting a reply to. It should still make sense when the extension is disabled and the talk page edited normally.
 
  
The MediaWiki Ajax handler should return the discussion in JSON format so that there is minimal reliance on the server-side for rendering the discussion thus making the system more portable. Probably in the form of a simple array with fields for user, data, html content and depth would be best. The comments can be identified simply by their numeric index into the array.
+
== 1.x Features ==
 
 
The data can be stored as wikitext in the talk page as normal headings followed by a line for the username, a line of the date, then the rest being the comment content.
 
 
 
*maybe the JSON should return the data in its proper hierarchical form as it will need to be rendered in hierarchical form
 
*maybe the server should in fact return HTML since only the server knows what edit/delete links to add since it has the user/group info
 
 
 
== Done ==
 
This has been finished already, there's still a few finishing touches to do. The source code is in our Subversion repository [http://svn.organicdesign.co.nz/listing.php?repname=extensions&path=%2FAjaxComments%2F here].
 
 
 
=== features ===
 
 
*Activates automatically for articles that have discussion pages removing discussion tab and adding a comments section below the article content
 
*Activates automatically for articles that have discussion pages removing discussion tab and adding a comments section below the article content
 
*Allows registered users to add comments or reply to existing comments
 
*Allows registered users to add comments or reply to existing comments
 
*Allows comments that a user has previously created to be edited or deleted '''as long as they have not been replied to yet'''
 
*Allows comments that a user has previously created to be edited or deleted '''as long as they have not been replied to yet'''
 +
*Sysops can edit/delete all comments
 
*All comment interaction is done via Ajax so that the page is never reloaded
 
*All comment interaction is done via Ajax so that the page is never reloaded
 
*Comment editing integrates properly with wikitext by retrieving the comment source via ajax
 
*Comment editing integrates properly with wikitext by retrieving the comment source via ajax
 
*The data that makes up the comments is stored in the talk page but is not in a humanly readable format
 
*The data that makes up the comments is stored in the talk page but is not in a humanly readable format
 
*The talkpage data is able to coexist with existing talk page content and is delineated by headings so it's clearly visible to avoid accidental editing
 
*The talkpage data is able to coexist with existing talk page content and is delineated by headings so it's clearly visible to avoid accidental editing
 +
*Displays gravitars for users with confirmed email addresses who have registered a gravitar
 +
*Users can like/dislike other users comments but not their own comments or comments they already like/dislike
 +
*Liking an already disliked comment will un-dislike it, and visa-versa, disliking a previously liked comment will unlike it.
  
=== Issues ===
+
== Issues / Todo  ==
*The comment data is stored in the articles talk page, but is currently not human readable<s>and does not work with existing talk page content</s>
+
*The comment data is stored in the articles talk page, but is currently not human readable <s>and does not work with existing talk page content</s>
 
*<s>The date/time of posts is not currently displayed in the users timzone or with their time formatting preferences</s>
 
*<s>The date/time of posts is not currently displayed in the users timzone or with their time formatting preferences</s>
 +
*At the moment, the most recent comments are first, but some sites may prefer most recent at the bottom
 +
*Because the comment storage method is not human-readable, the diff isn't very useful
 +
*<s>Mousing over the like/dislikes should show the users names</s>
 +
*Input box size should be set by JS to match the size and position of the comment text
 +
*<s>Editing should return only the rendered text content, not the whole comment and all its replies</s>
 +
*<s>Going to the talk page should redirect to the comments</s>
 +
*<s>The tab url can be changed to #comments</s>
  
== Example ==
+
== See also ==
The extension is now running on this site - you can test it below.
+
*[http://www.mediawikiwidgets.org/DISQUS MediaWiki DISQUS Widget]
 
+
__NOTOC__
[[Category:Projects]]
 

Latest revision as of 13:37, 21 June 2015

Info.svg This code is in our Git repository here.

Note: If there is no information in this page about this code and it's a MediaWiki extension, there may be something at mediawiki.org.

This extension replaces the normal MediaWiki talk page functionality by allowing comments to be added at the bottom of the page or replies made to existing comments. Authors can edit or delete any of their comments as long as no replies have been made to them, and sysops can edit or delete any comments at all (deleting a comment with replies will also remove all the replies). The system is mainly JavaScript and jQuery and all updates are done via Ajax. The discussion data is still stored in the article's talk page and is clearly delineated so that the talk page can still be used without interfering with the comment data if the extension is disabled. The comments are currently stored in a non-human readable format though, so although they can coexist with normal talk-page content, they can't be edited without the AjaxComments extension.

AjaxComments 2.0 & 2.5

In May 2015 version 2.0 was written which stores the comments in the database instead (it comes with a maintenance script to copy the existing comments over from talk pages into the new database table and reverts the talk pages back to how they were before comments were added). It logs the comment activity so it still shows up in the page history and recent changes. It also works with the WebSocket extension if it's installed and the server supports WebSockets so that polling the server using Ajax is no longer necessary.

Version 2.5 is for MediaWiki 1.25 and above and uses the new JSON based Extension registration methodology for loading the extension. If you're using a version of MediaWiki older than 1.25, then you should select the MediaWiki 1.24 branch of the code.

1.x Features

  • Activates automatically for articles that have discussion pages removing discussion tab and adding a comments section below the article content
  • Allows registered users to add comments or reply to existing comments
  • Allows comments that a user has previously created to be edited or deleted as long as they have not been replied to yet
  • Sysops can edit/delete all comments
  • All comment interaction is done via Ajax so that the page is never reloaded
  • Comment editing integrates properly with wikitext by retrieving the comment source via ajax
  • The data that makes up the comments is stored in the talk page but is not in a humanly readable format
  • The talkpage data is able to coexist with existing talk page content and is delineated by headings so it's clearly visible to avoid accidental editing
  • Displays gravitars for users with confirmed email addresses who have registered a gravitar
  • Users can like/dislike other users comments but not their own comments or comments they already like/dislike
  • Liking an already disliked comment will un-dislike it, and visa-versa, disliking a previously liked comment will unlike it.

Issues / Todo

  • The comment data is stored in the articles talk page, but is currently not human readable and does not work with existing talk page content
  • The date/time of posts is not currently displayed in the users timzone or with their time formatting preferences
  • At the moment, the most recent comments are first, but some sites may prefer most recent at the bottom
  • Because the comment storage method is not human-readable, the diff isn't very useful
  • Mousing over the like/dislikes should show the users names
  • Input box size should be set by JS to match the size and position of the comment text
  • Editing should return only the rendered text content, not the whole comment and all its replies
  • Going to the talk page should redirect to the comments
  • The tab url can be changed to #comments

See also