jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jalka...@apache.org
Subject svn commit: r664399 - in /incubator/jspwiki/trunk: ChangeLog src/com/ecyrd/jspwiki/PageManager.java src/com/ecyrd/jspwiki/Release.java src/com/ecyrd/jspwiki/content/PageRenamer.java
Date Sat, 07 Jun 2008 21:44:43 GMT
Author: jalkanen
Date: Sat Jun  7 14:44:43 2008
New Revision: 664399

URL: http://svn.apache.org/viewvc?rev=664399&view=rev
Log:
Implemented referrer change on rename.  Fixes JSPWIKI-265 and hopefully JSPWIKI-30.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/PageManager.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=664399&r1=664398&r2=664399&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sat Jun  7 14:44:43 2008
@@ -1,10 +1,25 @@
+2008-06-01  Janne Jalkanen <jalkanen@apache.org>
+
+        * 2.7.0-svn-34
+        
+        * JSPWIKI-265: All referrer changes (according to unit tests anyway)
+        work now.
+        
+        * JSPWIKI-30 should now also be resolved.
+        
+        * JSPWIKI-27: I have a suspicion that implementing WikiPage.equals()
+        has caused some interesting issues with attributes being leaked from
+        old versions.  Removed equals() for now.
+        
+        * Some JSPWikiMarkupParser speed optimizations by changing all
+        StringBuffers to StringBuilders.
+
 2007-06-07 Dirk Frederickx <dirk.frederickx@gmail.com>
 
         * 2.7.0-svn-33
         
         * Added favicon.ico, and updated the jspwiki.properties to support *.ico
 
-
 2008-06-01  Janne Jalkanen <jalkanen@apache.org>
 
         * 2.7.0-svn-32

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/PageManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/PageManager.java?rev=664399&r1=664398&r2=664399&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/PageManager.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/PageManager.java Sat Jun  7 14:44:43 2008
@@ -452,11 +452,16 @@
             //
             log.info("Repository has been modified externally while fetching info for "+pageName
);
 
-            WikiPage p = new WikiPage( m_engine, pageName );
-
-            m_engine.updateReferences( p );
-
             page = m_provider.getPageInfo( pageName, version );
+
+            if( page != null )
+            {
+                m_engine.updateReferences( page );
+            }
+            else
+            {
+                m_engine.getReferenceManager().pageRemoved( new WikiPage(m_engine,pageName)
);
+            }
         }
 
         //

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=664399&r1=664398&r2=664399&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java Sat Jun  7 14:44:43 2008
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "33";
+    public static final String     BUILD         = "34";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java?rev=664399&r1=664398&r2=664399&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java Sat Jun  7 14:44:43
2008
@@ -29,6 +29,7 @@
 
 import com.ecyrd.jspwiki.*;
 import com.ecyrd.jspwiki.attachment.Attachment;
+import com.ecyrd.jspwiki.parser.JSPWikiMarkupParser;
 import com.ecyrd.jspwiki.parser.MarkupParser;
 import com.ecyrd.jspwiki.providers.ProviderException;
 
@@ -44,6 +45,8 @@
 
     private static final Logger log = Logger.getLogger( PageRenamer.class );
     
+    private boolean m_camelCase = false;
+    
     /**
      *  Renames a page.
      *  
@@ -100,7 +103,15 @@
         {
             throw new WikiException("Page already exists "+renameTo);
         }
-                
+        
+        //
+        //  Options
+        //
+        
+        m_camelCase = TextUtil.getBooleanProperty( engine.getWikiProperties(), 
+                                                   JSPWikiMarkupParser.PROP_CAMELCASELINKS,

+                                                   m_camelCase );
+        
         //
         //  Do the actual rename by changing from the frompage to the topage, including
         //  all of the attachments
@@ -195,6 +206,9 @@
             
             String newText = replaceReferrerString( context, sourceText, fromPage.getName(),
toPage.getName() );
             
+            if( m_camelCase )
+                newText = replaceCCReferrerString( context, newText, fromPage.getName(),
toPage.getName() );
+            
             if( !sourceText.equals( newText ) )
             {
                 p.setAttribute( WikiPage.CHANGENOTE, "Renaming change "+fromPage.getName()+"
to "+toPage.getName() );
@@ -218,9 +232,53 @@
         }
     }
 
+    /**
+     *  Replaces camelcase links.
+     * @param context
+     * @param sourceText
+     * @param from
+     * @param to
+     * @return
+     */
+    private String replaceCCReferrerString( WikiContext context, String sourceText, String
from, String to )
+    {
+        StringBuilder sb = new StringBuilder( sourceText.length()+32 );
+        
+        Pattern linkPattern = Pattern.compile( "\\p{Lu}+\\p{Ll}+\\p{Lu}+[\\p{L}\\p{Digit}]*"
);
+        
+        Matcher matcher = linkPattern.matcher( sourceText );
+        
+        int start = 0;
+        
+        while( matcher.find(start) )
+        {
+            String match = matcher.group();
+
+            sb.append( sourceText.substring( start, matcher.start() ) );
+
+            int lastOpenBrace = sourceText.lastIndexOf( '[', matcher.start() );
+            int lastCloseBrace = sourceText.lastIndexOf( ']', matcher.start() );
+            
+            if( match.equals( from ) && lastCloseBrace >= lastOpenBrace )
+            {
+                sb.append( to );
+            }
+            else
+            {
+                sb.append( match );
+            }
+            
+            start = matcher.end();
+        }
+        
+        sb.append( sourceText.substring( start ) );
+        
+        return sb.toString();
+    }
+
     private String replaceReferrerString( WikiContext context, String sourceText, String
from, String to )
     {
-        StringBuffer sb = new StringBuffer( sourceText.length() );
+        StringBuilder sb = new StringBuilder( sourceText.length()+32 );
         
         Pattern linkPattern = Pattern.compile( "([\\[\\~]?)\\[([^\\|\\]]*)(\\|)?([^\\|\\]]*)(\\|)?([^\\|\\]]*)\\]"
);
         
@@ -232,7 +290,12 @@
         //System.out.println("SRC="+sourceText.trim());
         while( matcher.find(start) )
         {
-            if( matcher.group(1).length() > 0 ) 
+            char charBefore = (char)-1;
+            
+            if( matcher.start() > 0 ) 
+                charBefore = sourceText.charAt( matcher.start()-1 );
+            
+            if( matcher.group(1).length() > 0 || charBefore == '~' || charBefore == '['
) 
             {
                 //
                 //  Found an escape character, so I am escaping.
@@ -259,6 +322,11 @@
             else
             {
                 link = replaceSingleLink( context, link, from, to );
+                
+                //
+                //  A very simple substitution, but should work for quite a few cases.
+                //
+                text = TextUtil.replaceString( text, from, to );
             }
         
             //



Mime
View raw message