+++ /dev/null
-<?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;
- }
- }
- }
-}
define ('TITLE_DELIMITER', ' — ');
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
require_once 'markdown.php';
require_once 'model.php';
require_once 'view.php';
-require_once 'comments.php';
-
+++ /dev/null
-
-<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>
<? $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') ?>