[Xapian-discuss] Omega Script
Olly Betts
olly at survex.com
Mon Mar 2 02:01:18 GMT 2009
On Sun, Mar 01, 2009 at 02:32:37AM +1030, Frank J Bruzzaniti wrote:
> Thomas Viehmann wrote:
> > Frank J Bruzzaniti wrote:
> >
> >> When I return the names of files from a search result I use $field{url}
> >> which returns \\server\docs\foo.doc
> >
> >> What should I do if I only want foo.doc to be displayed?
> >>
> > If you want to do it with the current set of commands, using $transform
> > might be a good approach. Of course, that might be more difficult if you
> > have to cater for lots of different path conventions.
$transform requires trunk currently though, but yes you could do this
with:
$transform{.*[/\\],,$field{url}}
> >> And how hard would it be to create new script index commands like
> >> $filename and $path. If extending omega script is easy/"a good idea"
> >> I'd be happy
> >> to write some documentation once I learn how.
You ask about new "script index commands" (scriptindex is used at
indexing time), but then talk about extending omega script, and use
examples starting with a "$" as OmegaScript does (OmegaScript is used at
search time).
So I'm not totally sure which you're suggesting...
> > Extending OmegaScript is not that hard (add a few lines to query.cc),
> > but I am not sure that with the current implementation it is a good idea
> > to try to add a whole bunch of "library functions" to it.
I don't have a problem adding new OmegaScript commands provided they're
useful (and actually provide functionality which isn't already sanely
possible) and we keep things consistent. I think in this case, it's
probably better just to point people at $transform.
Note that you can just wrap it up as a macro:
$def{LEAFNAME,$transform{.*[/\\],,$1}}
And then use $LEAFNAME{$field{url}}
I'm not against adding new scriptindex commands either, though it is
often cleanest to just adjust whatever is producing the input to
scriptindex.
> One question I had regarding the query template.
>
> I found a function in php that dose what I want called basename().
> I wanted to use basename() to extract the filename from $url
>
> I tried adding some php to query template and it doesn't work.
>
> E.g. <?php echo "Hi"; ?>
>
> Guessing you can't mix in php into template?
You'd have to set up your webserver so that it can parse the output of
the CGI script as PHP. How to do that is really a question for another
mailing list (I don't know how).
> Guess the other option would be for me to re-write the default omega
> page as php.
> Apart from having another dependency via php-bindings and php, is there
> any other disadvantages/pit falls I'd be looking at?
Well, it's probably a reasonable amount of work to reimplement the omega
CGI. Seems rather an extreme approach to solving the problem!
Cheers,
Olly
More information about the Xapian-discuss
mailing list