文章评论列表及评论功能(TODO)

This commit is contained in:
oncereply 2012-12-14 17:59:18 +08:00
parent cbd582dea9
commit 7f5f552cb6
5 changed files with 258 additions and 115 deletions

View File

@ -1,4 +1,5 @@
<#include "macro-head.ftl"> <#include "macro-head.ftl">
<#include "macro-comments.ftl">
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -71,6 +72,7 @@
</div> </div>
</#if> </#if>
</div> </div>
<@comments commentList=articleComments article=article></@comments>
</div> </div>
<aside id="sidebar" class="span4" role="complementary"> <aside id="sidebar" class="span4" role="complementary">
<#include "side.ftl"> <#include "side.ftl">
@ -78,5 +80,17 @@
</div> </div>
</div> </div>
<#include "footer.ftl"> <#include "footer.ftl">
<@comment_script oId=article.oId>
page.tips.externalRelevantArticlesDisplayCount = "${externalRelevantArticlesDisplayCount}";
<#if 0 != randomArticlesDisplayCount>
page.loadRandomArticles('<h4 class="ft-gray">${randomArticlesLabel}</h4>');
</#if>
<#if 0 != relevantArticlesDisplayCount>
page.loadRelevantArticles('${article.oId}', '<h4 class="ft-gray">${relevantArticlesLabel}</h4>');
</#if>
<#if 0 != externalRelevantArticlesDisplayCount>
page.loadExternalRelevantArticles("<#list article.articleTags?split(",") as articleTag>${articleTag}<#if articleTag_has_next>,</#if></#list>");
</#if>
</@comment_script>
</body> </body>
</html> </html>

View File

@ -2,44 +2,156 @@ body.top-navbar {
padding-top: 60px; padding-top: 60px;
} }
a:hover{ a:hover {
text-decoration:none; text-decoration: none;
color: #00B; color: #00B;
} }
.page-header a{ .page-header a {
color: #000000; color: #000000;
} }
.page-header a:hover{
.page-header a:hover {
color: #9A9A9A; color: #9A9A9A;
} }
.page-header-m{ .page-header-m {
margin: 20px 0px 5px; margin: 20px 0px 5px;
} }
.page-header-bottom{ .page-header-bottom {
margin: 0px 0px 5px; margin: 0px 0px 5px;
font-size: 12px; font-size: 12px;
color: #585858; color: #585858;
} }
.article-tags{ .article-tags {
color: #676767; color: #676767;
font-size: 12px; font-size: 12px;
} }
.article-tags a{ .article-tags a {
text-decoration: none; text-decoration: none;
} }
#footer{ #footer {
margin-top: 20px; margin-top: 20px;
} }
#footer .container{
#footer .container {
padding: 10px 15px 10px; padding: 10px 15px 10px;
} }
.pagination-btn{ .pagination-btn {
margin-top: 20px; margin-top: 20px;
}
/* emotions */
.em00, .em01, .em02, .em03, .em04, .em05, .em06, .em07, .em08, .em09, .em10, .em11, .em12, .em13, .em14 {
cursor: pointer;
background-image: url("../images/emotions/emotions-ease.png");
float: left;
height: 24px;
margin-right: 5px;
width: 24px;
transition: all .2s ease-out;
-webkit-transition: all .2s ease-out;
-moz-transition: all .2s ease-out;
}
#emotions span:hover {
transform: scale(1.2) rotate(360deg);
-webkit-transform: scale(1.2) rotate(360deg);
-moz-transform: scale(1.2) rotate(360deg);
}
.em01 {
background-position: -24px 0;
}
.em02 {
background-position: -48px 0;
}
.em03 {
background-position: -72px 0;
}
.em04 {
background-position: -96px 1px;
}
.em05 {
background-position: 0 -24px;
}
.em06 {
background-position: -24px -24px;
}
.em07 {
background-position: -48px -24px;
}
.em08 {
background-position: -72px -24px;
}
.em09 {
background-position: -96px -24px;
}
.em10 {
background-position: 0 -48px;
}
.em11 {
background-position: -24px -48px ;
}
.em12 {
background-position: -48px -48px;
}
.em13 {
background-position: -72px -48px;
}
.em14 {
background-position: -96px -48px;
}
/* emotions */
.form-actions-m{
padding-left: 0px !important;
padding-bottom: 0px;
margin-bottom: 0px;
}
.article-relative {
background-color: #FCFCFC;
box-shadow: 0 0 2px #D5D5D5;
padding: 5px 0 5px 20px;
}
.article-relative:hover {
background-color: #fff;
box-shadow: 0 0 4px #D5D5D5;
}
.article-relative ul {
list-style: none;
}
.article-comments{
margin-bottom: 20px;
}
.bs-docs-example {
position: relative;
padding: 20px;
*padding-top: 0px;
background-color: #fff;
border: 1px solid #ddd;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
margin-bottom: 20px;
}
.bs-docs-example-child {
position: relative;
padding: 5px;
*padding-top: 0px;
background-color: #fff;
border: 1px solid #ddd;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
} }

View File

@ -2,28 +2,28 @@
<div class="navbar-inner"> <div class="navbar-inner">
<div class="container"> <div class="container">
<div class="pull-left"> <div class="pull-left">
<span class="ft-gray">&copy; ${year}</span> - <a href="${servePath}">${blogTitle}</a> <span>&copy; ${year}</span> - <a href="${servePath}">${blogTitle}</a>
Powered by Powered by
<a href="http://b3log.org" target="_blank" class="logo"> <a href="http://b3log.org" target="_blank" class="logo">
${b3logLabel}&nbsp; ${b3logLabel}&nbsp;
<span style="color: orangered; font-weight: bold;">Solo</span></a>, <span style="color: orangered; font-weight: bold;">Solo</span></a>,
ver ${version}&nbsp;&nbsp; ver ${version}&nbsp;&nbsp;
Theme by <a rel="friend" rel="friend" href="http://vanessa.b3log.org" target="_blank">Vanessa</a>. Theme by <a rel="friend" rel="friend" href="http://www.oncereply.me" target="_blank">oncereply</a>.
</div> </div>
<div class="pull-right"> <div class="pull-right">
<div class="pull-left"> <div class="pull-left">
${viewCount1Label} ${viewCount1Label}
<span class="ft-gray"> <span>
${statistic.statisticBlogViewCount} ${statistic.statisticBlogViewCount}
</span> </span>
&nbsp;&nbsp; &nbsp;&nbsp;
${articleCount1Label} ${articleCount1Label}
<span class="ft-gray"> <span>
${statistic.statisticPublishedBlogArticleCount} ${statistic.statisticPublishedBlogArticleCount}
</span> </span>
&nbsp;&nbsp; &nbsp;&nbsp;
${commentCount1Label} ${commentCount1Label}
<span class="ft-gray"> <span>
${statistic.statisticPublishedBlogCommentCount} ${statistic.statisticPublishedBlogCommentCount}
</span> </span>
</div> </div>

View File

@ -13,18 +13,12 @@
<#list pageNavigations as page> <#list pageNavigations as page>
<li><a href="${page.pagePermalink}" target="${page.pageOpenTarget}">${page.pageTitle}</a></li> <li><a href="${page.pagePermalink}" target="${page.pageOpenTarget}">${page.pageTitle}</a></li>
</#list> </#list>
<li>
<a href="${servePath}/dynamic.html">${dynamicLabel}</a>
</li>
<li> <li>
<a href="${servePath}/tags.html">${allTagsLabel}</a> <a href="${servePath}/tags.html">${allTagsLabel}</a>
</li> </li>
<li> <li>
<a href="${servePath}/archives.html">${archiveLabel}</a> <a href="${servePath}/archives.html">${archiveLabel}</a>
</li> </li>
<li>
<a href="${servePath}/links.html">${linkLabel}</a>
</li>
<li> <li>
<a rel="alternate" href="${servePath}/blog-articles-feed.do">Atom<img src="${staticServePath}/images/feed.png" alt="Atom"/></a> <a rel="alternate" href="${servePath}/blog-articles-feed.do">Atom<img src="${staticServePath}/images/feed.png" alt="Atom"/></a>
</li> </li>

View File

