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" <erik.hatc...@gmail.com>
À: "Velocity Users List" <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 <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" <erik.hatc...@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 <lstin...@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: 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" <mkien...@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,  <phi...@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-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
> 


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

Reply via email to