Design questions for a Silva Glossary

Samuel Schluep <[email protected]>
Newsgroups gmane.comp.web.zope.silva.devel
Message-ID <[email protected]>
Dear Developers

Planning for an Silva extension which implements glossary functionality 
I am struggling with some design questions. Therefore I would like to 
ask the Silva developer community for the best way to go which is in 
accordance with the Silva spirit of data handling and will work well 
with future versions of Silva -- thus I am looking for "the Silvanic" 
approach ;-)


THE IDEA

The software should be a Silva extension. A glossary basically needs two 
things:

1. The glossary entry containing a glossary term, the keyword(s) to be 
described, and the glossary definition, the description of the keyword.
2. A glossary link which marks up some text in a document and points to 
the glossary entry. Such a link might invoke a tooltip or a pop-up 
window or it may be a hyperlink to a glossary page.

The glossary entry is planned to be an asset content type with a title 
(glossary term) and a glossary definition. That should not be too 
difficult. The glossary link should be inserted into the text of a Silva 
Document. Here I have most open questions. Further, I would like to 
enable the layout designers to adapt the behavior and rendering of the 
glossary link to their preferences.


APPROACH TO THE GLOSSARY LINK AND ITS PROBLEMS

In order to extend the Silva Document functionality for a glossary link 
some extension code is needed. Unfortunately Silva does not allow for 
inline code sources, which would provide a clean approach for extending 
the Silva Document functionality. Thus, as a workaround, the Silva 
Document link tag might be used together with a special value for the 
target attribute (e.g. "silva_glossary"). Then, of course, the rendering 
of the link element needs to be adapted. Simply redirecting a rendering 
widget, as is done in SilvaExtETHLayout, does not work because the link 
is rendered by the help of Silva Document's mixedcontentsupport. Is 
there an easy way to customize the HTML rendering of links in 
mixedcontentsupport through an extension product?


The glossary link should be rendered as a tooltip (default rendering). 
Therefore the final page needs additional HTML and JavaScript. The HTML 
title attribute cannot be used because it is handled inconsistently by 
different browsers and no formatting can be applied to the attribute 
value (line breaks, emphasis, etc.) Currently, I am thinking of  
implementing the tooltip with some mouseover-JavaScript functionality 
which changes the css display style of a div containing the glossary 
entry (see http://www.webmatze.de/webdesign/javascript/tooltips.htm - 
unfortunately in German). I.e. the mouseover code changes the div's 
display style from 'none' to 'block' and back again. This solution is 
very small, easy to understand, and no additional data needs to be 
downloaded. However, several questions arise:

1. How to integrate the divs containing the glossary entries? The 
glossary entries are block elements and thus cannot be rendered by the 
glossary link rendering widget, which produces inline HTML. The glossary 
entry divs need to be appended at the end of the document, but how?

- Possibility 1.a) The layout_macro.html designer includes these 
glossary entry divs using a special function. The function gets the 
glossary entries needed from a REQUEST variable. This variable is a list 
to which the glossary link renderer has added all references to glossary 
entries found.
   Pros: The layout designer can influence the rendering style of the 
glossary entries
   Cons: This code will not be installed automatically together with the 
Silva Glossary Extension -- it needs to be copied manually into the 
layout_macro.

- Possibility 1.b) The glossary link renderer includes JavaScript code 
with adds the glossary divs in front of the HTML BODY end tag dynamically.
   Pros: No code needs to be added to the layout_macro.
   Cons: Overly complex HTML/JavaScript code -- well I just don't like 
this idea so much, therefore I did not analyze this solution any further.

- Possibility 1.c) The divs could be handled by the doc rendering widget 
(again the special REQUEST variable specifies which glossary entries 
must be included after the main content).
   Pros: This code will be installed automatically together with the 
Silva Glossary Extension.
   Cons: The layout designer can not influence the rendering style of 
the glossary entries. Needs customization of the Silva core doc 
rendering widget (possibly using widget redirection).


2. Where to put the JavaScript code (or the reference to an external 
file containing the code)? I think that it is not a good idea to place 
the JavaScript next to the inline glossary link code.

- Possibility 2.a) The JavaScript code could be included conditionally 
just in front of the glossary entry div tags in the layout_macro using 
some specific function call .
   Pros: The code will be included only if glossary items are found. The 
layout designer can control and customize the JavaScript code.
   Cons: The code will not be installed automatically together with the 
Silva Glossary Extension. The JavaScript is in the body section of the 
HTML page instead of the head.

- Possibility 2.b) The JavaScript code is added to the script section in 
the layout_macro.
   Pros: The code is in specified the HTML head section (the most 
obvious place for the declaration of JavaScript). The layout designer 
can control and customize the JavaScript code.
   Cons: The code is referenced even if there are no glossary items in 
the page. The code will not be installed automatically together with the 
Silva Glossary Extension Product.

- Possibility 1.c) The JavaScript code is included by the doc rendering 
widget.
   Pros:  The code is installed automatically together with the Silva 
Glossary Extension. The code will only be included if glossary items are 
found.
   Cons: The layout designer cannot control and customize the JavaScript 
code. The JavaScript is in the body section of the HTML page instead of 
the head. Needs customization of the Silva core doc rendering widget 
(through widget redirection).


So, there is no one solution which meets all requirements. Is there a 
Silvanic best practice to solve such a problem, has anybody faced a 
similar problem?

Best regards
Sam
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.