@ -1,103 +1,126 @@
<#macro comments commentList article> <#macro comments commentList article>
<div id="comments"> <!-- comments -->
<div id="comments" class="comments article-comments">
<#list commentList as comment> <#list commentList as comment>
<div id="${comment.oId}"> <div class="media bs-docs-example-child" id="${comment.oId}">
<img class="comment-header" title="${comment.commentName}" <#if "http://" == comment.commentURL>
alt="${comment.commentName}" src="${comment.commentThumbnailURL}"/> <a class="pull-left" title="${comment.commentName}"><img class="media-object img-polaroid" data-src="holder.js/64x64" style="width: 64px; height: 64px;" src="${comment.commentThumbnailURL}"></a>
<div class="comment-panel"> <#else>
<div class="left"> <a class="pull-left" href="${comment.commentURL}" target="_blank"><img class="media-object img-polaroid" data-src="holder.js/64x64" style="width: 64px; height: 64px;" src="${comment.commentThumbnailURL}"></a>
<#if "http://" == comment.commentURL>
<a>${comment.commentName}</a>
<#else>
<a href="${comment.commentURL}" target="_blank">${comment.commentName}</a>
</#if>
<#if comment.isReply>@
<a href="${servePath}${article.permalink}#${comment.commentOriginalCommentId}"
onmouseover="page.showComment(this, '${comment.commentOriginalCommentId}', 20);"
onmouseout="page.hideComment('${comment.commentOriginalCommentId}')">${comment.commentOriginalCommentName}</a>
</#if>
</div>
<#if article.commentable>
<div class="right ft-gray">
${comment.commentDate?string("yy-MM-dd HH:mm")}
<a rel="nofollow" href="javascript:replyTo('${comment.oId}');">${replyLabel}</a>
</div>
</#if> </#if>
<span class="clear"></span> <div class="media-body">
<div class="article-body">${comment.commentContent}</div> <h4 class="media-heading">
<#if "http://" == comment.commentURL>
<a>${comment.commentName}</a>
<#else>
<a href="${comment.commentURL}" target="_blank">${comment.commentName}</a>
</#if>
</h4>
${comment.commentContent}
<!-- Nested media object -->
<#if comment.isReply>
<div class="media">
<a href="${servePath}${article.permalink}#${comment.commentOriginalCommentId}"
onmouseover="page.showComment(this, '${comment.commentOriginalCommentId}', 20);"
onmouseout="page.hideComment('${comment.commentOriginalCommentId}')">${comment.commentOriginalCommentName}</a>
</div>
</#if>
</div>
</div> </div>
<span class="clear"></span>
</div>
</#list> </#list>
</div> </div>
<!-- Leave a comment -->
<#if article.commentable> <#if article.commentable>
<div class="form"> <form class="well form-horizontal">
<table id="commentForm"> <div class="control-group">
<tbody> <div class="input-prepend">
<tr> <span class="add-on"><i class="icon-user"></i></span>
<td colspan="2"> <input type="text" id="commentName" placeholder="${commentNameLabel}">
<input type="text" class="normalInput" id="commentName"/> </div>
<label for="commentName">${commentNameLabel}</label> </div>
</td> <div class="control-group">
</tr> <div class="input-prepend">
<tr> <span class="add-on"><i class="icon-envelope"></i></span>
<td colspan="2"> <input type="text" id="commentEmail" placeholder="${commentEmailLabel}">
<input type="text" class="normalInput" id="commentEmail"/> </div>
<label for="commentEmail">${commentEmailLabel}</label> </div>
</td> <div class="control-group">
</tr> <div class="input-prepend">
<tr> <span class="add-on"><i class="icon-globe"></i></span>
<td colspan="2"> <input type="text" id="commentURL" placeholder="${commentURLLabel}">
<input type="text" id="commentURL"/> </div>
<label for="commentURL">${commentURLLabel}</label> </div>
</td> <div class="control-group">
</tr> <span id="emotions">
<tr> <span class="em00" title="${em00Label}"></span>
<td id="emotions" colspan="2"> <span class="em01" title="${em01Label}"></span>
<span class="em00" title="${em00Label}"></span> <span class="em02" title="${em02Label}"></span>
<span class="em01" title="${em01Label}"></span> <span class="em03" title="${em03Label}"></span>
<span class="em02" title="${em02Label}"></span> <span class="em04" title="${em04Label}"></span>
<span class="em03" title="${em03Label}"></span> <span class="em05" title="${em05Label}"></span>
<span class="em04" title="${em04Label}"></span> <span class="em06" title="${em06Label}"></span>
<span class="em05" title="${em05Label}"></span> <span class="em07" title="${em07Label}"></span>
<span class="em06" title="${em06Label}"></span> <span class="em08" title="${em08Label}"></span>
<span class="em07" title="${em07Label}"></span> <span class="em09" title="${em09Label}"></span>
<span class="em08" title="${em08Label}"></span> <span class="em10" title="${em10Label}"></span>
<span class="em09" title="${em09Label}"></span> <span class="em11" title="${em11Label}"></span>
<span class="em10" title="${em10Label}"></span> <span class="em12" title="${em12Label}"></span>
<span class="em11" title="${em11Label}"></span> <span class="em13" title="${em13Label}"></span>
<span class="em12" title="${em12Label}"></span> <span class="em14" title="${em14Label}"></span>
<span class="em13" title="${em13Label}"></span> </span>
<span class="em14" title="${em14Label}"></span> <div>
</td> <textarea rows="7" cols="96" id="comment" class="input-block-level"></textarea>
</tr> </div>
<tr> </div>
<td colspan="2"> <div class="control-group">
<textarea rows="10" cols="96" id="comment"></textarea> <div class="input-prepend">
</td> <span class="add-on"><i class="icon-check"></i></span>
</tr> <input type="text" id="commentValidate"/>
<tr> <img id="captcha" alt="validate" src="${servePath}/captcha.do" class="img-polaroid" style="margin-left: 5px;" />
<td colspan="2"> </div>
<input type="text" class="normalInput" id="commentValidate"/> </div>
<img id="captcha" alt="validate" src="${servePath}/captcha.do" /> <div class="form-actions form-actions-m pagination-right">
</td> <span class="pull-left text-error" id="commentErrorTip"></span>
</tr> <button id="submitCommentButton" type="button" onclick="page.submitComment();" class="btn btn-primary">${submmitCommentLabel}</button>
<tr> </div>
<td> </form>
<span class="ft-gray" id="commentErrorTip"></span>
</td>
<td align="right">
<button id="submitCommentButton" onclick="page.submitComment();">${submmitCommentLabel}</button>
</td>
</tr>
</tbody>
</table>
</div>
<#if externalRelevantArticlesDisplayCount?? && 0 != externalRelevantArticlesDisplayCount> <#if externalRelevantArticlesDisplayCount?? && 0 != externalRelevantArticlesDisplayCount>
<div id="externalRelevantArticles" class="article-relative"></div> <div id="externalRelevantArticles" class="article-relative"></div>
</#if> </#if>
<span class="clear"></span>
</#if> </#if>
<div id="comments">
<#list commentList as comment>
<div id="${comment.oId}">
<img class="comment-header" title="${comment.commentName}"
alt="${comment.commentName}" src="${comment.commentThumbnailURL}"/>
<div class="comment-panel">
<div class="left">
<#if "http://" == comment.commentURL>
<a>${comment.commentName}</a>
<#else>
<a href="${comment.commentURL}" target="_blank">${comment.commentName}</a>
</#if>
<#if comment.isReply>@
<a href="${servePath}${article.permalink}#${comment.commentOriginalCommentId}"
onmouseover="page.showComment(this, '${comment.commentOriginalCommentId}', 20);"
onmouseout="page.hideComment('${comment.commentOriginalCommentId}')">${comment.commentOriginalCommentName}</a>
</#if>
</div>
<#if article.commentable>
<div class="right ft-gray">
${comment.commentDate?string("yy-MM-dd HH:mm")}
<a rel="nofollow" href="javascript:replyTo('${comment.oId}');">${replyLabel}</a>
</div>
</#if>
<span class="clear"></span>
<div class="article-body">${comment.commentContent}</div>
</div>
<span class="clear"></span>
</div>
</#list>
</div>
</#macro> </#macro>
<#macro comment_script oId> <#macro comment_script oId>
@ -120,7 +143,7 @@
var addComment = function (result, state) { var addComment = function (result, state) {
var commentHTML = '<div id="' + result.oId + '"><img class="comment-header" \ var commentHTML = '<div id="' + result.oId + '"><img class="comment-header" \
title="' + $("#commentName" + state).val() + '" alt="' + $("#commentName" + state).val() + title="' + $("#commentName" + state).val() + '" alt="' + $("#commentName" + state).val() +
'" src="' + result.commentThumbnailURL + '"/><div class="comment-panel"><div class="left">' + result.replyNameHTML; '" src="' + result.commentThumbnailURL + '"/><div class="comment-panel"><div class="left">' + result.replyNameHTML;
if (state !== "") { if (state !== "") {
@ -129,10 +152,10 @@
+ 'onmouseover="page.showComment(this, \'' + page.currentCommentId + '\', 20);"' + 'onmouseover="page.showComment(this, \'' + page.currentCommentId + '\', 20);"'
+ 'onmouseout="page.hideComment(\'' + page.currentCommentId + '\')">' + commentOriginalCommentName + '</a>'; + 'onmouseout="page.hideComment(\'' + page.currentCommentId + '\')">' + commentOriginalCommentName + '</a>';
} }
commentHTML += '</div><div class="right ft-gray">' + result.commentDate.substring(2, 16) commentHTML += '</div><div class="right ft-gray">' + result.commentDate.substring(2, 16)
+ '&nbsp;<a rel="nofollow" href="javascript:replyTo(\'' + result.oId + '&nbsp;<a rel="nofollow" href="javascript:replyTo(\'' + result.oId
+ '\');">${replyLabel}</a></div><span class="clear"></span><div class="article-body">' + + '\');">${replyLabel}</a></div><span class="clear"></span><div class="article-body">' +
Util.replaceEmString($("#comment" + state).val().replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g,"<br/>")) Util.replaceEmString($("#comment" + state).val().replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g,"<br/>"))
+ '</div></div><span class="clear"></span></div>'; + '</div></div><span class="clear"></span></div>';