changeset 269:53c79b52862a

Added
author Steve Kemp <steve@steve.org.uk>
date Mon, 04 Aug 2008 20:04:15 +0100
parents dbee53530497
children 6d4676b4f512
files themes/blog.mail-scanning.com/ajax.js themes/blog.mail-scanning.com/comment-form.inc themes/blog.mail-scanning.com/comment-loop.inc themes/blog.mail-scanning.com/entry.template themes/blog.mail-scanning.com/index.template themes/blog.mail-scanning.com/month.template themes/blog.mail-scanning.com/tags.template
diffstat 7 files changed, 183 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/blog.mail-scanning.com/ajax.js	Mon Aug 04 20:04:15 2008 +0100
@@ -0,0 +1,122 @@
+// -*-mode: C++; style: K&R; c-basic-offset: 4 ; -*- */
+//
+//  Simple collection of Javascript for Ajax form submission.
+//
+
+
+
+
+//
+//  Get an XMLHTTPRequest object.
+//
+function getXMLHTTPRequest()
+{
+    req = false;
+    if(window.XMLHttpRequest) 
+    {
+        try 
+        {
+             req = new XMLHttpRequest();
+        } 
+        catch(e) 
+        {
+             req = false;
+        }
+    }
+    else if(window.ActiveXObject)
+    {
+        try
+        {
+            req = new ActiveXObject("Msxml2.XMLHTTP");
+        }
+        catch(e) 
+        {
+            try 
+            {
+                req = new ActiveXObject("Microsoft.XMLHTTP");
+            } 
+            catch(e) 
+            {
+                req = false;
+            }
+        }
+    }
+ 
+    return( req );
+}
+
+
+//
+//  Submit the comment.
+//
+function submitComment() 
+{
+    showProgress();
+
+    var xhr = getXMLHTTPRequest();
+    if(! xhr ) 
+    {
+        hideProgress();
+        return;
+    }
+
+    xhr.onreadystatechange = function()
+    {
+        if(xhr.readyState == 4)
+        {
+            if(xhr.status  == 200)
+            {
+                var o = document.getElementById( "output" );
+                o.innerHTML = xhr.responseText;
+            }
+            else
+            {
+                var o = document.getElementById( "output" );
+                o.innerHTML = "Failed HTTP code " + xhr.status + " " +  xhr.responseText;
+            }
+
+            hideProgress();
+        }
+    };
+
+    data = 'ajax=1';
+    data = data + '&id=' + escape(document.forms[0].id.value );
+    data = data + '&captcha=' + escape( document.forms[0].captcha.value );
+    data = data + '&id=' + escape(document.forms[0].id.value );
+    data = data + '&captcha=' + escape( document.forms[0].captcha.value );
+    data = data + '&name=' + escape( document.forms[0].name.value );
+    data = data + '&mail=' + escape( document.forms[0].mail.value );
+    data = data + '&body=' + escape( document.forms[0].body.value );
+
+    //
+    //  Make the request
+    //
+    xhr.open("POST", "/cgi-bin/comments.cgi", true);
+    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+    xhr.send(data);
+}
+
+
+//
+//  Show our progress marker.
+//
+function showProgress()
+{
+    var i = document.getElementById( "progress" );
+    if ( i ) 
+    {
+        i.style.display = 'block';
+    }
+}
+
+//
+//  Hide our progress marker.
+//
+function hideProgress() 
+{
+    var i = document.getElementById( "progress" );
+    if ( i ) 
+    {
+        i.style.display = 'none';
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/blog.mail-scanning.com/comment-form.inc	Mon Aug 04 20:04:15 2008 +0100
@@ -0,0 +1,22 @@
+<!-- tmpl_if name='comments_enabled' -->
+<div id="output">
+<h3>Add A Comment</h3>
+<blockquote>
+<form action="/cgi-bin/comments.cgi" method="post">
+<input type="hidden" name="id" value="<!-- tmpl_var name='link' escape='html' -->">
+<input type="hidden" name="captcha" value="">
+<table>
+<tr><td>Your Name</td>
+    <td><input type="text" size="55" name="name"></td></tr>
+<tr><td>Your Email</td>
+    <td><input type="text" size="55" name="mail"></td></tr>
+<tr><td colspan="2">Your Comment<br />
+<textarea name="body" rows="10" cols="60">
+</textarea></td></tr>
+<tr><td></td><td align="right"><div id="progress" style="display:none;"><img src="progress.gif" alt="" width="36" height="36"></div><input type="submit" name="submit" value="Post Comment" onClick="submitComment(); return false;"></td></tr>
+</table>
+</form>
+<p>Your submission will be ignored if any field is left blank.  But your email address will not be displayed.</p>
+</blockquote>
+</div>
+<!-- /tmpl_if -->
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/blog.mail-scanning.com/comment-loop.inc	Mon Aug 04 20:04:15 2008 +0100
@@ -0,0 +1,12 @@
+<!-- tmpl_if name='comments' -->
+ <h3 id="comments">Comments On This Entry</h3>
+
+ <!-- tmpl_loop name='comments' -->
+ <div class="bubble">
+  <blockquote>
+   <!-- tmpl_var name='body' -->
+  </blockquote>
+  <cite><strong><!-- tmpl_var name='name' --></strong> <!-- tmpl_var name='date' --></cite>
+ </div>
+ <!-- /tmpl_loop -->
+<!-- /tmpl_if -->
--- a/themes/blog.mail-scanning.com/entry.template	Mon Aug 04 18:36:16 2008 +0100
+++ b/themes/blog.mail-scanning.com/entry.template	Mon Aug 04 20:04:15 2008 +0100
@@ -5,6 +5,10 @@
 
   <title><!-- tmpl_var name='blog_title' -->: <!-- tmpl_var name='title' --></title>
   <link rel="stylesheet" type="text/css" media="screen" href="<!-- tmpl_var name='top' -->layout.css">
+<!-- tmpl_if name='comments_enabled' -->
+  <script type="text/JavaScript" src="<!-- tmpl_var name='top' -->ajax.js"></script>
+<!-- /tmpl_if -->
+
  </head>
  <body>
 
@@ -23,6 +27,8 @@
   </div>
 
 
+<!-- tmpl_include name="comment-loop.inc" -->
+<!-- tmpl_include name="comment-form.inc" -->
 
 </div>
 <div id="left">
--- a/themes/blog.mail-scanning.com/index.template	Mon Aug 04 18:36:16 2008 +0100
+++ b/themes/blog.mail-scanning.com/index.template	Mon Aug 04 20:04:15 2008 +0100
@@ -10,7 +10,6 @@
 
  </head>
  <body>
-
 <!-- tmpl_include name='menu.inc' -->
 
  <div id="content">
@@ -27,6 +26,13 @@
   <!-- tmpl_else -->
     No tags
   <!-- /tmpl_if -->
+
+   <!-- tmpl_if name='comment_count' -->
+   <span class="comments">
+   <a href="<!-- tmpl_var name='top' --><!-- tmpl_var name='link' escape='html' -->#comments"><!-- tmpl_var name='comment_count' --> comment<!-- tmpl_if name='comment_plural' -->s<!-- /tmpl_if --></a>
+   </span>
+   <!-- /tmpl_if -->
+
   </div>
  </div>
  <p>&nbsp;</p>
--- a/themes/blog.mail-scanning.com/month.template	Mon Aug 04 18:36:16 2008 +0100
+++ b/themes/blog.mail-scanning.com/month.template	Mon Aug 04 20:04:15 2008 +0100
@@ -38,6 +38,13 @@
   No tags
  <!-- /tmpl_if -->
  </div>
+
+   <!-- tmpl_if name='comment_count' -->
+   <span class="comments">
+   <a href="<!-- tmpl_var name='top' --><!-- tmpl_var name='link' escape='html' -->#comments"><!-- tmpl_var name='comment_count' --> comment<!-- tmpl_if name='comment_plural' -->s<!-- /tmpl_if --></a>
+   </span>
+   <!-- /tmpl_if -->
+
 </div>
  <p>&nbsp;</p>
 <!-- /tmpl_loop -->
--- a/themes/blog.mail-scanning.com/tags.template	Mon Aug 04 18:36:16 2008 +0100
+++ b/themes/blog.mail-scanning.com/tags.template	Mon Aug 04 20:04:15 2008 +0100
@@ -35,6 +35,13 @@
   Tags: <!-- tmpl_loop name='tags' --><a href="<!-- tmpl_var name='top' -->tags/<!-- tmpl_var name='tag' escape='html' -->"><!-- tmpl_var name='tag' escape='html' --></a><!-- tmpl_if name="__last__" -->.<!-- tmpl_else -->, <!-- /tmpl_if --><!-- /tmpl_loop -->
  <!-- /tmpl_if -->
  </div>
+
+   <!-- tmpl_if name='comment_count' -->
+   <span class="comments">
+   <a href="<!-- tmpl_var name='top' --><!-- tmpl_var name='link' escape='html' -->#comments"><!-- tmpl_var name='comment_count' --> comment<!-- tmpl_if name='comment_plural' -->s<!-- /tmpl_if --></a>
+   </span>
+   <!-- /tmpl_if -->
+
 </div>
 <p>&nbsp;</p>
 <!-- /tmpl_loop -->