You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by EP...@upstate.com on 2003/04/21 21:31:21 UTC

RE: cvs commit: jakarta-turbine-2/proposals/henning/velocitymacro s README TurbineMacros.vm

Does this mean that out of the box I could put .vm files in a jar (with
other code like the actions etc) and share that accross multiple turbine
apps?

ERic

-----Original Message-----
From: henning@apache.org [mailto:henning@apache.org]
Sent: Monday, April 21, 2003 2:42 PM
To: jakarta-turbine-2-cvs@apache.org
Subject: cvs commit: jakarta-turbine-2/proposals/henning/velocitymacros
README TurbineMacros.vm


henning     2003/04/21 11:41:32

  Added:       proposals/henning/velocitymacros README TurbineMacros.vm
  Log:
  First cut at actually implementing the macros that Quinton described in
  HtmlPageAttributes. Please try out and report bugs.
  
  Revision  Changes    Path
  1.1
jakarta-turbine-2/proposals/henning/velocitymacros/README
  
  Index: README
  ===================================================================
  Velocity Macros for VelocityOnlyLayout
  ======================================
  
  These are two macros which can be used in conjunction with
  VelocityOnlyLayout and HtmlPageAttributes to provide the same
  Functionality as VelocityECSLayout with TemplatePageAttributes.
  
  These macros should be used in the Layout template like this:
  
  --- cut --- Layout Template --- cut ---
  
  ... here you should put things like setting the page name, adding
  style sheets and so on.
  
  <html>
  #TurbineHtmlHead()
  #TurbineHtmlBodyStart()
  .... your body information
  </body>
  </html>
  --- cut --- Layout Template --- cut ---
  
  As the layout template is rendered _after_ the screen template, you
  can of course, add information to the $page tool in your screen
  template. This will be added correctly to the <head>...</head> and
  <body> tags.
  
  
  Adding these Macros to the Turbine Code base
  ============================================
  
  I propose to add these Macros for loading by the classpath loader
  directly from the turbine.jar. To achieve this, the following is added
  to the java:compile postGoal in maven.xml:
  
  <copy
    file="${maven.src.dir}/macros/TurbineMacros.vm"
    todir="${maven.build.dest}/macros"
  />
  
  (assuming the Macro file is put into src/macros/TurbineMacros.vm in the
  Turbine code base)
  
  and then adding a load instruction to the TurbineResources.properties:
  
  services.VelocityService.velocimacro.library = macros/TurbineMacros.vm
  
  Of course, the classpath loader must be configured (it is by default):
  
  services.VelocityService.resource.loader = classpath
  services.VelocityService.classpath.resource.loader.description = Velocity
Classpath Resource Loader
  services.VelocityService.classpath.resource.loader.class =
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
  
  
  
  
  
  
  1.1
jakarta-turbine-2/proposals/henning/velocitymacros/TurbineMacros.vm
  
  Index: TurbineMacros.vm
  ===================================================================
  ## @version $Id: TurbineMacros.vm,v 1.1 2003/04/21 18:41:31 henning Exp $
  ## @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  
  ##
  ## Build the <head> ... </head> tag of a web page with VelocityOnly Layout
  ## 
  #macro (TurbineHtmlHead)
  <head>
    #if ($!page.Title)
      <title>$page.Title</title>
    #end
    #if ($page.MetaTags.size() > 0)
      #foreach($metaTag in $page.MetaTags.keySet())
        <meta name="$metaTag" content="$page.MetaTags.get($metaTag)">
      #end
    #end
    #if ($page.HttpEquivs.size() > 0)
      #foreach($httpEquiv in $page.HttpEquivs.keySet())
        <meta http-equiv="$httpEquiv"
