Re: [greenstone-devel] Reproducing drop down navigation menus in Greenstone

From Angela
DateThu, 14 Jul 2005 11:29:17 -0600
Subject Re: [greenstone-devel] Reproducing drop down navigation menus in Greenstone
In-Reply-To (42D5EC45-2060708-cs-waikato-ac-nz)
Hi Michael,

Thank you for all your help Michael. I tried the fix but it didn't work.
Greenstone doesn't replace the links. I searched through HTMLPlug and I
think this is what's happening (I could be wrong though). HTMLPlug seems to
only check for href and src tags following a, area, frame, link, or script.
I haven't found a place where it would replace any other links.
The code in HTMLPlug's sub process_section:

$$textref =~
s/(<(?:a|area|frame|link|script)s+[^>]*?s*(?:href|src)s*=s*"?)([^">s]
+)("?[^>]*>)/
$self->replace_href_links ($1, $2, $3, $base_dir, $file, $doc_obj,
$cursection)/isge;

The solution I came up with is to add a placeholder (_replacelink_) inside
<option value>:

<form action="" class="changeView" name="view" title="Use this to change the
way the information in this document is displayed."><select name="choices"
size="1"
onchange="location=document.view.choices.options[document.view.choices.selec
tedIndex].value"><option selected="selected"
value="_replacelink_index.htm">Reading text</option><option
value="_replacelink_significant.htm">Significant variants</option><option
value="_replacelink_substantive.htm">Substantive variants</option><option
value="_replacelink_orthographic.htm">Orthographic variants</option><option
value="_replacelink_analytic.htm">All readings (analytic)</option><option
value="_replacelink_parallel.htm">All readings
(parallel)</option></select></form>

I changed HTMLPlug to replace links that contain the _replacelink_
placeholder:

$$textref =~ s/(_replacelink_?)([^">s]+)("?[^>]*>)/
$self->replace_href_links ($1, $2, $3, $base_dir, $file, $doc_obj,
$cursection)/isge;

# remove _replacelink_ placeholder
$$textref =~ s/_replacelink_//ig;

This is probably not the best way of doing it, but it does seem to work.

Take care,
Angela

-----Original Message-----
From: greenstone-devel-bounces@list.scms.waikato.ac.nz
[mailto:greenstone-devel-bounces@list.scms.waikato.ac.nz]On Behalf Of
Michael Dewsnip
Sent: July 13, 2005 10:38 PM
To: daniel.odonnell@uleth.ca
Cc: greenstone-devel@list.scms.waikato.ac.nz
Subject: Re: [greenstone-devel] Reproducing drop down navigation menus in
Greenstone

Hi Daniel,

Greenstone has code for dealing with relative links in source documents,
so I think you can get the effect you're after by tapping into this.

In a simple case, imagine a Greenstone collection with two documents,
doc1.html and doc2.html, each with a relative link to the other, eg:

<a href="doc2.html>Link to doc2.html</a>

When you build this collection, Greenstone will replace the relative
links with calls to the Greenstone "extlink" action:

<a href="/gsdlmod?e=d-00000-00---off-0gsarch--00-0----0-10-0---0---0direct-10---4-----dfr--0-1l--11-en-50---20-preferences-bounama+kouider--00-0-1-00-0--4----0-0-11-10-0utfZz-8-00&a=extlink&rl=1&href=http://doc2.html">Link to doc2.html</a>

This means that when you're browsing the built collection and click on
the link, Greenstone will redirect you to the appropriate document.

In your case, you need to extend the option values to have the full
relative paths, since the value must uniquely identify a document:

<option value="http://foldername/substantive.htm">Substantive
variants</option>

When your users select one of these options, loading
"/gsdlmod?a=extlink&rl=1&href=[value]" should take you to the correct
document.

Hope this helps,

Michael

Daniel Paul O'Donnell wrote:

>Hi,
> I've gone through the archives and documentation, and while I can
find
>a number of almost similar examples to this problem, I can't find
>anything that does the crucial thing I need to answer the problem.
>Please excuse me if that's because the answer is so obvious nobody's
>ever asked. I have gone over it with a real expert, though.
> Basically, the issue is that in an HTML document set, I use drop
down
>menus with javascript to navigate between different "views" of a text.
>There can be as many as 12 different "views" so a list of links is
>inefficient; it also doesn't get the idea across that all 5 to 12
>documents are actually the same text with different features emphasised.
>Here is the code I use in my HTML:
>
><form action="" class="changeView">
> <select name="choices" size="1"
>onchange="location=document.view.choices.options[document.view.choices.sele
ctedIndex].value">
> <option value="index.htm">Reading text</option>
> <option selected="selected" value="significant.htm">Significant
>variants</option>
> <option value="substantive.htm">Substantive variants</option>
> <option value="orthographic.htm">Orthographic variants</option>
> <option value="analytic.htm">All readings (analytic)</option>
> <option value="parallel.htm">All readings (parallel)</option>
> </select>
></form>
>
>The trouble in Greenstone is that these URLs on option@value are not
>converted to hash addresses. It appears that what I need to do is write
>a macro for the Javascript, but I confess I'm not sure how to do it so
>the values are correctly converted to Greenstone hashes (if that's the
>right term). There are a fair number of examples of almost identical
>code in the archives, but none that seem to be used for arbitrary
>addresses like this. Any suggestions?
>
>-d
>
>


_______________________________________________
greenstone-devel mailing list
greenstone-devel@list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/greenstone-devel