]> git.quilime.com - plog.git/commitdiff
comments stuff
authorGabriel Dunne <gdunne@quilime.com>
Fri, 11 Nov 2011 12:47:55 +0000 (18:17 +0530)
committerGabriel Dunne <gdunne@quilime.com>
Fri, 11 Nov 2011 12:47:55 +0000 (18:17 +0530)
content/categori1/cat_2/hello_comments
content/category_2/cat_2/hello_comments2 [new file with mode: 0644]
css/comments.css [deleted file]
css/style.css
lib/comments.php [deleted file]
lib/data.php
lib/init.php
templates/comments.html.tpl [deleted file]
templates/entry.html.tpl
templates/single.html.tpl

index b395a5dbd5905c90c6c046ceec98707eaf169bbe..c44983d8f848db806bdedd1039896a249e33e4e0 100644 (file)
@@ -1,6 +1,5 @@
-       
 date = today
 comments = 1
 --
 
-Hello again. Leave some comments.
\ No newline at end of file
+Hello again.
\ No newline at end of file
diff --git a/content/category_2/cat_2/hello_comments2 b/content/category_2/cat_2/hello_comments2
new file mode 100644 (file)
index 0000000..3a8b8e5
--- /dev/null
@@ -0,0 +1,5 @@
+date = today
+comments = 1
+--
+
+Hello again. Leave some comments again;
\ No newline at end of file
diff --git a/css/comments.css b/css/comments.css
deleted file mode 100644 (file)
index f45764c..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* comments */
-
-.comments {
-    margin-top:50px;
-}
-.comments textarea {
-       width:315px;
-       height:130px;
-}
-.comments .error {
-       color:#900;
-}
-.comments .comment {
-
-    margin:20px 0;
-}
-.comments .comment .name {
-    font-style:italic;
-    color:#aaa;
-}
-.comments .comment_form {
-    margin-top:40px;
-}
\ No newline at end of file
index a7d734c560fabddc67d4b0913cdeee88fa5d6462..f040e5225999c8104848559d7ff730b044ecc377 100644 (file)
@@ -81,4 +81,10 @@ pre {
 .entry .metadata .tags li { 
     display:inline-block; 
     margin-right:0.3em; 
+}
+
+
+.comments {
+    margin:50px 50px;
+    
 }
\ No newline at end of file
diff --git a/lib/comments.php b/lib/comments.php
deleted file mode 100644 (file)
index c413a0c..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-<?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 129b419452648542f3aeb1050d1cd647b1e5698c..196e6ed233994db25e543bb9f3125065613b9675 100644 (file)
@@ -153,8 +153,7 @@ function parse_entry($fileInfo, $page = false)
        $f['timestamp'] = $f['config']['date'] ? date('U', strtotime( $f['config']['date'])) : $fileInfo->getCTime();
        $f['tags'] = isset($f['config']['tags']) ? explode(" ", $f['config']['tags']) : null;
 
-       $f['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments'];
-       $f['comments'] = new Comments($fileInfo); 
+       $f['comments'] = isset($f['config']['comments']) && $f['config']['comments'];
     
     $f['content'] = Markdown($content);
 
index 9e84f7cc47f6102d679e4cf09d18711f3c244795..187b6527a34be59e378ae15b65a14036a65bcfa9 100644 (file)
@@ -34,14 +34,10 @@ define ('MORE_DELIM',                '<!--more-->');
 define ('TITLE_DELIMITER',      ' &mdash; ');
 define ('ENTRY_DATE_FORMAT', 'M d Y, h:i:s A T');
 
-$_FILE_IGNORES = array(CONFIG_FILE, '.DS_Store');
-
+# external comment system
+define ('DISQUS_SHORTNAME',  'quilime')
 
-# 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";
+$_FILE_IGNORES = array(CONFIG_FILE, '.DS_Store');
 
 
 # includes
@@ -50,5 +46,3 @@ require_once 'output.php';
 require_once 'markdown.php';
 require_once 'model.php';
 require_once 'view.php';
-require_once 'comments.php';
-
diff --git a/templates/comments.html.tpl b/templates/comments.html.tpl
deleted file mode 100644 (file)
index f4459d1..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-
-<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">
-    <input type="text" name="name" /><label for="name">name</label>  <br />
-    <input type="text" name="www" /><label for="www">www (optional)</label>  <br />
-    <textarea name="comment"></textarea>
-    <br />
-    
-       <?php echo $entry['comments']->recaptcha_html(); ?>
-
-    <br/>
-    <input type="submit" value="submit" />
-
-    </form>
-       </div>
-</div>
index d5c4c205d308b433e87f780039374d6361a3d7b8..755e5a33285d125ddea93abe68200a6f2c6bf422 100644 (file)
@@ -15,9 +15,6 @@
                <? if (!empty($entry['cat']['name'])): ?>
                in <a href="<?=$entry['cat']['url'];?>"><?=$entry['cat']['name'];?></a>
                <? endif; ?>            
-               <? if (count($entry['comments']->comments) > 0 || $entry['comments_enabled']) : ?>
-               | <a href="<?=$entry['url'];?>#c"><? echo sizeof($entry['comments']->comments) ?> comments</a>
-               <? endif; ?>            
                <br />
                <ul class="tags">
                <? if ($entry['tags']) foreach($entry['tags'] as $tag) : ?>
@@ -26,9 +23,4 @@
                </ul>
        </div>  
 
-       <? 
-       if ($entry['comments_enabled'])
-               $this->include_template('comments.html.tpl', array('entry' => $entry));
-       ?>
-
 </div>
index cae3f0234eddb2c62a96abede5a6c77d8fa83144..4bb5e76bbe12afd51d8bbf269b4c550477f3ff8d 100644 (file)
                <? $this->include_template('nextprev.html.tpl'); ?>
        </div>
 
+       <? if ($entry['comments']) : ?>
+       <div class="comments">
+               
+<div id="disqus_thread"></div>
+<script type="text/javascript">
+    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
+    var disqus_shortname = 'quilime'; // required: replace example with your forum shortname
+
+    /* * * DON'T EDIT BELOW THIS LINE * * */
+    (function() {
+        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
+        dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
+        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+    })();
+</script>
+<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
+
+
+       </div>
+       <? endif; ?>
+
        <? $this->include_template('nav.html.tpl') ?>   
        <? $this->include_template('footer.html.tpl') ?>