Dashboard > blojsom > ... > Developers Guide > Configuring the Velocity dispatcher
  blojsom Log In   View a printable version of the current page.  
  Configuring the Velocity dispatcher
Added by David Czarnecki, last edited by David Czarnecki on Dec 21, 2004  (view change)
Labels: 
(None)

Installing the Velocity dispatcher

  • Add the following line to your /WEB-INF/dispatcher.properties file.
    vm=org.blojsom.dispatcher.VelocityDispatcher
    
  • In the above configuration, Velocity templates will be associated with the .vm file extension.
  • You may then add templates to an individual blog's /WEB-INF/(blog-id)/templates directory that use Velocity.
  • You must restart your server if you are adding the Velocity dispatcher while blojsom is running.

Configuring the Velocity dispatcher

The Velocity dispatcher is configured by configuring Velocity. The Velocity configuration file is specified in the following initialization parameter for the blojsom servlet in /WEB-INF/web.xml.

<init-param>
    <param-name>velocity-properties</param-name>
    <param-value>/WEB-INF/velocity.properties</param-value>
</init-param>

The default velocity.properties file that comes with blojsom is given below. You may refer to the Velocity developer's guide for the details on configuring Velocity. blojsom, by default, uses Velocity's file resource loader which loads Velocity templates from disk.

#
# blojsom Velocity dispatcher configuration file
#
# Tell Velocity which resource loader we are using
#
resource.loader=file, class
#

#
# File resource loader information
#
file.resource.loader.description=Velocity File Resource Loader
file.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
file.resource.loader.cache=true
file.resource.loader.modificationCheckInterval=60

#
# Class resource loader information
#
class.resource.loader.description=Velocity Classpath Resource Loader
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
class.resource.loader.cache=true
class.resource.loader.modificationCheckInterval=0

#
# Other properties
#
input.encoding=UTF-8
output.encoding=UTF-8
runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem

#
# Velocity macro properties
#
velocimacro.library=org/blojsom/plugin/admin/templates/admin-macros.vm
velocimacro.permissions.allow.inline=true
velocimacro.permissions.allow.inline.local.scope=true

Configuring a flavor template to use the Velocity dispatcher

You can configure individual flavors to use the Velocity dispatcher by changing the properties in your /WEB-INF/(blog-id)/flavor.properties file. For example:

html=html.vm, text/html;charset=UTF-8

This line in the flavor.properties file configures the html flavor to use the html.vm template, where in the standard blojsom installation, templates with a .vm extension are associated with the Velocity dispatcher.

Writing templates using Velocity

Take a look at the Velocity templates that come with the blojsom installation. You may refer to the Velocity user's guide for all the details on the syntax of writing templates using Velocity.

Site running on a free Atlassian Confluence Open Source Project License granted to blojsom. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators