You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2009/11/27 21:31:39 UTC
svn commit: r884992 - in /incubator/jspwiki/trunk/src:
WebContent/NewBlogEntry.jsp java/org/apache/wiki/action/EditActionBean.java
Author: ajaquith
Date: Fri Nov 27 20:31:39 2009
New Revision: 884992
URL: http://svn.apache.org/viewvc?rev=884992&view=rev
Log:
NewBlogEntry.jsp received the Stripes treatment; its logic moved to EditActionBean.blog().
Modified:
incubator/jspwiki/trunk/src/WebContent/NewBlogEntry.jsp
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java
Modified: incubator/jspwiki/trunk/src/WebContent/NewBlogEntry.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/NewBlogEntry.jsp?rev=884992&r1=884991&r2=884992&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/WebContent/NewBlogEntry.jsp (original)
+++ incubator/jspwiki/trunk/src/WebContent/NewBlogEntry.jsp Fri Nov 27 20:31:39 2009
@@ -18,40 +18,5 @@
specific language governing permissions and limitations
under the License.
--%>
-<%@ page import="java.net.URI" %>
-<%@ page import="org.apache.wiki.log.Logger" %>
-<%@ page import="org.apache.wiki.log.LoggerFactory" %>
-<%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.plugin.*" %>
-<%@ page errorPage="/Error.jsp" %>
-<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld" prefix="wiki" %>
<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s" %>
-<s:useActionBean beanclass="org.apache.wiki.action.EditActionBean" event="edit" id="wikiActionBean" />
-<%!
- Logger log = LoggerFactory.getLogger("JSPWiki");
-%>
-
-<%
- WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
- // Create wiki context; no need to check for authorization since the
- // redirect will take care of that
- WikiContext wikiContext = wiki.createContext( request, WikiContext.EDIT );
- String pagereq = wikiContext.getPage().getName();
-
- // Redirect if the request was for a 'special page'
- URI specialpage = wiki.getSpecialPageReference( pagereq );
- if( specialpage != null )
- {
- // FIXME: Do Something Else
- response.sendRedirect( specialpage.toString() );
- return;
- }
-
- WeblogEntryPlugin p = new WeblogEntryPlugin();
-
- String newEntry = p.getNewEntryPage( wiki, pagereq );
-
- // Redirect to a new page for user to edit
- response.sendRedirect( wiki.getEditURL(newEntry) );
-%>
-
+<s:useActionBean beanclass="org.apache.wiki.action.EditActionBean" event="blog" executeResolution="true" id="wikiActionBean" />
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java?rev=884992&r1=884991&r2=884992&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java Fri Nov 27 20:31:39 2009
@@ -56,9 +56,13 @@
import org.apache.wiki.htmltowiki.HtmlStringToWikiTranslator;
import org.apache.wiki.log.Logger;
import org.apache.wiki.log.LoggerFactory;
+import org.apache.wiki.parser.MarkupParser;
+import org.apache.wiki.parser.WikiDocument;
+import org.apache.wiki.plugin.WeblogEntryPlugin;
import org.apache.wiki.preferences.Preferences;
import org.apache.wiki.preferences.Preferences.TimeFormat;
import org.apache.wiki.providers.ProviderException;
+import org.apache.wiki.render.RenderingManager;
import org.apache.wiki.ui.stripes.HandlerPermission;
import org.apache.wiki.ui.stripes.SpamProtect;
import org.apache.wiki.ui.stripes.WikiActionBeanContext;
@@ -101,6 +105,34 @@
private long m_startTime = -1;
/**
+ * Using AJAX, returns a {@link StreamingResolution} containing
+ * a preview for the current page.
+ *
+ * @return always returns a {@link StreamingResolution} containing the
+ * results
+ */
+ @HandlesEvent( "ajaxPreview" )
+ public Resolution ajaxPreview()
+ {
+ Resolution r = new StreamingResolution( "text/html; charset=UTF-8" ) {
+ public void stream( HttpServletResponse response ) throws IOException
+ {
+ // Parse the wiki markup
+ WikiContext context = getContext();
+ RenderingManager renderer = context.getEngine().getRenderingManager();
+ MarkupParser mp = renderer.getParser( context, m_wikiText );
+ mp.disableAccessRules();
+ WikiDocument doc = mp.parse();
+
+ // Get the text directly from the RenderingManager, without caching
+ String result = renderer.getHTML( context, doc );
+ response.getWriter().write( result );
+ }
+ };
+ return r;
+ }
+
+ /**
* Event handler method that cancels any locks the user possesses for the
* current wiki page, and redirects the user to the {@link ViewActionBean}
* "view" handler.
@@ -126,6 +158,24 @@
return new RedirectResolution( ViewActionBean.class ).addParameter( "page", pagereq );
}
+ /**
+ * Event handler for new blog entries. The handler looks up the correct
+ * blog page and redirects the user to it.
+ * @return always returns a {@link RedirectResolution} to the editing
+ * page for the blog entry.
+ */
+ @HandlesEvent( "blog" )
+ public Resolution blog() throws ProviderException
+ {
+ // Determine the correct page to redirect to
+ WikiEngine engine = getContext().getEngine();
+ WeblogEntryPlugin p = new WeblogEntryPlugin();
+ String blogPage = p.getNewEntryPage( engine, getPage().getName() );
+
+ // Redirect to the blog page for user to edit
+ return new RedirectResolution( EditActionBean.class ).addParameter( "page", blogPage );
+ }
+
@HandlesEvent( "comment" )
@HandlerPermission( permissionClass = PagePermission.class, target = "${page.path}", actions = PagePermission.COMMENT_ACTION )
@WikiRequestContext( "comment" )