content="$page.HttpEquivs.get($httpEquiv)">
      #end
    #end
    #if ($page.StyleSheets.size() > 0)
      #foreach( $styleSheet in $page.StyleSheets )
        <link rel="stylesheet" href="$styleSheet.Url"
          #if($!styleSheet.Type)  type="$styleSheet.Type"   #end
          #if($!styleSheet.Media) media="$styleSheet.Media" #end
          #if($!styleSheet.Title) title="$styleSheet.Title" #end
        >
      #end
    #end
    #if ($page.Scripts.size() > 0)
      #foreach( $script in $page.Scripts )
        <script type="text/javascript" src="$script"
language="JavaScript"></script>
      #end
    #end
  </head>
  #end
  
  ##
  ## Build the <body> start tag of a web page with VelocityOnly Layout
  ## 
  #macro (TurbineHtmlBodyStart)
  #if ($page.BodyAttributes.size() > 0)
    <body
      #foreach( $attributeName in $page.BodyAttributes.keySet() )
        $attributeName = "$page.BodyAttributes.get($attributeName)"
      #end
    >
  #else
    <body>
  #end
  #end
  
  
  
  
  

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

Re: TurbineMacros (was: cvs commit: jakarta-turbine-2/proposals/henning/velocitymacro)

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Angelo Turetta" <at...@commit.it> writes:

>>  <html>
>>  #TurbineHtmlHead()
>>  #TurbineHtmlBodyStart()
>>  .... your body information
>>  </body>
>>  </html>

>Henning,

>perhaps it might be changed to:

> <html>
> #TurbineHtmlHead()
> <body #TurbineHtmlBodyAttributes() >
> .... your body information
> </body>
> </html>

>This way, the template file is a little more standard, and may be edited with an
>HTML editor.

Thanks for your suggestion. This is a good idea.

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

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


TurbineMacros (was: cvs commit: jakarta-turbine-2/proposals/henning/velocitymacro)

Posted by Angelo Turetta <at...@commit.it>.
>  <html>
>  #TurbineHtmlHead()
>  #TurbineHtmlBodyStart()
>  .... your body information
>  </body>
>  </html>

Henning,

perhaps it might be changed to:

 <html>
 #TurbineHtmlHead()
 <body #TurbineHtmlBodyAttributes() >
 .... your body information
 </body>
 </html>

This way, the template file is a little more standard, and may be edited with an
HTML editor.

(my 2 euroCents)

Angelo Turetta
Italy

---------------------------------------------------------------------
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-2/proposals/henning/velocitymacro

Posted by "Jeffrey D. Brekke" <jb...@wi.rr.com>.
Have you found a way to include properties files for your jar'd apps?
We ususally have these *include*d at the bottom of the main TR.props
file.  It would be nice to get the properties files into the jars
along with the templates and classes.


>>>>> On Tue, 22 Apr 2003 08:19:38 +0000 (UTC), "Henning P. Schmiedehausen" <hp...@intermeta.de> said:

> EPugh@upstate.com writes:
>> ------_=_NextPart_001_01C3083C.9698EB90 Content-Type: text/plain;
>> charset="iso-8859-1"

>> Does this mean that out of the box I could put .vm files in a jar
>> (with other code like the actions etc) and share that accross
>> multiple turbine apps?

> Yeah, sure. That's what the classpath loader is all about. I
> distribute my applications like this all the time. They all have a
> "templates" jar which contains four packages: screens, navigations,
> layouts and macros. In my app, I simply add e.g.

> services.VelocityService.velocimacro.library =
> macros/ToolboxMacros.vm

> and toolbox.jar contains:

> % jar tvf ~/javalibs/maven/intermeta/jars/toolbox-2.0-dev.jar | grep
> -i vm 818 Thu Apr 10 14:02:02 CEST 2003 macros/ToolboxMacros.vm 5679
> Thu Apr 10 14:02:02 CEST 2003 macros/GridMacros.vm 4826 Thu Apr 10
> 14:02:02 CEST 2003 macros/IntakeMacros.vm

> The classpath loader then finds this on the classpath and loads it
> into Velocity.

> You might understand now, why I'm such a stickler for template
> naming and pathes. I don't have any template files (besides an
> Index.vm which is different for each installation) at all in my
> apps, once they're deployed.

