From: Gabriel Dunne Date: Fri, 11 Nov 2011 12:47:55 +0000 (+0530) Subject: comments stuff X-Git-Url: https://git.quilime.com/?a=commitdiff_plain;h=cdff2283c610e00695f5d4c33346c30179ae03b0;p=plog.git comments stuff --- diff --git a/content/categori1/cat_2/hello_comments b/content/categori1/cat_2/hello_comments index b395a5d..c44983d 100644 --- a/content/categori1/cat_2/hello_comments +++ b/content/categori1/cat_2/hello_comments @@ -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 index 0000000..3a8b8e5 --- /dev/null +++ b/content/category_2/cat_2/hello_comments2 @@ -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 index f45764c..0000000 --- a/css/comments.css +++ /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 diff --git a/css/style.css b/css/style.css index a7d734c..f040e52 100644 --- a/css/style.css +++ b/css/style.css @@ -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 index c413a0c..0000000 --- a/lib/comments.php +++ /dev/null @@ -1,118 +0,0 @@ -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 '
', $this->_comment_error, '
'; - 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; - } - } - } -} diff --git a/lib/data.php b/lib/data.php index 129b419..196e6ed 100644 --- a/lib/data.php +++ b/lib/data.php @@ -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); diff --git a/lib/init.php b/lib/init.php index 9e84f7c..187b652 100644 --- a/lib/init.php +++ b/lib/init.php @@ -34,14 +34,10 @@ define ('MORE_DELIM', ''); 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 @@ -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 index f4459d1..0000000 --- a/templates/comments.html.tpl +++ /dev/null @@ -1,32 +0,0 @@ - -
-

comments

- - -
- - comments as $comment) : ?> -
- -
, ago
-
- - -
- -
- -
-
-
- -
- - recaptcha_html(); ?> - -
- - -
-
-
diff --git a/templates/entry.html.tpl b/templates/entry.html.tpl index d5c4c20..755e5a3 100644 --- a/templates/entry.html.tpl +++ b/templates/entry.html.tpl @@ -15,9 +15,6 @@ in - comments) > 0 || $entry['comments_enabled']) : ?> - | comments) ?> comments -
- include_template('comments.html.tpl', array('entry' => $entry)); - ?> - diff --git a/templates/single.html.tpl b/templates/single.html.tpl index cae3f02..4bb5e76 100644 --- a/templates/single.html.tpl +++ b/templates/single.html.tpl @@ -16,6 +16,27 @@ include_template('nextprev.html.tpl'); ?> + +
+ +
+ + + + +
+ + include_template('nav.html.tpl') ?> include_template('footer.html.tpl') ?>