This is version . It is not the current version, and thus it cannot be edited.
[Back to current version]   [Restore this version]

Here is a patch to add a save button to the preview page. It just makes it more convenient if you are happy with the changes you have made and want to commit them without having to go back first.
The patch simply copies some code for supporting the save button from the Edit JSP files into the Preview files.

Thanks. The patch is now included in 2.1.1 (though I simplified it a bit - you don't need to check latestversion for previewing. --JanneJalkanen
Oops. It seems that if the page is long enough, you can't put the text into a hidden input element; the browser (Mozilla, in this case) cuts off the rest of the page. --JanneJalkanen
There's another problem. If the contents of the page include a double-quote character, the contents get truncated at it. --KellyDenehy


Patch for src/webdocs/Preview.jsp

--- src/webdocs/Preview.jsp.orig     Fri Jan 10 22:27:04 2003
+++ src/webdocs/Preview.jsp Mon Mar 10 16:14:26 2003
@@ -1,3 +1,4 @@
+<%@ page import="java.util.Date" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="com.ecyrd.jspwiki.*" %>
 <%@ page import="com.ecyrd.jspwiki.tags.WikiTagBase" %>
@@ -24,10 +25,11 @@
     NDC.push( wiki.getApplicationName()+":"+pagereq );

     WikiPage wikipage = wiki.getPage( pagereq );
-
+    WikiPage latestversion = wikipage;
     if( wikipage == null )
     {
         wikipage = new WikiPage( pagereq );
+        latestversion = wikipage;
     }

     WikiContext wikiContext = new WikiContext( wiki, wikipage );
@@ -43,6 +45,19 @@
     pageContext.setAttribute( "usertext",
                               wiki.safeGetParameter( request, "text" ),
                               PageContext.REQUEST_SCOPE );
+    //
+    //  Determine and store the date the latest version was changed.  Since
+    //  the newest version is the one that is changed, we need to track
+    //  that instead of the edited version.
+    //
+    long lastchange = 0;
+
+    Date d = latestversion.getLastModified();
+    if( d != null ) lastchange = d.getTime();
+
+    pageContext.setAttribute( "lastchange",
+                              Long.toString( lastchange ),
+                              PageContext.REQUEST_SCOPE );

     String contentPage = "templates/"+skin+"/ViewTemplate.jsp";
 %>

Patch for src/webdocs/templates/default/PreviewContent.jsp
--- src/webdocs/templates/default/PreviewContent.jsp.orig    Fri Nov  8 01:26:48 2002
+++ src/webdocs/templates/default/PreviewContent.jsp    Mon Mar 10 17:04:41 2003
@@ -4,6 +4,7 @@

    <DIV class="previewnote">
       <B>This is a PREVIEW!  Hit "back" on your browser to go back to the editor.</B>
+      <B>Or just hit the save button if you are happy with what you see.</B>
    </DIV>

    <P><HR></P>
@@ -18,4 +19,21 @@

    <DIV class="previewnote">
       <B>This is a PREVIEW!  Hit "back" on your browser to go back to the editor.</B>
+      <B>Or just hit the save button if you are happy with what you see.</B>
    </DIV>
+
+  <FORM action="<wiki:EditLink format="url" />" method="POST" ACCEPT-CHARSET="ISO-8859-1,UTF-8">
+  <%-- These are required parts of this form.  If you do not include these,
+       horrible things will happen.  Do not modify them either. --%>
+
+  <%-- FIXME: This is not required, is it? --%>
+  <INPUT type="hidden" name="page"     value="<wiki:PageName/>">
+  <INPUT type="hidden" name="action"   value="save">
+  <INPUT type="hidden" name="edittime" value="<%=pageContext.getAttribute("lastchange", PageContext.REQUEST_SCOPE )%>">
+  <INPUT type="hidden" name="text" value="<%=pageContext.getAttribute("usertext",PageContext.REQUEST_SCOPE)%>">
+  <%-- End of required area --%>
+
+  <br clear="all" />
+  <input type="submit" name="ok" value="Save" />
+  &nbsp;&nbsp;
+</FORM>

-MarkAnderson


More Category Patches.

Add new attachment

Only authorized users are allowed to upload new attachments.
« This particular version was published on 14-Jul-2003 16:54 by 167.1.146.100.