Complete default individual list view in FreeMarker

This commit is contained in:
rjy7 2010-06-02 17:06:55 +00:00
parent b3ddf9e822
commit 037ff45736
9 changed files with 78 additions and 36 deletions

View file

@ -16,6 +16,7 @@
<ul>
<#list individuals as individual>
<li>
<#-- Currently we just use the search view here; there's no custom list view defined. -->
<#include "partials/class/view/search/${individual.searchView}">
</li>
</#list>

View file

@ -1,3 +1,15 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<a href="${individual.profileUrl}">${individual.name}</a> ${individual.tagline}
<#-- Default individual search view -->
<#import "/macros/list.ftl" as l>
<a href="${individual.profileUrl}">${individual.name}</a>
<ul class="individualData">
<@l.firstLastList>
<li>${individual.tagline}</li>,
<#list individual.links as link>
<li><a class="externalLink" href="${link.url}">${link.anchor}</a></li>,
</#list>
</@l.firstLastList>
</ul>

View file

@ -1,6 +1,8 @@
<#--
Macro: firstLastList
Output a sequence of <li> elements, adding classes "first" and "last" to first and last list elements, respectively.
It is helpful when the list elements are generated conditionally, to avoid complex tests for the presence/absence
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 separated by some delimiter. Default delimiter value is ",".
@ -8,27 +10,27 @@
Tolerates a delimiter following the last <li> element.
Usage:
<@makeList>
<@firstLastList>
<li>apples</li>,
<li>bananas</li>,
<li>oranges</li>
<@makeList>
<@firstLastList>
<@makeList delim="??">
<@firstLastList delim="??">
<li>apples, oranges</li>??
<li>bananas, lemons</li>??
<li>grapefruit, limes</li>
<@makeList>
<@firstLastList>
RY Consider rewriting in Java. Probably designers won't want to modify this.
-->
<#macro makeList delim=",">
<#macro firstLastList delim=",">
<#assign text>
<#nested>
</#assign>
<#-- Strip out a list-final delimiter, else (unlike most languages) it results in an empty final array item. -->
<#assign text = text?replace("${delim}$", "", "r")>
<#assign text = text?replace("${delim}\\s*$", "", "r")>
<#assign items = text?split(delim)>
@ -45,13 +47,9 @@
<#assign newItem = newItem?replace(m?groups[1], "")>
</#list>
<#-- Test indices, rather than comparing content, on the remote chance
that there are two list items with the same content. -->
<#-- <#if item == arr?first> -->
<#if item_index == 0>
<#assign classVal = "${classVal} first">
</#if>
<#-- <#if item == arr?last> -->
<#if !item_has_next>
<#assign classVal = "${classVal} last">
</#if>
@ -65,4 +63,6 @@
</#list>
</#macro>
<#----------------------------------------------------------------------------->
<#----------------------------------------------------------------------------->

View file

@ -10,12 +10,12 @@
<div class="footerLinks">
<ul class="otherNav">
<@l.makeList>
<@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>
</@l.makeList>
</@l.firstLastList>
</ul>
</div>

View file

@ -11,7 +11,7 @@
</#if>
<ul id="otherMenu">
<@l.makeList>
<@l.firstLastList>
<#if loginName??>
<li>
Logged in as <strong>${loginName}</strong> (<a href="${urls.logout}">Log out</a>)
@ -25,6 +25,6 @@
<#if urls.contact??>
<li><a href="${urls.contact}">Contact Us</a></li>
</#if>
</@l.makeList>
</@l.firstLastList>
</ul>
</div>

View file

@ -16,13 +16,16 @@
request.parameters:
None yet.
********************************************* */
if (request.getAttribute("beans") == null) {
String e = "searchBaisc.jsp expects that request attribute " +
"'beans' be set to a List of Individuals to display.";
throw new JspException(e);
}
Portal portal = (Portal) request.getAttribute("portalBean");
String portalParm = "&amp;home=" + portal.getPortalId();
String portalParm = "&amp;home=" + portal.getPortalId();
%>
<div id='content'><!-- searchPaged.jsp -->