On 5/9/06, David M Johnson <[EMAIL PROTECTED]> wrote:


On May 9, 2006, at 6:01 PM, Matt Raible wrote:
> My modifications to the *.vm templates fix JavaScript and CSS issues -
> should those go in 2.3 or 2.4?

I've already found 1 problem in RC2, so they could conceivably go in
2.3.

How extensive and how risky are those *.vm changes?

I've attached the patch so you can see.  The only major thing is a new
form for comments that more CSS-friendly. Other things include new
macros and fixing comments HTML so it renders with XHTML compliance. I also fixed a bug in the JavaScript for Remember Me (only happens
with IE).

I've successfully upgraded a site from 2.0 to 2.3 RC2 today, but I
have noticed an issue with the LineBreak Plugin.  As soon as it's
added to an entry, the entry cannot be rendered and there's no way of
getting it back - even though it's stored in the database and renders
in the editor. Below is an example.

http://virtuastravels.com/page/road?entry=a_federal_incident_8230

Any ideas?

Thanks,

Matt


- Dave


Index: web/WEB-INF/classes/weblog.vm
===================================================================
--- web/WEB-INF/classes/weblog.vm       (revision 405559)
+++ web/WEB-INF/classes/weblog.vm       (working copy)
@@ -72,7 +72,11 @@
         #showEntryLinkbacks($entry)
         #showComments($entry)
         #if($commentsEnabled && $website.allowComments && 
$entry.commentsStillAllowed)
-            #showCommentForm($entry)
+            #if ($cssCommentsForm)
+                #showCommentCSSForm($entry)
+            #else
+                #showCommentForm($entry)
+            #end
         #else
             $text.get("comments.disabled")
         #end
Index: web/WEB-INF/classes/comments.vm
===================================================================
--- web/WEB-INF/classes/comments.vm     (revision 405559)
+++ web/WEB-INF/classes/comments.vm     (working copy)
@@ -30,7 +30,27 @@
     #end
 #end
 
+
 #**
+ * Display the in-page comments link for a weblog entry. Uses Comments: # 
syntax.
+ * @param entry WeblogEntryData object for which link is to be displayed.
+ *#
+#macro( showCommentsCountAndLink $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="commentsLink">
+        #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>
+    #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.
@@ -41,7 +61,7 @@
         <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">
+            <a href="$ctxPath$entry.permaLink#comments" class="plain">
             #if($commentCount == 0)
                 $text.get( "macro.weblog.addcomment" )
             #elseif($commentCount == 1)
@@ -84,7 +104,8 @@
  * @param entry WeblogEntryData object for which comments are to be displayed.
  *#
 #macro( showComments $entry )
-    <div class="comments" id="comments">
+    <a name="comments"></a>
+    <div class="comments">
     #if( $previewComments )
         #set( $comments = $previewComments )
         <div class="comments-head">$text.get( "macro.weblog.preview" ):</div>
@@ -106,8 +127,9 @@
                 #set($content = $utilities.autoformat($content))
             #end
             #set($content = $utilities.addNofollow($content))
-            <div class="comment" id="comment${velocityCount}">
-                ${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}
                 #showCommentDetails($comment true)
             </div>
         #end
@@ -123,7 +145,7 @@
     #if( !$numComments ) #set( $numComments = 20 ) #end
     #if( $numComments > 100 ) #set( $numComments = 50 ) #end
     #set( $comments = $pageModel.getRecentComments($numComments) )
-    <div class="comments" id="comments">
+    <div class="comments">
     #foreach( $comment in $comments )
         #set($content = $utilities.encodeEmail($comment.content))
         #if($escapeHtml)
@@ -252,7 +274,7 @@
         <tr>
             <td align="left" nowrap="nowrap">
                <input type="button" name="post" value="&nbsp;$text.get( 
"macro.weblog.preview" )&nbsp;"
-                  
onClick="this.form.method.value='preview';this.form.submit()" />
+                  
onclick="this.form.method.value='preview';this.form.submit()" />
                <input type="submit" name="post" value="&nbsp;$text.get( 
"macro.weblog.post" )&nbsp;" />
             </td>
             <td align="right">
