velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phi...@free.fr
Subject Re: $link
Date Thu, 19 Feb 2015 15:16:59 GMT
Hi Erik,

thanks for the pointers.

I ended up using a combination of Java String methods and $esc.url().

Philippe

----- Mail original -----
De: "Erik Hatcher" <erik.hatcher@gmail.com>
À: "Velocity Users List" <user@velocity.apache.org>
Envoyé: Jeudi 19 Février 2015 16:01:12
Objet: Re: $link

I love how the Velocity list e-mails end up being about Solr ;)   

Here are the tools that (Solr 5, a little bit different that previous Solr versions) has these
tools:

context.put("esc", new EscapeTool());
context.put("date", new ComparisonDateTool());
context.put("list", new ListTool());
context.put("math", new MathTool());
context.put("number", new NumberTool());
context.put("sort", new SortTool());
context.put("display", new DisplayTool());
context.put("resource", new SolrVelocityResourceTool(
    request.getCore().getSolrConfig().getResourceLoader().getClassLoader(),
    request.getParams().get(LOCALE)));

LinkTool is not wired in.   There isn’t really a way to add new tools into the mix without
plugging in a new response writer based on Solr’s VelocityResponseWriter (VrW) or overwriting
the built-in one.  But you probably don’t really need $link, do you?

There’s the $esc tool that allows for URL escaping.  It’s used to $esc.html() and $esc.url()
in the example templates.

Happy to help work through this, and even add the LinkTool if you feel it’d be helpful (or
work through a way to make tools pluggable in VrW).

    Erik (author/maintainer of VrW)




—
Erik Hatcher, Senior Solutions Architect
http://www.lucidworks.com




> On Feb 19, 2015, at 9:40 AM, Logan Stinger <lstinger@bluelid.com> wrote:
> 
> SOLR uses response writers to convert a SOLR response in to the desired output format.
 There are various response writers you can use right out of the box and you can control which
one is used via command line parameters or via solrconfig.xml file.  Ie. wt=xml, wt=json,
wt=velocity
> The VelocityResponseWriter class has a hard coded list of tools that it injects in to
the context.  I don't know what version of velocity you are using but the link below is the
source of the VelocityResponseWriter for version 3.5.  I'm sure later versions of this class
are similar.  I have a custom version of this class in my project that only injects the tools
I use/need.
> 
> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.solr/solr-velocity/3.5.0/org/apache/solr/response/VelocityResponseWriter.java
> 
> -----Original Message-----
> From: phiroc@free.fr [mailto:phiroc@free.fr] 
> Sent: Thursday, February 19, 2015 8:03 AM
> To: Velocity Users List
> Subject: Re: $link
> 
> Hi,
> 
> I am using the SOLR version of Velocity, running in Tomcat, which doesn't seem to have
a toolbox.xml file. I have manually created such a file, and added it to
> 
> ...apache-tomcat-8.0.15/webapps/solr/WEB-INF
> 
> but to no avail.
> 
> Philippe
> 
> 
> 
> ----- Mail original -----
> De: "Mike Kienenberger" <mkienenb@gmail.com>
> À: "Velocity Users List" <user@velocity.apache.org>
> Envoyé: Jeudi 19 Février 2015 14:30:14
> Objet: Re: $link
> 
> Add "link" to your velocity toolbox.xml file.
> 
> If you search for "<key>math</key>", you should be able to find the file
and then add a new entry for "link"
> 
> See LinkTool.html for more information specific to link.
> 
> http://velocity.apache.org/tools/devel/view/LinkTool.html
> 
> 
> See config.html for general information on tool configuration.
> 
> http://velocity.apache.org/tools/releases/2.0/config.html
> 
> 
> On Thu, Feb 19, 2015 at 5:59 AM,  <phiroc@free.fr> wrote:
>> Hi,
>> 
>> how do you access $link in velocity templates?
>> 
>> I have access to $math, but not link.
>> 
>> Many thanks.
>> 
>> Philippe
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message