How To Create AJAX Commenting System for Static HTML Pages Cómo crear AJAX sistema de comentarios para las páginas HTML
I wanted to create ajax based commenting system for some html pages. Quería crear la base ajax sistema de comentarios para algunas páginas html. The design goals were: Los objetivos de diseño fueron los siguientes:
1. Simple to use and install Fácil de usar e instalar
2. Database (MySQL) backed Base de datos (MySQL) respaldada
3. Minimal changes to HTML template / files Cambios mínimos de plantilla HTML / archivos
4. Support effective (no frequent cache refreshes) html page compression / caching strategy for heavily commented sites. Apoyo eficaz (no se actualiza con frecuencia caché) html página de compresión y caching estrategia para sitios muy comentado.
An AJAX based system fits the bill. Un sistema basado en AJAX se enmarca en el proyecto de ley. The new comments are displayed instantaneously. Los nuevos comentarios se muestran instantáneamente. The html pages can be cached and / or compressed without requiring to refresh after each comment. Las páginas HTML en caché se pueden y / o comprimidos sin necesidad de refrescar después de cada comentario.
Spam is an issue with any commenting system. El spam es un problema con cualquier sistema de comentarios. I have decided to strip html tags in the first iteration to deter spammers. He decidido tira etiquetas html en la primera iteración para disuadir a los spammers. As a personal decision I have decided not to capture email address. Como una decisión personal que he decidido no captura la dirección de correo electrónico. However it can be trivially added along with url if so desired. Sin embargo, puede ser añadido a lo largo de trivially con url si así lo desea.
I used Sajax as my Ajax framework. He utilizado mi SAJAX como marco Ajax. It presented Presentó few pocos problems as Sajax is more suited for PHP / Ruby pages and not HTML. problemas como SAJAX es más adecuado para PHP / Ruby páginas HTML y no. Here is Aquí está my solution mi solución .
Schema:
CREATE TABLE `comments` ( CREATE TABLE `comentarios` (
`id` INT NOT NULL AUTO_INCREMENT , `id` INT NOT NULL AUTO_INCREMENT,
`url` VARCHAR( 255 ) NOT NULL , `url` VARCHAR (255) NOT NULL,
`ip` VARCHAR( 30 ) NOT NULL , `ip` VARCHAR (30) NOT NULL,
`author` VARCHAR( 255 ) DEFAULT ‘Anonymous Coward’ NOT NULL , `autor` VARCHAR (255) DEFAULT 'Anónimo Coward' NOT NULL,
`location` VARCHAR( 255 ) DEFAULT ‘Cyberspace’ NOT NULL , «ubicación» VARCHAR (255) DEFAULT 'ciberespacio' NOT NULL,
`comment` TEXT NOT NULL , `comentario` TEXT NOT NULL,
`when` TIMESTAMP NOT NULL, `` cuando TIMESTAMP NOT NULL,
PRIMARY KEY ( `id` ) ) PRIMARY KEY ( `id`))
);
Design notes: Diseño de notas:
The code for adding comment passed the url of the page. El código para añadir comentarios aprobó la url de la página. When the page is loaded a sajax call is made to fetch all the comment for the url of the page. Cuando la página se carga una llamada SAJAX se hace para obtener todas las observaciones para la url de la página. New comments are displayed instantaneously as new comments are fetched after a comment has been submitted. Nueva comentarios se muestran instantáneamente como nuevos comentarios se han obtenido después de un comentario ha sido enviado. This can additionally fetch comments from other users. Esto puede además obtener comentarios de otros usuarios. However I have decided not to implement timed refresh as that may unnecessarily increase server load without adding much value to users. Sin embargo he decidido no aplicar el tiempo de refresco que pueda aumentar innecesariamente la carga del servidor sin agregar mucho valor a los usuarios. Validation checks are made to detect and not add duplicate comments. Comprobaciones de validación se realizan para detectar y no duplicar añadir comentarios. Comment throttling by same user can be added to prevent abuse. Comentario de la regulación mismo usuario puede ser añadido para evitar los abusos.
Hope that helps in designing your commenting system. Espero que ayude en el diseño de su sistema de comentarios.
Filed under Filed under CMS Software CMS Software , Headline News Headline News , How To Cómo , Open Source Software Open Source Software , PHP , Pro Blogging Blogging Pro , Spam Watch Spam Watch , Tech Note Nota técnica , Web , Web Services Web Services | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | este artículo |
Email this Article Enviar artículo
You may also like to read También puede leer |




June 10th, 2006 at 4:27 pm 10 de junio de 2006, a las 4:27 pm
I think that works as long as search engine indexing of the comments is not important (as you outlined in “When *NOT* to use AJAX.” Creo que funciona siempre y cuando la indexación de los motores de búsqueda de los comentarios no es importante (como se indica en "Cuando * NO * usar AJAX."
I don’t understand how stripping markup deters spammers. No entiendo cómo el paso de marcas disuade a los spammers. A spambot has no way of knowing whether you are stripping HTML/links or not. Un spambot no tiene forma de saber si usted es el paso de HTML / enlaces o no. It is just going to submit the spam and hope you leave the HTML intact. Es sólo va a presentar el spam y la esperanza de dejar intacto el HTML.
August 21st, 2006 at 12:15 pm 21 de Agosto de 2006 a las 12:15 pm
For antibots the best solution is generating a code automatically in an image. Por antibots la mejor solución es generar un código automáticamente en una imagen.
August 21st, 2006 at 12:33 pm Agosto 21, 2006 a las 12:33 pm
@Brian Brian @
> I think that works as long as search engine indexing of the comments is not important > Creo que funciona siempre y cuando la indexación de los motores de búsqueda de los comentarios no es importante
Definitely. Definitivamente. That is also a deterrent for spammers. Esto es también un elemento de disuasión para los spammers.
> A spambot has no way of knowing whether you are stripping HTML/links or not. > Un spambot no tiene forma de saber si usted es el paso de HTML / enlaces o no. It is just going to submit the spam and hope you leave the HTML intact. Es sólo va a presentar el spam y la esperanza de dejar intacto el HTML.
In my experience I have seen most spambots target sites with specific signature like those of WordPress or Movable Type. En mi experiencia he visto más spambots parcelas con destino específico la firma como los de WordPress o Movable Type. They spam based on site signature. Ellos spam basado en la obra la firma. So normally home-grown commenting system are unlikely to be invaded. Así que normalmente el hogar crecido sistema de comentarios es poco probable que se invadió. When they find a popular commenting system is stripping html then they will not have any incentive to develop code for that system. Cuando encuentran un popular sistema de comentarios es el paso de html, entonces no tendrá ningún incentivo para el desarrollo de código para ese sistema.
@Gunther Gunther @
Do you mean spambots & CAPTCHA? ¿Quiere decir spambots & CAPTCHA?
November 11th, 2007 at 6:56 pm 11 de noviembre de 2007, a las 6:56 pm
Thanks Gracias