Skip to content

Commit

Permalink
Added a comment system
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoduncan committed Mar 31, 2009
1 parent a853eae commit 1c6f249
Show file tree
Hide file tree
Showing 27 changed files with 969 additions and 174 deletions.
157 changes: 157 additions & 0 deletions cgi-bin/comments.cgi
Original file line number Diff line number Diff line change
@@ -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
}
5 changes: 3 additions & 2 deletions cl-blog-generator.asd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion content/site/index.atom
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 17 additions & 3 deletions content/site/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
6 changes: 5 additions & 1 deletion content/site/post/2009/blog_generator_configuration.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 9 additions & 1 deletion content/site/post/2009/blog_generator_design.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 9 additions & 1 deletion content/site/post/2009/blog_site_generators.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion content/site/tag/blog.atom
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 13 additions & 4 deletions content/site/tag/blog.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion content/site/tag/clbloggenerator.atom
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 1c6f249

Please sign in to comment.