I have just finish coding the commenting feature
. Again, I was pleasently surprised at how fast I was able to complete this task.
I only about 5 days I added the comments
system with all these options:
- Admin can allow/disallow comments on the site
- Admin can configure maximum number of comments that a question or answer can have.
After this limit is reached the user will see error alerts when trying to add comment
- A flood-check applies to comments allowing one comment per 30 seconds. This timeout
is configurable. The flood check does not apply to moderators
- Duplicate comments check to prevent accidental duplicate comment posting
- Comments can be edited but only in the first 5 minutes after the comment has been posted.
This edit timeout is configurable.
- Author of the comment can delete own comment any time. Admin can delete any comment.
- When a comment is made by the same user who asked the original question (meaning a comment is either for that question or for any of its answers), the special css class is added to the username link of that comment, indicating that commentor is also the question author
- If comment is edited, a special icon will be displayed next to comment and hovering over it will reveal info on who and when has last edited the comment.
- Comment can be "Liked", sort of a up-only vote. The likes of the comment do not add to author's reputation but they are logged in a special collection and later on I will be able to add showing of how many comment likes the user got in user's profile page.
- When processing the "Likes" for the comment the system checks that only one like per user per comment is counted and also Likes for own comments do not count.
- Counts of likes displayed next to the "Like" icon
- Cool css styles for all the edit/delete/like tools, thanks to Alloy UI button collection. I also made a black-and-white copy of the icons sprite, so initially only black and white icons are shown, but color version is shown on mouse over. This is a neat effect.
- I put some extra features in place to later allow for easy replying to comments. This will be much better than just having to add the @username in the reply. A reply to comment will automatically know the parent comment id and will automatically prepends the In-reply-to @user and also we will have some css styles assisted in identifying which comment is a reply to which other comment.
- All comment-related operations post onBefore and on events. For example, there are onBeforeNewComment and onNewComment; onBeforeCommentEdit and onCommentEdit. This way plugins can easily listen to these events. By the way, the comment flood check is a plugin that listens to the onBeforeNewComment event. Other plugins can also be written, for example to disallow some bad words in comments or to disallow comments from certain countries, or whatever else you need.
- The master email notifier class will also work as a plugin and will listen to comment events to notify question/answer owners of new comments and commentors of new replies.
- Forgot one more feature: comments can be reported for inappropriate content, just like any question and answer, by using the little flag icon and then using the form to report to moderator.
Alright, just give it a try here. I set it that any registered user can comment, so login and try it. Oh yes, the comment system also checks to allow comments only from logged in users. This is checked by JS on client and then again on the server.
Updated sources will be uploaded to github today.
Next feature: follow tag, then follow questions, then follow users.