> You should see the eyes of my customers' engineers when they decide
> to "improve" the web layout of the application pages and don't find
> any files which contain the template pages...  =:-)

> 	Regards Henning



>> ERic

>> -----Original Message----- From: henning@apache.org
>> [mailto:henning@apache.org] Sent: Monday, April 21, 2003 2:42 PM
>> To: jakarta-turbine-2-cvs@apache.org Subject: cvs commit:
>> jakarta-turbine-2/proposals/henning/velocitymacros README
>> TurbineMacros.vm


>> henning 2003/04/21 11:41:32

>> Added: proposals/henning/velocitymacros README TurbineMacros.vm
>> Log: First cut at actually implementing the macros that Quinton
>> described in HtmlPageAttributes. Please try out and report bugs.
>> 
>> Revision Changes Path 1.1
>> jakarta-turbine-2/proposals/henning/velocitymacros/README
>> 
>> Index: README
>> ===================================================================
>> Velocity Macros for VelocityOnlyLayout
>> ======================================
>> 
>> These are two macros which can be used in conjunction with
>> VelocityOnlyLayout and HtmlPageAttributes to provide the same
>> Functionality as VelocityECSLayout with TemplatePageAttributes.
>> 
>> These macros should be used in the Layout template like this:
>> 
>> --- cut --- Layout Template --- cut ---
>> 
>> ... here you should put things like setting the page name, adding
>> style sheets and so on.
>> 
>> <html> #TurbineHtmlHead() #TurbineHtmlBodyStart() .... your body
>> information </body> </html> --- cut --- Layout Template --- cut ---
>> 
>> As the layout template is rendered _after_ the screen template, you
>> can of course, add information to the $page tool in your screen
>> template. This will be added correctly to the <head>...</head> and
>> <body> tags.
>> 
>> 
>> Adding these Macros to the Turbine Code base
>> ============================================
>> 
>> I propose to add these Macros for loading by the classpath loader
>> directly from the turbine.jar. To achieve this, the following is
>> added to the java:compile postGoal in maven.xml:
>> 
>> <copy file="${maven.src.dir}/macros/TurbineMacros.vm"
>> todir="${maven.build.dest}/macros" />
>> 
>> (assuming the Macro file is put into src/macros/TurbineMacros.vm in
>> the Turbine code base)
>> 
>> and then adding a load instruction to the
>> TurbineResources.properties:
>> 
>> services.VelocityService.velocimacro.library =
>> macros/TurbineMacros.vm
>> 
>> Of course, the classpath loader must be configured (it is by
>> default):
>> 
>> services.VelocityService.resource.loader = classpath
>> services.VelocityService.classpath.resource.loader.description =
>> Velocity Classpath Resource Loader
>> services.VelocityService.classpath.resource.loader.class =
>> org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
>> 
>> 
>> 
>> 
>> 
>> 
>> 1.1
>> jakarta-turbine-2/proposals/henning/velocitymacros/TurbineMacros.vm
>> 
>> Index: TurbineMacros.vm
>> ===================================================================
>> ## @version $Id: TurbineMacros.vm,v 1.1 2003/04/21 18:41:31 henning
>> Exp $ ## @author <a href="mailto:hps@intermeta.de">Henning
>> P. Schmiedehausen</a>
>> 
>> ## ## Build the <head> ... </head> tag of a web page with
>> VelocityOnly Layout ## #macro (TurbineHtmlHead) <head> #if
>> ($!page.Title) <title>$page.Title</title> #end #if
>> ($page.MetaTags.size() > 0) #foreach($metaTag in
>> $page.MetaTags.keySet()) <meta name="$metaTag"
>> content="$page.MetaTags.get($metaTag)"> #end #end #if
>> ($page.HttpEquivs.size() > 0) #foreach($httpEquiv in
>> $page.HttpEquivs.keySet()) <meta http-equiv="$httpEquiv"
>> content="$page.HttpEquivs.get($httpEquiv)"> #end #end #if
>> ($page.StyleSheets.size() > 0) #foreach( $styleSheet in
>> $page.StyleSheets ) <link rel="stylesheet" href="$styleSheet.Url"
>> #if($!styleSheet.Type) type="$styleSheet.Type" #end
>> #if($!styleSheet.Media) media="$styleSheet.Media" #end
>> #if($!styleSheet.Title) title="$styleSheet.Title" #end
>> >
>> #end #end #if ($page.Scripts.size() > 0) #foreach( $script in
>> $page.Scripts ) <script type="text/javascript" src="$script"
>> language="JavaScript"></script> #end #end </head> #end
>> 
>> ## ## Build the <body> start tag of a web page with VelocityOnly
>> Layout ## #macro (TurbineHtmlBodyStart) #if
>> ($page.BodyAttributes.size() > 0) <body #foreach( $attributeName in
>> $page.BodyAttributes.keySet() ) $attributeName =
>> "$page.BodyAttributes.get($attributeName)" #end
>> >
>> #else <body> #end #end
>> 
>> 
>> 
>> 
>> 

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

