Skip to main content.
home | support | download

Back to List Archive

Re: URL display in property

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Thu May 06 2004 - 14:46:55 GMT
On Thu, May 06, 2004 at 06:03:56AM -0700, Victor Babitchev wrote:
> Hi,
> 
> I defined one property ("LinkToAleph") that should be displayed as link, =
> instead the URL is displayed as a plain text.
> 
> 1 Good test title  ... -- rank: 1000
> 
>     Year:       2002
>     swishdocsize:       31324
>     LinkToAleph:           <A =
> HREF=3D"http://magnum.bibvb.ac.at/ALEPH/-/ext-find?base=3DACC01&find=3DID=
> N=3DAC00000000" target=3D"_blank">AC00000000</A
> 
> 
> Can one give me a tip where should I look at? (I could not not find it =
> in the discussion list).

There's not way to do that swish the default swish.cgi program.

Is LinkToAleph just a URL or a bit of HTML that includes the <a> tag?

The basic problem is swish.cgi assumes all "display_props" are text
properties and will HTML-escape them.  That's done in swish.cgi itself.

    # HTML escape all properties that were not highlighted
    for my $prop (keys %$props) {
        next if  $highlighted->{$prop};

        # not highlighted, so escape
        html_escape( $props->{$prop} );

So, if the property is a full link then you would need to change swish.cgi.
so the HTML is not escaped for that property.

        html_escape( $props->{$prop} ) 
            unless $prop eq 'LinkToAleph';

(You would probably want to add a hash to the config file that has the
names of the properties to not escape and check the hash instead of
hard-coding the property names in swish.cgi.)

If LinkToAleph is just a URL then you would want to adjust the template
(or template module) code to modify the way the property is written.

The other example program, search.cgi, is better for customizing the
output.  In that case, search.cgi provides raw data to the template
module and then how things are displayed are defined in the template --
where they should be.

For example, in the template for search.cgi the title link is created
like:

    <a href="[% item.Property('swishdocpath') | uri | html %]">
        [%  item.Property('swishtitle') || item.Property('swishdocpath') | html %]</a>

So the href is filtered by the "uri" and "html" filters, and the link
text is filtered just by the "html" filter.


> In the previous ver. of swish-e (2002) the same construct worked.

With swish.cgi and the HTML markup stored in the property?  That would
have been a bug to allow non-escaped HTML into the output.

-- 
Bill Moseley
moseley@hank.org
Received on Thu May 6 07:46:56 2004