You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2006/10/20 18:56:07 UTC

svn commit: r466200 - in /incubator/roller/trunk: src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java src/org/apache/roller/util/URLUtilities.java web/WEB-INF/jsps/authoring/WeblogEdit.jsp

Author: agilliland
Date: Fri Oct 20 09:56:03 2006
New Revision: 466200

URL: http://svn.apache.org/viewvc?view=rev&rev=466200
Log:
enable full preview for entries that have already been saved.


Modified:
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
    incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java?view=diff&rev=466200&r1=466199&r2=466200
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java Fri Oct 20 09:56:03 2006
@@ -50,6 +50,7 @@
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.ui.core.RollerContext;
 import org.apache.roller.ui.core.plugins.UIPluginManager;
+import org.apache.roller.util.URLUtilities;
 
 /**
  * All data needed to render the edit-weblog page.
@@ -388,6 +389,13 @@
         if (weblogEntry.getId() == null) return 0;
         List comments = comments = weblogEntry.getComments(false, false);
         return comments != null ? comments.size() : 0;
+    }
+    
+    public String getFullPreviewURL() {
+        if (weblogEntry.getId() != null) {
+            return URLUtilities.getPreviewWeblogEntryURL(weblogEntry.getAnchor(), website, null, false);
+        }
+        return null;
     }
 }
 

Modified: incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java?view=diff&rev=466200&r1=466199&r2=466200
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java Fri Oct 20 09:56:03 2006
@@ -392,6 +392,42 @@
     
     
     /**
+     * Get url for a given *preview* weblog entry.  
+     * Optionally for a certain locale.
+     */
+    public static final String getPreviewWeblogEntryURL(String previewAnchor,
+                                                        WebsiteData weblog,
+                                                        String locale,
+                                                        boolean absolute) {
+        
+        if(weblog == null) {
+            return null;
+        }
+        
+        StringBuffer url = new StringBuffer();
+        
+        if(absolute) {
+            url.append(RollerRuntimeConfig.getAbsoluteContextURL());
+        } else {
+            url.append(RollerRuntimeConfig.getRelativeContextURL());
+        }
+        
+        url.append("/roller-ui/authoring/preview/").append(weblog.getHandle()).append("/");
+        
+        if(locale != null) {
+            url.append(locale).append("/");
+        }
+        
+        Map params = new HashMap();
+        if(previewAnchor != null) {
+            params.put("previewEntry", encode(previewAnchor));
+        }
+        
+        return url.toString() + getQueryString(params);
+    }
+    
+    
+    /**
      * Get a url to a *preview* resource on a given weblog.
      */
     public static final String getPreviewWeblogResourceURL(String previewTheme,

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp?view=diff&rev=466200&r1=466199&r2=466200
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp Fri Oct 20 09:56:03 2006
@@ -61,6 +61,9 @@
     document.weblogEntryFormEx.method.value = "save";
     postWeblogEntry();
 }
+function fullPreviewMode() {
+    window.open('<%= model.getFullPreviewURL() %>', '_preview', '');
+}
 -->
 </script>
 
@@ -379,10 +382,19 @@
 
         <%-- edit mode buttons --%>
         <c:if test="${model.editMode}" >
-
-            <input type="button" name="preview"
-                   value='<fmt:message key="weblogEdit.previewMode" />'
-                   onclick="previewMode()" />
+            
+            <c:choose>
+                <c:when test="${!empty weblogEntryFormEx.id}">
+                    <input type="button" name="fullPreview"
+                            value='<fmt:message key="weblogEdit.fullPreviewMode" />'
+                            onclick="fullPreviewMode()" />
+                </c:when>
+                <c:otherwise>
+                    <input type="button" name="preview"
+                            value='<fmt:message key="weblogEdit.previewMode" />'
+                            onclick="previewMode()" />
+                </c:otherwise>
+            </c:choose>
 
         </c:if>