diff --git a/_sakura/changelog.json b/_sakura/changelog.json
index 744120c..b54f913 100644
--- a/_sakura/changelog.json
+++ b/_sakura/changelog.json
@@ -3005,7 +3005,7 @@
],
- "20151003": [
+ "20151004": [
"eminence",
{
@@ -3014,6 +3014,17 @@
"user": "Flashwave"
}
+ ],
+
+ "20151006": [
+
+ "eminence",
+ {
+ "type": "ADD",
+ "change": "Added comment posting.",
+ "user": "Flashwave"
+ }
+
]
}
diff --git a/_sakura/components/Comments.php b/_sakura/components/Comments.php
index dfd4fd2..dc6554b 100644
--- a/_sakura/components/Comments.php
+++ b/_sakura/components/Comments.php
@@ -74,4 +74,32 @@ class Comments
return $layer;
}
+
+ // Sorting
+ public function makeComment($uid, $reply, $content)
+ {
+
+ // Check if the comment is long enough
+ if (strlen($content) < Configuration::getConfig('comment_min_length')) {
+ return [0, 'TOO_SHORT'];
+ }
+
+ // Check if the comment isn't too long
+ if (strlen($content) > Configuration::getConfig('comment_max_length')) {
+ return [0, 'TOO_LONG'];
+ }
+
+ // Insert into database
+ Database::insert('comments', [
+ 'comment_category' => $this->category,
+ 'comment_timestamp' => time(),
+ 'comment_poster' => $uid,
+ 'comment_reply_to' => (int) $reply,
+ 'comment_text' => $content,
+ ]);
+
+ // Return success
+ return [1, 'SUCCESS'];
+
+ }
}
diff --git a/_sakura/sakura.php b/_sakura/sakura.php
index fe0e3ee..c3057f7 100644
--- a/_sakura/sakura.php
+++ b/_sakura/sakura.php
@@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
-define('SAKURA_VERSION', '20151003');
+define('SAKURA_VERSION', '20151006');
define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082');
define('SAKURA_STABLE', false);
diff --git a/_sakura/templates/yuuno/elements/comment.tpl b/_sakura/templates/yuuno/elements/comment.tpl
index bd97cc8..e4e1acd 100644
--- a/_sakura/templates/yuuno/elements/comment.tpl
+++ b/_sakura/templates/yuuno/elements/comment.tpl
@@ -7,7 +7,7 @@
@@ -18,11 +18,9 @@
- {% if comment.comment_replies %}
-
- {% for comment in comment.comment_replies %}
- {% include 'elements/comment.tpl' %}
- {% endfor %}
-
- {% endif %}
+
+ {% for comment in comment.comment_replies %}
+ {% include 'elements/comment.tpl' %}
+ {% endfor %}
+
diff --git a/_sakura/templates/yuuno/elements/comments.tpl b/_sakura/templates/yuuno/elements/comments.tpl
index 6ccd6fe..de531b3 100644
--- a/_sakura/templates/yuuno/elements/comments.tpl
+++ b/_sakura/templates/yuuno/elements/comments.tpl
@@ -3,13 +3,14 @@
{% if session.checkLogin %}
{% else %}
@@ -18,8 +19,8 @@
diff --git a/_sakura/templates/yuuno/main/news.tpl b/_sakura/templates/yuuno/main/news.tpl
index 14ac0cc..a229ad3 100644
--- a/_sakura/templates/yuuno/main/news.tpl
+++ b/_sakura/templates/yuuno/main/news.tpl
@@ -4,6 +4,11 @@
{% set pagination = {'page': currentPage, 'pages': news.getPosts(postsPerPage), 'urlPattern': 'SITE_NEWS_PAGE'} %}
+{% if viewPost and postExists %}
+{% set commentsCategory = 'news-' ~ newsPosts[0].category ~ '-' ~ newsPosts[0].id %}
+{% set comments = newsPosts[0].comments.comments %}
+{% endif %}
+
{% set title %}
{% if not (viewPost ? postExists : newsPosts|length) %}Post does not exist!{% elseif viewPost and postExists %}{{ newsPosts[0].title }}{% else %}News{% endif %}
{% endset %}
diff --git a/public/content/data/yuuno/css/yuuno.css b/public/content/data/yuuno/css/yuuno.css
index f6672d4..241a1e2 100644
--- a/public/content/data/yuuno/css/yuuno.css
+++ b/public/content/data/yuuno/css/yuuno.css
@@ -2064,6 +2064,7 @@ textarea.inputStyling {
border: 0;
min-height: 50px;
height: 50px;
+ min-width: 300px;
flex-grow: 2;
padding: 5px;
font: 12px/20px "SegoeUI", "Segoe UI", sans-serif;
@@ -2101,8 +2102,7 @@ textarea.inputStyling {
#comments .comment > .comment-submit {
flex-shrink: 0;
font-family: FontAwesome;
- height: 60px;
- width: 60px;
+ width: 50px;
border-radius: 4px;
margin-left: 2px;
font-size: 2em;
@@ -2112,6 +2112,10 @@ textarea.inputStyling {
cursor: pointer;
}
+#comments .comment > .comment-submit.new {
+ width: 60px;
+}
+
#comments .comment > .comment-submit:hover {
background: linear-gradient(0deg, #9475B2 30%, #C2AFFE 70%);
}
@@ -2120,6 +2124,10 @@ textarea.inputStyling {
background: linear-gradient(180deg, #9475B2 30%, #C2AFFE 70%);
}
+#comments .comments-discussion {
+ overflow: auto;
+}
+
#comments ul {
list-style: none;
}
diff --git a/public/content/data/yuuno/js/yuuno.js b/public/content/data/yuuno/js/yuuno.js
index c0e48db..d1b1bcf 100644
--- a/public/content/data/yuuno/js/yuuno.js
+++ b/public/content/data/yuuno/js/yuuno.js
@@ -853,14 +853,107 @@ function safeTagsReplace(str) {
return str.replace(/[&<>]/g, replaceTag);
}
+function commentReply(id, session, category, action, avatar) {
+
+ // Find subject post
+ var replyingTo = document.getElementById('comment-' + id);
+
+ // Check if it actually exists
+ if(typeof replyingTo === 'undefined') {
+ return false;
+ }
+
+ // Container
+ var replyContainer = document.createElement('li');
+
+ // Form
+ var replyForm = document.createElement('form');
+ replyForm.id = 'comment-reply-' + id;
+ replyForm.action = action;
+ replyForm.method = 'post';
+
+ // Session
+ var replyInput = document.createElement('input');
+ replyInput.type = 'hidden';
+ replyInput.name = 'session';
+ replyInput.value = session;
+ replyForm.appendChild(replyInput);
+
+ // Category
+ var replyInput = document.createElement('input');
+ replyInput.type = 'hidden';
+ replyInput.name = 'category';
+ replyInput.value = category;
+ replyForm.appendChild(replyInput);
+
+ // Reply ID
+ var replyInput = document.createElement('input');
+ replyInput.type = 'hidden';
+ replyInput.name = 'replyto';
+ replyInput.value = id;
+ replyForm.appendChild(replyInput);
+
+ // Mode
+ var replyInput = document.createElement('input');
+ replyInput.type = 'hidden';
+ replyInput.name = 'mode';
+ replyInput.value = 'comment';
+ replyForm.appendChild(replyInput);
+
+ // Comment container
+ var replyDiv = document.createElement('div');
+ replyDiv.className = 'comment';
+
+ // Avatar
+ var replyAvatar = document.createElement('div');
+ replyAvatar.className = 'comment-avatar';
+ replyAvatar.style = 'background-image: url(' + avatar + ')';
+ replyDiv.appendChild(replyAvatar);
+
+ // Pointer
+ var replyPoint = document.createElement('div');
+ replyPoint.className = 'comment-pointer';
+ replyDiv.appendChild(replyPoint);
+
+ // Textarea
+ var replyText = document.createElement('textarea');
+ replyText.className = 'comment-content';
+ replyText.name = 'comment';
+ replyDiv.appendChild(replyText);
+
+ // Submit
+ var replySubmit = document.createElement('input');
+ replySubmit.className = 'comment-submit';
+ replySubmit.type = 'submit';
+ replySubmit.name = 'submit';
+ replySubmit.value = "\uf1d8";
+ replyDiv.appendChild(replySubmit);
+
+ // Append to form
+ replyForm.appendChild(replyDiv);
+
+ // Append form to container
+ replyContainer.appendChild(replyForm);
+
+ // Insert the HTML
+ replyingTo.children[1].appendChild(replyContainer);
+
+ // Prepare AJAX submission
+ prepareAjaxForm(replyForm.id, 'Replying...');
+
+}
+
// Formatting money
Number.prototype.formatMoney = function(c, d, t) {
-var n = this,
- c = isNaN(c = Math.abs(c)) ? 2 : c,
- d = d == undefined ? "." : d,
- t = t == undefined ? "," : t,
- s = n < 0 ? "-" : "",
- i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
- j = (j = i.length) > 3 ? j % 3 : 0;
- return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
- };
+
+ var n = this,
+ c = isNaN(c = Math.abs(c)) ? 2 : c,
+ d = d == undefined ? "." : d,
+ t = t == undefined ? "," : t,
+ s = n < 0 ? "-" : "",
+ i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
+ j = (j = i.length) > 3 ? j % 3 : 0;
+
+ return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
+
+};
diff --git a/public/settings.php b/public/settings.php
index 8aaf357..c8f3931 100644
--- a/public/settings.php
+++ b/public/settings.php
@@ -72,22 +72,39 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
if ($continue) {
switch (isset($_REQUEST['mode']) ? $_REQUEST['mode'] : false) {
case 'like':
-
break;
case 'dislike':
-
break;
case 'delete':
+ break;
+ case 'comment':
+ // Attempt to make a new comment
+ $comment = (new Comments($_POST['category']))->makeComment($currentUser->data['id'], $_POST['replyto'], $_POST['comment']);
+
+ // Messages
+ $messages = [
+ 'TOO_SHORT' => 'The comment you\'re trying to make is too short!',
+ 'TOO_LONG' => 'The comment you\'re trying to make is too long!',
+ 'SUCCESS' => 'Posted!',
+ ];
+
+ $renderData['page'] = [
+
+ 'redirect' => $redirect,
+ 'message' => $messages[$comment[1]],
+ 'success' => $comment[0],
+
+ ];
break;
default:
$renderData['page'] = [
'redirect' => $redirect,
- 'message' => 'Did nothing.',
+ 'message' => 'Unknown action.',
'success' => 0,
];
- {% if post.comments.comments %} - {% for comment in post.comments.comments %} + {% if comments %} + {% for comment in comments %} {% include 'elements/comment.tpl' %} {% endfor %} {% else %} @@ -30,8 +31,6 @@