You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by me...@apache.org on 2008/11/09 15:23:06 UTC
svn commit: r712502 - in /incubator/jspwiki/trunk: ./ etc/i18n/plugin/
src/com/ecyrd/jspwiki/ src/com/ecyrd/jspwiki/plugin/
tests/com/ecyrd/jspwiki/plugin/
Author: metskem
Date: Sun Nov 9 06:23:06 2008
New Revision: 712502
URL: http://svn.apache.org/viewvc?rev=712502&view=rev
Log:
3.0.0-svn-3 JSPWIKI-415: Favorites not displayed properly, also added 2 JUnit tests
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources.properties
incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources_nl.properties
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/InsertPage.java
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=712502&r1=712501&r2=712502&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Nov 9 06:23:06 2008
@@ -1,3 +1,11 @@
+2008-11-09 Harry Metske <me...@apache.org>
+
+ * 3.0.0-svn-3
+
+ * JSPWIKI-415: Favorites not displayed properly when blank in userName, reported by Trevor Harrison
+ also i18n'ed the InsertPlugin as the fix for JSPWIKI-415 was there.
+ Added 2 JUnit tests for InsertPage plugin
+
2008-11-08 Harry Metske <me...@apache.org>
* 3.0.0-svn-2
Modified: incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources.properties?rev=712502&r1=712501&r2=712502&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources.properties (original)
+++ incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources.properties Sun Nov 9 06:23:06 2008
@@ -53,4 +53,13 @@
plugin.listlocks.locked.by=Locked by
plugin.listlocks.acquired=Acquired
plugin.listlocks.expires=Expires
-plugin.listlocks.no.locks.exist=No locks exist currently.
\ No newline at end of file
+plugin.listlocks.no.locks.exist=No locks exist currently.
+
+# InsertPage plugin
+plugin.insert.notfound=Page could not be found by the page provider.
+plugin.insert.recursion=Error: Circular reference - you can't include a page in itself!
+plugin.insert.nopermission=You do not have permission to view this included page.
+plugin.insert.nopage1=There is no page called
+plugin.insert.nopage2=Would you like to
+plugin.insert.nopage3=create it?
+plugin.insert.definepage=You have to define a page!
\ No newline at end of file
Modified: incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources_nl.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources_nl.properties?rev=712502&r1=712501&r2=712502&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources_nl.properties (original)
+++ incubator/jspwiki/trunk/etc/i18n/plugin/PluginResources_nl.properties Sun Nov 9 06:23:06 2008
@@ -61,4 +61,13 @@
plugin.listlocks.locked.by=In gebruik door
plugin.listlocks.acquired=Sinds
plugin.listlocks.expires=Loopt af
-plugin.listlocks.no.locks.exist=Er zijn momenteel geen locks.
\ No newline at end of file
+plugin.listlocks.no.locks.exist=Er zijn momenteel geen locks.
+
+# InsertPage plugin
+plugin.insert.notfound=Pagina niet gevonden door de Page Provider
+plugin.insert.recursion=Error: Recursie - Je kunt een pagina niet in zichzelf includen !
+plugin.insert.nopermission=Je hebt geen permissies om de include pagina te bekijken
+plugin.insert.nopage1=Er bestaat geen pagina met de naam
+plugin.insert.nopage2=Wil je 'm
+plugin.insert.nopage3=aanmaken ?
+plugin.insert.definepage=Je moet een pagina opgeven !
\ No newline at end of file
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java?rev=712502&r1=712501&r2=712502&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java Sun Nov 9 06:23:06 2008
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "2";
+ public static final String BUILD = "3";
/**
* This is the generic version string you should use
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/InsertPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/InsertPage.java?rev=712502&r1=712501&r2=712502&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/InsertPage.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/InsertPage.java Sun Nov 9 06:23:06 2008
@@ -23,6 +23,7 @@
import com.ecyrd.jspwiki.*;
import com.ecyrd.jspwiki.auth.*;
import com.ecyrd.jspwiki.auth.permissions.PermissionFactory;
+import com.ecyrd.jspwiki.providers.ProviderException;
import java.util.*;
@@ -73,17 +74,16 @@
throws PluginException
{
WikiEngine engine = context.getEngine();
+ ResourceBundle rb = context.getBundle(WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
StringBuffer res = new StringBuffer();
String clazz = (String) params.get( PARAM_CLASS );
String includedPage = (String) params.get( PARAM_PAGENAME );
String style = (String) params.get( PARAM_STYLE );
- String defaultstr = (String) params.get( PARAM_DEFAULT );
- int section = TextUtil.parseIntParameter((String) params.get( PARAM_SECTION ),
- -1 );
- int maxlen = TextUtil.parseIntParameter((String) params.get( PARAM_MAXLENGTH ),
- -1 );
+ String defaultstr = (String) params.get( PARAM_DEFAULT );
+ int section = TextUtil.parseIntParameter( (String) params.get( PARAM_SECTION ), -1 );
+ int maxlen = TextUtil.parseIntParameter( (String) params.get( PARAM_MAXLENGTH ), -1 );
if( style == null ) style = DEFAULT_STYLE;
@@ -91,8 +91,24 @@
if( includedPage != null )
{
- WikiPage page = engine.getPage( includedPage );
-
+ WikiPage page = null;
+ try
+ {
+ String pageName = engine.getFinalPageName( includedPage );
+ if( pageName != null )
+ {
+ page = engine.getPage( pageName );
+ }
+ else
+ {
+ page = engine.getPage( includedPage );
+ }
+ }
+ catch( ProviderException e )
+ {
+ res.append("<span class=\"error\">" + rb.getString( "plugin.insert.notfound" ) + "</span>");
+ return res.toString();
+ }
if( page != null )
{
@@ -106,7 +122,7 @@
{
if( previousIncludes.contains( page.getName() ) )
{
- return "<span class=\"error\">Error: Circular reference - you can't include a page in itself!</span>";
+ return "<span class=\"error\">"+ rb.getString( "plugin.insert.recursion")+"</span>";
}
}
else
@@ -125,7 +141,7 @@
if( !mgr.checkPermission( context.getWikiSession(),
PermissionFactory.getPagePermission( page, "view") ) )
{
- res.append("<span class=\"error\">You do not have permission to view this included page.</span>");
+ res.append("<span class=\"error\">"+rb.getString("plugin.insert.nopermission")+"</span>");
return res.toString();
}
@@ -177,15 +193,15 @@
}
else
{
- res.append("There is no page called '"+includedPage+"'. Would you like to ");
- res.append("<a href=\""+context.getURL( WikiContext.EDIT, includedPage )+"\">create it?</a>");
+ res.append(rb.getString("plugin.insert.nopage1") +" '"+includedPage+"'. " + rb.getString( "plugin.insert.nopage2" ));
+ res.append("<a href=\""+context.getURL( WikiContext.EDIT, includedPage )+"\"> "+rb.getString("plugin.insert.nopage3")+"</a>");
}
}
}
else
{
res.append("<span class=\"error\">");
- res.append("You have to define a page!");
+ res.append(rb.getString("plugin.insert.definepage"));
res.append("</span>");
}
Modified: incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java?rev=712502&r1=712501&r2=712502&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java (original)
+++ incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java Sun Nov 9 06:23:06 2008
@@ -25,6 +25,8 @@
TestEngine.deleteTestPage( "ThisPage" );
TestEngine.deleteTestPage( "ThisPage2" );
TestEngine.deleteTestPage( "Test_Page" );
+ TestEngine.deleteTestPage( "TestPage" );
+ TestEngine.deleteTestPage( "Test Page" );
}
public void testRecursive() throws Exception
@@ -79,6 +81,32 @@
assertEquals( "found != 1", "<div style=\"\">foo\n</div>\n", testEngine.getHTML("ThisPage") );
}
+
+ /**
+ * a link containing a blank should work if there is a page with exact the
+ * same name ('Test Page')
+ */
+ public void testWithBlanks1() throws Exception
+ {
+ testEngine.saveText( "ThisPage", "[{InsertPage page='Test Page'}]" );
+ testEngine.saveText( "Test Page", "foo[{ALLOW view Anonymous}]" );
+
+ assertEquals( "found != 1", "<div style=\"\">foo\n</div>\n", testEngine.getHTML( "ThisPage" ) );
+ }
+
+ /**
+ * same as testWithBlanks1, but it should still work if the page does not
+ * have the blank in it ( 'Test Page' should work if the included page is
+ * called 'TestPage')
+ */
+ public void testWithBlanks2() throws Exception
+ {
+ testEngine.saveText( "ThisPage", "[{InsertPage page='Test Page'}]" );
+ testEngine.saveText( "TestPage", "foo[{ALLOW view Anonymous}]" );
+
+ assertEquals( "found != 1", "<div style=\"\">foo\n</div>\n", testEngine.getHTML( "ThisPage" ) );
+ }
+
public static Test suite()
{
return new TestSuite( InsertPageTest.class );