geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1424104 - in /geronimo/site/trunk/wiki-export: conf/ src/main/java/org/apache/cxf/cwiki/
Date Wed, 19 Dec 2012 20:59:44 GMT
Author: gawor
Date: Wed Dec 19 20:59:43 2012
New Revision: 1424104

URL: http://svn.apache.org/viewvc?rev=1424104&view=rev
Log:
get cross site links working

Added:
    geronimo/site/trunk/wiki-export/conf/GMOxDOC12.cfg
    geronimo/site/trunk/wiki-export/conf/GMOxDOC20.cfg
    geronimo/site/trunk/wiki-export/conf/GMOxDOC21.cfg
    geronimo/site/trunk/wiki-export/conf/GMOxPMGT.cfg
    geronimo/site/trunk/wiki-export/conf/GMOxSAMPLES.cfg
Modified:
    geronimo/site/trunk/wiki-export/conf/GMOxDOC10.cfg
    geronimo/site/trunk/wiki-export/conf/GMOxDOC11.cfg
    geronimo/site/trunk/wiki-export/conf/GMOxDOC22.cfg
    geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
    geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Page.java
    geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: geronimo/site/trunk/wiki-export/conf/GMOxDOC10.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/GMOxDOC10.cfg?rev=1424104&r1=1424103&r2=1424104&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/GMOxDOC10.cfg (original)
+++ geronimo/site/trunk/wiki-export/conf/GMOxDOC10.cfg Wed Dec 19 20:59:43 2012
@@ -1,6 +1,6 @@
 spaceKey:GMOxDOC10
 pageCacheFile:cache/GMOxDOC10.pageCache
 templateName:../template/GMOxDOC10_autoexport_template.xml
-outputDir:/
+outputDir:/GMOxDOC10
 globalPages:Navigation,Banner,QuickLinks
 mainDivClass:wiki-content maincontent

Modified: geronimo/site/trunk/wiki-export/conf/GMOxDOC11.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/GMOxDOC11.cfg?rev=1424104&r1=1424103&r2=1424104&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/GMOxDOC11.cfg (original)
+++ geronimo/site/trunk/wiki-export/conf/GMOxDOC11.cfg Wed Dec 19 20:59:43 2012
@@ -1,6 +1,6 @@
 spaceKey:GMOxDOC11
 pageCacheFile:cache/GMOxDOC11.pageCache
-templateName:../templates/GMOxDOC11_autoexport_template.xml
+templateName:../template/GMOxDOC11_autoexport_template.xml
 outputDir:/GMOxDOC11
 globalPages:Navigation,Banner,QuickLinks
 mainDivClass:wiki-content maincontent

Added: geronimo/site/trunk/wiki-export/conf/GMOxDOC12.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/GMOxDOC12.cfg?rev=1424104&view=auto
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/GMOxDOC12.cfg (added)
+++ geronimo/site/trunk/wiki-export/conf/GMOxDOC12.cfg Wed Dec 19 20:59:43 2012
@@ -0,0 +1,6 @@
+spaceKey:GMOxDOC12
+pageCacheFile:cache/GMOxDOC12.pageCache
+templateName:../template/GMOxDOC12_autoexport_template.xml
+outputDir:/GMOxDOC12
+globalPages:Navigation,Banner,QuickLinks
+mainDivClass:wiki-content maincontent

Added: geronimo/site/trunk/wiki-export/conf/GMOxDOC20.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/GMOxDOC20.cfg?rev=1424104&view=auto
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/GMOxDOC20.cfg (added)
+++ geronimo/site/trunk/wiki-export/conf/GMOxDOC20.cfg Wed Dec 19 20:59:43 2012
@@ -0,0 +1,6 @@
+spaceKey:GMOxDOC20
+pageCacheFile:cache/GMOxDOC20.pageCache
+templateName:../template/GMOxDOC20_autoexport_template.xml
+outputDir:/GMOxDOC20
+globalPages:Navigation,Banner,QuickLinks
+mainDivClass:wiki-content maincontent

Added: geronimo/site/trunk/wiki-export/conf/GMOxDOC21.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/GMOxDOC21.cfg?rev=1424104&view=auto
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/GMOxDOC21.cfg (added)
+++ geronimo/site/trunk/wiki-export/conf/GMOxDOC21.cfg Wed Dec 19 20:59:43 2012
@@ -0,0 +1,6 @@
+spaceKey:GMOxDOC21
+pageCacheFile:cache/GMOxDOC21.pageCache
+templateName:../template/GMOxDOC21_autoexport_template.xml
+outputDir:/GMOxDOC21
+globalPages:Navigation,Banner,QuickLinks
+mainDivClass:wiki-content maincontent

