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/05/05 01:47:54 UTC
svn commit: r771501 - in /incubator/jspwiki/trunk/src/java/org/apache/wiki:
WikiEngine.java plugin/AbstractFilteredPlugin.java
plugin/RecentChangesPlugin.java plugin/Search.java tags/PageNameTag.java
tags/ParentPageNameTag.java
Author: ajaquith
Date: Mon May 4 23:47:53 2009
New Revision: 771501
URL: http://svn.apache.org/viewvc?rev=771501&view=rev
Log:
Added method WikiEngine.beautify(WikiPath), which works identically to the String version, except that those paths who are prefixed with the default space name (plus a colon) are rendered without the space name. WikiEngine also gains a method getSpaces(), which today only returns the default space. In the future this will be configurable.
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Search.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageNameTag.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java?rev=771501&r1=771500&r2=771501&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java Mon May 4 23:47:53 2009
@@ -262,6 +262,9 @@
/** Each engine has their own application id. */
private String m_appid = "";
+ /** The spaces defined for this WikiEngine. */
+ private String[] m_spaces;
+
private boolean m_isConfigured = false; // Flag.
private List<PageNameResolver> m_nameResolvers = new ArrayList<PageNameResolver>();
@@ -522,6 +525,10 @@
m_templateDir = TextUtil.getStringProperty( props, PROP_TEMPLATEDIR, "default" );
m_frontPage = TextUtil.getStringProperty( props, PROP_FRONTPAGE, "Main" );
+ // Initialize the spaces for this wiki
+ // TODO: make this configurable
+ m_spaces = new String[] { ContentManager.DEFAULT_SPACE };
+
//
// Initialize the important modules. Any exception thrown by the
// managers means that we will not start up.
@@ -784,6 +791,15 @@
}
/**
+ * Returns the spaces this wiki knows about.
+ * @return an array of Strings representing the spaces defined for this wiki.
+ */
+ public String[] getSpaces()
+ {
+ return m_spaces;
+ }
+
+ /**
* Returns the moment when this engine was started.
*
* @since 2.0.15.
@@ -1110,6 +1126,22 @@
}
/**
+ * Beautifies the wiki path. Delegates to {@link #beautifyTitle(String)}, except that
+ * any paths that denote the default space ({@link ContentManager#DEFAULT_SPACE}
+ * have their space prefixes omitted.
+ * @param path the path to beautify
+ * @return the result
+ */
+ public String beautifyTitle( WikiPath path )
+ {
+ if ( ContentManager.DEFAULT_SPACE.equals( path.getSpace() ) )
+ {
+ return beautifyTitle( path.getPath() );
+ }
+ return beautifyTitle( path.toString() );
+ }
+
+ /**
* Beautifies the title of the page by appending spaces in suitable
* places, if the user has so decreed in the properties when constructing
* this WikiEngine. However, attachment names are only beautified by
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java?rev=771501&r1=771500&r2=771501&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java Mon May 4 23:47:53 2009
@@ -251,27 +251,27 @@
/**
* Filters a collection according to the include and exclude -parameters.
*
- * @param c The collection to filter.
+ * @param items The collection to filter.
* @return A filtered collection.
*/
- protected <T extends Object>Collection<T> filterCollection( Collection<T> c )
+ protected <T extends Object>Collection<T> filterCollection( Collection<T> items )
{
- ArrayList<T> result = new ArrayList<T>();
+ ArrayList<T> filteredItems = new ArrayList<T>();
- for( T objectje : c )
+ for( T item : items )
{
String pageName = null;
- if( objectje instanceof WikiPage )
+ if( item instanceof WikiPage )
{
- pageName = ((WikiPage) objectje).getName();
+ pageName = ((WikiPage) item).getName();
}
- else if ( objectje instanceof WikiPath )
+ else if ( item instanceof WikiPath )
{
- pageName = ((WikiPath) objectje).toString();
+ pageName = ((WikiPath) item).toString();
}
- else if ( objectje instanceof String )
+ else if ( item instanceof String )
{
- pageName = (String) objectje;
+ pageName = (String) item;
}
//
@@ -315,9 +315,9 @@
boolean isAttachment = pageName.contains( "/" );
if( !isAttachment || (isAttachment && m_showAttachments) )
{
- if( objectje instanceof WikiPage || objectje instanceof WikiPath || objectje instanceof String )
+ if( item instanceof WikiPage || item instanceof WikiPath || item instanceof String )
{
- result.add( objectje );
+ filteredItems.add( item );
}
}
@@ -349,7 +349,7 @@
}
}
- return result;
+ return filteredItems;
}
/**
@@ -360,14 +360,14 @@
* @param numItems How many items to show.
* @return The WikiText
*/
- protected String wikitizeCollection( Collection<String> links, String separator, int numItems )
+ protected String wikitizeCollection( Collection<WikiPath> links, String separator, int numItems )
{
if( links == null || links.isEmpty() )
return "";
StringBuilder output = new StringBuilder();
- Iterator<String> it = links.iterator();
+ Iterator<WikiPath> it = links.iterator();
int count = 0;
//
@@ -375,7 +375,7 @@
//
while( it.hasNext() && ( (count < numItems) || ( numItems == ALL_ITEMS ) ) )
{
- String value = (String)it.next();
+ WikiPath value = it.next();
if( count > 0 )
{
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java?rev=771501&r1=771500&r2=771501&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java Mon May 4 23:47:53 2009
@@ -148,7 +148,7 @@
String link = context.getURL( pageref.isAttachment() ? WikiContext.ATTACH : WikiContext.VIEW,
pageref.getName() ) ;
- a linkel = new a(link,engine.beautifyTitle(pageref.getName()));
+ a linkel = new a(link,engine.beautifyTitle(pageref.getPath()));
tr row = new tr();
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Search.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Search.java?rev=771501&r1=771500&r2=771501&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Search.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Search.java Mon May 4 23:47:53 2009
@@ -142,7 +142,7 @@
td name = new td().setWidth("30%");
name.addElement( "<a href=\""+
context.getURL( WikiContext.VIEW, sr.getPage().getName() )+
- "\">"+engine.beautifyTitle(sr.getPage().getName())+"</a>");
+ "\">"+engine.beautifyTitle(sr.getPage().getPath())+"</a>");
row.addElement( name );
row.addElement( new td().addElement(""+sr.getScore()));
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageNameTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageNameTag.java?rev=771501&r1=771500&r2=771501&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageNameTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageNameTag.java Mon May 4 23:47:53 2009
@@ -52,7 +52,7 @@
}
else
{
- pageContext.getOut().print( engine.beautifyTitle( page.getName() ) );
+ pageContext.getOut().print( engine.beautifyTitle( page.getPath() ) );
}
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java?rev=771501&r1=771500&r2=771501&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java Mon May 4 23:47:53 2009
@@ -53,7 +53,7 @@
{
if( page.isAttachment() )
{
- pageContext.getOut().print( engine.beautifyTitle( page.getParent().getName()) );
+ pageContext.getOut().print( engine.beautifyTitle( page.getParent().getPath() ) );
}
else
{