]> git.quilime.com - plog.git/commitdiff
comments
authorGabriel Dunne <gdunne@quilime.com>
Sun, 13 May 2012 08:25:38 +0000 (01:25 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Sun, 13 May 2012 08:25:38 +0000 (01:25 -0700)
15 files changed:
content/code/config
content/code/mostused
css/comments.css [new file with mode: 0644]
css/style.css
js/prettify/prettify.css
lib/comments.php [new file with mode: 0644]
lib/data.php
lib/init.php
lib/model.php
lib/recaptchalib.php [new file with mode: 0644]
pages/about
templates/comments.html.tpl [new file with mode: 0644]
templates/entry.html.tpl
templates/head-inc.html.tpl
templates/nav.html.tpl

index 38a8b8e13bf3be0581f90648e741dbd8722f71fd..b76bddfa34fb0e8991925997bb007196e4f21bc1 100644 (file)
@@ -1,2 +1,2 @@
-template = code
+
 --
index 30944b1a4f1f006362a1b22d7384cce1021555c3..2b451bf936e733ccb4cd3fa2eaa5b1751eeab1d8 100644 (file)
@@ -29,4 +29,4 @@ example
    5 ln
    4 mkdir
    4 ./scripts/content
-</pre>
\ No newline at end of file
+</pre>
diff --git a/css/comments.css b/css/comments.css
new file mode 100644 (file)
index 0000000..61a873b
--- /dev/null
@@ -0,0 +1,26 @@
+/* comments */
+
+.comments {
+    margin-top:50px;
+    color:#d04;
+}
+.comments textarea {
+    width:315px;
+    height:130px;
+}
+.comments .error {
+    color:#900;
+}
+.comments .comment {
+    margin:30px 0;
+}
+.comments .comment p {
+    margin:10px 0;
+}
+.comments .comment .name {
+    font-style:italic;
+    color:#600;
+}
+.comments .comment_form {
+    margin-top:40px;
+}
index fc105d735876822f92b9e2c1dfac3423d65d6b99..4576766dccd59cf0c42a9d84b7edc52bb1408aa9 100644 (file)
@@ -68,14 +68,17 @@ blockquote {
 }
 pre, code {
     color:#df0;
-    line-height:1.3em;
-    font-family: monaco, monospace;
+    line-height:1.4em;
+    font-size:14px;
+    font-family:menlo, monaco, "Lucida Console", monospace; 
     padding:1px 5px 2px;
     background:#090909;
-    border-radius:4px;
+    border-radius:3px;
 }
 pre {
-    padding:10px 30px;
+    padding:10px 20px;
+    position:relative;
+    left:-20px;
 }
 table, td, tr {
   margin:0;
index 24cce10bf81232dee24769a7af8a454c73b13f04..7384ce1854030138d570398ac8000822352f698b 100644 (file)
@@ -6,15 +6,12 @@
 .typ { color: #93d44f; }
 .lit { color: #099; }
 .pun { color: #66d; }
-.pln { color: #ffd; }
+.pln { color: #df0; }
 .tag { color: #008; }
 .atn { color: #606; }
 .atv { color: #080; }
 .dec { color: #606; }
-pre.prettyprint, code.prettyprint {
-  font-family:monaco, "Lucida Console", monospace; font-size:12px; line-height:1.5em; padding:0.2em 0.6em; background:#181818;
-  border-radius: 6px;
-}
+pre.prettyprint, code.prettyprint { }
 pre.prettyprint { padding:20px; }
 
 @media print {
diff --git a/lib/comments.php b/lib/comments.php
new file mode 100644 (file)
index 0000000..c413a0c
--- /dev/null
@@ -0,0 +1,118 @@
+<?php
+
+class Comments
+{      
+       var $comments = array();
+       var $comments_loc = '';
+       var $fileInfo = null;
+
+
+       function __construct( &$fileInfo ) {
+               $this->fileInfo = $fileInfo;
+               $this->comments = $this->get_comments( $fileInfo );
+               $this->comments_loc = get_comments_location($fileInfo);
+       }
+
+
+       /**
+        *      get comments
+        * @param fileInfo      the fileinfo object
+        * @return array()      comments
+        */
+       function get_comments(&$fileInfo)
+       {
+               $comments_location = get_comments_location($fileInfo);
+               $comments = array();
+               if (is_dir($comments_location)) {
+                       $dir_iterator = new DirectoryIterator($comments_location);
+                       foreach ($dir_iterator as $file => $info) {
+                               if (!$info->isDir() && !$info->isDot()) {
+                                       $contents = file_get_contents($info->getPath() . DIRECTORY_SEPARATOR . $info->getFilename());
+                                       $comments[] = json_decode($contents, true);
+                               }
+                       }
+               }
+               return $comments;
+       }
+
+
+       function create_comments_dir( &$dir )
+       {
+               try {
+                       if (!mkdir($dir, 0777, true)) {
+                               throw new Exception('Error creating comments directory');
+                       }
+               } catch (Exception $e) {
+                       echo 'Caught exception', $e->getMessage(), "\n";
+               }
+       }
+
+
+       function process_post_request() 
+       {
+               $this->_recaptcha_post_request();
+       }
+
+
+       # the response from reCAPTCHA
+       var $_recaptcha_resp = null;
+       # the error code from reCAPTCHA, if any
+       var $_recaptcha_error = null;
+       #error making comments
+       var $_comment_error = null;
+
+
+       function recaptcha_html()
+       {               
+               global $captcha_publickey, $captcha_privatekey;
+               if ($this->_comment_error)
+                       echo '<div class="error">', $this->_comment_error, '</div>';
+               echo recaptcha_get_html($captcha_publickey, $this->_recaptcha_error);
+       }
+
+
+       function _recaptcha_post_request() {
+
+               global $captcha_publickey, $captcha_privatekey;
+
+               # was there a reCAPTCHA response?
+               if (isset($_POST["recaptcha_response_field"])) {
+
+                       $this->_recaptcha_resp = recaptcha_check_answer ($captcha_privatekey,
+                                                                                       $_SERVER["REMOTE_ADDR"],
+                                                   $_POST["recaptcha_challenge_field"],
+                                                   $_POST["recaptcha_response_field"]);
+                       if ($this->_recaptcha_resp->is_valid) {
+
+                               $new_comment = array();
+                               $new_comment['name']    = !empty($_POST['name'])    ? $_POST['name']    : 'anon';
+                               $new_comment['www']     = !empty($_POST['www'])     ? $_POST['www']     : null;
+                               $new_comment['comment'] = !empty($_POST['comment']) ? $_POST['comment'] : null;
+                               $new_comment['timestamp'] = date('U');
+
+                               if (!$new_comment['comment']) {
+
+                                       $this->_comment_error = 'You must enter a comment.';
+
+                               } else {
+
+                                       if (!is_dir($this->comments_loc)) {
+                                               $this->create_comments_dir($this->comments_loc);
+                                       }
+
+                                       # put new comment
+                                       if (!file_put_contents($this->comments_loc . date('U') . '.json', json_encode($new_comment))) {
+                                               $_comment_error = 'error creating comment';
+                                       }
+
+                                       # all comments once new one is created
+                                       $this->comments = $this->get_comments( $this->fileInfo );
+                               }
+
+                       } else {
+                               # set the error code so that we can display it
+                               $this->_recaptcha_error = $this->_recaptcha_resp->error;
+                       }
+               }
+       }
+}
index 3d4a35fe249a94512d17bba576fc82cc35bb3cd2..08e03169f3d8cb479fe5019beffbd13650324117 100644 (file)
@@ -145,6 +145,9 @@ function parse_entry($fileInfo, $page = false)
        $f['tags'] = isset($f['config']['tags']) ? explode(" ", $f['config']['tags']) : null;
        $f['content'] = Markdown($content);
 
+       $f['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments'];
+       $f['comments'] = new Comments($fileInfo);       
+
     if ($passed_more)
       $f['content_short'] = Markdown($content_short);
 
@@ -163,6 +166,17 @@ function parse_entry($fileInfo, $page = false)
        return $f;
 }
 
+function get_comments_location ( &$fileInfo ) {
+       return LOCAL_ROOT . COMMENTS_DIR . get_clean_path($fileInfo) . DIRECTORY_SEPARATOR . $fileInfo->getFilename() . DIRECTORY_SEPARATOR;
+}
+
+function get_clean_path ( &$fileInfo, $page = false ) {
+       if (!$page) {
+               return str_replace(LOCAL_ROOT . CONTENT_DIR, "", clean_slashes($fileInfo->getPath()));
+       } else {
+               return str_replace(LOCAL_ROOT . PAGE_DIR, "", clean_slashes($fileInfo->getPath()));
+       }
+}
 
 function get_entry ( $relative_path )
 {
index 870319479996ae49135c0d7485645d5829663266..6ac949c0f20762909f55c20f16fb04e6671980f9 100644 (file)
@@ -30,6 +30,7 @@ define ('SITE_TITLE',                  'quilime');
 define ('LOCAL_ROOT',           '/home/quilime/quilime.com/');
 define ('WEB_ROOT',             '/');
 define ('CONTENT_DIR',                  'content/');
+define ('COMMENTS_DIR',      'comments/');
 define ('TEMPLATE_DIR',         'templates/');
 define ('PAGE_DIR',             'pages/');
 define ('CONFIG_DELIMITER',  '--');
@@ -42,6 +43,11 @@ $_FILE_IGNORES = array(CONFIG_FILE, '.DS_Store');
 
 
 
+# recaptcha for comments
+require_once 'recaptchalib.php';
+// Get a key from https://www.google.com/recaptcha/admin/create
+$captcha_publickey  = "6Lek-MkSAAAAAAZknQQGSx9DiCqm_wAiFGytc37d";
+$captcha_privatekey = "6Lek-MkSAAAAAK4FAaPKO0Cwp-iHa0OcUaqipee4";
 
 
 
@@ -51,3 +57,4 @@ require_once 'output.php';
 require_once 'markdown.php';
 require_once 'model.php';
 require_once 'view.php';
+require_once 'comments.php';
index 3cd2c00388b5c70d16899a9736bbc77c3d7fe6ae..86a5ddff47bb19c5e238272b97aff4ceaff00d8f 100644 (file)
@@ -51,6 +51,11 @@ class Model
                        // prev/next
                        $entries = get_entries($request['dirname']);
 
+                       // post request
+                       if ($_SERVER['REQUEST_METHOD'] == 'POST') 
+                               $this->process_post_request($this->entry);
+                       
+
                        for($i = count($entries)-1; $i>=0; $i--) {
                                if ($this->entry['url'] == $entries[$i]['url']) {
                                        $this->entry['prev_entry'] = isset($entries[$i-1]) ? $entries[$i-1] : null;
@@ -78,6 +83,11 @@ class Model
                }
        }
 
+       function process_post_request( &$entry ) {
+               if ($entry['comments']) 
+                       $entry['comments']->process_post_request();
+       }       
+
        function has_config()
        {
                return is_file(join(array( LOCAL_ROOT, CONTENT_DIR, $this->content_request, CONFIG_FILE ), DIRECTORY_SEPARATOR )) ? 1 : 0;
diff --git a/lib/recaptchalib.php b/lib/recaptchalib.php
new file mode 100644 (file)
index 0000000..32c4f4d
--- /dev/null
@@ -0,0 +1,277 @@
+<?php
+/*
+ * This is a PHP library that handles calling reCAPTCHA.
+ *    - Documentation and latest version
+ *          http://recaptcha.net/plugins/php/
+ *    - Get a reCAPTCHA API Key
+ *          https://www.google.com/recaptcha/admin/create
+ *    - Discussion group
+ *          http://groups.google.com/group/recaptcha
+ *
+ * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
+ * AUTHORS:
+ *   Mike Crawford
+ *   Ben Maurer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/**
+ * The reCAPTCHA server URL's
+ */
+define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
+define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
+define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
+
+/**
+ * Encodes the given data into a query string format
+ * @param $data - array of string elements to be encoded
+ * @return string - encoded request
+ */
+function _recaptcha_qsencode ($data) {
+        $req = "";
+        foreach ( $data as $key => $value )
+                $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
+
+        // Cut the last '&'
+        $req=substr($req,0,strlen($req)-1);
+        return $req;
+}
+
+
+
+/**
+ * Submits an HTTP POST to a reCAPTCHA server
+ * @param string $host
+ * @param string $path
+ * @param array $data
+ * @param int port
+ * @return array response
+ */
+function _recaptcha_http_post($host, $path, $data, $port = 80) {
+
+        $req = _recaptcha_qsencode ($data);
+
+        $http_request  = "POST $path HTTP/1.0\r\n";
+        $http_request .= "Host: $host\r\n";
+        $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
+        $http_request .= "Content-Length: " . strlen($req) . "\r\n";
+        $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
+        $http_request .= "\r\n";
+        $http_request .= $req;
+
+        $response = '';
+        if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
+                die ('Could not open socket');
+        }
+
+        fwrite($fs, $http_request);
+
+        while ( !feof($fs) )
+                $response .= fgets($fs, 1160); // One TCP-IP packet
+        fclose($fs);
+        $response = explode("\r\n\r\n", $response, 2);
+
+        return $response;
+}
+
+
+
+/**
+ * Gets the challenge HTML (javascript and non-javascript version).
+ * This is called from the browser, and the resulting reCAPTCHA HTML widget
+ * is embedded within the HTML form it was called from.
+ * @param string $pubkey A public key for reCAPTCHA
+ * @param string $error The error given by reCAPTCHA (optional, default is null)
+ * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
+
+ * @return string - The HTML to be embedded in the user's form.
+ */
+function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
+{
+       if ($pubkey == null || $pubkey == '') {
+               die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
+       }
+       
+       if ($use_ssl) {
+                $server = RECAPTCHA_API_SECURE_SERVER;
+        } else {
+                $server = RECAPTCHA_API_SERVER;
+        }
+
+        $errorpart = "";
+        if ($error) {
+           $errorpart = "&amp;error=" . $error;
+        }
+        return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
+
+       <noscript>
+               <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
+               <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
+               <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
+       </noscript>';
+}
+
+
+
+
+/**
+ * A ReCaptchaResponse is returned from recaptcha_check_answer()
+ */
+class ReCaptchaResponse {
+        var $is_valid;
+        var $error;
+}
+
+
+/**
+  * Calls an HTTP POST function to verify if the user's guess was correct
+  * @param string $privkey
+  * @param string $remoteip
+  * @param string $challenge
+  * @param string $response
+  * @param array $extra_params an array of extra variables to post to the server
+  * @return ReCaptchaResponse
+  */
+function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
+{
+       if ($privkey == null || $privkey == '') {
+               die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
+       }
+
+       if ($remoteip == null || $remoteip == '') {
+               die ("For security reasons, you must pass the remote ip to reCAPTCHA");
+       }
+
+       
+       
+        //discard spam submissions
+        if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
+                $recaptcha_response = new ReCaptchaResponse();
+                $recaptcha_response->is_valid = false;
+                $recaptcha_response->error = 'incorrect-captcha-sol';
+                return $recaptcha_response;
+        }
+
+        $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
+                                          array (
+                                                 'privatekey' => $privkey,
+                                                 'remoteip' => $remoteip,
+                                                 'challenge' => $challenge,
+                                                 'response' => $response
+                                                 ) + $extra_params
+                                          );
+
+        $answers = explode ("\n", $response [1]);
+        $recaptcha_response = new ReCaptchaResponse();
+
+        if (trim ($answers [0]) == 'true') {
+                $recaptcha_response->is_valid = true;
+        }
+        else {
+                $recaptcha_response->is_valid = false;
+                $recaptcha_response->error = $answers [1];
+        }
+        return $recaptcha_response;
+
+}
+
+/**
+ * gets a URL where the user can sign up for reCAPTCHA. If your application
+ * has a configuration page where you enter a key, you should provide a link
+ * using this function.
+ * @param string $domain The domain where the page is hosted
+ * @param string $appname The name of your application
+ */
+function recaptcha_get_signup_url ($domain = null, $appname = null) {
+       return "https://www.google.com/recaptcha/admin/create?" .  _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));
+}
+
+function _recaptcha_aes_pad($val) {
+       $block_size = 16;
+       $numpad = $block_size - (strlen ($val) % $block_size);
+       return str_pad($val, strlen ($val) + $numpad, chr($numpad));
+}
+
+/* Mailhide related code */
+
+function _recaptcha_aes_encrypt($val,$ky) {
+       if (! function_exists ("mcrypt_encrypt")) {
+               die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
+       }
+       $mode=MCRYPT_MODE_CBC;   
+       $enc=MCRYPT_RIJNDAEL_128;
+       $val=_recaptcha_aes_pad($val);
+       return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
+}
+
+
+function _recaptcha_mailhide_urlbase64 ($x) {
+       return strtr(base64_encode ($x), '+/', '-_');
+}
+
+/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */
+function recaptcha_mailhide_url($pubkey, $privkey, $email) {
+       if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
+               die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
+                    "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
+       }
+       
+
+       $ky = pack('H*', $privkey);
+       $cryptmail = _recaptcha_aes_encrypt ($email, $ky);
+       
+       return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);
+}
+
+/**
+ * gets the parts of the email to expose to the user.
+ * eg, given johndoe@example,com return ["john", "example.com"].
+ * the email is then displayed as john...@example.com
+ */
+function _recaptcha_mailhide_email_parts ($email) {
+       $arr = preg_split("/@/", $email );
+
+       if (strlen ($arr[0]) <= 4) {
+               $arr[0] = substr ($arr[0], 0, 1);
+       } else if (strlen ($arr[0]) <= 6) {
+               $arr[0] = substr ($arr[0], 0, 3);
+       } else {
+               $arr[0] = substr ($arr[0], 0, 4);
+       }
+       return $arr;
+}
+
+/**
+ * Gets html to display an email address given a public an private key.
+ * to get a key, go to:
+ *
+ * http://www.google.com/recaptcha/mailhide/apikey
+ */
+function recaptcha_mailhide_html($pubkey, $privkey, $email) {
+       $emailparts = _recaptcha_mailhide_email_parts ($email);
+       $url = recaptcha_mailhide_url ($pubkey, $privkey, $email);
+       
+       return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
+               "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
+
+}
+
+
+?>
index 5db10ad819129807d0dd7d53bdd14353a523e0a2..76643c4d1a03d7118ae850ff12ca8818ed9195fc 100644 (file)
@@ -5,26 +5,26 @@ title = about
 
 quilime is an ongoing collection of projects, sketches, ideas, and process by **gabriel dunne** ([www](http://gabrieldunne.com), [email](&#x6d;&#x61;&#x69;&#108;&#x74;&#111;&#x3a;&#x67;&#x64;&#x75;&#x6e;&#110;&#x65;&#x40;&#x71;&#117;&#105;&#x6c;&#x69;&#x6d;&#101;&#x2e;&#x63;&#111;&#x6d;))
 
-<br />
-
-built with <a href="http://git.quilime.com/?p=plog.git;a=summary">plog</a>, a static-file `p`roject`log` engine.
-
+quilime.com is built with <a href="http://git.quilime.com/?p=plog.git;a=summary">plog</a>, a static-file `p`roject`log` engine written in PHP.
 
 
 <!--add <a href="http://quilime.com/.rss" class="rss">.rss</a>-->
 
 <br />
 
+## related
+[aggregate](http://media.quilime.com/aggregate/) images  
+[clmpr](http://clmpr.com/quilime/)  links  
 
+<br />
+
+## elsewhere
+[twitter (@quilime)](http://twitter.com/quilime/)  
+[vimeo](http://vimeo.com/quilime/)  
+[github](http://github.com/quilime/)  
+[flickr](http://flickr.com/photos/quilime/)  
 
 
 
 
 
-## elsewhere
-[clmpr.com/quilime](http://clmpr.com/quilime/)  
-[media.quilime.com/aggregate/](http://media.quilime.com/aggregate/)  
-[github.com/quilime](http://github.com/quilime/)  
-[flickr.com/photos/quilime](http://flickr.com/photos/quilime/)  
-[vimeo.com/quilime](http://vimeo.com/quilime/)  
-[twitter.com/quilime](http://twitter.com/quilime/)  
diff --git a/templates/comments.html.tpl b/templates/comments.html.tpl
new file mode 100644 (file)
index 0000000..2f8cbf6
--- /dev/null
@@ -0,0 +1,33 @@
+
+<div class="comments">
+       <h2>comments</h2>
+
+       <a name="c"></a>
+       <div class="comment_list">
+               
+               <? foreach($entry['comments']->comments as $comment) : ?>
+               <div class="comment">
+                       <?=Markdown($comment['comment']);?>
+                       <div class="name"><?=$comment['name'];?>, <?=approximate_time(date('U') - $comment['timestamp'])?> ago</div>
+               </div>
+               <? endforeach; ?>
+
+       </div>
+       
+       <div class="comment_form">
+
+    <form action="" method="post">
+    <label for="name">name</label><br /><input type="text" name="name" />
+    <br />
+    comment<br />
+    <textarea name="comment"></textarea>
+    <br />
+    
+       <?php echo $entry['comments']->recaptcha_html(); ?>
+
+    <br/>
+    <input type="submit" value="submit" />
+
+    </form>
+       </div>
+</div>
index ae845d1655ca3357d80c11873a3c7a563d17ca03..e21bca3c28ac32df5c47ef874eee1ad641810190 100644 (file)
@@ -16,4 +16,9 @@
                <a href="/<?=$entry['cat']['url'];?>">/<?=$entry['cat']['url'];?></a><? if ($entry['tags']) echo '<br/>tags: ' . implode(', ', $entry['tags']); ?>
        </div>
 
+       <? 
+       if ($entry['is_single'] && $entry['comments_enabled'])
+               $this->include_template('comments.html.tpl', array('entry' => $entry));
+       ?>      
+
 </div>
index ed48403054a9a2cfcb329eb6f5ac84020edfc6d4..8a61884848c6ca0bf8dda70fec8503fd05c76f10 100644 (file)
@@ -7,6 +7,7 @@
 
 <link rel="stylesheet" href="<?= get_base_dir(); ?>/css/style.css" type="text/css">
 
+<script type="text/javascript" src="<?= get_base_dir(); ?>/js/prettify/prettify.js"></script>
 <link href="<?= get_base_dir(); ?>/js/prettify/prettify.css" type="text/css" rel="stylesheet" />
 <script type="text/javascript" src="<?= get_base_dir(); ?>/js/jquery-1.3.2.min.js"></script>
 <script type="text/javascript" src="<?= get_base_dir(); ?>/js/prettify/prettify.js"></script>
@@ -35,5 +36,16 @@ $(document).ready(function() {
 */ ?>
 <link rel="alternate" type="application/rss+xml" title="RSS" href="<?=get_base_dir();?>/.rss" />
 <link rel="stylesheet" href="<?=get_base_dir();?>/css/style.css" type="text/css">
+<link rel="stylesheet" href="<?=get_base_dir();?>/css/comments.css" type="text/css">
+
+<script type="text/javascript" src="/js/prettify/prettify.js"></script>
+<link href="/js/prettify/prettify.css" type="text/css" rel="stylesheet" />
+
+<script>
+window.onload = function() {
+    prettyPrint();
+}
+</script>
+
+
 
-<? /* <!-- >>>>>>> 2ae0cd949c331f83dcb05116cffdca21b2ecb871 --> */ ?> 
index 6b0b116197181d7b31b7b0fa59e6e5f6f277bce7..28e773d46df5ac0d2d54f7e18d5bc873b38eb9f6 100644 (file)
@@ -12,7 +12,7 @@
 
     <br />
 
-       <li><a href="/agg">aggregate</a></li>
+       <!-- <li><a href="/agg">aggregate</a></li> -->
        <li><a href="/photo">photo</a></li>
        <li><a href="/links">links</a></li>
        <li><a href="/about">about</a></li>