Modified: geronimo/site/trunk/wiki-export/conf/GMOxDOC22.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/GMOxDOC22.cfg?rev=1424104&r1=1424103&r2=1424104&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/GMOxDOC22.cfg (original)
+++ geronimo/site/trunk/wiki-export/conf/GMOxDOC22.cfg Wed Dec 19 20:59:43 2012
@@ -1,6 +1,6 @@
 spaceKey:GMOxDOC22
 pageCacheFile:cache/GMOxDOC22.pageCache
 templateName:../template/GMOxDOC22_autoexport_template.xml
-outputDir:/
+outputDir:/GMOxDOC22
 globalPages:Navigation,Banner,QuickLinks
 mainDivClass:wiki-content maincontent

Added: geronimo/site/trunk/wiki-export/conf/GMOxPMGT.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/GMOxPMGT.cfg?rev=1424104&view=auto
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/GMOxPMGT.cfg (added)
+++ geronimo/site/trunk/wiki-export/conf/GMOxPMGT.cfg Wed Dec 19 20:59:43 2012
@@ -0,0 +1,6 @@
+spaceKey:GMOxPMGT
+pageCacheFile:cache/GMOxPMGT.pageCache
+templateName:../template/GMOxPMGT_autoexport_template.xml
+outputDir:/GMOxPMGT
+globalPages:Navigation,Banner,QuickLinks
+mainDivClass:wiki-content maincontent

Added: geronimo/site/trunk/wiki-export/conf/GMOxSAMPLES.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/GMOxSAMPLES.cfg?rev=1424104&view=auto
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/GMOxSAMPLES.cfg (added)
+++ geronimo/site/trunk/wiki-export/conf/GMOxSAMPLES.cfg Wed Dec 19 20:59:43 2012
@@ -0,0 +1,6 @@
+spaceKey:GMOxSAMPLES
+pageCacheFile:cache/GMOxSAMPLES.pageCache
+templateName:../template/GMOxSAMPLES_autoexport_template.xml
+outputDir:/GMOxSAMPLES
+globalPages:Navigation,Banner,QuickLinks
+mainDivClass:wiki-content maincontent

Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java?rev=1424104&r1=1424103&r2=1424104&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
(original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
Wed Dec 19 20:59:43 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.cwiki;
 
+import java.io.File;
 import java.io.Writer;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -76,9 +77,13 @@ public class ConfluenceCleanupWriter ext
                     href = href.substring(0, href.indexOf('?'));
                 }
                 try {
-                    final Page p = exporter.findPageByURL(href);
+                    final Page p = SiteExporter.findPageWithURL(href);                  
 
                     if (p != null) {
-                        newAtts.addMapping("href", p.createFileName() + params);
+                        String prefix = getRelativePath(SiteExporter.rootOutputDir, page.getExporter().outputDir,
p.getExporter().outputDir);
+                        if (prefix.length() != 0) {
+                            System.out.println(prefix);
+                        }
+                        newAtts.addMapping("href", prefix + p.createFileName() + params);
                     } else {
                         if (href.indexOf('~') == -1) {
                             //link to a user page is OK, don't warn about it
@@ -310,4 +315,29 @@ public class ConfluenceCleanupWriter ext
         }
     }
 
+    private static String getRelativePath(File root, File current, File other) throws Exception
{
+        if (current.equals(other)) {
+            return "";
+        }
+        StringBuilder builder = new StringBuilder();
+        while (!root.equals(current)) {
+            current = current.getParentFile();
+            builder.append("../");
+        }
+        
+        String rootPath = root.getCanonicalPath();
+        String otherPath = other.getCanonicalPath();
+        
+        if (rootPath.equals(otherPath)) {
+            // nothing to do
+        } else if (otherPath.startsWith(rootPath)) {
+            String name = otherPath.substring(rootPath.length() + 1);
+            builder.append(name);
+            builder.append("/");
+        } else {
+            throw new RuntimeException("Non-relative locations: " + rootPath + " " + otherPath);
+        }       
+        
+        return builder.toString();
+    }
 }

Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Page.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Page.java?rev=1424104&r1=1424103&r2=1424104&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Page.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Page.java Wed Dec 19
20:59:43 2012
@@ -231,7 +231,11 @@ public class Page implements Serializabl
         return exporter.getChildren(this);
     }
 
