AjaxComments

From Organic Design wiki
Revision as of 12:57, 26 June 2012 by Nad (talk | contribs) (Discussion data: maybe the JSON should return the data in its proper hierarchical form as it will need to be rendered in hierarchical form)

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.

Ajax requests

  • 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.

Discussion data

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.

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