You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2006/07/20 20:09:59 UTC

svn commit: r424008 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller: pojos/WeblogEntryData.java ui/rendering/model/ConfigModel.java ui/rendering/model/URLModel.java

Author: agilliland
Date: Thu Jul 20 11:09:59 2006
New Revision: 424008

URL: http://svn.apache.org/viewvc?rev=424008&view=rev
Log:
more url building cleanup.

- renamed getCommentsLink() in WeblogEntryData to getCommentsPermalink() since that's better differentiated from the deprecated getCommentLink() method and is more descriptive since it returns an absolute url.

- updated URLModel with a set of new methods, including moving a bunch of methods from ConfigModel.


Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigModel.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/URLModel.java

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java?rev=424008&r1=424007&r2=424008&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java Thu Jul 20 11:09:59 2006
@@ -787,16 +787,18 @@
      */
     public void setCommentsLink(String ignored) {}
     
+    
     /**
      * Get absolute URL of comment page.
      * @roller.wrapPojoMethod type="simple"
      */
-    public String getCommentLink() {
+    public String getCommentsPermalink() {
         String absPath = RollerRuntimeConfig.getAbsoluteContextURL();
         return absPath + getCommentsLink(); 
     }
+    
     /** to please XDoclet */
-    public void setCommentLink(String ignored) {}
+    public void setCommentsPermalink(String ignored) {}
     
     
     /**

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigModel.java?rev=424008&r1=424007&r2=424008&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigModel.java Thu Jul 20 11:09:59 2006
@@ -36,33 +36,31 @@
 
 
 /**
- * Model which provides access to application config data like site URLs and 
+ * Model which provides access to application config data like site
  * config properties.
  */
 public class ConfigModel implements Model {
     
-   private static Log log = LogFactory.getLog(ConfigModel.class); 
-        
-    /** TODO 3.0: remove dependency on pageContext */
-    private PageContext pageContext = null;
+    private static Log log = LogFactory.getLog(ConfigModel.class);
+    
     
     /** Hand-picked list of runtime properties to be made available */
-    private static List allowedProperties = 
-        Arrays.asList(new String[] {
-            "site.name",
-            "site.shortName",
-            "site.description",
-            "site.adminemail",
-            "users.registration.enabled",
-            "users.registration.url",
-            "users.comments.enabled",
-            "users.trackbacks.enabled",
-            "users.comments.autoformat",
-            "users.comments.escapehtml",
-            "users.comments.emailnotify",
-            "site.linkbacks.enabled",
-            "site.newsfeeds.defaultEntries",
-            "site.newsfeeds.maxEntries"
+    private static List allowedProperties =
+            Arrays.asList(new String[] {
+        "site.name",
+        "site.shortName",
+        "site.description",
+        "site.adminemail",
+        "users.registration.enabled",
+        "users.registration.url",
+        "users.comments.enabled",
+        "users.trackbacks.enabled",
+        "users.comments.autoformat",
+        "users.comments.escapehtml",
+        "users.comments.emailnotify",
+        "site.linkbacks.enabled",
+        "site.newsfeeds.defaultEntries",
+        "site.newsfeeds.maxEntries"
     });
     
     
@@ -74,25 +72,13 @@
     
     /** Init model */
     public void init(Map map) throws RollerException {
-        pageContext = (PageContext)map.get("pageContext");
-    }
-    
-    
-    /** Relative URL of Roller, e.g. /roller */
-    public String getContextURL() {
-        return RollerRuntimeConfig.getRelativeContextURL();
-    }
-    
-    
-    /** Absolute URL of Roller, e.g. http://localhost:8080/roller */
-    public String getAbsoluteContextURL() {
-        return RollerRuntimeConfig.getAbsoluteContextURL();
+        // no-op
     }
     
     
-    /** 
+    /**
      * Get Roller string runtime configuration property.
-     * @return Property value or null if not found 
+     * @return Property value or null if not found
      */
     public String getProperty(String name) {
         String ret = null;
@@ -103,9 +89,9 @@
     }
     
     
-    /** 
-     * Get Roller integer runtime configuration property 
-     * @return Property value or -999 if not found 
+    /**
+     * Get Roller integer runtime configuration property
+     * @return Property value or -999 if not found
      */
     public int getIntProperty(String name) {
         int ret = -999;
@@ -116,15 +102,15 @@
     }
     
     
-    /** 
+    /**
      * Get Roller boolean runtime configuration property.
-     * @return Property value or false if not found 
+     * @return Property value or false if not found
      */
     public boolean getBooleanProperty(String name) {
         boolean ret = false;
         if (allowedProperties.contains(name)) {
             return RollerRuntimeConfig.getBooleanProperty(name);
-        } 
+        }
         return ret;
     }
     
@@ -146,76 +132,5 @@
         return RollerContext.getRollerContext().getRollerBuildUser();
     }
     
-    
-    /** URL for editing a weblog entry */
-    public String getWeblogEntryEditURL(WeblogEntryDataWrapper entry) {
-        String ret = null;
-        Map params = new HashMap();
-        params.put(RequestConstants.WEBLOGENTRY_ID, entry.getId());
-        params.put(RequestConstants.ANCHOR, entry.getAnchor());
-        try {
-            ret = RequestUtils.computeURL(pageContext,
-                "weblogEdit", null, null, null, params, null, false);
-        } catch (MalformedURLException mue) {
-            log.error("ERROR forming Struts URL: ", mue);
-        }
-        return ret;
-    } 
-    
-    
-    /** URL for creating a new weblog entry */
-    public String getWeblogEntryCreateURL(WebsiteDataWrapper weblog) {
-        String returnURL = null;
-        Map params = new HashMap();
-        params.put(RequestConstants.WEBLOG, weblog.getHandle());
-        try {
-            returnURL = RequestUtils.computeURL(pageContext,
-                "weblogCreate", null, null, null, params, null, false);
-        } catch (MalformedURLException mue) {
-            log.error("ERROR forming Struts URL: ", mue);
-        }
-        return returnURL;
-    }
-    
-    
-    /** URL for editing weblog settings */
-    public String getWeblogSettingsURL(WebsiteDataWrapper weblog) {
-        String returnURL = null;
-        Map params = new HashMap();
-        params.put(RequestConstants.WEBLOG, weblog.getHandle());        
-        try {
-            returnURL = RequestUtils.computeURL(pageContext,
-                "editWebsite", null, null, null, params, null, false);
-        } catch (MalformedURLException mue) {
-            log.error("ERROR forming Struts URL: ", mue);
-        }
-        return returnURL;
-    }
-    
-    
-    /** URL for logging in */  
-    public String getLoginURL() {
-        String returnURL = null;
-        try {
-            returnURL = RequestUtils.computeURL(pageContext,
-                "login-redirect", null, null, null, null, null, false);
-        } catch (MalformedURLException mue) {
-            log.error("ERROR forming Struts URL: ", mue);
-        }
-        return returnURL;
-    }
-    
-    
-    /** URL for logging out */
-    public String getLogoutURL() {
-        String returnURL = null;
-        try {
-            returnURL = RequestUtils.computeURL(pageContext,
-                "logout-redirect", null, null, null, null, null, false);
-        } catch (MalformedURLException mue) {
-            log.error("ERROR forming Struts URL: ", mue);
-        }
-        return returnURL;
-    }    
 }
 

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/URLModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/URLModel.java?rev=424008&r1=424007&r2=424008&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/URLModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/URLModel.java Thu Jul 20 11:09:59 2006
@@ -19,12 +19,18 @@
 package org.apache.roller.ui.rendering.model;
 
 import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
 import java.net.URLEncoder;
+import java.util.HashMap;
 import java.util.Map;
+import javax.servlet.jsp.PageContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
+import org.apache.roller.config.RollerRuntimeConfig;
 import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.ui.core.RequestConstants;
+import org.apache.struts.util.RequestUtils;
 
 
 /**
@@ -46,6 +52,9 @@
     
     private WebsiteData weblog = null;
     
+    /** TODO 3.0: remove dependency on pageContext */
+    private PageContext pageContext = null;
+    
     
     public String getModelName() {
         return "url";
@@ -58,9 +67,50 @@
         if(weblog == null) {
             throw new RollerException("Expected 'weblog' init param!");
         }
+        
+        // need page context as well :(
+        pageContext = (PageContext) initData.get("pageContext");
+    }
+    
+    
+    /** Relative URL of Roller, e.g. /roller */
+    public String getSite() {
+        return RollerRuntimeConfig.getRelativeContextURL();
     }
     
     
+    /** Absolute URL of Roller, e.g. http://localhost:8080/roller */
+    public String getAbsoluteSite() {
+        return RollerRuntimeConfig.getAbsoluteContextURL();
+    }
+    
+    
+    /** URL for logging in */  
+    public String getLogin() {
+        String returnURL = null;
+        try {
+            returnURL = RequestUtils.computeURL(pageContext,
+                "login-redirect", null, null, null, null, null, false);
+        } catch (MalformedURLException mue) {
+            log.error("ERROR forming Struts URL: ", mue);
+        }
+        return returnURL;
+    }
+    
+    
+    /** URL for logging out */
+    public String getLogout() {
+        String returnURL = null;
+        try {
+            returnURL = RequestUtils.computeURL(pageContext,
+                "logout-redirect", null, null, null, null, null, false);
+        } catch (MalformedURLException mue) {
+            log.error("ERROR forming Struts URL: ", mue);
+        }
+        return returnURL;
+    }    
+    
+    
     public String getHome() {
         return weblog.getURL();
     }
@@ -166,11 +216,16 @@
     }
     
     