@@ -272,17 +294,17 @@
     var url = getCookie("commentUrl");
     // check each field - IE will render "null"
     if (author) {
-        document.form.name.value = author;
+        document.forms['commentForm'].name.value = author;
     }
     if (email) {
-        document.form.email.value = email;
+        document.forms['commentForm'].email.value = email;
     }
     if (url) {
-        document.form.url.value = url;
+        document.forms['commentForm'].url.value = url;
     }
 
     if (author || email || url) {
-        document.form.rememberInfo.checked = true;
+        document.forms['commentForm'].rememberInfo.checked = true;
     }
 
     function fixURL(theForm) {
@@ -313,6 +335,125 @@
 #end
 
 #**
+ * Display comment form for a weblog entry.
+ * @param entry WeblogEntry object for which form is to be shown.
+ *#
+#macro( showCommentCSSForm $entry )
+    <div class="comments-form">
+    <div 
class="comments-head">$text.get("macro.weblog.postcommentHeader")</div>
+
+    #showStatusMessage()
+
+    <form method="post" action="$ctxPath/comment" id="commentForm" 
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" />
+
+        <ul>
+            <li>
+                <label class="desc">$text.get( "macro.weblog.name" )</label>
+                <input type="text" name="name" class="text large" 
value="$commentForm.name" size="50" maxlength="255" />
+            </li>
+
+
+            <li><label class="desc">$text.get( "macro.weblog.email" )</label>
+                <input type="text" name="email" class="text large" 
value="$commentForm.email" size="50" maxlength="255" />
+            </li>
+
+            <li><label class="desc">$text.get( "macro.weblog.url" )</label>
+                <input type="text" name="url" class="text large" 
value="$commentForm.url" size="50" maxlength="255" />
+            </li>
+
+        #if ($pageModel.emailComments)
+            <li><input type="checkbox" class="checkbox" id="notify" 
name="notify" />
+                <label for="notify" class="choice">$text.get( 
"macro.weblog.notifyMeOfComments" )</label>
+            </li>
+        #end
+            <li>
+                <input type="checkbox" class="checkbox" id="rememberInfo" 
name="rememberInfo" />
+                <label for="rememberInfo" class="choice">$text.get( 
"macro.weblog.rememberinfo" )</label>
+            </li>
+            <li>
+                <label class="desc">$text.get( "macro.weblog.yourcomment" 
)</label>
+                <textarea name="content" class="textarea large" cols="" 
rows="">$commentForm.content</textarea>
+            </li>
+            <li class="info">
+                <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>
+            </li>
+            <li class="info">
+               <script type="text/javascript" 
src="$ctxPath/theme/scripts/clientSideInclude.js"></script>
+               <div id="commentAuthenticator"></div>
+            </li>
+            <li>
+               <input type="button" class="button" name="post" 
value="&nbsp;$text.get( "macro.weblog.preview" )&nbsp;"
+                  
onclick="this.form.method.value='preview';this.form.submit()" />
+               <input type="submit" class="button" name="post" 
value="&nbsp;$text.get( "macro.weblog.post" )&nbsp;" />
+            </li>
+        </ul>
+    </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.forms['commentForm'].name.value = author;
+    }
+    if (email) {
+        document.forms['commentForm'].email.value = email;
+    }
+    if (url) {
+        document.forms['commentForm'].url.value = url;
+    }
+
+    if (author || email || url) {
+        document.forms['commentForm'].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,
  *#
Index: web/WEB-INF/classes/website.vm
===================================================================
--- web/WEB-INF/classes/website.vm      (revision 405559)
+++ web/WEB-INF/classes/website.vm      (working copy)
@@ -109,6 +109,40 @@
 #macro( showWeblogCategoryChooser )#showWeblogSubcategoryChooser2("nil" 
"|")#end
 
 #**
+ * Shows weblog category chooser with ul and li
+ * @param parentCategory Name of top-level category to display.
+ *#
+#macro( showCategoriesAsList $parentCategory )
+    #set( $rawUrl = "${ctxPath}/page/${website.handle}" )
+
+    <ul class="clearfix">
+    #set( $weblogUrl = $rawUrl )
+    #set( $chosenCat = "" )
+    #if( $req.getParameter( $WEBLOGCATEGORYNAME_KEY ) )
+        #set( $chosenCat = $req.getParameter( $WEBLOGCATEGORYNAME_KEY ) )
+        <li><a href="$weblogUrl">$text.get( "macro.weblog.allcategories" 
)</a></li>
+    #else
+        <li class="selected"><a href="$weblogUrl">$text.get( 
"macro.weblog.allcategories" )</a></li>
+    #end
+
+    #if ( $req.getParameter($PAGEID_KEY)  )
+        #set( $pageParam = "&$PAGEID_KEY=$req.getParameter($PAGEID_KEY)" )
+    #end
+    #set( $cats = $pageModel.getWeblogCategories($parentCategory) )
+    #foreach( $cat in $cats )
+        ## $pageHelper.strutsUrlHelper() wasn't working, so do it manually
+        #set( $catParam = 
"?$WEBLOGCATEGORYNAME_KEY=$utilities.encode($cat.path)" )
+        #set( $weblogUrl = "$rawUrl$catParam$!pageParam" )
+        #if( $chosenCat == $cat.path )
+            <li class="selected"><a href="$weblogUrl">$cat.Name</a></li>
+        #else
+            <li><a href="$weblogUrl">$cat.Name</a></li>
+        #end
+    #end
+    </ul>
+#end
+
+#**
  * Display weblog calandar for one specific category.
  * @param big            True to display a BIG calendar, good for an archive 
page.
  * @param parentCategory Name of top-level category to display.
Index: web/WEB-INF/classes/navbar.vm
===================================================================
--- web/WEB-INF/classes/navbar.vm       (revision 405559)
+++ web/WEB-INF/classes/navbar.vm       (working copy)
@@ -75,6 +75,7 @@
                     #else $delimiter
                     #end
                     $iPage.Name
+                    #if( $useCSS )</li>#end
                 #end
             #end
         #end

Reply via email to