You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Jason van Zyl <jv...@apache.org> on 2001/08/09 14:13:24 UTC

Re: cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocity TurbineVelocityService.java

On 8/9/01 4:31 AM, "jon@apache.org" <jo...@apache.org> wrote:

> jon         01/08/09 01:31:17
> 
> Modified:    src/services/java/org/apache/fulcrum/velocity
>                       TurbineVelocityService.java
> Log:
> I just added the ability to specify an "absolute:" path to the templates
> directory.
> 
> It works something like this:
> 
> services.VelocityService.file.resource.loader.path =
> @ABSOLUTE_PATH@/templates,@ABSOLUTE_PATH@/templates/flux
> 
> You can then use Ant to do the filtering of the TR.props file:
> 
>         <filter token="ABSOLUTE_PATH" value="absolute:${src.dir}"/>
>         <copy todir="${build.project.webinf}/conf" filtering="yes">
>             <fileset dir="${src.conf.dir}/" defaultexcludes="no">
>                 <include name="*.properties"/>
>                 <include name="*.xml"/>
>             </fileset>
>         </copy>
> 
> This has been tested and works wonderfully!
 
> What this means is that your build system can define an absolute path and
> you don't need to copy the templates into the webapp's directory anymore!
> You can simply point at them in any directory for development purposes.
> This makes it easier for designers because the templates directory doesn't
> need to be nested way down in a complicated directory structure. It also
> removes the need to have a "build" step in order to copy the modified
> templates into another directory.
> 
> I'm open to suggestions for something other than "absolute:", but this
> works for me for now.
> 
> woo hoo! I have been wanting to solve this problem for a long while now.

We definitely need a solution, but I was thinking of something a little more
general for the services. Paths with a leading '/' are treated as absolute
paths whereas something without will be treated relative the application
root. This won't really affect anything but the general solution of
absolute/relative paths should be be resolved in fulcrum at the service
level. This require a bit of work in fulcrum.
 
