I wanted to create ajax based commenting system for some html pages.我想创建基于AJAX技术的评论系统,为一些HTML的页面。 The design goals were:设计目标:
1. 1 。 Simple to use and install简单的使用和安装
2. 2 。 Database (MySQL) backed数据库( MySQL的)支持
3. 3 。 Minimal changes to HTML template / files微小的变化,以HTML模板/档案
4. 4 。 Support effective (no frequent cache refreshes) html page compression / caching strategy for heavily commented sites.支持有效的(没有频繁的高速缓存刷新) HTML网页压缩/缓存策略,大量评论的网站。

An AJAX based system fits the bill. 1基于Ajax的制度相适应的条例草案。 The new comments are displayed instantaneously.新的评论显示瞬间。 The html pages can be cached and / or compressed without requiring to refresh after each comment. HTML网页可以被缓存和/或压缩,而不需要重新整理后,每个评论。
Spam is an issue with any commenting system.垃圾邮件的一个问题是,与任何的评论系统。 I have decided to strip html tags in the first iteration to deter spammers.我已决定带HTML标记,在第一次迭代,以遏止垃圾邮件发送者。 As a personal decision I have decided not to capture email address.作为一个个人的决定,我决定不捕捉的电子邮件地址。 However it can be trivially added along with url if so desired.不过可以trivially补充说:随着网址,若有理想。

I used Sajax as my Ajax framework.我用sajax作为我的AJAX框架。 It presented它介绍了 few少数的 problems as Sajax is more suited for PHP / Ruby pages and not HTML.问题sajax更适合对PHP /红宝石的页面,而不是HTML格式。 Here is这里是 my solution我的解决方案 .

Schema:架构:
CREATE TABLE `comments` (创建表`评论` (
`id` INT NOT NULL AUTO_INCREMENT , `编号`诠释不空auto_increment ,
`url` VARCHAR( 255 ) NOT NULL , `网址` varchar ( 255 )不空,
`ip` VARCHAR( 30 ) NOT NULL , `叶` varchar ( 30 )不空,
`author` VARCHAR( 255 ) DEFAULT ‘Anonymous Coward’ NOT NULL ,作者` ` varchar ( 255 )默认的'无名氏懦夫'不空,
`location` VARCHAR( 255 ) DEFAULT ‘Cyberspace’ NOT NULL , `位置` varchar ( 255 )默认的'网络'不空,
`comment` TEXT NOT NULL , `评论`文本不空,
`when` TIMESTAMP NOT NULL, `当`时间戳不空,
PRIMARY KEY ( `id` ) )主键( `编号` ) )
); ) ;

Design notes:设计说明:
The code for adding comment passed the url of the page.代码加入评论通过网页的网址。 When the page is loaded a sajax call is made to fetch all the comment for the url of the page.当页面加载1 sajax呼吁作出市值的所有评论的网页的网址。 New comments are displayed instantaneously as new comments are fetched after a comment has been submitted.新的评论显示瞬时作为新的评论是牵强的评论后,已提交。 This can additionally fetch comments from other users.这可以此外,市值评论从其他用户。 However I have decided not to implement timed refresh as that may unnecessarily increase server load without adding much value to users.但我已决定不执行定时刷新,因为这可能会增加不必要的服务器负载增加很大的价值给用户。 Validation checks are made to detect and not add duplicate comments.验证检查作出检测和不添加重复的意见。 Comment throttling by same user can be added to prevent abuse.评论节流由同一用户可以添加,以防止滥用。

Hope that helps in designing your commenting system.希望有助于在设计您的评论系统。