$link

2015-02-19 Thread phiroc
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-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org



Re: $link

2015-02-19 Thread Mike Kienenberger
Add "link" to your velocity toolbox.xml file.

If you search for "math", 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,   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-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
>

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



Re: $link

2015-02-19 Thread phiroc
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" 
À: "Velocity Users List" 
Envoyé: Jeudi 19 Février 2015 14:30:14
Objet: Re: $link

Add "link" to your velocity toolbox.xml file.

If you search for "math", 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,   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-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
>

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


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



RE: $link

2015-02-19 Thread Logan Stinger
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: phi...@free.fr [mailto:phi...@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" 
À: "Velocity Users List" 
Envoyé: Jeudi 19 Février 2015 14:30:14
Objet: Re: $link

Add "link" to your velocity toolbox.xml file.

If you search for "math", 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,   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-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
>

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


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



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



Re: $link

2015-02-19 Thread Erik Hatcher
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  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: phi...@free.fr [mailto:phi...@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" 
> À: "Velocity Users List" 
> Envoyé: Jeudi 19 Février 2015 14:30:14
> Objet: Re: $link
> 
> Add "link" to your velocity toolbox.xml file.
> 
> If you search for "math", 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,   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-unsubscr...@velocity.apache.org
>> For additional commands, e-mail: user-h...@velocity.apache.org
>> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 


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



Re: $link

2015-02-19 Thread phiroc
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" 
À: "Velocity Users List" 
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  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: phi...@free.fr [mailto:phi...@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" 
> À: "Velocity Users List" 
> Envoyé: Jeudi 19 Février 2015 14:30:14
> Objet: Re: $link
> 
> Add "link" to your velocity toolbox.xml file.
> 
> If you search for "math", 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,   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-unsubscr...@velocity.apache.org
>> For additional commands, e-mail: user-h...@velocity.apache.org
>> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 


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


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



Re: $link

2015-02-19 Thread Erik Hatcher
If you could show me what you’ve done, I’d be happy to adjust VrW to better 
suit your needs if that makes sense.

Feedback welcome!


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




> On Feb 19, 2015, at 10:16 AM, phi...@free.fr wrote:
> 
> 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" 
> À: "Velocity Users List" 
> 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  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: phi...@free.fr [mailto:phi...@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" 
>> À: "Velocity Users List" 
>> Envoyé: Jeudi 19 Février 2015 14:30:14
>> Objet: Re: $link
>> 
>> Add "link" to your velocity toolbox.xml file.
>> 
>> If you search for "math", 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,   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-unsubscr...@velocity.apache.org
>>> For additional commands, e-mail: user-h...@velocity.apache.org
>>> 
>> 
>> -
>> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
>> For additional commands, e-mail: user-h...@velocity.apache.org
>> 
>> 
>> -
>> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
>> For additional commands, e-mail: user-h...@velocity.apache.org
>> 
>> 
>> 
>> -
>> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
>> For additional commands, e-mail: user-h...@velocity.apache.org
>> 
> 
> 
> -
> To unsubscribe

Functions

2015-02-19 Thread phiroc

Is there a way to create dynamic methods/functions in Velocity Templates?

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



Re: $link

2015-02-19 Thread phiroc
Here's the code:

-





## e.g., apdf0 in /apdf0/189311/28/003_E_PDF.pdf
#set($pdf_dir_v = $list.get($doc.getFirstValue('url').split("/"),1))

## e.g., 189311
#set($pdf_year_mon_v = $list.get($doc.getFirstValue('url').split("/"),2))
 
## e.g., 28
#set($pdf_day_v = $list.get($doc.getFirstValue('url').split("/"),3))

## e.g., 003_E_PDF.pdf
#set($pdf_name_v= $list.get($doc.getFirstValue('url').split("/"),4))

## Generated URL example: 
http://abc.com:8983/inytapdf0/pdfjs/web/viewer.html?file=../../189009/01/002_E_PDF.pdf#tv=the%20man
#if ($params.q and $pdf_dir_v and $pdf_year_mon_v and $pdf_day_v and 
$pdf_name_v)

##set ( $paramsQ = $params.q )
## Remove double quotes
#set ( $temp0 = $params.q.replaceAll("\"", "") )
##temp0 : $temp0

#set ($andIndex = $temp0.indexOf("AND"))
#if ($andIndex >= 0) 
## eg. "time" in example above
#set ($temp2 = $temp0.substring(0, $andIndex))
#else
#set ($temp2 = $temp0)
#end
##1) temp2 = $temp2

#set ($orIndex = $temp0.indexOf("OR"))
#if ($orIndex >= 0) 
## eg. "time" in example above
#set ($temp2 = $temp0.substring(0, $orIndex))
#else
#set ($temp2 = $temp0)
#end
##2) temp2 = $temp2

#if ($temp2 and $temp2.length() > 0) 
##3) temp2 = '$temp2'
#set( $viewer_js_url = 
"/${pdf_dir_v}/pdfjs/web/viewer.html?file=../../${pdf_year_mon_v}/${pdf_day_v}/${pdf_name_v}#tv=${temp2}"
 )
#else
## If the user didn't select a search criteria (q), let him 
view PDF anyway
#set( $viewer_js_url = 
"/${pdf_dir_v}/pdfjs/web/viewer.html?file=../../${pdf_year_mon_v}/${pdf_day_v}/${pdf_name_v}"
 )
#end

#end

---

- Mail original -
De: "Erik Hatcher" 
À: "Velocity Users List" 
Envoyé: Jeudi 19 Février 2015 16:19:25
Objet: Re: $link

If you could show me what you’ve done, I’d be happy to adjust VrW to better 
suit your needs if that makes sense.

Feedback welcome!


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




> On Feb 19, 2015, at 10:16 AM, phi...@free.fr wrote:
> 
> 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" 
> À: "Velocity Users List" 
> 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  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: phi...@free.fr [mailto:phi...@free.fr] 
>> Sent: Thursday, February 19, 2015 8:03 AM
>> To: Velocity Users List
>> Subject: Re: $l

Re: Functions

2015-02-19 Thread Mike Kienenberger
Depends what you need.

Take a look at # macros if the only output from the function is generated text.

http://velocity.apache.org/engine/releases/velocity-1.7/user-guide.html#Velocimacros


Otherwise, the way to do this is to create a new tool (which is any
java class with a zero-arg constructor aka POJO) and add it to your
toolkit (covered in the other thread and a bit complicated in your
case).  But the tool itself is as trivial as it sounds.

class FooTool {
  public Integer barFunction(Object x, String y, List z) {
   // return Integer.valueOf(...);
  }
}

Assuming FooTool is registered under tool name "foo", then use this in
your template.

${foo.barFunction(x, y, z)}

Look at the existing velocity tools (like math) if you need more examples.




On Thu, Feb 19, 2015 at 10:22 AM,   wrote:
>
> Is there a way to create dynamic methods/functions in Velocity Templates?
>
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
>

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



Re: $link

2015-02-19 Thread Erik Hatcher
I don’t see any $esc() usage below, so looks like I’m missing the full picture.

However, seeing how you’re splitting off pieces of the “url” field in the 
results display, maybe it’d make sense to script that piecing out of the url at 
index time instead into separate fields (month, day, year) or in some way 
massage the incoming data to be what you need in the results?

Erik




> On Feb 19, 2015, at 10:25 AM, phi...@free.fr wrote:
> 
> Here's the code:
> 
> -
> 
> 
> 
> 
> 
> ## e.g., apdf0 in /apdf0/189311/28/003_E_PDF.pdf
> #set($pdf_dir_v = $list.get($doc.getFirstValue('url').split("/"),1))
> 
> ## e.g., 189311
> #set($pdf_year_mon_v = $list.get($doc.getFirstValue('url').split("/"),2))
> 
> ## e.g., 28
> #set($pdf_day_v = $list.get($doc.getFirstValue('url').split("/"),3))
> 
> ## e.g., 003_E_PDF.pdf
> #set($pdf_name_v= $list.get($doc.getFirstValue('url').split("/"),4))
> 
> ## Generated URL example: 
> http://abc.com:8983/inytapdf0/pdfjs/web/viewer.html?file=../../189009/01/002_E_PDF.pdf#tv=the%20man
>  
> 
> #if ($params.q and $pdf_dir_v and $pdf_year_mon_v and $pdf_day_v and 
> $pdf_name_v)
> 
>   ##set ( $paramsQ = $params.q )
>   ## Remove double quotes
>   #set ( $temp0 = $params.q.replaceAll("\"", "") )
>   ##temp0 : $temp0
>   
>   #set ($andIndex = $temp0.indexOf("AND"))
>   #if ($andIndex >= 0) 
>   ## eg. "time" in example above
>   #set ($temp2 = $temp0.substring(0, $andIndex))
>   #else
>   #set ($temp2 = $temp0)
>   #end
>   ##1) temp2 = $temp2
>   
>   #set ($orIndex = $temp0.indexOf("OR"))
>   #if ($orIndex >= 0) 
>   ## eg. "time" in example above
>   #set ($temp2 = $temp0.substring(0, $orIndex))
>   #else
>   #set ($temp2 = $temp0)
>   #end
>   ##2) temp2 = $temp2
>   
>   #if ($temp2 and $temp2.length() > 0) 
>   ##3) temp2 = '$temp2'
>   #set( $viewer_js_url = 
> "/${pdf_dir_v}/pdfjs/web/viewer.html?file=../../${pdf_year_mon_v}/${pdf_day_v}/${pdf_name_v}#tv=${temp2}"
>  )
>   #else
>   ## If the user didn't select a search criteria (q), let him 
> view PDF anyway
>   #set( $viewer_js_url = 
> "/${pdf_dir_v}/pdfjs/web/viewer.html?file=../../${pdf_year_mon_v}/${pdf_day_v}/${pdf_name_v}"
>  )
>   #end
> 
> #end
> 
> ---
> 
> - Mail original -
> De: "Erik Hatcher" mailto:erik.hatc...@gmail.com>>
> À: "Velocity Users List"  >
> Envoyé: Jeudi 19 Février 2015 16:19:25
> Objet: Re: $link
> 
> If you could show me what you’ve done, I’d be happy to adjust VrW to better 
> suit your needs if that makes sense.
> 
> Feedback welcome!
> 
> 
> —
> Erik Hatcher, Senior Solutions Architect
> http://www.lucidworks.com  
> >
> 
> 
> 
> 
>> On Feb 19, 2015, at 10:16 AM, phi...@free.fr wrote:
>> 
>> 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" 
>> À: "Velocity Users List" 
>> 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  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 a

