You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by he...@apache.org on 2003/07/31 18:30:36 UTC

cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/pull/tools TemplateLink.java

henning     2003/07/31 09:30:36

  Modified:    src/java/org/apache/turbine/services/pull/tools
                        TemplateLink.java
  Log:
  - Make it possible to switch between relative and absolute links with a
    property in TR.props, just like the ContentTool
  
  Revision  Changes    Path
  1.6       +26 -2     jakarta-turbine-2/src/java/org/apache/turbine/services/pull/tools/TemplateLink.java
  
  Index: TemplateLink.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/pull/tools/TemplateLink.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TemplateLink.java	3 Jun 2003 13:41:27 -0000	1.5
  +++ TemplateLink.java	31 Jul 2003 16:30:36 -0000	1.6
  @@ -54,9 +54,12 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.commons.configuration.Configuration;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  +import org.apache.turbine.Turbine;
   import org.apache.turbine.services.pull.ApplicationTool;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.parser.ParameterParser;
  @@ -89,6 +92,19 @@
   public class TemplateLink
       implements ApplicationTool
   {
  +    /** Prefix for Parameters for this tool */
  +    public static final String TEMPLATE_LINK_PREFIX = "tool.link";
  +
  +    /** Should this tool return relative URIs or absolute? Default: Absolute. */
  +    public static final String TEMPLATE_LINK_RELATIVE_KEY = "want.relative";
  +
  +    /** Default Value for TEMPLATE_LINK_RELATIVE_KEY */
  +    public static final boolean TEMPLATE_LINK_RELATIVE_DEFAULT = false;
  +
  +
  +    /** Do we want a relative link? */
  +    boolean wantRelative = false;
  +        
       /** cache of the template name for getPage() */
       private String template = null;
   
  @@ -130,6 +146,13 @@
           // exception.
   
           templateURI = new TemplateURI((RunData) data);
  +
  +        Configuration conf = 
  +                Turbine.getConfiguration().subset(TEMPLATE_LINK_PREFIX);
  +        
  +        wantRelative = conf.getBoolean(TEMPLATE_LINK_RELATIVE_KEY,
  +                TEMPLATE_LINK_RELATIVE_DEFAULT);
  +
       }
   
       /**
  @@ -555,7 +578,8 @@
        */
       public String toString()
       {
  -        return getAbsoluteLink();
  +        return wantRelative ? 
  +                getRelativeLink() : getAbsoluteLink();
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org