>> ------_=_NextPart_001_01C3083C.9698EB90--

> -- Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
> hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/

> Java, perl, Solaris, Linux, xSP Consulting, Web Services freelance
> consultant -- Jakarta Turbine Development -- hero for hire

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

-- 
=====================================================================
Jeffrey D. Brekke                                   jbrekke@wi.rr.com
Wisconsin,  USA                                     brekke@apache.org
                                                    ekkerbj@yahoo.com


---------------------------------------------------------------------
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-2/proposals/henning/velocitymacro

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
EPugh@upstate.com writes:

>------_=_NextPart_001_01C3083C.9698EB90
>Content-Type: text/plain;
>	charset="iso-8859-1"

>Does this mean that out of the box I could put .vm files in a jar (with
>other code like the actions etc) and share that accross multiple turbine
>apps?

Yeah, sure. That's what the classpath loader is all about. I
distribute my applications like this all the time. They all have a
"templates" jar which contains four packages: screens, navigations,
layouts and macros. In my app, I simply add e.g.

services.VelocityService.velocimacro.library = macros/ToolboxMacros.vm

and toolbox.jar contains:

% jar tvf ~/javalibs/maven/intermeta/jars/toolbox-2.0-dev.jar | grep -i vm
   818 Thu Apr 10 14:02:02 CEST 2003 macros/ToolboxMacros.vm
  5679 Thu Apr 10 14:02:02 CEST 2003 macros/GridMacros.vm
  4826 Thu Apr 10 14:02:02 CEST 2003 macros/IntakeMacros.vm

The classpath loader then finds this on the classpath and loads it
into Velocity.

You might understand now, why I'm such a stickler for template naming
and pathes. I don't have any template files (besides an Index.vm which
is different for each installation) at all in my apps, once they're
deployed. 

You should see the eyes of my customers' engineers when they decide to
"improve" the web layout of the application pages and don't find any
files which contain the template pages...  =:-)

	Regards
		Henning



>ERic

>-----Original Message-----
>From: henning@apache.org [mailto:henning@apache.org]
>Sent: Monday, April 21, 2003 2:42 PM
>To: jakarta-turbine-2-cvs@apache.org
>Subject: cvs commit: jakarta-turbine-2/proposals/henning/velocitymacros
>README TurbineMacros.vm


>henning     2003/04/21 11:41:32

