You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by ul...@apache.org on 2013/02/04 13:45:10 UTC

svn commit: r1442093 - in /tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki: ConfluenceCleanupWriter.java SiteExporter.java

Author: uli
Date: Mon Feb  4 12:45:10 2013
New Revision: 1442093

URL: http://svn.apache.org/viewvc?rev=1442093&view=rev
Log:
download icons to speed up page rendering

Modified:
    tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
    tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java?rev=1442093&r1=1442092&r2=1442093&view=diff
==============================================================================
--- tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java (original)
+++ tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java Mon Feb  4 12:45:10 2013
@@ -136,7 +136,18 @@ public class ConfluenceCleanupWriter ext
             }
             String cls = atts.getValue("class");
             if (href != null && href.startsWith("/confluence/images/")) {
-                newAtts.addMapping("src", SiteExporter.HOST + href);
+                //newAtts.addMapping("src", SiteExporter.HOST + href);
+                try
+                {
+                    String name = exporter.loadIcon(href);
+                    String dirName = "/" + SiteExporter.CONFLUENCE_IMAGES;
+                    newAtts.addMapping("src", dirName + "/" + name);
+                }
+                catch (Exception e)
+                {
+                    System.out.println("Could not download icon " + href 
+                            + " linked from " + page.getTitle());
+                }
             } else if (href != null && href.startsWith("/confluence/download/attachments")) {
                 if (cls == null) {
                     href = href.substring(0, href.lastIndexOf('?'));

Modified: tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1442093&r1=1442092&r2=1442093&view=diff
==============================================================================
--- tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ tapestry/tapestry-site/trunk/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Mon Feb  4 12:45:10 2013
@@ -95,6 +95,9 @@ public class SiteExporter implements Run
     static final String ROOT = HOST + "/confluence";
     static final String RPC_ROOT = "/rpc/soap-axis/confluenceservice-v1";
     static final String SOAPNS = "http://soap.rpc.confluence.atlassian.com";
+    
+    
+    static final String CONFLUENCE_IMAGES = "images/confluence";
 
     
     
@@ -414,6 +417,23 @@ public class SiteExporter implements Run
             el = DOMUtils.getNextElement(el);
         }
     }
+    String loadIcon(String href) throws Exception {
+        
+        String filename = href.replace("/confluence/images", "images/confluence");
+        File file = new File(outputDir + filename);
+        if(file.exists())
+            return file.getName();
+        if(!file.getParentFile().exists()) {
+            file.getParentFile().mkdirs();
+        }
+        FileOutputStream out = new FileOutputStream(file);
+        URL url = new URL(HOST + href);
+        InputStream ins = url.openStream();
+        IOUtils.copy(ins, out);
+        out.close();
+        ins.close();
+        return file.getName();
+    }
     String loadUserImage(Page p, String href) throws Exception {
         return loadPageBinaryData(p, href, "userimage", true);
     }