roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r426248 - in /incubator/roller/branches/roller_3.0: src/org/apache/roller/ui/rendering/model/ src/org/apache/roller/ui/rendering/servlets/ src/org/apache/roller/ui/rendering/util/ src/org/apache/roller/ui/rendering/velocity/deprecated/ web/...
Date Thu, 27 Jul 2006 21:21:45 GMT
Author: agilliland
Date: Thu Jul 27 14:21:45 2006
New Revision: 426248

URL: http://svn.apache.org/viewvc?rev=426248&view=rev
Log:
Updating weblog entry comment form handling.

- created new WeblogEntryCommentForm object to replace the use of CommentFormEx.  this object
has status/error messaging and comment previewing logic built in.

- modified CommentServlet to use new WeblogEntryCommentForm

- removed getPreviewComment() method from page model since it's inside WeblogEntryCommentForm
now.

- modified getCommentForm() in page model so that it doesn't need request object anymore and
returns new WeblogEntryCommentForm object.

- modified old ContextLoader to use new WeblogEntryCommentForm even in the old model.

- did a bit of cleanup on new #showWeblogEntryComments() and #showWeblogEntryCommentForm()
3.0 macros

- updated old #showCommentForm() macro to match new one and EOLed old #showEntryComments()
method and changed it to just call the new #showWeblogEntryComments() macro.


Added:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogEntryCommentForm.java
Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
    incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/deprecated/comments.vm
    incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/weblog.vm

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java?rev=426248&r1=426247&r2=426248&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java
Thu Jul 27 14:21:45 2006
@@ -18,10 +18,6 @@
 
 package org.apache.roller.ui.rendering.model; 
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import org.apache.commons.logging.Log;
@@ -29,19 +25,15 @@
 import org.apache.roller.RollerException;
 import org.apache.roller.model.Roller;
 import org.apache.roller.model.RollerFactory;
-import org.apache.roller.model.UserManager;
 import org.apache.roller.model.WeblogManager;
-import org.apache.roller.pojos.CommentData;
 import org.apache.roller.pojos.WeblogCategoryData;
-import org.apache.roller.pojos.WeblogEntryData;
-import org.apache.roller.pojos.WeblogTemplate;
 import org.apache.roller.pojos.WebsiteData;
-import org.apache.roller.pojos.wrapper.CommentDataWrapper;
 import org.apache.roller.pojos.wrapper.TemplateWrapper;
 import org.apache.roller.pojos.wrapper.WeblogCategoryDataWrapper;
 import org.apache.roller.pojos.wrapper.WeblogEntryDataWrapper;
 import org.apache.roller.pojos.wrapper.WebsiteDataWrapper;
 import org.apache.roller.ui.authoring.struts.formbeans.CommentFormEx;
+import org.apache.roller.ui.rendering.util.WeblogEntryCommentForm;
 import org.apache.roller.ui.rendering.util.WeblogPageRequest;
 
 
@@ -52,8 +44,9 @@
     
     private static Log log = LogFactory.getLog(PageModel.class);
     
-    private HttpServletRequest request = null;
     private WeblogPageRequest pageRequest = null;
+    private WeblogEntryCommentForm commentForm = null;
+    
     private WebsiteData weblog = null;
     
     
@@ -77,15 +70,15 @@
      */
     public void init(Map initData) throws RollerException {
         
-        HttpServletRequest request = (HttpServletRequest) initData.get("request");
-        this.request = request;
-        
         // we expect the init data to contain a pageRequest object
         this.pageRequest = (WeblogPageRequest) initData.get("pageRequest");
         if(this.pageRequest == null) {
             throw new RollerException("expected pageRequest from init data");
         }
         
+        // see if there is a comment form
+        this.commentForm = (WeblogEntryCommentForm) initData.get("commentForm");
+        
         // extract weblog object
         weblog = pageRequest.getWeblog();
     }    
@@ -195,41 +188,16 @@
         
     
     /**
-     * Get comment form to be displayed, may contain preview data. 
-     * @return Comment form object or null if not on a comment page.
+     * Get comment form to be displayed, may contain preview data.
+     *
+     * @return Comment form object
      */