-    public String file(String filePath) {
+    public String resource(String filePath) {
         return weblog.getURL()+"/resource/"+filePath;
     }
     
     
+    public String themeResource(String filePath) {
+        return getSite()+RollerRuntimeConfig.getProperty("users.themes.path")+"/"+weblog.getEditorTheme()+"/"+filePath;
+    }
+    
+    
     public String getRsd() {
         return weblog.getURL()+"/rsd";
     }
@@ -178,6 +233,51 @@
     
     public FeedURLS getFeed() {
         return new FeedURLS();
+    }
+    
+    
+    /** URL for editing a weblog entry */
+    public String editEntry(String anchor) {
+        String ret = null;
+        Map params = new HashMap();
+        params.put(RequestConstants.ANCHOR, anchor);
+        try {
+            ret = RequestUtils.computeURL(pageContext,
+                "weblogEdit", null, null, null, params, null, false);
+        } catch (MalformedURLException mue) {
+            log.error("ERROR forming Struts URL: ", mue);
+        }
+        return ret;
+    } 
+    
+    
+    /** URL for creating a new weblog entry */
+    public String getCreateEntry() {
+        String returnURL = null;
+        Map params = new HashMap();
+        params.put(RequestConstants.WEBLOG, weblog.getHandle());
+        try {
+            returnURL = RequestUtils.computeURL(pageContext,
+                "weblogCreate", null, null, null, params, null, false);
+        } catch (MalformedURLException mue) {
+            log.error("ERROR forming Struts URL: ", mue);
+        }
+        return returnURL;
+    }
+    
+    
+    /** URL for editing weblog settings */
+    public String getEditSettings() {
+        String returnURL = null;
+        Map params = new HashMap();
+        params.put(RequestConstants.WEBLOG, weblog.getHandle());        
+        try {
+            returnURL = RequestUtils.computeURL(pageContext,
+                "editWebsite", null, null, null, params, null, false);
+        } catch (MalformedURLException mue) {
+            log.error("ERROR forming Struts URL: ", mue);
+        }
+        return returnURL;
     }