jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r884986 - in /incubator/jspwiki/trunk/src: WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/action/
Date Fri, 27 Nov 2009 20:28:30 GMT
Author: ajaquith
Date: Fri Nov 27 20:28:29 2009
New Revision: 884986

URL: http://svn.apache.org/viewvc?rev=884986&view=rev
Log:
Default template AJAXCategories.jsp logic moved to ViewActionBean.ajaxCategories(). AJAXPreview.jsp
logic moved to EditActionBean.ajaxPreview(). Script files jspwiki-common.js and jspwiki-edit.js
were slightly tweaked. ** not fully tested yet **

Removed:
    incubator/jspwiki/trunk/src/WebContent/templates/default/AJAXCategories.jsp
    incubator/jspwiki/trunk/src/WebContent/templates/default/AJAXPreview.jsp
Modified:
    incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
    incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java

Modified: incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=884986&r1=884985&r2=884986&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js (original)
+++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js Fri Nov 27 20:28:29 2009
@@ -2598,7 +2598,7 @@
 
 				event.stop();  //dont jump to top of page ;-)
 				new Request.HTML({
-					url:Wiki.TemplateUrl + 'AJAXCategories.jsp',
+					url:Wiki.BaseUrl + '/View.action?ajaxCategories=',
 					data: '&page=' + page,
 					update: popup,
 					onComplete: function(){

Modified: incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js?rev=884986&r1=884985&r2=884986&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js (original)
+++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js Fri Nov 27 20:28:29 2009
@@ -584,8 +584,8 @@
 			self.previewcache = text;
 
 			new Request.HTML({
-				url:Wiki.TemplateUrl + "/AJAXPreview.jsp?page=" + page,
-				data: 'wikimarkup=' + encodeURIComponent( text ),
+				url:Wiki.BaseUrl + "/Edit.action?ajaxPreview=&page=" + page,
+				data: 'wikiText=' + encodeURIComponent( text ),
 				update: preview,
 				onRequest: function(){ spin.show(); },
 				onComplete: function(){ spin.hide(); Wiki.renderPage(preview, page); }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java?rev=884986&r1=884985&r2=884986&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java Fri Nov 27
20:28:29 2009
@@ -21,9 +21,13 @@
 
 package org.apache.wiki.action;
 
+import java.io.IOException;
+import java.io.Writer;
 import java.net.URI;
 import java.util.List;
 
+import javax.servlet.http.HttpServletResponse;
+
 import net.sourceforge.stripes.action.*;
 import net.sourceforge.stripes.controller.LifecycleStage;
 import net.sourceforge.stripes.validation.LocalizableError;
@@ -31,14 +35,17 @@
 import net.sourceforge.stripes.validation.ValidationError;
 import net.sourceforge.stripes.validation.ValidationErrors;
 
+import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiProvider;
+import org.apache.wiki.api.PluginException;
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
+import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.ui.stripes.HandlerPermission;
 import org.apache.wiki.ui.stripes.WikiActionBeanContext;
 import org.apache.wiki.ui.stripes.WikiRequestContext;
@@ -62,6 +69,43 @@
     }
 
     /**
+     * Using AJAX, returns a {@link StreamingResolution} containing
+     * divs with categories for a supplied current page.
+     * 
+     * @return always returns a {@link StreamingResolution} containing the
+     * results
+     */
+    @HandlesEvent( "ajaxCategories" )
+    public Resolution ajaxCategories()
+    {
+        Resolution r = new StreamingResolution( "text/html; charset=UTF-8" ) {
+            public void stream( HttpServletResponse response ) throws IOException
+            {
+                WikiContext context = getContext();
+                WikiPage page = getPage();
+                Writer out = response.getWriter();
+                out.write( "<div class='categoryTitle'>");
+                out.write( context.getViewURL( page.getName() ) );
+                out.write( "</div>" );
+                out.write( "<div class='categoryText'>");
+                PluginManager mgr = context.getEngine().getPluginManager();
+                String result;
+                try
+                {
+                    result = mgr.execute( context, "{ReferringPagesPlugin,page="+page.getName()+",max=20,before='*',after='\n'}"
);
+                }
+                catch (PluginException e)
+                {
+                    result = e.getMessage();
+                }
+                out.write( result );
+                out.write( "</div>" );
+            }
+        };
+        return r;
+    }
+
+    /**
      * Handler that forwards to the page information display JSP
      * <code>/Attachments.jsp</code>.
      * 



Mime
View raw message