Re: Functions

2015-02-19 Thread Erik Hatcher
You mean like the macros?  Since you’re in Solr-land, look at the 
VM_global_library.vm file and how those pieces are used.  (it’s a bit uglier 
than it should be in the Solr example macro library, but should give you some 
insight there).


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




> On Feb 19, 2015, at 10:22 AM, phi...@free.fr wrote:
> 
> 
> Is there a way to create dynamic methods/functions in Velocity Templates?
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 



Re: Functions

2015-02-19 Thread phiroc
Ah, I never thought of using macros as methods/functions. Thanks.

- Mail original -
De: "Erik Hatcher" 
À: "Velocity Users List" 
Envoyé: Jeudi 19 Février 2015 16:43:43
Objet: Re: Functions

You mean like the macros?  Since you’re in Solr-land, look at the 
VM_global_library.vm file and how those pieces are used.  (it’s a bit uglier 
than it should be in the Solr example macro library, but should give you some 
insight there).


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




> On Feb 19, 2015, at 10:22 AM, phi...@free.fr wrote:
> 
> 
> Is there a way to create dynamic methods/functions in Velocity Templates?
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 


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



Re: Functions

2015-02-19 Thread Nathan Bubna
(shaking his head)

please use a tool object, if at all possible. using macros as functions
gives me the willies. :)  they're meant to clean/simplify repetition of
content. just because they can be used as functions, doesn't mean they
should be. things can get ugly down that road. :)

