Update of /var/cvs/speeltuin/andre/mmsite/src/org/mmbase/mmsite
In directory james.mmbase.org:/tmp/cvs-serv14393

Modified Files:
        SiteUrlConverter.java 
Log Message:
homepage is nonsense, code for extension



See also: 
http://cvs.mmbase.org/viewcvs/speeltuin/andre/mmsite/src/org/mmbase/mmsite


Index: SiteUrlConverter.java
===================================================================
RCS file: 
/var/cvs/speeltuin/andre/mmsite/src/org/mmbase/mmsite/SiteUrlConverter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- SiteUrlConverter.java       11 Feb 2009 21:06:13 -0000      1.1
+++ SiteUrlConverter.java       17 Apr 2009 12:16:57 -0000      1.2
@@ -23,7 +23,7 @@
  * It presumes (pages) nodes with the fields 'path' and 'template'.
  *
  * @author Andre van Toly
- * @version $Id: SiteUrlConverter.java,v 1.1 2009/02/11 21:06:13 andre Exp $
+ * @version $Id: SiteUrlConverter.java,v 1.2 2009/04/17 12:16:57 andre Exp $
  * @since MMBase-1.9
  */
 public class SiteUrlConverter extends DirectoryUrlConverter {
@@ -33,7 +33,6 @@
        protected static ArrayList<String> excludedPaths = new 
ArrayList(Arrays.asList(
            "mmbase"
        ));
-    protected static String homepage = "/index.jsp";
     protected static String extension = "";
     protected static boolean useExtension = false;
 
@@ -51,23 +50,20 @@
         extension = e;
     }
 
-    public void setHomepage(String s) {
-        homepage = s;
-    }
-
     @Override public int getDefaultWeight() {
         int q = super.getDefaultWeight();
         return Math.max(q, q + 2000);
     }
 
     /**
-     * Generates a nice url linking to a template for a 'pages' node. 
+     * Generates a nice url linking to a template for a ('pages') node. 
      */
     @Override protected void getNiceDirectoryUrl(StringBuilder b, Block block, 
Parameters parameters, Parameters frameworkParameters,  boolean action) throws 
FrameworkException {
         if (log.isDebugEnabled()) {
             if (log.isDebugEnabled()) log.debug("" + parameters + 
frameworkParameters);
             if (log.isDebugEnabled()) log.debug("Found 'page' block: " + 
block);
         }
+        int b_len = b.length();
         
         if (block.getName().equals("page")) {
             Node n = parameters.get(Framework.N);
@@ -78,8 +74,10 @@
                        if (path.endsWith("/")) path = path.substring(0, 
path.length() - 1);
                        b.append(path);
                        
-                       if (log.isDebugEnabled()) log.debug("b: " + 
b.toString());
         }
+
+        if (useExtension && b.length() > b_len) b.append(extension);
+        if (log.isDebugEnabled()) log.debug("b: " + b.toString());
     }
 
 
@@ -99,21 +97,23 @@
                String path = sb.toString();
                //if (log.isDebugEnabled()) log.debug("path: " + path);
         
-        if (pa.size() == 0) {
-            result.append(homepage);
-                       if (log.isDebugEnabled()) log.debug("Returning: " + 
result.toString());
-            return new BasicUrl(this, result.toString());
+        if (useExtension && path.indexOf(extension) > -1) {
+            path = path.substring(0, path.lastIndexOf(extension));
+            //pa.set(pa.size() - 1, id);
+        }
+        
             
-               } else if (excludedPaths.contains(pa.get(0))) {
+           if (excludedPaths.contains(pa.get(0))) {
                        if (log.isDebugEnabled()) log.debug("Returning null, 
path in excludepaths: " + path);
                    return Url.NOT;
                    
         } else {
-                       Node page = UrlUtils.getPagebyPath(cloud, path);
-            if (page != null) {
-                               String template = 
page.getNodeValue("template").getStringValue("url");
+            // find the node with this path
+                       Node node = UrlUtils.getPagebyPath(cloud, path);
+            if (node != null) {
+                               String template = 
node.getNodeValue("template").getStringValue("url");
                                if (!template.startsWith("/")) 
result.append("/");
-                               result.append(template).append("?n=" + 
page.getNumber());
+                               result.append(template).append("?n=" + 
node.getNumber());
                                
             } else {
                                return Url.NOT;
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to