Permalink
Browse files

Added a comment system

  • Loading branch information...
1 parent a853eae commit 1c6f249de3b689124e4aa4757a79b834ec2c01f5 @hugoduncan committed Mar 31, 2009
View
@@ -0,0 +1,157 @@
+#!/usr/bin/perl -w
+#
+# Based on chronicle's comments.cgi.
+#
+# This is a simple script which is designed to accept comment requests,
+# and save the details to local text files upon the localhost.
+#
+# This code is very simple and should be easy to extend with anti-spam
+# at a later point.
+#
+# NOTE: If you wish to use this you must edit three things at the
+# top of the script.
+#
+# 1. The email address to notify.
+# 2. The email address to use as the sender.
+
+use strict;
+use warnings;
+
+use CGI;
+use POSIX qw(strftime);
+
+#
+# The notification addresses - leave blank to disable
+#
+my $TO = 'comments@hugoduncan.org';
+my $FROM = 'weblog@hugoduncan.org';
+
+#
+# Find sendmail
+#
+my $SENDMAIL = undef;
+foreach my $file (qw ! /usr/lib/sendmail /usr/sbin/sendmail !)
+{
+ $SENDMAIL = $file if ( -x $file );
+}
+
+
+#
+# Get the parameters from the request.
+#
+my $cgi = new CGI();
+my $name = $cgi->param('name') || undef;
+my $mail = $cgi->param('mail') || undef;
+my $body = $cgi->param('body') || undef;
+my $id = $cgi->param('id') || undef;
+my $uri = $cgi->param('uri') || undef;
+my $cap = $cgi->param('captcha') || undef;
+my $ajax = $cgi->param("ajax") || 0;
+
+
+#
+# If any are missing just redirect back to the referer.
+#
+if ( !defined($name) ||
+ !length($name) ||
+ !defined($uri) ||
+ !length($uri) ||
+ !defined($body) ||
+ !length($body) ||
+ !defined($id) ||
+ !length($id) )
+{
+ if ($ajax)
+ {
+ print "Content-type: text/html\n\n";
+ print "Missing fields.\n";
+ }
+ else
+ {
+ print "Location: " . $ENV{ 'HTTP_REFERER' } . "\n\n";
+ }
+ exit;
+}
+
+#
+# Does the captcha value contain text? If so spam.
+#
+if ( defined($cap) && length($cap) )
+{
+ if ($ajax)
+ {
+ print "Content-type: text/html\n\n";
+ print "Missing fields.\n";
+ }
+ else
+ {
+ print "Location: " . $ENV{ 'HTTP_REFERER' } . "/\n\n";
+ }
+ exit;
+}
+
+
+
+#
+# get the current time
+#
+my $timestr = strftime "%Y-%m-%dT%H:%M:%S.000000Z", gmtime;
+
+
+#
+# Send a mail.
+#
+if ( length($TO) && length($FROM) && defined($SENDMAIL) )
+{
+ open( SENDMAIL, "|$SENDMAIL -t -f $FROM" );
+ print SENDMAIL "To: $TO\n";
+ print SENDMAIL "From: $FROM\n";
+ print SENDMAIL "Subject: New Comment [$id]\n";
+ print SENDMAIL "Content-type: text/html\n";
+ print SENDMAIL "X-Blogen-Name: $name\n";
+ print SENDMAIL "X-Blogen-Mail: $mail\n";
+ print SENDMAIL "X-Blogen-Uri: $uri\n";
+ print SENDMAIL "X-Blogen-User-Agent: $ENV{'HTTP_USER_AGENT'}\n";
+ print SENDMAIL "X-Blogen-IP-Address: $ENV{'REMOTE_ADDR'}\n";
+ print SENDMAIL "X-Blogen-When: $timestr\n";
+ print SENDMAIL "X-Blogen-id: $id\n";
+ print SENDMAIL "\n";
+ print SENDMAIL $body;
+ close(SENDMAIL);
+}
+
+#
+# Now show the user the thanks message..
+#
+
+#
+# Show the header
+#
+print "Content-type: text/html\n\n";
+
+if ( $cgi->param("ajax") )
+{
+ print <<EOF;
+<h3>Comment Submitted</h3>
+<blockquote>
+<p>Thanks for your comment, it will be made live when the queue is moderated next.</p>
+</blockquote>
+
+EOF
+ exit;
+}
+else
+{
+ print <<EOF;
+<html>
+ <head>
+ <title>Thanks For Your Comment</title>
+ </head>
+ <body>
+ <h2>Thanks!</h2>
+ <p>Your comment will be included the next time this blog is rebuilt.</p>
+ <p><a href="$ENV{'HTTP_REFERER'}">Return to blog</a>.</p>
+ </body>
+</html>
+EOF
+}
View
@@ -13,12 +13,13 @@
:maintainer "Hugo Duncan <hugo@hugoduncan.org>"
:licence "BSD Open Source"
:description "A generator for blog sites."
- :depends-on (:cxml :cl-fad :elephant :local-time :flexi-streams)
+ :depends-on (:cxml :cl-fad :elephant :local-time :flexi-streams :mel-base :cl-ppcre :babel)
:components
((:module "src"
:components
((:file "package" )
- (:file "post" :depends-on ("package"))))))
+ (:file "post" :depends-on ("package"))
+ (:file "comment-mail" :depends-on ("post"))))))
(defsystem #:cl-blog-generator-test
:name "cl-blog-generator-test"
View
@@ -9,7 +9,7 @@
<author><name>Hugo Duncan</name></author>
<subtitle>Development Blog</subtitle>
<rights>All content written by Hugo Duncan and photos by Hugo Duncan Copyright Hugo Duncan, all rights reserved.</rights>
- <updated>2009-03-27T12:04:28.596533-04:00</updated>
+ <updated>2009-03-30T20:47:43.919555-04:00</updated>
<entry xml:base="http://hugoduncan.github.com/cl-blog-generator/content/site/"><title>Blog Site Generators</title><link href="http://hugoduncan.github.com/cl-blog-generator/content/site/post/2009/blog_site_generators.xhtml"/><id>http://hugoduncan.github.com/cl-blog-generator/content/site/post/2009/blog_site_generators.xhtml</id><published>2009-03-26T20:00:00.000000-04:00</published><updated>2009-03-26T20:00:00.000000-04:00</updated><published>2009-03-26T20:00:00.000000-04:00</published><category scheme="http://hugoduncan.github.com/cl-blog-generator/content/site/tags" term="cl-blog-generator"/><category scheme="http://hugoduncan.github.com/cl-blog-generator/content/site/tags" term="lisp"/><category scheme="http://hugoduncan.github.com/cl-blog-generator/content/site/tags" term="blog"/><summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>
I recently uploaded some links to my <a href="http://github.com/hugoduncan/cl-blog-generator">cl-blog-generator</a> project, and have been getting some feedback with comparisons to other blog site generators, or compilers, such as <a href="http://www.advogato.org/person/Stevey/">Steve Kemp</a>'s <a href="http://www.steve.org.uk/Software/chronicle/">Chronicle</a>, or <a href="http://github.com/mojombo/jekyll">Jekyll</a> as used on <a href="http://github.com/blog/272-github-pages">GitHub Pages</a>. Compared to these, cl-blog-generator is immature, but takes a different approach in several areas that <a href="http://advogato.org/person/chalst/">Charles Stewart</a> suggested might be worth exploring. I look forward to any comments you might have.
View
@@ -13,10 +13,24 @@
<div id="container">
<div id="banner"><h1>cl-blog-generator</h1></div>
<div id="centercontent">
-<div id="posts"><div class="post-synopsis"><span class="post-link"><a href="post/2009/blog_site_generators.xhtml">Blog Site Generators</a></span><p>
+<div class="posts">
+ <div class="post-link-with-synopsis">
+ <span class="post-link"><a href="post/2009/blog_site_generators.xhtml">Blog Site Generators</a></span> ·
+ <span class="post-synopsis"><p>
I recently uploaded some links to my <a href="http://github.com/hugoduncan/cl-blog-generator">cl-blog-generator</a> project, and have been getting some feedback with comparisons to other blog site generators, or compilers, such as <a href="http://www.advogato.org/person/Stevey/">Steve Kemp</a>'s <a href="http://www.steve.org.uk/Software/chronicle/">Chronicle</a>, or <a href="http://github.com/mojombo/jekyll">Jekyll</a> as used on <a href="http://github.com/blog/272-github-pages">GitHub Pages</a>. Compared to these, cl-blog-generator is immature, but takes a different approach in several areas that <a href="http://advogato.org/person/chalst/">Charles Stewart</a> suggested might be worth exploring. I look forward to any comments you might have.
-</p></div><div class="post-synopsis"><span class="post-link"><a href="post/2009/blog_generator_configuration.xhtml">Blog Generator Configuration</a></span><p>The blog generator is intended to be quite flexible, within the design constraints, which has lead to a large number of possible configurations, both on the lisp side, and for Emacs. Drafts can be written using any editor, but I shall describe use with Emacs. The package has only been tested with SBCL, but should work with any common lisp implentation.</p></div><div class="post-synopsis"><span class="post-link"><a href="post/2009/blog_generator_design.xhtml">Blog Generator Design</a></span><p>I want to be able publish posts easily to a statically served site. I am sure that there are lots of blog site generators out there, but I could not find one that I liked, and which was in a language I would enjoy hacking, and so I wrote my own.</p></div></div>
-<div id="footer"/>
+</p></span>
+ </div>
+
+ <div class="post-link-with-synopsis">
+ <span class="post-link"><a href="post/2009/blog_generator_configuration.xhtml">Blog Generator Configuration</a></span> ·
+ <span class="post-synopsis"><p>The blog generator is intended to be quite flexible, within the design constraints, which has lead to a large number of possible configurations, both on the lisp side, and for Emacs. Drafts can be written using any editor, but I shall describe use with Emacs. The package has only been tested with SBCL, but should work with any common lisp implentation.</p></span>
+ </div>
+
+ <div class="post-link-with-synopsis">
+ <span class="post-link"><a href="post/2009/blog_generator_design.xhtml">Blog Generator Design</a></span> ·
+ <span class="post-synopsis"><p>I want to be able publish posts easily to a statically served site. I am sure that there are lots of blog site generators out there, but I could not find one that I liked, and which was in a language I would enjoy hacking, and so I wrote my own.</p></span>
+ </div>
+</div>
</div>
<div id="rightcontent">
@@ -54,7 +54,11 @@
<div id="post-title">Blog Generator Configuration</div>
<div>Written: <span id="post-when">4-3-2009</span></div>
<div><span id="post-updated"/></div>
-Tags: <div class="post-tags"><ul><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/lisp.xhtml">lisp</a></span></li></ul></div>
+Tags: <div id="post-tags">
+<ul class="post-tags">
+ <li class="post-tag"><a href="/cl-blog-generator/content/site/tag/lisp.xhtml">lisp</a></li>
+</ul>
+</div>
</div>
</div>
</div>
@@ -37,7 +37,15 @@
<div id="post-title">Blog Generator Design</div>
<div>Written: <span id="post-when">4-3-2009</span></div>
<div><span id="post-updated"/></div>
-Tags: <div class="post-tags"><ul><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/generator.xhtml">generator</a></span></li><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/blog.xhtml">blog</a></span></li><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/lisp.xhtml">lisp</a></span></li></ul></div>
+Tags: <div id="post-tags">
+<ul class="post-tags">
+ <li class="post-tag"><a href="/cl-blog-generator/content/site/tag/generator.xhtml">generator</a></li>
+
+ <li class="post-tag"><a href="/cl-blog-generator/content/site/tag/blog.xhtml">blog</a></li>
+
+ <li class="post-tag"><a href="/cl-blog-generator/content/site/tag/lisp.xhtml">lisp</a></li>
+</ul>
+</div>
</div>
</div>
</div>
@@ -75,7 +75,15 @@ However, having <a href="http://common-lisp.net/project/elephant/">Elephant</a>
<div id="post-title">Blog Site Generators</div>
<div>Written: <span id="post-when">27-3-2009</span></div>
<div><span id="post-updated"/></div>
-Tags: <div class="post-tags"><ul><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/clbloggenerator.xhtml">cl-blog-generator</a></span></li><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/lisp.xhtml">lisp</a></span></li><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/blog.xhtml">blog</a></span></li></ul></div>
+Tags: <div id="post-tags">
+<ul class="post-tags">
+ <li class="post-tag"><a href="/cl-blog-generator/content/site/tag/clbloggenerator.xhtml">cl-blog-generator</a></li>
+
+ <li class="post-tag"><a href="/cl-blog-generator/content/site/tag/lisp.xhtml">lisp</a></li>
+
+ <li class="post-tag"><a href="/cl-blog-generator/content/site/tag/blog.xhtml">blog</a></li>
+</ul>
+</div>
</div>
</div>
</div>
@@ -9,7 +9,7 @@
<author><name>Hugo Duncan</name></author>
<subtitle>Development Blog</subtitle>
<rights>All content written by Hugo Duncan and photos by Hugo Duncan Copyright Hugo Duncan, all rights reserved.</rights>
- <updated>2009-03-27T12:04:28.810283-04:00</updated>
+ <updated>2009-03-30T20:47:44.151965-04:00</updated>
<entry xml:base="http://hugoduncan.github.com/cl-blog-generator/content/site/"><title>Blog Site Generators</title><link href="http://hugoduncan.github.com/cl-blog-generator/content/site/post/2009/blog_site_generators.xhtml"/><id>http://hugoduncan.github.com/cl-blog-generator/content/site/post/2009/blog_site_generators.xhtml</id><published>2009-03-26T20:00:00.000000-04:00</published><updated>2009-03-26T20:00:00.000000-04:00</updated><published>2009-03-26T20:00:00.000000-04:00</published><category scheme="http://hugoduncan.github.com/cl-blog-generator/content/site/tags" term="cl-blog-generator"/><category scheme="http://hugoduncan.github.com/cl-blog-generator/content/site/tags" term="lisp"/><category scheme="http://hugoduncan.github.com/cl-blog-generator/content/site/tags" term="blog"/><summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>
I recently uploaded some links to my <a href="http://github.com/hugoduncan/cl-blog-generator">cl-blog-generator</a> project, and have been getting some feedback with comparisons to other blog site generators, or compilers, such as <a href="http://www.advogato.org/person/Stevey/">Steve Kemp</a>'s <a href="http://www.steve.org.uk/Software/chronicle/">Chronicle</a>, or <a href="http://github.com/mojombo/jekyll">Jekyll</a> as used on <a href="http://github.com/blog/272-github-pages">GitHub Pages</a>. Compared to these, cl-blog-generator is immature, but takes a different approach in several areas that <a href="http://advogato.org/person/chalst/">Charles Stewart</a> suggested might be worth exploring. I look forward to any comments you might have.
@@ -13,10 +13,19 @@
<div id="container">
<div id="banner"><h1>cl-blog-generator :</h1></div>
<div id="centercontent">
-<div id="posts"><div class="post-synopsis"><span class="post-link"><a href="/Users/duncan/projects/blog/content/site/post/2009/blog_site_generators.xhtml">Blog Site Generators</a></span><p>
+<div class="posts">
+ <div class="post-link-with-synopsis">
+ <span class="post-link"><a href="/Users/duncan/projects/blog/content/site/post/2009/blog_site_generators.xhtml">Blog Site Generators</a></span> ·
+ <span class="post-synopsis"><p>
I recently uploaded some links to my <a href="http://github.com/hugoduncan/cl-blog-generator">cl-blog-generator</a> project, and have been getting some feedback with comparisons to other blog site generators, or compilers, such as <a href="http://www.advogato.org/person/Stevey/">Steve Kemp</a>'s <a href="http://www.steve.org.uk/Software/chronicle/">Chronicle</a>, or <a href="http://github.com/mojombo/jekyll">Jekyll</a> as used on <a href="http://github.com/blog/272-github-pages">GitHub Pages</a>. Compared to these, cl-blog-generator is immature, but takes a different approach in several areas that <a href="http://advogato.org/person/chalst/">Charles Stewart</a> suggested might be worth exploring. I look forward to any comments you might have.
-</p></div><div class="post-synopsis"><span class="post-link"><a href="/Users/duncan/projects/blog/content/site/post/2009/blog_generator_design.xhtml">Blog Generator Design</a></span><p>I want to be able publish posts easily to a statically served site. I am sure that there are lots of blog site generators out there, but I could not find one that I liked, and which was in a language I would enjoy hacking, and so I wrote my own.</p></div></div>
-<div id="footer"/>
+</p></span>
+ </div>
+
+ <div class="post-link-with-synopsis">
+ <span class="post-link"><a href="/Users/duncan/projects/blog/content/site/post/2009/blog_generator_design.xhtml">Blog Generator Design</a></span> ·
+ <span class="post-synopsis"><p>I want to be able publish posts easily to a statically served site. I am sure that there are lots of blog site generators out there, but I could not find one that I liked, and which was in a language I would enjoy hacking, and so I wrote my own.</p></span>
+ </div>
+</div>
</div>
<div id="rightcontent">
@@ -30,7 +39,7 @@ I recently uploaded some links to my <a href="http://github.com/hugoduncan/cl-bl
</a></div>
</div>
<hr/>
-Related Tags: <div class="tags-related"><ul><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/clbloggenerator.xhtml">cl-blog-generator</a></span></li><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/generator.xhtml">generator</a></span></li><li><span class="tag"><a href="/cl-blog-generator/content/site/tag/lisp.xhtml">lisp</a></span></li></ul></div>
+Related Tags: <div class="tags-related"><ul><li><a href="/cl-blog-generator/content/site/tag/clbloggenerator.xhtml">cl-blog-generator</a></li><li><a href="/cl-blog-generator/content/site/tag/generator.xhtml">generator</a></li><li><a href="/cl-blog-generator/content/site/tag/lisp.xhtml">lisp</a></li></ul></div>
</div>
</div>
</body>
@@ -9,7 +9,7 @@
<author><name>Hugo Duncan</name></author>
<subtitle>Development Blog</subtitle>
<rights>All content written by Hugo Duncan and photos by Hugo Duncan Copyright Hugo Duncan, all rights reserved.</rights>
- <updated>2009-03-27T12:04:28.655989-04:00</updated>
+ <updated>2009-03-30T20:47:43.993889-04:00</updated>
<entry xml:base="http://hugoduncan.github.com/cl-blog-generator/content/site/"><title>Blog Site Generators</title><link href="http://hugoduncan.github.com/cl-blog-generator/content/site/post/2009/blog_site_generators.xhtml"/><id>http://hugoduncan.github.com/cl-blog-generator/content/site/post/2009/blog_site_generators.xhtml</id><published>2009-03-26T20:00:00.000000-04:00</published><updated>2009-03-26T20:00:00.000000-04:00</updated><published>2009-03-26T20:00:00.000000-04:00</published><category scheme="http://hugoduncan.github.com/cl-blog-generator/content/site/tags" term="cl-blog-generator"/><category scheme="http://hugoduncan.github.com/cl-blog-generator/content/site/tags" term="lisp"/><category scheme="http://hugoduncan.github.com/cl-blog-generator/content/site/tags" term="blog"/><summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>
I recently uploaded some links to my <a href="http://github.com/hugoduncan/cl-blog-generator">cl-blog-generator</a> project, and have been getting some feedback with comparisons to other blog site generators, or compilers, such as <a href="http://www.advogato.org/person/Stevey/">Steve Kemp</a>'s <a href="http://www.steve.org.uk/Software/chronicle/">Chronicle</a>, or <a href="http://github.com/mojombo/jekyll">Jekyll</a> as used on <a href="http://github.com/blog/272-github-pages">GitHub Pages</a>. Compared to these, cl-blog-generator is immature, but takes a different approach in several areas that <a href="http://advogato.org/person/chalst/">Charles Stewart</a> suggested might be worth exploring. I look forward to any comments you might have.
Oops, something went wrong.

0 comments on commit 1c6f249

Please sign in to comment.