cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1143515 - in /cxf/web: pom.xml src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java src/main/java/org/apache/cxf/cwiki/SiteExporter.java
Date Wed, 06 Jul 2011 18:08:27 GMT
Author: dkulp
Date: Wed Jul  6 18:08:27 2011
New Revision: 1143515

URL: http://svn.apache.org/viewvc?rev=1143515&view=rev
Log:
Update site exported to remove the nofollow rels from URL's in the apache.org domain.

Modified:
    cxf/web/pom.xml
    cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
    cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: cxf/web/pom.xml
URL: http://svn.apache.org/viewvc/cxf/web/pom.xml?rev=1143515&r1=1143514&r2=1143515&view=diff
==============================================================================
--- cxf/web/pom.xml (original)
+++ cxf/web/pom.xml Wed Jul  6 18:08:27 2011
@@ -28,11 +28,11 @@
     <parent>
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-parent</artifactId>
-        <version>2.3.3</version>
+        <version>2.4.1</version>
     </parent>
 
     <properties>
-        <cxf.version>2.4.0-SNAPSHOT</cxf.version>
+        <cxf.version>2.4.1</cxf.version>
         <extra.arg></extra.arg>
     </properties>
 

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java?rev=1143515&r1=1143514&r2=1143515&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java Wed Jul  6 18:08:27
2011
@@ -20,7 +20,9 @@
 package org.apache.cxf.cwiki;
 
 import java.io.Writer;
-import java.util.HashMap;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Stack;
 
@@ -86,6 +88,22 @@ public class ConfluenceCleanupWriter ext
                 dirName = dirName.substring(0, dirName.lastIndexOf(".")) + ".data";
 
                 newAtts.addMapping("href", dirName + href);
+            } else if (href != null 
+                && (href.startsWith("http://")
+                    || href.startsWith("https://"))) {
+                URL url;
+                try {
+                    url = new URL(href);
+                    if (url.getHost().contains("apache.org")) {
+                        newAtts.remove("rel");
+                    }
+                    if (url.getHost().equals("cxf.apache.org")
+                        && "external-link".equals(newAtts.getValue("class"))) {
+                        newAtts.remove("class");
+                    }
+                } catch (MalformedURLException e) {
+                    //ignore
+                }
             }
         } else if ("img".equals(localName.toLowerCase())
             || "img".equals(qName.toLowerCase())) {
@@ -151,72 +169,87 @@ public class ConfluenceCleanupWriter ext
     }
 
     final class AttributesWrapper implements Attributes {
-        private final Attributes atts;
-        private final Map<String, String> newAtts = new HashMap<String, String>();
+        private final Map<String, String> atts = new LinkedHashMap<String, String>();
 
         private AttributesWrapper(Attributes atts) {
-            this.atts = atts;
+            for (int x = 0; x < atts.getLength(); x++) {
+                this.atts.put(atts.getQName(x), atts.getValue(x));
+            }
         }
+        private Map.Entry<String, String> getByIndex(int i) {
+            for (Map.Entry<String, String> a : atts.entrySet()) {
+                if  (i == 0) {
+                    return a;
+                }
+                --i;
+            }
+            return null;
+        }
+        private int findIndex(String k) {
+            int i = 0;
+            for (Map.Entry<String, String> a : atts.entrySet()) {
+                if  (a.getKey().equals(k)) {
+                    return i;
+                }
+                ++i;
+            }
+            return -1;
+        }
+        
+        public void remove(String k) {
+            atts.remove(k);
+        }
+        
         public void addMapping(String k, String v) {
-            newAtts.put(k, v);
+            atts.put(k, v);
         }
         
         public int getLength() {
-            return atts.getLength();
+            return atts.size();
         }
-
+        
         public String getURI(int index) {
-            return atts.getURI(index);
+            return "";
         }
 
         public String getLocalName(int index) {
-            return atts.getLocalName(index);
+            return getByIndex(index).getKey();
         }
 
         public String getQName(int index) {
-            return atts.getQName(index);
+            return getByIndex(index).getKey();
         }
 
         public String getType(int index) {
-            return atts.getType(index);
+            return "CDATA";
         }
 
         public int getIndex(String uri, String localName) {
-            return atts.getIndex(uri, localName);
+            return findIndex(localName);
         }
 
         public int getIndex(String qName) {
-            return atts.getIndex(qName);
+            return findIndex(qName);
         }
 
         public String getType(String uri, String localName) {
-            return atts.getType(uri, localName);
+            return "CDATA";
         }
 
         public String getType(String qName) {
-            return atts.getType(qName);
+            return "CDATA";
         }
 
         public String getValue(int index) {
-            String f = getLocalName(index);
-            if (newAtts.containsKey(f.toLowerCase())) {
-                return newAtts.get(f.toLowerCase());
-            }
-            return atts.getValue(index);
+            return getByIndex(index).getValue();
         }
 
         public String getValue(String uri, String localName) {
-            if (newAtts.containsKey(localName.toLowerCase())) {
-                return newAtts.get(localName.toLowerCase());
-            }
-            return atts.getValue(uri, localName);
+            return atts.get(localName);
         }
 
         public String getValue(String qName) {
-            if (newAtts.containsKey(qName.toLowerCase())) {
-                return newAtts.get(qName.toLowerCase());
-            }
-            return atts.getValue(qName);
+            return atts.get(qName);
         }
     }
 

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1143515&r1=1143514&r2=1143515&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Wed Jul  6 18:08:27 2011
@@ -173,7 +173,7 @@ public class SiteExporter {
         loadPagesCache();
         
         // debug stuff, force regen of a page
-        //modifiedPages.add(findPage("FAQ"));
+        //modifiedPages.add(findPage("Navigation"));
         //modifiedPages.add(findPage("FAQ"));
         
         if (modifiedPages.isEmpty() && checkRSS()) {



Mime
View raw message