geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1435264 - in /geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki: AbstractPage.java Page.java PageManager.java SiteExporter.java
Date Fri, 18 Jan 2013 17:39:12 GMT
Author: gawor
Date: Fri Jan 18 17:39:12 2013
New Revision: 1435264

URL: http://svn.apache.org/viewvc?rev=1435264&view=rev
Log:
fix generating relative navigation links for blog entries

Modified:
    geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/AbstractPage.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/PageManager.java
    geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/AbstractPage.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/AbstractPage.java?rev=1435264&r1=1435263&r2=1435264&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/AbstractPage.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/AbstractPage.java Fri
Jan 18 17:39:12 2013
@@ -35,6 +35,8 @@ public class AbstractPage implements Ser
     final String title;
     final String url;
     
+    transient String directory;
+    
     public AbstractPage(Element root) throws Exception {
         // org.apache.cxf.helpers.XMLUtils.printDOM(doc.getDocumentElement());
 
@@ -43,8 +45,15 @@ public class AbstractPage implements Ser
         url = DOMUtils.getChildContent(root, "url");
     }
     
+    public AbstractPage(AbstractPage source) {
+        this.id = source.id;
+        this.title = source.title;
+        this.url = source.url;
+        this.directory = source.directory;
+    }
+    
     public String getDirectory() {
-        return "";
+        return directory == null ? "" : directory;
     }
     
     public String getPath() {

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=1435264&r1=1435263&r2=1435264&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 Fri Jan 18
17:39:12 2013
@@ -42,7 +42,7 @@ public class Page extends AbstractPage i
     
     private static final long serialVersionUID = 1L;
     
-    XMLGregorianCalendar modified;
+    final XMLGregorianCalendar modified;
     final String parent;
     final String spaceKey;
     Map<String, String> attachments;
@@ -52,6 +52,7 @@ public class Page extends AbstractPage i
     transient String renderedContent;
     transient String renderedDivContent;
     transient String divIdForContent;
+    
     transient SiteExporter exporter;
 
     public Page(Document doc) throws Exception {
@@ -113,6 +114,20 @@ public class Page extends AbstractPage i
         }
     }
     
+    /*
+     * Makes a shallow copy without any content
+     */
+    public Page(Page source) {
+        super(source);
+        this.modified = source.modified;
+        this.parent = source.parent;
+        this.spaceKey = source.spaceKey;
+        this.attachments = source.attachments;
+        this.includes = source.includes;
+        this.childrenOf = source.childrenOf;
+        this.exporter = source.exporter;
+    }
+    
     public boolean hasChildrenOf(String t, int d) {
         if (childrenOf == null) {
             return false;
@@ -193,7 +208,7 @@ public class Page extends AbstractPage i
     }
 
     public Space getSpace() {
-        return exporter.getSpace(spaceKey);
+        return SiteExporter.getSpace(spaceKey);
     }
 
     public boolean hasChildren() {
@@ -211,4 +226,5 @@ public class Page extends AbstractPage i
     protected SiteExporter getExporter() {
         return exporter;
     }
+    
 }

Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/PageManager.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/PageManager.java?rev=1435264&r1=1435263&r2=1435264&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/PageManager.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/PageManager.java Fri
Jan 18 17:39:12 2013
@@ -19,28 +19,45 @@
 
 package org.apache.cxf.cwiki;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 
  */
 public class PageManager {
 
     private SiteExporter exporter;
+    private String dir;
+    private Map<String, Page> pages = new HashMap<String, Page>();
     
     public PageManager(SiteExporter exporter) {
         this.exporter = exporter;
     }
     
+    public void setDirectory(String dir) {
+        this.dir = dir;
+    }
+    
     public Page getPage(String spaceKey, String title) throws Exception {
-        Page page = exporter.findPage(title);
-        if (page != null) {
-            String s = page.getContent();
-            if (s == null) {
-                s = exporter.loadPageContent(page, null, null);
+        // XXX: spaceKey must match exporter.getSpace().getKey()
+        
+        // lookup cached page
+        Page cachedPage = pages.get(title);
+        if (cachedPage == null) {
+            // lookup real page       
+            Page page = exporter.findPage(title);
+            if (page != null) {
+                cachedPage = new Page(page);                
+                cachedPage.directory = dir;
+                exporter.loadPageContent(cachedPage, null, null);
+                pages.put(title, cachedPage);
+            } else {
+                System.err.println("Page not found: " + title);
             }
-        } else {
-            System.err.println("Page not found: " + title);
         }
-        return page;
+        
+        return cachedPage;
     }
     
 }

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=1435264&r1=1435263&r2=1435264&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 Fri
Jan 18 17:39:12 2013
@@ -350,6 +350,9 @@ public class SiteExporter implements Run
     }
 
     private void renderPages() throws Exception {
+        PageManager pageManager = new PageManager(this);
+        Renderer renderer = new Renderer(this);
+        
         int total = modifiedPages.size();
         int count = 0;
         for (Page p : modifiedPages) {
@@ -364,8 +367,8 @@ public class SiteExporter implements Run
             ctx.put("page", p);
             ctx.put("body", p.getContent());
             ctx.put("confluenceUri", ROOT);
-            ctx.put("pageManager", new PageManager(this));
-            ctx.put("renderer", new Renderer(this));
+            ctx.put("pageManager", pageManager);
+            ctx.put("renderer", renderer);
             
             File file = new File(outputDir, p.createFileName());
             boolean isNew = !file.exists();
@@ -387,6 +390,9 @@ public class SiteExporter implements Run
     }
     
     private void renderBlog() throws Exception {
+        PageManager pageManager = new PageManager(this);
+        Renderer renderer = new Renderer(this);
+        
         int total = modifiedBlog.size();
         int count = 0;
         for (BlogEntrySummary entry : modifiedBlog) {
@@ -397,14 +403,15 @@ public class SiteExporter implements Run
             String body = renderPage(entry);
             body = updateContentLinks(entry, body, null, mainDivClass);
             
+            pageManager.setDirectory(entry.getDirectory());
             
             VelocityContext ctx = new VelocityContext();
             ctx.put("autoexport", this);
             ctx.put("page", entry);
             ctx.put("body", body);
             ctx.put("confluenceUri", ROOT);
-            ctx.put("pageManager", new PageManager(this));
-            ctx.put("renderer", new Renderer(this));
+            ctx.put("pageManager", pageManager);
+            ctx.put("renderer", renderer);
             
             File file = new File(outputDir, entry.getPath());
             file.getParentFile().mkdirs();



Mime
View raw message