> -jon
> 
> Revision  Changes    Path
> 1.3       +5 -1  
> jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocity/TurbineV
> elocityService.java
> 
> Index: TurbineVelocityService.java
> ===================================================================
> RCS file: 
> /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocit
> y/TurbineVelocityService.java,v
> retrieving revision 1.2
> retrieving revision 1.3
> diff -u -r1.2 -r1.3
> --- TurbineVelocityService.java    2001/08/08 23:34:07    1.2
> +++ TurbineVelocityService.java    2001/08/09 08:31:17    1.3
> @@ -91,7 +91,7 @@
>   * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
>   * @author <a href="mailto:sean@informage.ent">Sean Legassick</a>
>   * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
> - * @version $Id: TurbineVelocityService.java,v 1.2 2001/08/08 23:34:07 dlr
> Exp $
> + * @version $Id: TurbineVelocityService.java,v 1.3 2001/08/09 08:31:17 jon
> Exp $
>   */
>  public class TurbineVelocityService
>      extends BaseTemplateEngineService
> @@ -380,6 +380,10 @@
>                              path = path.substring(9);
>                          }
>                          path = "jar:file:" + getRealPath(path) + entry;
> +                    }
> +                    else if (path.startsWith("absolute:"))
> +                    {
> +                        path = path.substring ("absolute:".length(),
> path.length());
>                      }
>                      else if (!path.startsWith("jar:"))
>                      {
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



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


Re: cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocity TurbineVelocityService.java

Posted by Jon Stevens <jo...@latchkey.com>.
on 8/9/01 8:59 AM, "Jon Stevens" <jo...@latchkey.com> wrote:

> That won't work because paths currently start with a /template by default
> and will break existing TR.props. Having them be just "template" would be
> even more confusing to people because it wouldn't look like a path.
> 
> I like the declaration of absolute: because it is similar to
> "jar:file"...you are really defining what you really want and not playing
> more guessing games.
> 
> -jon

I should also add that if anything we should make it so that people have to
say:

webapp:/templates

Instead of just the current

/templates

And default to the webapp:/templates if it is only /templates.

That would make my day.

-jon


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


Re: cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocity TurbineVelocityService.java

Posted by Jon Stevens <jo...@latchkey.com>.
on 8/9/01 10:12 AM, "Jason van Zyl" <jv...@apache.org> wrote:

> On 8/9/01 11:59 AM, "Jon Stevens" <jo...@latchkey.com> wrote:
> 
>> on 8/9/01 5:13 AM, "Jason van Zyl" <jv...@apache.org> wrote:
>> 
>>> We definitely need a solution, but I was thinking of something a little more
>>> general for the services. Paths with a leading '/' are treated as absolute
>>> paths whereas something without will be treated relative the application
>>> root. This won't really affect anything but the general solution of
>>> absolute/relative paths should be be resolved in fulcrum at the service
>>> level. This require a bit of work in fulcrum.
>> 
>> That won't work because paths currently start with a /template by default
>> and will break existing TR.props. Having them be just "template" would be
>> even more confusing to people because it wouldn't look like a path.
> 
> I said it would require some work. What we have is confusing, I think people
> generally associate a leading '/' with an absolute path and the absence of
> leading '/' to be a relative path.

Ok, so lets just make it ./

> You are using an URL notation for something that is not an URL, which is not
> standard which is bound to confuse people.

Maybe then the solution is to change it to be "file://" instead of
"absolute:". That won't confuse people. :-) In fact, that is what I'm going
to do.

> Plus you've hacked off a solution
> for one service which satisfies your needs but won't help any of the other
> template services. So what works for velocity based apps will not work for
> JSP or any other templating service.

Correct. I scratched my itches.

> Someone is going to see the "absolute:" notation in a TRP file and try with
> JSP and than ask why it doesn't work. I guarantee it. A one off solution for
> one service using non-standard notation is definitely not the way to go.

I'm strongly +0 to an effort to generalize the approach.

-jon


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


Re: cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocity TurbineVelocityService.java

Posted by Eric Dobbs <er...@dobbse.net>.
On Thursday, August 9, 2001, at 04:59  PM, Jon Stevens wrote:

> I think you are missing the point. It isn't a property called 
> 'templates' it
> is a PATH called 'templates'.
>
> Look in your tr.props file.


sorry for the noise.

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


Re: cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocity TurbineVelocityService.java

Posted by Jon Stevens <jo...@latchkey.com>.
on 8/9/01 3:38 PM, "Eric Dobbs" <er...@dobbse.net> wrote:

> 
> On Thursday, August 9, 2001, at 11:12  AM, Jason van Zyl wrote:
> 
>> On 8/9/01 11:59 AM, "Jon Stevens" <jo...@latchkey.com> wrote:
>> 
>>> on 8/9/01 5:13 AM, "Jason van Zyl" <jv...@apache.org> wrote:
>>> 
>>>> We definitely need a solution, but I was thinking of something a
>>>> little more
>>>> general for the services. Paths with a leading '/' are treated as
>>>> absolute
>>>> paths whereas something without will be treated relative the
>>>> application
>>>> root. This won't really affect anything but the general solution of
>>>> absolute/relative paths should be be resolved in fulcrum at the
>>>> service
>>>> level. This require a bit of work in fulcrum.
>>> 
>>> That won't work because paths currently start with a /template by
>>> default
>>> and will break existing TR.props. Having them be just "template" would
>>> be
>>> even more confusing to people because it wouldn't look like a path.
>> 
>> I said it would require some work. What we have is confusing, I think
>> people
>> generally associate a leading '/' with an absolute path and the absence
>> of
>> leading '/' to be a relative path.
> 
> 
> what about renaming the property from 'template' to 'templatePath'
> 
> if it's a path, then call it a path.
> 
> $0.02

I think you are missing the point. It isn't a property called 'templates' it
is a PATH called 'templates'.

Look in your tr.props file.

-jon


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


Re: cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocity TurbineVelocityService.java

Posted by Eric Dobbs <er...@dobbse.net>.
On Thursday, August 9, 2001, at 11:12  AM, Jason van Zyl wrote:

> On 8/9/01 11:59 AM, "Jon Stevens" <jo...@latchkey.com> wrote:
>
>> on 8/9/01 5:13 AM, "Jason van Zyl" <jv...@apache.org> wrote:
>>
>>> We definitely need a solution, but I was thinking of something a 
>>> little more
>>> general for the services. Paths with a leading '/' are treated as 
>>> absolute
>>> paths whereas something without will be treated relative the 
>>> application
>>> root. This won't really affect anything but the general solution of
>>> absolute/relative paths should be be resolved in fulcrum at the 
>>> service
>>> level. This require a bit of work in fulcrum.
>>
>> That won't work because paths currently start with a /template by 
>> default
>> and will break existing TR.props. Having them be just "template" would 
>> be
>> even more confusing to people because it wouldn't look like a path.
>
> I said it would require some work. What we have is confusing, I think 
> people
> generally associate a leading '/' with an absolute path and the absence 
> of
> leading '/' to be a relative path.


what about renaming the property from 'template' to 'templatePath'

if it's a path, then call it a path.

$0.02

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


Re: cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocity TurbineVelocityService.java

Posted by Jason van Zyl <jv...@apache.org>.
On 8/9/01 11:59 AM, "Jon Stevens" <jo...@latchkey.com> wrote:

> on 8/9/01 5:13 AM, "Jason van Zyl" <jv...@apache.org> wrote:
> 
>> We definitely need a solution, but I was thinking of something a little more
>> general for the services. Paths with a leading '/' are treated as absolute
>> paths whereas something without will be treated relative the application
>> root. This won't really affect anything but the general solution of
>> absolute/relative paths should be be resolved in fulcrum at the service
>> level. This require a bit of work in fulcrum.
> 
> That won't work because paths currently start with a /template by default
> and will break existing TR.props. Having them be just "template" would be
> even more confusing to people because it wouldn't look like a path.

I said it would require some work. What we have is confusing, I think people
generally associate a leading '/' with an absolute path and the absence of
leading '/' to be a relative path.
 
> I like the declaration of absolute: because it is similar to
> "jar:file"...you are really defining what you really want and not playing
> more guessing games.

You are using an URL notation for something that is not an URL, which is not
standard which is bound to confuse people. Plus you've hacked off a solution
for one service which satisfies your needs but won't help any of the other
template services. So what works for velocity based apps will not work for
JSP or any other templating service.

Someone is going to see the "absolute:" notation in a TRP file and try with
JSP and than ask why it doesn't work. I guarantee it. A one off solution for
one service using non-standard notation is definitely not the way to go.
 
> -jon

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



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


Re: cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/velocity TurbineVelocityService.java

Posted by Jon Stevens <jo...@latchkey.com>.
on 8/9/01 5:13 AM, "Jason van Zyl" <jv...@apache.org> wrote:

> We definitely need a solution, but I was thinking of something a little more
> general for the services. Paths with a leading '/' are treated as absolute
> paths whereas something without will be treated relative the application
> root. This won't really affect anything but the general solution of
> absolute/relative paths should be be resolved in fulcrum at the service
> level. This require a bit of work in fulcrum.

That won't work because paths currently start with a /template by default
and will break existing TR.props. Having them be just "template" would be
even more confusing to people because it wouldn't look like a path.

I like the declaration of absolute: because it is similar to
"jar:file"...you are really defining what you really want and not playing
more guessing games.

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


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