On Thu, Feb 19, 2015 at 7:47 AM,  wrote:

> Ah, I never thought of using macros as methods/functions. Thanks.
>
> - Mail original -
> De: "Erik Hatcher" 
> À: "Velocity Users List" 
> Envoyé: Jeudi 19 Février 2015 16:43:43
> Objet: Re: Functions
>
> You mean like the macros?  Since you’re in Solr-land, look at the
> VM_global_library.vm file and how those pieces are used.  (it’s a bit
> uglier than it should be in the Solr example macro library, but should give
> you some insight there).
>
>
> —
> Erik Hatcher, Senior Solutions Architect
> http://www.lucidworks.com 
>
>
>
>
> > On Feb 19, 2015, at 10:22 AM, phi...@free.fr wrote:
> >
> >
> > Is there a way to create dynamic methods/functions in Velocity Templates?
> >
> > -
> > To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> > For additional commands, e-mail: user-h...@velocity.apache.org
> >
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
>
>


Java classes in SOLR 4.9's Velocity

2015-02-19 Thread phiroc
Hi,

is there a way to use Java classes in SOLR 4.9's Velocity Engine?

If so, how?

Thanks.

Philippe

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



Re: Java classes in SOLR 4.9's Velocity

2015-02-19 Thread Erik Hatcher
What are you trying to do?  May be best to inquire on the Solr list for this 
aspect.  