>  Added:       proposals/henning/velocitymacros README TurbineMacros.vm
>  Log:
>  First cut at actually implementing the macros that Quinton described in
>  HtmlPageAttributes. Please try out and report bugs.
>  
>  Revision  Changes    Path
>  1.1
>jakarta-turbine-2/proposals/henning/velocitymacros/README
>  
>  Index: README
>  ===================================================================
>  Velocity Macros for VelocityOnlyLayout
>  ======================================
>  
>  These are two macros which can be used in conjunction with
>  VelocityOnlyLayout and HtmlPageAttributes to provide the same
>  Functionality as VelocityECSLayout with TemplatePageAttributes.
>  
>  These macros should be used in the Layout template like this:
>  
>  --- cut --- Layout Template --- cut ---
>  
>  ... here you should put things like setting the page name, adding
>  style sheets and so on.
>  
>  <html>
>  #TurbineHtmlHead()
>  #TurbineHtmlBodyStart()
>  .... your body information
>  </body>
>  </html>
>  --- cut --- Layout Template --- cut ---
>  
>  As the layout template is rendered _after_ the screen template, you
>  can of course, add information to the $page tool in your screen
>  template. This will be added correctly to the <head>...</head> and
>  <body> tags.
>  
>  
>  Adding these Macros to the Turbine Code base
>  ============================================
>  
>  I propose to add these Macros for loading by the classpath loader
>  directly from the turbine.jar. To achieve this, the following is added
>  to the java:compile postGoal in maven.xml:
>  
>  <copy
>    file="${maven.src.dir}/macros/TurbineMacros.vm"
>    todir="${maven.build.dest}/macros"
>  />
>  
>  (assuming the Macro file is put into src/macros/TurbineMacros.vm in the
>  Turbine code base)
>  
>  and then adding a load instruction to the TurbineResources.properties:
>  
>  services.VelocityService.velocimacro.library = macros/TurbineMacros.vm
>  
>  Of course, the classpath loader must be configured (it is by default):
>  
>  services.VelocityService.resource.loader = classpath
>  services.VelocityService.classpath.resource.loader.description = Velocity
>Classpath Resource Loader
>  services.VelocityService.classpath.resource.loader.class =
>org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
>  
>  
>  
>  
>  
>  
>  1.1
>jakarta-turbine-2/proposals/henning/velocitymacros/TurbineMacros.vm
>  
>  Index: TurbineMacros.vm
>  ===================================================================
>  ## @version $Id: TurbineMacros.vm,v 1.1 2003/04/21 18:41:31 henning Exp $
>  ## @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
>  
>  ##
>  ## Build the <head> ... </head> tag of a web page with VelocityOnly Layout
>  ## 
>  #macro (TurbineHtmlHead)
>  <head>
>    #if ($!page.Title)
>      <title>$page.Title</title>
>    #end
>    #if ($page.MetaTags.size() > 0)
>      #foreach($metaTag in $page.MetaTags.keySet())
>        <meta name="$metaTag" content="$page.MetaTags.get($metaTag)">
>      #end
>    #end
>    #if ($page.HttpEquivs.size() > 0)
>      #foreach($httpEquiv in $page.HttpEquivs.keySet())
>        <meta http-equiv="$httpEquiv"
>content="$page.HttpEquivs.get($httpEquiv)">
>      #end
>    #end
>    #if ($page.StyleSheets.size() > 0)
>      #foreach( $styleSheet in $page.StyleSheets )
>        <link rel="stylesheet" href="$styleSheet.Url"
>          #if($!styleSheet.Type)  type="$styleSheet.Type"   #end
>          #if($!styleSheet.Media) media="$styleSheet.Media" #end
>          #if($!styleSheet.Title) title="$styleSheet.Title" #end
>        >
>      #end
>    #end
>    #if ($page.Scripts.size() > 0)
>      #foreach( $script in $page.Scripts )
>        <script type="text/javascript" src="$script"
>language="JavaScript"></script>
>      #end
>    #end
>  </head>
>  #end
>  
>  ##
>  ## Build the <body> start tag of a web page with VelocityOnly Layout
>  ## 
>  #macro (TurbineHtmlBodyStart)
>  #if ($page.BodyAttributes.size() > 0)
>    <body
>      #foreach( $attributeName in $page.BodyAttributes.keySet() )
>        $attributeName = "$page.BodyAttributes.get($attributeName)"
>      #end
>    >
>  #else
>    <body>
>  #end
>  #end
>  
>  
>  
>  
>  

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

>------_=_NextPart_001_01C3083C.9698EB90--

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

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