-    void setExporter(SiteExporter exporter) {
+    protected void setExporter(SiteExporter exporter) {
         this.exporter = exporter;
     }
+    
+    protected SiteExporter getExporter() {
+        return exporter;
+    }
 }

Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1424104&r1=1424103&r2=1424104&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Wed
Dec 19 20:59:43 2012
@@ -126,6 +126,8 @@ public class SiteExporter implements Run
     File outputDir = rootOutputDir;
 
     Template template;
+    
+    static List<SiteExporter> siteExporters;
 
     public SiteExporter(String fileName, boolean force) throws Exception {
         forceAll = force;
@@ -222,7 +224,11 @@ public class SiteExporter implements Run
         }
     }
     
-    public void doExport() throws Exception {
+    /**
+     * @return true if some pages have changed - rendering is needed
+     * @throws Exception
+     */
+    public boolean initialize() throws Exception {
         if (!forceAll) {
             loadPagesCache();
         }
@@ -235,7 +241,7 @@ public class SiteExporter implements Run
         
         if (modifiedPages.isEmpty() && checkRSS()) {
             System.out.println("(" + spaceKey + ") No changes detected from RSS");
-            return;
+            return false;
         }
         
         doLogin();
@@ -245,6 +251,15 @@ public class SiteExporter implements Run
 
         loadPages();
         
+        return true;
+    }
+    
+    public void doExport() throws Exception {
+        initialize();
+        render();
+    }
+    
+    protected void render() throws Exception {
         for (Page p : modifiedPages) {
             if (globalPages.contains(p.getTitle())) {
                 modifiedPages.clear();
@@ -262,8 +277,6 @@ public class SiteExporter implements Run
             renderPages();
             savePages();
         }
-        
-
     }
 
 
@@ -347,6 +360,8 @@ public class SiteExporter implements Run
             } else {
                 svnCommitMessage.append("Modified: " + file.getName() + "\n");          
     
             }
+            
+            p.setContent(null);
         }
     }
     void callSvn(String ... commands) throws Exception {
@@ -641,8 +656,13 @@ public class SiteExporter implements Run
             ObjectInputStream oin = new ObjectInputStream(fin);
             pages = CastUtils.cast((Map<?, ?>)oin.readObject());
             oin.close();
+            
+            for (Page p : pages.values()) {
+                p.setExporter(this);
+            }
         }
     }
+    
     public void loadPages() throws Exception {
         Document doc = XMLUtils.newDocument();
         Element el = doc.createElementNS(SOAPNS, "ns1:getPages");
@@ -860,6 +880,28 @@ public class SiteExporter implements Run
             }
         }
         
+        
+        List<SiteExporter> exporters = new ArrayList<SiteExporter>();
+        for (String file : files) {
+            exporters.add(new SiteExporter(file, forceAll));
+        }
+
+        List<SiteExporter> modified = new ArrayList<SiteExporter>();
+        for (SiteExporter exporter : exporters) {
+            if (exporter.initialize()) {
+                modified.add(exporter);
+            }
+        }
+        
+        // render stuff only if needed
+        if (!modified.isEmpty()) {
+            setSiteExporters(exporters);
+            for (SiteExporter exporter : modified) {
+                exporter.render();
+            }
+        }
+        
+        /*
         List<Thread> threads = new ArrayList<Thread>(files.size());
         for (String file : files) {
             Thread t = new Thread(new SiteExporter(file, forceAll));
@@ -869,6 +911,7 @@ public class SiteExporter implements Run
         for (Thread t : threads) {
             t.join();
         }
+        */
         
         if (commit) {
             File file = FileUtils.createTempFile("svncommit", "txt");
@@ -909,4 +952,17 @@ public class SiteExporter implements Run
         return page.getLink();
     }
 
+    private static void setSiteExporters(List<SiteExporter> exporters) {
+        siteExporters = exporters;
+    }
+    
+    public static Page findPageWithURL(String url) throws Exception {
+        for (SiteExporter exporter : siteExporters) {
+            Page p = exporter.findPageByURL(url);
+            if (p != null) {
+                return p;
+            }
+        }
+        return null;
+    }
 }



Mime
View raw message