You can use standard Velocity templating on the objects and tools exposed, and 
that’s about it.  What exactly are your needs?

The Solr stuff is documented here, with it being updated for the Solr 5 version 
(releasing today!), so slightly different from previous versions but not by 
much: 
https://cwiki.apache.org/confluence/display/solr/Response+Writers#ResponseWriters-VelocityResponseWriter
 


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




> On Feb 19, 2015, at 11:19 AM, phi...@free.fr wrote:
> 
> Hi,
> 
> is there a way to use Java classes in SOLR 4.9's Velocity Engine?
> 
> If so, how?
> 
> Thanks.
> 
> Philippe
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 



Re: Java classes in SOLR 4.9's Velocity

2015-02-19 Thread phiroc

I was thinking of doing the string-manipulation stuff I currently carry out in 
my templates [and which pollutes them], in a Java object, especially when the 
appropriate tools is missing (e.g., $display).

- Mail original -
De: "Erik Hatcher" 
À: "Velocity Users List" 
Envoyé: Jeudi 19 Février 2015 17:24:10
Objet: Re: Java classes in SOLR 4.9's Velocity

What are you trying to do?  May be best to inquire on the Solr list for this 
aspect.  

You can use standard Velocity templating on the objects and tools exposed, and 
that’s about it.  What exactly are your needs?

The Solr stuff is documented here, with it being updated for the Solr 5 version 
(releasing today!), so slightly different from previous versions but not by 
much: 
https://cwiki.apache.org/confluence/display/solr/Response+Writers#ResponseWriters-VelocityResponseWriter
 


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




> On Feb 19, 2015, at 11:19 AM, phi...@free.fr wrote:
> 
> Hi,
> 
> is there a way to use Java classes in SOLR 4.9's Velocity Engine?
> 
> If so, how?
> 
> Thanks.
> 
> Philippe
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
> For additional commands, e-mail: user-h...@velocity.apache.org
> 


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



Re: $link

2015-02-19 Thread Philippe de Rochambeau

You don’t see any $esc.url() because unescaped URLs, such as the one below 
(notice the lack of %20 between ‘the’  and ‘man’) work fine, as far as I am 
concerned.

I do have ‘year’, ‘month’ and ‘day’ fields, but I find it simpler to split the 
URL rather than padding the day and the month with a zero whenever they are 
less than 10.

I could perhaps use $display.printf to pad the day and month, but 
unfortunately, the Display Tool is not available in SOLR 4.9, as far as I know.

Cheers,

Philippe


>> http://abc.com:8983/inytapdf0/pdfjs/web/viewer.html?file=../../189009/01/002_E_PDF.pdf#tv=the
>>  man



Le 19 févr. 2015 à 16:42, Erik Hatcher  a écrit :