-    public CommentFormEx getCommentForm() {
-        CommentFormEx commentForm =
-                (CommentFormEx) request.getAttribute("commentForm");
-        if (commentForm == null) {
-            commentForm = new CommentFormEx();
-            // Set fields to spaces to please Velocity
-            commentForm.setName("");
-            commentForm.setEmail("");
-            commentForm.setUrl("");
-            commentForm.setContent("");
-        }
-        return commentForm;
-    }
+    public WeblogEntryCommentForm getCommentForm() {
         
-    
-    /**
-     * Get preview comment or null if none exists.
-     */
-    public CommentDataWrapper getCommentPreview() {
-        CommentDataWrapper commentWrapper = null;
-        try {
-            if (request.getAttribute("previewComments") != null) {
-                ArrayList list = new ArrayList();
-                CommentData comment = new CommentData();
-                CommentFormEx commentForm = getCommentForm();
-                commentForm.copyTo(comment, request.getLocale());
-                commentWrapper = CommentDataWrapper.wrap(comment);
-            }
-        } catch (RollerException e) {
-            log.warn("ERROR: creating comment form", e);
+        if(commentForm == null) {
+            commentForm = new WeblogEntryCommentForm();
         }
-        return commentWrapper;
+        return commentForm;
     }
     
 }

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java?rev=426248&r1=426247&r2=426248&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/CommentServlet.java
Thu Jul 27 14:21:45 2006
@@ -37,7 +37,6 @@
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -52,12 +51,11 @@
 import org.apache.roller.pojos.UserData;
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WebsiteData;
-import org.apache.roller.ui.authoring.struts.formbeans.CommentFormEx;
-import org.apache.roller.ui.core.RollerSession;
 import org.apache.roller.ui.rendering.model.UtilitiesModel;
 import org.apache.roller.ui.rendering.util.CommentAuthenticator;
 import org.apache.roller.ui.rendering.util.DefaultCommentAuthenticator;
 import org.apache.roller.ui.rendering.util.WeblogCommentRequest;
+import org.apache.roller.ui.rendering.util.WeblogEntryCommentForm;
 import org.apache.roller.util.GenericThrottle;
 import org.apache.roller.util.IPBanList;
 import org.apache.roller.util.MailUtil;
@@ -226,13 +224,31 @@
         
         log.debug("Doing comment posting for entry = "+entry.getPermaLink());
         
+        // collect input from request params and construct new comment object
+        // fields: name, email, url, content, notify
+        // TODO: data validation on collected comment data
+        CommentData comment = new CommentData();
+        comment.setName(commentRequest.getName());
+        comment.setEmail(commentRequest.getEmail());
+        comment.setUrl(commentRequest.getUrl());
+        comment.setContent(commentRequest.getContent());
+        comment.setNotify(new Boolean(commentRequest.isNotify()));
+        comment.setWeblogEntry(entry);
+        comment.setRemoteHost(request.getRemoteHost());
+        comment.setPostTime(new Timestamp(System.currentTimeMillis()));
+        
+        WeblogEntryCommentForm cf = new WeblogEntryCommentForm();
+        cf.setData(comment);
+        
         // check if site is allowing comments
         if(!RollerRuntimeConfig.getBooleanProperty("users.comments.enabled")) {
+            // TODO: i18n
             error = "Comments are disabled for this site.";
         
         // check if weblog and entry are allowing comments
         } else if(!weblog.getAllowComments().booleanValue() ||
                 !entry.getCommentsStillAllowed()) {
+            // TODO: i18n
             error = "Comments not allowed on this entry";
         
         // make sure comment authentication passed
@@ -243,39 +259,18 @@
         
         // bail now if we have already found an error
         if(error != null) {
-            HttpSession session = request.getSession();
-            session.setAttribute(RollerSession.ERROR_MESSAGE, error);
+            cf.setError(error);
+            request.setAttribute("commentForm", cf);
             RequestDispatcher dispatcher = request.getRequestDispatcher(dispatch_url);
             dispatcher.forward(request, response);
             return;
         }
         
         
-        // collect input from request params and construct new comment object
-        // fields: name, email, url, content, notify
-        // TODO: data validation on collected comment data
-        CommentData comment = new CommentData();
-        comment.setName(commentRequest.getName());
-        comment.setEmail(commentRequest.getEmail());
-        comment.setUrl(commentRequest.getUrl());
-        comment.setContent(commentRequest.getContent());
-        comment.setNotify(new Boolean(commentRequest.isNotify()));
-        comment.setWeblogEntry(entry);
-        comment.setRemoteHost(request.getRemoteHost());
-        comment.setPostTime(new Timestamp(System.currentTimeMillis()));
-        
-        // this is legacy stuff, but still used by ContextLoader
-        // we can probably switch this to a CommentData without problems
-        CommentFormEx cf = new CommentFormEx();
-        RequestUtils.populate(cf, request);
-        cf.setWeblogEntry(entry);
-        cf.setPostTime(comment.getPostTime());
-        request.setAttribute("commentForm", cf);
-        request.setAttribute("blogEntry", entry);
-        
-        
         if (preview) {
+            // TODO: i18n
             message = "This is a comment preview only";
+            cf.setPreview(comment);
             
             // If comment contains blacklisted text, warn commenter
             SpamChecker checker = new SpamChecker();
@@ -283,7 +278,6 @@
                 error = bundle.getString("commentServlet.previewMarkedAsSpam");
                 log.debug("Comment marked as spam");
             }
-            request.setAttribute("previewComments", "dummy");
             log.debug("Comment is a preview");
             
         } else {
@@ -323,7 +317,7 @@
                 sendEmailNotification(comment, rootURL);
                 
                 // comment was successful, clear the comment form
-                request.removeAttribute("commentForm");
+                cf = new WeblogEntryCommentForm();
                 
             } catch (RollerException re) {
                 log.error("Error saving comment", re);
@@ -333,11 +327,11 @@
         
 
         // the work has been done, now send the user back to the entry page
-        HttpSession session = request.getSession();
         if (error != null)
-            session.setAttribute(RollerSession.ERROR_MESSAGE, error);
+            cf.setError(error);
         if (message != null)
-            session.setAttribute(RollerSession.STATUS_MESSAGE, message);
+            cf.setMessage(message);
+        request.setAttribute("commentForm", cf);
         
         log.debug("comment processed, forwarding to "+dispatch_url);
         RequestDispatcher dispatcher =

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java?rev=426248&r1=426247&r2=426248&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
Thu Jul 27 14:21:45 2006
@@ -44,6 +44,7 @@
 import org.apache.roller.ui.rendering.RendererManager;
 import org.apache.roller.ui.rendering.model.ModelLoader;
 import org.apache.roller.ui.rendering.util.SiteWideCache;
+import org.apache.roller.ui.rendering.util.WeblogEntryCommentForm;
 import org.apache.roller.ui.rendering.util.WeblogPageCache;
 
  
@@ -274,6 +275,13 @@
             initData.put("pageRequest", pageRequest);
             initData.put("weblogRequest", pageRequest);
             initData.put("pageContext", pageContext);
+            
+            // if this was a comment posting, check for comment form
+            WeblogEntryCommentForm commentForm = 
+                    (WeblogEntryCommentForm) request.getAttribute("commentForm");
+            if(commentForm != null) {
+                initData.put("commentForm", commentForm);
+            }
             
             // Load models for pages
             String pageModels = RollerConfig.getProperty("rendering.pageModels");

Added: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogEntryCommentForm.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogEntryCommentForm.java?rev=426248&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogEntryCommentForm.java
(added)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogEntryCommentForm.java
Thu Jul 27 14:21:45 2006
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.util;
+
+import org.apache.roller.pojos.CommentData;
+import org.apache.roller.pojos.WeblogEntryData;
+import org.apache.roller.pojos.wrapper.CommentDataWrapper;
+import org.apache.roller.pojos.wrapper.WeblogEntryDataWrapper;
+
+
+/**
+ * A simple class to represent the comment form displayed on a weblog entry
+ * permalink page.  We use this class to manage the interaction with that form.
+ */
+public class WeblogEntryCommentForm {
+    
+    private boolean error = false;
+    private String message = null;
+    
+    private String name = "";
+    private String email = "";
+    private String url = "";
+    private String content = "";
+    private boolean notify = false;
+    
+    private CommentData previewComment = null;
+    
+    
+    public WeblogEntryCommentForm() {}
+    
+    
+    public void setPreview(CommentData preview) {
+        this.previewComment = preview;
+        setData(preview);
+    }
+    
+    public void setData(CommentData comment) {
+        this.name = comment.getName();
+        this.email = comment.getEmail();
+        this.url = comment.getUrl();
+        this.content = comment.getContent();
+        this.notify = comment.getNotify().booleanValue();
+    }
+    
+    public void setError(String errorMessage) {
+        this.error = true;
+        this.message = errorMessage;
+    }
+    
+    public CommentDataWrapper getPreviewComment() {
+        return CommentDataWrapper.wrap(previewComment);
+    }
+    
+    public boolean isPreview() {
+        return (this.previewComment != null);
+    }
+    
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public boolean isNotify() {
+        return notify;
+    }
+
+    public void setNotify(boolean notify) {
+        this.notify = notify;
+    }
+
+    public boolean isError() {
+        return error;
+    }
+
+    public void setError(boolean error) {
+        this.error = error;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+    
+}

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java?rev=426248&r1=426247&r2=426248&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
Thu Jul 27 14:21:45 2006
@@ -37,8 +37,6 @@
 import org.apache.roller.config.RollerRuntimeConfig;
 import org.apache.roller.model.Roller;
 import org.apache.roller.model.RollerFactory;
-import org.apache.roller.model.UserManager;
-import org.apache.roller.model.WeblogManager;
 import org.apache.roller.pojos.CommentData;
 import org.apache.roller.pojos.FolderData;
 import org.apache.roller.pojos.RollerPropertyData;
@@ -50,14 +48,11 @@
 import org.apache.roller.pojos.wrapper.TemplateWrapper;
 import org.apache.roller.pojos.wrapper.WeblogEntryDataWrapper;
 import org.apache.roller.pojos.wrapper.WebsiteDataWrapper;
-import org.apache.roller.ui.authoring.struts.formbeans.CommentFormEx;
 import org.apache.roller.ui.core.RollerContext;
 import org.apache.roller.ui.core.RollerSession;
 import org.apache.roller.ui.rendering.newsfeeds.NewsfeedCache;
-import org.apache.roller.ui.rendering.util.InvalidRequestException;
+import org.apache.roller.ui.rendering.util.WeblogEntryCommentForm;
 import org.apache.roller.ui.rendering.util.WeblogPageRequest;
-import org.apache.roller.ui.rendering.util.WeblogRequest;
-import org.apache.roller.ui.rendering.util.WeblogSearchRequest;
 import org.apache.roller.util.DateUtil;
 import org.apache.roller.util.RegexUtil;
 import org.apache.roller.util.URLUtilities;
@@ -308,10 +303,10 @@
         ctx.put("autoformat",        new Boolean(autoFormat) );
         
         // Make sure comment form object is available in context
-        CommentFormEx commentForm =
-                (CommentFormEx) request.getAttribute("commentForm");
+        WeblogEntryCommentForm commentForm =
+                (WeblogEntryCommentForm) request.getAttribute("commentForm");
         if ( commentForm == null ) {
-            commentForm = new CommentFormEx();
+            commentForm = new WeblogEntryCommentForm();
             
             // Set fields to spaces to please Velocity
             commentForm.setName("");
@@ -322,12 +317,10 @@
         ctx.put("commentForm",commentForm);
         
         // Either put a preview comment in to context
-        if ( request.getAttribute("previewComments")!=null ) {
+        if(commentForm.isPreview()) {
             ArrayList list = new ArrayList();
-            CommentData cd = new CommentData();
-            commentForm.copyTo(cd, request.getLocale());
-            list.add(CommentDataWrapper.wrap(cd));
-            ctx.put("previewComments",list);
+            list.add(commentForm.getPreviewComment());
+            ctx.put("previewComments", list);
         }
         
         if (entry.getStatus().equals(WeblogEntryData.PUBLISHED)) {

Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/deprecated/comments.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/deprecated/comments.vm?rev=426248&r1=426247&r2=426248&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/deprecated/comments.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/deprecated/comments.vm Thu Jul
27 14:21:45 2006
@@ -84,35 +84,8 @@
  * @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>
+    ## replaced by Roller 3.0 version
+    #showWeblogEntryComments($entry)
 #end
 
 #**
@@ -181,10 +154,19 @@
  * @param entry WeblogEntry object for which form is to be shown.
  *#
 #macro( showCommentForm $entry )
+    #set($cform = $model.getCommentForm())
+
     <div class="comments-form">
     <div class="comments-head">$text.get("macro.weblog.postcommentHeader")</div><br/>
 
-    #showStatusMessage()
+#if( $entry.commentsStillAllowed )
+
+    #if( $cform.error )
+        <span class="error">$cform.message</span>
+    #end
+    #if( !$cform.error && !$utils.isEmpty($cform.message) )
+        <span class="status">$cform.message</span>
+    #end
 
     <form method="post" action="$url.entry($entry.anchor)" focus="name"
         name="form" onsubmit="fixURL(this); return validateComments(this)">
@@ -198,25 +180,27 @@
 
         <table cellspacing="0" cellpadding="1" border="0" width="95%">
         <tr><th>$text.get( "macro.weblog.name" )</th>
-            <td><input type="text" name="name" value="$commentForm.name" size="50"
maxlength="255" /></td>
+            <td><input type="text" name="name" value="$cform.name" size="50" maxlength="255"
/></td>
         </tr>
 
         <tr><th>$text.get( "macro.weblog.email" )</th>
-            <td><input type="text" name="email" value="$commentForm.email" size="50"
maxlength="255" /></td>
+            <td><input type="text" name="email" value="$cform.email" size="50" maxlength="255"
/></td>
         </tr>
 
         <tr><th>$text.get( "macro.weblog.url" )</th>
-            <td><input type="text" name="url" value="$commentForm.url" size="50"
maxlength="255" /></td>
+            <td><input type="text" name="url" value="$cform.url" size="50" maxlength="255"
/></td>
         </tr>
-        #if ($pageModel.emailComments)
+
+        #if ($config.getBooleanProperty("users.comments.emailnotify"))
         <tr>
             <td></td>
             <td>
-                <input type="checkbox" id="notify" name="notify" />
+                <input type="checkbox" id="notify" name="notify" #if($cform.notify)CHECKED
#end/>
                 <label for="notify">$text.get( "macro.weblog.notifyMeOfComments" )</label>
             </td>
         </tr>
         #end
+
         <tr>
             <td></td>
             <td>
@@ -231,10 +215,10 @@
         <tr><th style="text-align: left">$text.get( "macro.weblog.yourcomment"
)</th></tr>
         <tr>
             <td>
-            <textarea name="content" cols="50" rows="10">$commentForm.content</textarea><br
/>
+            <textarea name="content" cols="50" rows="10">$cform.content</textarea><br
/>
             <span class="comments-syntax-indicator">
             $text.get( "macro.weblog.htmlsyntax" )
-            #if( $escapeHtml )
+            #if($config.getBooleanProperty("users.comments.escapehtml"))
                 <span class="disabled">$text.get( "macro.weblog.htmldisabled" )</span>
             #else
                 <span class="enabled">$text.get( "macro.weblog.htmlenabled" )</span>
@@ -308,8 +292,14 @@
         }
     }
     </script>
+
+#else
+    <span class="status">$text.get( "comments.disabled" )</span>
+#end
+
     </div>
 #end
+
 
 #**
  * Display hidden comment form for a weblog entry.

Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/weblog.vm
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/weblog.vm?rev=426248&r1=426247&r2=426248&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/weblog.vm (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/velocity/weblog.vm Thu Jul 27 14:21:45
2006
@@ -149,21 +149,19 @@
 *#
 #macro(showWeblogEntryComments $entry)
     <a name="comments"></a>
-    <div class="comments">
+    <div class="comments" id="comments">
 
-    #if($model.commentPreview)
-        #set($comments = [$model.commentPreview])
+    #if($model.commentForm.preview)
+        #set($comments = [$model.commentForm.previewComment])
         <div class="comments-head">$text.get( "macro.weblog.preview" ):</div>
     #else
         <div class="comments-head">$text.get( "macro.weblog.comments" ):</div>
-        #set($entry = $map.getValues().get(0))
         #set($comments = $entry.getComments(true, true))
     #end
 
     <br/>
     #foreach( $comment in $comments )
-        <!-- comment: $comment.id -->
-        #if($comment.approved || $commentPreview)
+        #if($comment.approved || $model.commentForm.preview)
             #set($content = $utils.encodeEmail($comment.content))
             #if($config.getBooleanProperty("users.comments.escapehtml"))
                 #set($content = $utils.escapeHTML($content))
@@ -176,27 +174,25 @@
             #set($content = $utils.addNofollow($content))
 
             <div class="comment#if($velocityCount % 2 == 0) even#else odd#end" id="comment${velocityCount}">
-                #if ($content.startsWith("<p>")) #set ($content = $content.substring(3))
#end
-                <strong>${velocityCount}.</strong> ${content}
+
+                ${content}
 
                 $dateFormatter.applyPattern($text.get( "macro.weblog.datepattern" ))
                 <p class="comment-details">
                 $text.get("macro.weblog.postedby")
-                #if (!$utils.isEmpty($comment.name) && !$utils.isEmpty($comment.remoteHost))
-                    <b>$comment.name</b> ($comment.remoteHost)
+                #if (!$utils.isEmpty($comment.name) && !$utils.isEmpty($comment.url))
+                    <a rel="nofollow" href="$comment.url"><b>$comment.name</b></a>
                 #elseif (!$utils.isEmpty($comment.name))
                     <b>$comment.name</b>
-                #elseif (!$utils.isEmpty($comment.remoteHost))
+                #else
                     <b>$comment.remoteHost</b>
                 #end
                 $text.get("macro.weblog.on") $dateFormatter.format($comment.postTime)
-                #if( $utils.isNotEmpty($comment.url) )
-                    $text.get( "macro.weblog.postedbywebsite", [$comment.url, $comment.url]
)
-                #end
                 <a href="$url.comment($entry.anchor, $velocityCount)"
                    class="entrypermalink"
                    title="$text.get( "macro.weblog.commentpermalink.title" )">#</a>
                 </p>
+
             </div>
 
         #end
@@ -214,15 +210,17 @@
     <div class="comments-form">
     <div class="comments-head">$text.get("macro.weblog.postcommentHeader")</div>
 
-    #if( $model.errorMessage )
-        <span class="error">$model.errorMessage</span>
+#if( $entry.commentsStillAllowed )
+
+    #if( $cform.error )
+        <span class="error">$cform.message</span>
     #end
-    #if( $model.statusMessage )
-        <span class="status">$model.statusMessage</span>
+    #if( !$cform.error && !$utils.isEmpty($cform.message) )
+        <span class="status">$cform.message</span>
     #end
 
-    <form method="post" action="$url.entry($entry.anchor)" 
-        focus="name" name="form" onsubmit="fixURL(this); return validateComments(this)">
   
+    <form method="post" action="$url.entry($entry.anchor)" focus="name" 
+        name="form" onsubmit="fixURL(this); return validateComments(this)">    
         <input type="hidden" name="method" value="post" />
 
         <ul>
@@ -241,7 +239,7 @@
             </li>
 
         #if ($config.getBooleanProperty("users.comments.emailnotify"))
-            <li><input type="checkbox" class="checkbox" id="notify" name="notify"
/>
+            <li><input type="checkbox" class="checkbox" id="notify" name="notify"
#if($cform.notify)CHECKED #end/>
                 <label for="notify" class="choice">$text.get( "macro.weblog.notifyMeOfComments"
)</label>
             </li>
         #end
@@ -322,6 +320,11 @@
         }
     }
     </script>
+
+#else
+    <span class="status">$text.get( "comments.disabled" )</span>
+#end
+
     </div>
 #end
 



Mime
View raw message