Re: File exists
Unfortunately, I am using SOLR's implementation of Velocity, and don't know how to create FileHelpers in that context. - Mail original - De: Will Glass-Husain wglasshus...@gmail.com À: Velocity Users List user@velocity.apache.org Envoyé: Jeudi 9 Avril 2015 15:06:47 Objet: Re: File exists You can't instantiate objects in Velocity for an arbitrary class. remember, Velocity is intended to be a templating, not a scripting language. Create a new class FileHelper which has a method fileExists(string). Pass it into the context in your java code as a reference fileHelper. Then in your template call do $fileHelper.fileExists(/mnt/etc/etc/etc/) WILL On Thu, Apr 9, 2015 at 5:58 AM, phi...@free.fr wrote: Hello, does anyone know how to check if a file exists in Velocity? I have tried: #set ($exists = new File().exists(/mnt/xxxparnex01_pdf/PDF/IHT/${pdf_year_mon_v}/${pdf_day_v}/${pdf_name_page_number}_${pdf_name_page_type}_VIG.jpg) ) to no avail. Cheers, 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
Fwd: Trouble with Velocity in SOLR 5.0.0
Good morning, I have found the cause of the error (see below) in this line: #set ($temp0 = $paramsq.replaceAll(\, )) I replaced \ by \u0022, and the error message vanished. #set ($temp0 = $test.replaceAll(\u0022, )) Philippe ERROR 500 Encountered AND at richtext_doc.vm[line 65, column 51] Was expecting one of: , ... ) ... ... - #if ($params.q and $pdf_dir_v and $pdf_year_mon_v and $pdf_day_v and $pdf_name_v) #set ($paramsq = $params.q) #if ($paramsq.length() 0) paramsq = $paramsq ## Remove double quotes #set ($temp0 = $paramsq.replaceAll(\, )) - - Mail transféré - De: phi...@free.fr À: Velocity Users List user@velocity.apache.org Envoyé: Mardi 10 Mars 2015 16:29:48 Objet: Re: Trouble with Velocity in SOLR 5.0.0 Problem solved. A query Response Writer was not declared in my solrconfig.xml file. queryResponseWriter name=velocity class=solr.VelocityResponseWriter startup=lazy str name=template.base.dir${velocity.template.base.dir:}/str /queryResponseWriter - Mail original - De: phi...@free.fr À: Velocity Users List user@velocity.apache.org Envoyé: Mardi 10 Mars 2015 14:16:41 Objet: Trouble with Velocity in SOLR 5.0.0 Hello, I am trying to make Velocity work in SOLR 5.0.0. First of all, I have added the following lines to my core's solrconfig.xml file: luceneMatchVersion5.0.0/luceneMatchVersion lib dir=../../../contrib/extraction/lib regex=.*\.jar / lib dir=../../../dist/ regex=solr-cell-\d.*\.jar / lib dir=../../../contrib/langid/lib/ regex=.*\.jar / lib dir=../../../dist/ regex=solr-langid-\d.*\.jar / lib dir=../../../contrib/velocity/lib regex=.*\.jar / lib dir=../../../dist/ regex=solr-velocity-\d.*\.jar / ... ... and created a /browse request handler requestHandler name=/browse class=solr.SearchHandler lst name=defaults str name=echoParamsexplicit/str !-- VelocityResponseWriter settings -- str name=wtvelocity/str str name=v.templatebrowse/str str name=v.layoutlayout/str str name=titleArchives/str !-- Query settings -- str name=defTypeedismax/str I have also copied the 'velocity' directory from a 4.9 core to the /archives/solr-5.0.0/server/solr/mycore1/conf directory as well as the toolbox.xml file. The mycore1's conf directory now contains the following files and directories: currency.xml lang protwords.txt _rest_managed.json schema.xml solrconfig.xml stopwords.txt synonyms.txt toolbox.xml velocity When I type http://myserver.com:8990/solr/mycore1/select?q=*:* in a browser, I get an XML page, not HTML generated by Velocity, as expected. response lst name=responseHeader int name=status0/int int name=QTime5/int lst name=params/ /lst result name=response numFound=0 start=0 maxScore=0.0/ lst name=facet_counts lst name=facet_queries/ lst name=facet_fields lst name=ymd/ /lst lst name=facet_dates/ lst name=facet_ranges/ lst name=facet_intervals/ /lst lst name=highlighting/ /response What did I miss? Cheers, Philippe - To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org For additional commands, e-mail: user-h...@velocity.apache.org
Re: Trouble with Velocity in SOLR 5.0.0
Problem solved. A query Response Writer was not declared in my solrconfig.xml file. queryResponseWriter name=velocity class=solr.VelocityResponseWriter startup=lazy str name=template.base.dir${velocity.template.base.dir:}/str /queryResponseWriter - Mail original - De: phi...@free.fr À: Velocity Users List user@velocity.apache.org Envoyé: Mardi 10 Mars 2015 14:16:41 Objet: Trouble with Velocity in SOLR 5.0.0 Hello, I am trying to make Velocity work in SOLR 5.0.0. First of all, I have added the following lines to my core's solrconfig.xml file: luceneMatchVersion5.0.0/luceneMatchVersion lib dir=../../../contrib/extraction/lib regex=.*\.jar / lib dir=../../../dist/ regex=solr-cell-\d.*\.jar / lib dir=../../../contrib/langid/lib/ regex=.*\.jar / lib dir=../../../dist/ regex=solr-langid-\d.*\.jar / lib dir=../../../contrib/velocity/lib regex=.*\.jar / lib dir=../../../dist/ regex=solr-velocity-\d.*\.jar / ... ... and created a /browse request handler requestHandler name=/browse class=solr.SearchHandler lst name=defaults str name=echoParamsexplicit/str !-- VelocityResponseWriter settings -- str name=wtvelocity/str str name=v.templatebrowse/str str name=v.layoutlayout/str str name=titleArchives/str !-- Query settings -- str name=defTypeedismax/str I have also copied the 'velocity' directory from a 4.9 core to the /archives/solr-5.0.0/server/solr/mycore1/conf directory as well as the toolbox.xml file. The mycore1's conf directory now contains the following files and directories: currency.xml lang protwords.txt _rest_managed.json schema.xml solrconfig.xml stopwords.txt synonyms.txt toolbox.xml velocity When I type http://myserver.com:8990/solr/mycore1/select?q=*:* in a browser, I get an XML page, not HTML generated by Velocity, as expected. response lst name=responseHeader int name=status0/int int name=QTime5/int lst name=params/ /lst result name=response numFound=0 start=0 maxScore=0.0/ lst name=facet_counts lst name=facet_queries/ lst name=facet_fields lst name=ymd/ /lst lst name=facet_dates/ lst name=facet_ranges/ lst name=facet_intervals/ /lst lst name=highlighting/ /response What did I miss? Cheers, Philippe - To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org For additional commands, e-mail: user-h...@velocity.apache.org
$link
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
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 keymath/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
Functions
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
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
Re: Functions
Ah, I never thought of using macros as methods/functions. Thanks. - Mail original - De: Erik Hatcher erik.hatc...@gmail.com À: Velocity Users List user@velocity.apache.org 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 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
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: $link
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 keymath/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
Re: Standalone pages
Hi, in my test.vm template, I would like to dynamically display all images in the server's directory. Can this be done in Velocity, or are system calls nonos? Many thanks. Philippe - Mail original - De: Erik Hatcher erik.hatc...@gmail.com À: Velocity Users List user@velocity.apache.org Envoyé: Jeudi 9 Octobre 2014 19:15:33 Objet: Re: Standalone pages Interestingly, if you don’t even need to add a template to the server (filesystem) at all with Solr’s VelocityResponseWriter: http://localhost:8983/solr/select?wt=velocityv.template=tv.template.t=template%20from%20thin%20air ;) But even with /browse, you can override bits and pieces (thanks to Velocity’s resource loader trickery) of a template (from thin air): http://localhost:8983/solr/browse?v.template.header=Solritas! And maybe more to your liking, you could leverage /browse as-is, and switch the template, even dynamically (this time you’d save it to the file system or pass the whole template in as a HTTP parameter like above): http://localhost:8983/solr/browse?v.template=test - which will use your test.vm file. Your template gets all the data that is presented in /browse should you choose to render it. While I love hammers, if all you wanted was Velocity “server pages”, Solr’s VelocityResponseWriter admittedly is overkill. *I’d* still do it that way :), but that’s just me (Mr. VrW). However, I’m all for your data being in Solr, and having it be immediately navigable with straightforward Velocity templating is a real treat! Erik On Oct 9, 2014, at 9:13 AM, phi...@free.fr wrote: Hi Erik, thank you for your reply. However, come to think of it, my question is not SOLR-specific. I would like to know if it is possible to create lightweight Web pages with Velocity, in Tomcat, without resorting to servlets, JSP, etc. In other words, can you add a Velocity template to a Tomcat server as easily as you can drop a .php file in an Apache server's DocumentRoot directory. Many thanks. Philippe - Mail original - De: Erik Hatcher erik.hatc...@gmail.com À: Velocity Users List user@velocity.apache.org Envoyé: Jeudi 9 Octobre 2014 14:59:02 Objet: Re: Standalone pages Philiippe - I just noticed you posted this to the velocity user list. How Solr uses Velocity is perhaps a bit niche/different, so best to ask over on the Solr user list for future questions about the Solr/Velocity integration. But I’m on both lists :) Erik On Oct 9, 2014, at 4:19 AM, phi...@free.fr wrote: Hello, I am using currently the Velocity templates that come with the example provided with SOLR, in Tomcat 7. I would like to add a Velocity template called test.vm, in the example/solr/mycollection directory, to display an HTML page containing an image. Unfortunately, the following URL http://myserver:8983/solr/mycollection/test returns a 404 error. http://myserver:8983/solr/mycollection/browse works, though. How does one create standalone Velocity pages, such as test.vm? 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
Standalone pages
Hello, I am using currently the Velocity templates that come with the example provided with SOLR, in Tomcat 7. I would like to add a Velocity template called test.vm, in the example/solr/mycollection directory, to display an HTML page containing an image. Unfortunately, the following URL http://myserver:8983/solr/mycollection/test returns a 404 error. http://myserver:8983/solr/mycollection/browse works, though. How does one create standalone Velocity pages, such as test.vm? Many thanks. Philippe - To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org For additional commands, e-mail: user-h...@velocity.apache.org
Re: Standalone pages
Hi Erik, thank you for your reply. However, come to think of it, my question is not SOLR-specific. I would like to know if it is possible to create lightweight Web pages with Velocity, in Tomcat, without resorting to servlets, JSP, etc. In other words, can you add a Velocity template to a Tomcat server as easily as you can drop a .php file in an Apache server's DocumentRoot directory. Many thanks. Philippe - Mail original - De: Erik Hatcher erik.hatc...@gmail.com À: Velocity Users List user@velocity.apache.org Envoyé: Jeudi 9 Octobre 2014 14:59:02 Objet: Re: Standalone pages Philiippe - I just noticed you posted this to the velocity user list. How Solr uses Velocity is perhaps a bit niche/different, so best to ask over on the Solr user list for future questions about the Solr/Velocity integration. But I’m on both lists :) Erik On Oct 9, 2014, at 4:19 AM, phi...@free.fr wrote: Hello, I am using currently the Velocity templates that come with the example provided with SOLR, in Tomcat 7. I would like to add a Velocity template called test.vm, in the example/solr/mycollection directory, to display an HTML page containing an image. Unfortunately, the following URL http://myserver:8983/solr/mycollection/test returns a 404 error. http://myserver:8983/solr/mycollection/browse works, though. How does one create standalone Velocity pages, such as test.vm? 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