> I don’t see any $esc() usage below, so looks like I’m missing the full 
> picture.
> 
> However, seeing how you’re splitting off pieces of the “url” field in the 
> results display, maybe it’d make sense to script that piecing out of the url 
> at index time instead into separate fields (month, day, year) or in some way 
> massage the incoming data to be what you need in the results?
> 
>   Erik
> 
> 
> 
> 
>> On Feb 19, 2015, at 10:25 AM, phi...@free.fr wrote:
>> 
>> Here's the code:
>> 
>> -
>> 
>> 
>> 
>> 
>> 
>> ## e.g., apdf0 in /apdf0/189311/28/003_E_PDF.pdf
>> #set($pdf_dir_v = $list.get($doc.getFirstValue('url').split("/"),1))
>> 
>> ## e.g., 189311
>> #set($pdf_year_mon_v = $list.get($doc.getFirstValue('url').split("/"),2))
>> 
>> ## e.g., 28
>> #set($pdf_day_v = $list.get($doc.getFirstValue('url').split("/"),3))
>> 
>> ## e.g., 003_E_PDF.pdf
>> #set($pdf_name_v= $list.get($doc.getFirstValue('url').split("/"),4))
>> 
>> ## Generated URL example: 
>> http://abc.com:8983/inytapdf0/pdfjs/web/viewer.html?file=../../189009/01/002_E_PDF.pdf#tv=the%20man
>> #if ($params.q and $pdf_dir_v and $pdf_year_mon_v and $pdf_day_v and 
>> $pdf_name_v)
>> 
>>  ##set ( $paramsQ = $params.q )
>>  ## Remove double quotes
>>  #set ( $temp0 = $params.q.replaceAll("\"", "") )
>>  ##temp0 : $temp0
>>  
>>  #set ($andIndex = $temp0.indexOf("AND"))
>>  #if ($andIndex >= 0) 
>>  ## eg. "time" in example above
>>  #set ($temp2 = $temp0.substring(0, $andIndex))
>>  #else
>>  #set ($temp2 = $temp0)
>>  #end
>>  ##1) temp2 = $temp2
>>  
>>  #set ($orIndex = $temp0.indexOf("OR"))
>>  #if ($orIndex >= 0) 
>>  ## eg. "time" in example above
>>  #set ($temp2 = $temp0.substring(0, $orIndex))
>>  #else
>>  #set ($temp2 = $temp0)
>>  #end
>>  ##2) temp2 = $temp2
>>  
>>  #if ($temp2 and $temp2.length() > 0) 
>>  ##3) temp2 = '$temp2'
>>  #set( $viewer_js_url = 
>> "/${pdf_dir_v}/pdfjs/web/viewer.html?file=../../${pdf_year_mon_v}/${pdf_day_v}/${pdf_name_v}#tv=${temp2}"
>>  )
>>  #else
>>  ## If the user didn't select a search criteria (q), let him 
>> view PDF anyway
>>  #set( $viewer_js_url = 
>> "/${pdf_dir_v}/pdfjs/web/viewer.html?file=../../${pdf_year_mon_v}/${pdf_day_v}/${pdf_name_v}"
>>  )
>>  #end
>> 
>> #end
>> 
>> ---
>> 
>> - Mail original -
>> De: "Erik Hatcher" mailto:erik.hatc...@gmail.com>>
>> À: "Velocity Users List" 
>> mailto:user@velocity.apache.org>>
>> Envoyé: Jeudi 19 Février 2015 16:19:25
>> Objet: Re: $link
>> 
>> If you could show me what you’ve done, I’d be happy to adjust VrW to better 
>> suit your needs if that makes sense.
>> 
>> Feedback welcome!
>> 
>> 
>> —
>> Erik Hatcher, Senior Solutions Architect
>> http://www.lucidworks.com  
>> >
>> 
>> 
>> 
>> 
>>> On Feb 19, 2015, at 10:16 AM, phi...@free.fr wrote:
>>> 
>>> 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" 
>>> À: "Velocity Users List" 
>>> 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 
>>> VelocityR