Added Support link to header and footer link lists. Modified firstLastList macro so it doesn't require delimiters separating the list items.
This commit is contained in:
parent
1aa4bb00d6
commit
4e168078c6
5 changed files with 89 additions and 22 deletions
|
@ -64,7 +64,6 @@ public class FreeMarkerSetup implements ServletContextListener {
|
|||
try {
|
||||
cfg.setSetting("url_escaping_charset", "ISO-8859-1");
|
||||
} catch (TemplateException e) {
|
||||
// TODO Auto-generated catch block
|
||||
log.error("Error setting value for url_escaping_charset.");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,39 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#--
|
||||
Macro: firstLastList
|
||||
|
||||
Output a sequence of <li> elements, adding classes "first" and "last" to first and last list elements, respectively.
|
||||
Especially useful when the list elements are generated conditionally, to avoid complex tests for the presence/absence
|
||||
of other list elements in order to assign these classes.
|
||||
|
||||
Input should be a series of <li> elements. It is currently not supported for these <li> elements to contain nested
|
||||
<li> elements. An <li> element may span multiple lines.
|
||||
|
||||
Usage:
|
||||
<@firstLastList>
|
||||
<li>apples</li>
|
||||
<li>bananas</li>
|
||||
<li>oranges</li>
|
||||
<@firstLastList>
|
||||
|
||||
RY Consider rewriting in Java. Probably designers won't want to modify this. That would allow us to support
|
||||
nested <li> elements.
|
||||
|
||||
-->
|
||||
<#macro firstLastList>
|
||||
<#assign text>
|
||||
<#nested>
|
||||
</#assign>
|
||||
|
||||
<@processListItems text?matches("<li>.*?</li>", "s") />
|
||||
|
||||
</#macro>
|
||||
|
||||
<#---------------------------------------------------------------------------->
|
||||
|
||||
<#--
|
||||
Macro: firstLastListNested
|
||||
|
||||
Output a sequence of <li> elements, adding classes "first" and "last" to first and last list elements, respectively.
|
||||
Especially useful when the list elements are generated conditionally, to avoid complex tests for the presence/absence
|
||||
|
@ -9,31 +43,64 @@
|
|||
|
||||
Tolerates a delimiter following the last <li> element.
|
||||
|
||||
Unlike firstLastList, this macro can process <li> elements that contain other <li> elements, because the delimiters
|
||||
indicate how to split the text.
|
||||
|
||||
Usage:
|
||||
<@firstLastList>
|
||||
<@firstLastListNested>
|
||||
<li>apples</li>,
|
||||
<li>bananas</li>,
|
||||
<li>oranges</li>
|
||||
<@firstLastList>
|
||||
<@firstLastListNested>
|
||||
|
||||
<@firstLastList delim="??">
|
||||
<@firstLastListNested delim="??">
|
||||
<li>apples, oranges</li>??
|
||||
<li>bananas, lemons</li>??
|
||||
<li>grapefruit, limes</li>
|
||||
<@firstLastList>
|
||||
<@firstLastListNested>
|
||||
|
||||
<@firstLastListNested delim="??">
|
||||
<li>Books
|
||||
<ul>
|
||||
<li>Persuasion</li>
|
||||
<li>Sense and Sensibility</li>
|
||||
</ul>
|
||||
</li>,
|
||||
<li>Magazines
|
||||
<ul>
|
||||
<li>The New Yorker</li>
|
||||
<li>Time</li>
|
||||
</ul>
|
||||
</li>
|
||||
<@firstLastListNested>
|
||||
|
||||
RY Consider rewriting in Java. Probably designers won't want to modify this.
|
||||
-->
|
||||
<#macro firstLastList delim=",">
|
||||
<#macro firstLastListNested delim=",">
|
||||
<#assign text>
|
||||
<#nested>
|
||||
</#assign>
|
||||
|
||||
<#-- Strip out a list-final delimiter, else (unlike most languages) it results in an empty final array item. -->
|
||||
<#-- Strip out a list-final delimiter, else (unlike most languages) it
|
||||
results in an empty final array item. -->
|
||||
<#assign text = text?replace("${delim}\\s*$", "", "r")>
|
||||
|
||||
<#assign items = text?split(delim)>
|
||||
|
||||
<@processListItems text?split(delim) />
|
||||
|
||||
</#macro>
|
||||
|
||||
<#---------------------------------------------------------------------------->
|
||||
|
||||
<#--
|
||||
Macro: processListItems
|
||||
|
||||
Given a list of <li> elements, adds class "first" to the first item and
|
||||
"last" to the last item. The <li> elements must have already been put into
|
||||
a list; this macro does not handle the raw text. Can be called from
|
||||
firstLastList
|
||||
|
||||
-->
|
||||
<#macro processListItems items>
|
||||
<#list items as item>
|
||||
<#-- A FreeMarker loop variable cannot have its value modified, so we use a new variable. -->
|
||||
<#assign newItem = item?trim>
|
||||
|
@ -63,6 +130,4 @@
|
|||
</#list>
|
||||
</#macro>
|
||||
|
||||
<#----------------------------------------------------------------------------->
|
||||
|
||||
|
||||
|
|
|
@ -11,10 +11,7 @@
|
|||
<div class="footerLinks">
|
||||
<ul class="otherNav">
|
||||
<@l.firstLastList>
|
||||
<li><a href="${urls.about}" title="more about this web site">About</a></li>,
|
||||
<#if urls.contact??>
|
||||
<li><a href="${urls.contact}" title="feedback form">Contact Us</a></li>
|
||||
</#if>
|
||||
<#include "subMenuLinks.ftl">
|
||||
</@l.firstLastList>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -15,16 +15,13 @@
|
|||
<#if loginName??>
|
||||
<li>
|
||||
Logged in as <strong>${loginName}</strong> (<a href="${urls.logout}">Log out</a>)
|
||||
</li>,
|
||||
<li><a href="${urls.siteAdmin}">Site Admin</a></li>,
|
||||
</li>
|
||||
<li><a href="${urls.siteAdmin}">Site Admin</a></li>
|
||||
<#else>
|
||||
<li><a title="log in to manage this site" href="${urls.login}">Log in</a></li>,
|
||||
<li><a title="log in to manage this site" href="${urls.login}">Log in</a></li>
|
||||
</#if>
|
||||
|
||||
<li><a href="${urls.about}">About</a></li>,
|
||||
<#if urls.contact??>
|
||||
<li><a href="${urls.contact}">Contact Us</a></li>
|
||||
</#if>
|
||||
<#include "subMenuLinks.ftl">
|
||||
</@l.firstLastList>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,9 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- List of links that appear in submenus, like the header and footer. -->
|
||||
|
||||
<li><a href="${urls.about}">About</a></li>
|
||||
<#if urls.contact??>
|
||||
<li><a href="${urls.contact}">Contact Us</a></li>
|
||||
</#if>
|
||||
<li><a href="http://www.vivoweb.org/support">Support</a></li>
|
Loading…
Add table
Add a link
Reference in a new issue