| #** |
| * Comment page links and comment forms. |
| *# |
| |
| #** |
| * Display the pop-up comments link for a weblog entry. |
| * Use the URL for the href attribute for those who have disabled |
| * javascript or who desire to open the comments window in another (Mozilla) tab. |
| * @param entry WeblogEntryData object for which link is to be displayed. |
| *# |
| #macro( showCommentsLink $entry ) |
| #set( $commentCount = $pageModel.getCommentCount($entry.Id) ) |
| #if (($commentsEnabled && $entry.commentsStillAllowed && $website.allowComments) || $commentCount > 0) |
| #set( $link = "$ctxPath$entry.permaLink&popup=true#comments" ) |
| <a href="$link " onclick="window.open('$link', 'comments', |
| 'width=480,height=480,scrollbars=yes,status=yes,resizable'); return false;" |
| class="entrycommentslink">$text.get( "macro.weblog.comments" ) [$commentCount]</a> |
| #end |
| #end |
| |
| #** |
| * Display the in-page comments link for a weblog entry. |
| * @param entry WeblogEntryData object for which link is to be displayed. |
| *# |
| #macro( showCommentsPageLink $entry ) |
| #set( $commentCount = $pageModel.getCommentCount($entry.Id) ) |
| #if (($commentsEnabled && $entry.commentsStillAllowed && $website.allowComments) || $commentCount > 0) |
| #set( $link = "$ctxPath$entry.permaLink#comments" ) |
| <a href="$link" class="entrycommentslink">$text.get( "macro.weblog.comments" ) [$commentCount]</a> |
| #end |
| #end |
| |
| #** |
| * Display link for comments that renders a dynamically (DHTML) generated |
| * comments form - Matt Raible's "twisty comments" style. |
| * @param entry WeblogEntryData object for which link is to be displayed. |
| *# |
| #macro( showCommentsDiv $entry ) |
| #set( $commentCount = $pageModel.getCommentCount($entry.Id) ) |
| #if (($commentsEnabled && $entry.commentsStillAllowed && $website.allowComments) || $commentCount > 0) |
| <div class="comments" id="comments"> |
| <div id="commentTwisty$entry.Id" class="commentTwisty" |
| onclick="toggleComments('$entry.Id', '${ctxPath}/page/${website.handle}'); return false;"> |
| <a href="$ctxPath$entry.permaLink" class="plain"> |
| #if($commentCount == 0) |
| $text.get( "macro.weblog.addcomment" ) |
| #elseif($commentCount == 1) |
| $commentCount $text.get( "macro.weblog.comment" ) |
| #else |
| $commentCount $text.get( "macro.weblog.comments" ) |
| #end</a></div> |
| </div> |
| #end |
| #end |
| |
| #** |
| * PRIVATE. Macro for displaying Comment details (not content). |
| **# |
| #macro( showCommentDetails $comment $showPermalink ) |
| $dateFormatter.applyPattern($text.get( "macro.weblog.datepattern" )) |
| <p class="comment-details"> |
| $text.get("macro.weblog.postedby") |
| #if (!$stringUtils.isEmpty($comment.name) && !$stringUtils.isEmpty($comment.remoteHost)) |
| <b>$utilities.escapeHTML($comment.name)</b> ($utilities.escapeHTML($comment.remoteHost)) |
| #elseif (!$stringUtils.isEmpty($comment.name)) |
| <b>$utilities.escapeHTML($comment.name)</b> |
| #elseif (!$stringUtils.isEmpty($comment.remoteHost)) |
| <b>$utilities.escapeHTML($comment.remoteHost)</b> |
| #end |
| $text.get("macro.weblog.on") $dateFormatter.format($comment.postTime) |
| #if( $stringUtils.isNotEmpty($comment.url) ) |
| $text.get( "macro.weblog.postedbywebsite", [$utilities.escapeHTML($comment.url), $utilities.escapeHTML($comment.url)] ) |
| #end |
| #if( $showPermalink ) |
| <a href="${ctxPath}${entry.permaLink}#comment${velocityCount}" |
| class="entrypermalink" |
| title="$text.get( "macro.weblog.commentpermalink.title" )">#</a> |
| #end |
| </p> |
| #end |
| |
| #** |
| * Display all comments comments for an entry. |
| * @param entry WeblogEntryData object for which comments are to be displayed. |
| *# |
| #macro( showComments $entry ) |
| <div class="comments" id="comments"> |
| #if( $previewComments ) |
| #set( $comments = $previewComments ) |
| <div class="comments-head">$text.get( "macro.weblog.preview" ):</div> |
| #else |
| <div class="comments-head">$text.get( "macro.weblog.comments" ):</div> |
| #set($comments = $pageModel.getComments($entry)) |
| #end |
| <br/> |
| #foreach( $comment in $comments ) |
| <!-- comment: $comment.id --> |
| #if($comment.approved || $previewComments) |
| #set($content = $utilities.encodeEmail($comment.content)) |
| #if($escapeHtml) |
| #set($content = $utilities.escapeHTML($content)) |
| #else |
| #set($content = $utilities.transformToHTMLSubset($utilities.escapeHTML($content))) |
| #end |
| #if($autoformat) |
| #set($content = $utilities.autoformat($content)) |
| #end |
| #set($content = $utilities.addNofollow($content)) |
| <div class="comment" id="comment${velocityCount}"> |
| ${content} |
| #showCommentDetails($comment true) |
| </div> |
| #end |
| #end |
| </div> |
| #end |
| |
| #** |
| * Display recent comments for whole blog (not just one entry). |
| * @param numComments Maximum number of comments to be displayed |
| **# |
| #macro( showRecentComments $numComments ) |
| #if( !$numComments ) #set( $numComments = 20 ) #end |
| #if( $numComments > 100 ) #set( $numComments = 50 ) #end |
| #set( $comments = $pageModel.getRecentComments($numComments) ) |
| <div class="comments" id="comments"> |
| #foreach( $comment in $comments ) |
| #set($content = $utilities.encodeEmail($comment.content)) |
| #if($escapeHtml) |
| #set($content = $utilities.escapeHTML($content)) |
| #end |
| #if($autoformat) |
| #set($content = $stringUtils.replace($content,"\n","<br />")) |
| #end |
| #set($content = $utilities.addNofollow($content)) |
| <div class="comment" style="border: 1px solid #dadada; padding-left: 3px; padding-right: 5px;" > |
| <p>Commenting on <a class="entrypermalink" |
| href="${ctxPath}${comment.weblogEntry.permaLink}">${comment.weblogEntry.title}</a>:</p> |
| ${content} |
| #showCommentDetails($comment false) |
| </div> |
| #end |
| </div> |
| #end |
| |
| #** |
| * Display list of most recent comments for a blog. |
| * @param numComments Max number of comments to show. |
| * @param maxWidth Limit width of comment text to this number of characters |
| **# |
| #macro( showRecentCommentsListWidth $numComments $maxWidth ) |
| #if( !$numComments ) #set( $numComments = 20 ) #end |
| #if( $numComments > 100 ) #set( $numComments = 100 ) #end |
| #set( $minWidth = $maxWidth - 5 ) |
| #set( $comments = $pageModel.getRecentComments($numComments) ) |
| <ul class="commentsList">Recent Comments |
| #foreach( $comment in $comments ) |
| #set($content = $utilities.encodeEmail($comment.content)) |
| #set($content = $utilities.addNofollow($content)) |
| <li class="commentsListItem"><a |
| href="${ctxPath}${comment.weblogEntry.permaLink}#comments" |
| class="entrypermalink" |
| title="$text.get( "macro.weblog.commentpermalink.title" ) to |
| '$utilities.removeHTML($comment.weblogEntry.title)'" |
| >$utilities.truncateNicely($utilities.removeHTML($content), $minWidth, $maxWidth, "...")</a> |
| </li> |
| #end |
| </ul> |
| #end |
| |
| #** |
| * Display list of most recent comments for a blog (with maxWidth = 25) |
| * @param numComments Max number of comments to show. |
| **# |
| #macro( showRecentCommentsList $numComments ) |
| #showRecentCommentsListWidth( $numComments 25 ) |
| #end |
| |
| #** |
| * Display comment form for a weblog entry. |
| * @param entry WeblogEntry object for which form is to be shown. |
| *# |
| #macro( showCommentForm $entry ) |
| <div class="comments-form"> |
| <div class="comments-head">$text.get("macro.weblog.postcommentHeader")</div><br/> |
| |
| #showStatusMessage() |
| |
| <form method="post" action="$ctxPath/comment" focus="name" |
| name="form" onsubmit="fixURL(this); return validateComments(this)"> |
| |
| #if($requestParameters.popup) |
| <input type="hidden" name="popup" value="true" /> |
| #end |
| |
| <!-- is this a post or a preview --> |
| <input type="hidden" name="method" value="post" /> |
| <input type="hidden" name="entryid" value="$entry.id" /> |
| |
| <table cellspacing="0" cellpadding="1" border="0" width="95%"> |
| <tr><th>$text.get( "macro.weblog.name" )</th> |
| <td><input type="text" name="name" value="$utilities.escapeHTML($commentForm.name)" size="50" maxlength="255" /></td> |
| </tr> |
| |
| <tr><th>$text.get( "macro.weblog.email" )</th> |
| <td><input type="text" name="email" value="$utilities.escapeHTML($commentForm.email)" size="50" maxlength="255" /></td> |
| </tr> |
| |
| <tr><th>$text.get( "macro.weblog.url" )</th> |
| <td><input type="text" name="url" value="$utilities.escapeHTML($commentForm.url)" size="50" maxlength="255" /></td> |
| </tr> |
| #if ($pageModel.emailComments) |
| <tr> |
| <td></td> |
| <td> |
| <input type="checkbox" id="notify" name="notify" /> |
| <label for="notify">$text.get( "macro.weblog.notifyMeOfComments" )</label> |
| </td> |
| </tr> |
| #end |
| <tr> |
| <td></td> |
| <td> |
| <input type="checkbox" id="rememberInfo" name="rememberInfo" /> |
| <label for="rememberInfo">$text.get( "macro.weblog.rememberinfo" )</label> |
| </td> |
| </tr> |
| </table> |
| <br/> |
| |
| <table> |
| <tr><th style="text-align: left">$text.get( "macro.weblog.yourcomment" )</th></tr> |
| <tr> |
| <td> |
| <textarea name="content" cols="50" rows="10">$utilities.escapeHTML($commentForm.content)</textarea><br /> |
| <span class="comments-syntax-indicator"> |
| $text.get( "macro.weblog.htmlsyntax" ) |
| #if( $escapeHtml ) |
| <span class="disabled">$text.get( "macro.weblog.htmldisabled" )</span> |
| #else |
| <span class="enabled">$text.get( "macro.weblog.htmlenabled" )</span> |
| #end |
| </span> |
| </td> |
| </tr> |
| </table> |
| |
| <script type="text/javascript" src="$ctxPath/theme/scripts/clientSideInclude.js"></script> |
| <div id="commentAuthenticator"></div> |
| |
| <table cellspacing="0" cellpadding="1" border="0" width="95%"> |
| <tr> |
| <td align="left" nowrap="nowrap"> |
| <input type="button" name="post" value=" $text.get( "macro.weblog.preview" ) " |
| onClick="this.form.method.value='preview';this.form.submit()" /> |
| <input type="submit" name="post" value=" $text.get( "macro.weblog.post" ) " /> |
| </td> |
| <td align="right"> |
| <!-- <input type="button" value=" $text.get( "macro.weblog.clear" ) " /> --> |
| </td> |
| </tr> |
| </table> |
| |
| </form> |
| |
| <script type="text/javascript" src="$ctxPath/theme/scripts/roller.js"></script> |
| <script type="text/javascript"> |
| clientSideInclude('commentAuthenticator', '$ctxPath/CommentAuthenticatorServlet'); |
| |
| var author = getCookie("commentAuthor"); |
| var email = getCookie("commentEmail"); |
| var url = getCookie("commentUrl"); |
| // check each field - IE will render "null" |
| if (author) { |
| document.form.name.value = author; |
| } |
| if (email) { |
| document.form.email.value = email; |
| } |
| if (url) { |
| document.form.url.value = url; |
| } |
| |
| if (author || email || url) { |
| document.form.rememberInfo.checked = true; |
| } |
| |
| function fixURL(theForm) { |
| if (theForm.url.value != "" && |
| theForm.url.value.indexOf("http://") == -1) { //prepend http:// |
| theForm.url.value = "http://"+theForm.url.value; |
| } |
| saveUserInformation(theForm); |
| } |
| |
| function saveUserInformation(theForm) { |
| if (theForm.rememberInfo.checked) { |
| rememberUser(theForm); |
| } else { |
| forgetUser(theForm); |
| } |
| } |
| |
| function validateComments(theForm) { |
| if (theForm.content.value == "") { |
| alert("$text.get( "macro.weblog.commentwarning" )"); |
| theForm.content.focus(); |
| return false; |
| } |
| } |
| </script> |
| </div> |
| #end |
| |
| #** |
| * Display hidden comment form for a weblog entry. |
| * @param entry WeblogEntry object for which form is to be shown, |
| *# |
| #macro( showHiddenCommentForm ) |
| <div style="display: none" class="comments"> |
| <div id="commentBoxTemplate" class="commentBox"> |
| <form class="commentFormBox" id="commentForm" |
| method="post" action="$ctxPath/comment" |
| onsubmit="onSubmitComments(this.entryid.value);fixURL(this);return validateComments(this)"> |
| |
| <table> |
| <tr class="commentFormRow"> |
| <td>$text.get( "macro.weblog.name" )</td> |
| <td> |
| <input name="name" type="text" class="commentFormInput" size="50"/> |
| <input type="hidden" name="method" value="updateFromPage" /> |
| <input type="hidden" name="entryid" value="" id="entryid" /> |
| </td> |
| </tr> |
| <tr class="commentFormRow"> |
| <td>$text.get( "macro.weblog.email" )</td> |
| <td><input name="email" type="text" class="commentFormInput" size="50"/></td> |
| </tr> |
| <tr class="commentFormRow"> |
| <td>$text.get( "macro.weblog.url" )</td> |
| <td><input name="url" type="text" class="commentFormInput" size="50"/></td> |
| </tr> |
| #if ($pageModel.emailComments) |
| <tr> |
| <td></td> |
| <td> |
| <input type="checkbox" id="notify" name="notify" /> |
| <label for="notify">$text.get( "macro.weblog.notifyMeOfComments" )</label> |
| </td> |
| </tr> |
| #end |
| <tr> |
| <td></td> |
| <td> |
| <input type="checkbox" id="rememberInfo" name="rememberInfo" /> |
| <label for="rememberInfo">$text.get( "macro.weblog.rememberinfo" )</label> |
| </td> |
| </tr> |
| </table> |
| <div class="commentFormRow"> |
| <textarea name="content" class="commentFormTextarea" rows="4" cols="60"></textarea> |
| <div class="htmlSyntax"> |
| $text.get( "macro.weblog.htmlsyntax" ) |
| #if( $escapeHtml ) |
| <span class="disabled">$text.get( "macro.weblog.htmldisabled" )</span> |
| #else |
| <span class="enabled">$text.get( "macro.weblog.htmlenabled" )</span> |
| #end |
| </div> |
| </div> |
| |
| $pageHelper.commentAuthenticatorHtml |
| |
| <div class="commentFormRow"> |
| <input type="submit" name="post" value=" $text.get( "macro.weblog.postcomment" ) " /> |
| </div> |
| </form> |
| </div> |
| <script type="text/javascript"> |
| // add a target to the iframe on the commentForm |
| var commentForm = document.getElementById("commentForm"); |
| commentForm.target = "commentFrame"; |
| </script> |
| |
| <div id="commentTemplate" class="comment"> |
| <div class="commentBody" id="commentBody"></div> |
| <div class="commentByline"> |
| <a class="commentAuthor" id="commentAuthorLink"></a> |
| <span> on </span><span id="commentTimestamp"></span> |
| </div> |
| </div> |
| |
| <iframe name="commentFrame" src="about:blank"></iframe> |
| |
| <script type="text/javascript" src="$ctxPath/theme/scripts/roller.js"></script> |
| </div> |
| #end |