You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tv...@apache.org on 2007/04/29 18:38:54 UTC
svn commit: r533520 - in /jakarta/turbine/core/branches/TURBINE_2_3_BRANCH:
src/java/org/apache/turbine/util/template/HtmlPageAttributes.java
src/macros/TurbineMacros.vm xdocs/changes.xml
xdocs/howto/velocityonlylayout-howto.xml
Author: tv
Date: Sun Apr 29 09:38:52 2007
New Revision: 533520
URL: http://svn.apache.org/viewvc?view=rev&rev=533520
Log:
Extended HtmlPageAttributes to allow generic <link /> tags in the
HTML head section. Changed docs and macros to reflect this.
Modified:
jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/template/HtmlPageAttributes.java
jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/macros/TurbineMacros.vm
jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/changes.xml
jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/howto/velocityonlylayout-howto.xml
Modified: jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/template/HtmlPageAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/template/HtmlPageAttributes.java?view=diff&rev=533520&r1=533519&r2=533520
==============================================================================
--- jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/template/HtmlPageAttributes.java (original)
+++ jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/template/HtmlPageAttributes.java Sun Apr 29 09:38:52 2007
@@ -66,12 +66,12 @@
* #foreach($httpEquiv in $page.HttpEquivs.keySet())<br>
* <meta http-equiv="$httpEquiv" content="$page.HttpEquivs.get($httpEquiv)"><br>
* #end<br>
- * #foreach( $styleSheet in $page.StyleSheets )<br>
- * <link rel="stylesheet" href="$styleSheet.Url"<br>
- * #if($styleSheet.Type != "" ) type="$styleSheet.Type" #end<br>
- * #if($styleSheet.Media != "") media="$styleSheet.Media" #end<br>
- * #if($styleSheet.Title != "") title="$styleSheet.Title" #end<br>
- * ><br>
+ * #foreach( $linkTag in $page.Links )<br>
+ * <link rel="$linkTag.Relation" href="$linkTag.Url"<br>
+ * #if($linkTag.Type != "" ) type="$linkTag.Type" #end<br>
+ * #if($linkTag.Media != "") media="$linkTag.Media" #end<br>
+ * #if($linkTag.Title != "") title="$linkTag.Title" #end<br>
+ * /><br>
* #end<br>
* #foreach( $script in $page.Scripts )<br>
* <script type="text/javascript" src="$script" language="JavaScript"></script><br>
@@ -93,6 +93,7 @@
*
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
public class HtmlPageAttributes
@@ -110,8 +111,8 @@
/** Script references */
private List scripts = new ArrayList();
- /** Stylesheet references */
- private List styleSheets = new ArrayList();
+ /** External references */
+ private List linkTags = new ArrayList();
/** Inline styles */
private List styles = new ArrayList();
@@ -153,7 +154,7 @@
this.title = null;
this.bodyAttributes.clear();
this.scripts.clear();
- this.styleSheets.clear();
+ this.linkTags.clear();
this.styles.clear();
this.metaTags.clear();
this.httpEquivs.clear();
@@ -297,11 +298,11 @@
public HtmlPageAttributes addStyleSheet(String styleSheetURL,
String media, String title, String type)
{
- StyleSheet ss = new StyleSheet(styleSheetURL);
+ LinkTag ss = new LinkTag("stylesheet", styleSheetURL);
ss.setMedia(media);
ss.setTitle(title);
ss.setType(type);
- this.styleSheets.add(ss);
+ this.linkTags.add(ss);
return this;
}
@@ -335,13 +336,68 @@
}
/**
+ * Adds a generic external reference
+ *
+ * @param relation type of the reference (prev, next, first, last, top, etc.)
+ * @param linkURL URL of the reference
+ * @return a <code>HtmlPageAttributes</code> (self).
+ */
+ public HtmlPageAttributes addLink(String relation, String linkURL)
+ {
+ return addLink(relation, linkURL, null, null);
+ }
+
+ /**
+ * Adds a generic external reference
+ *
+ * @param relation type of the reference (prev, next, first, last, top, etc.)
+ * @param linkURL URL of the reference
+ * @param title title of the reference
+ * @return a <code>HtmlPageAttributes</code> (self).
+ */
+ public HtmlPageAttributes addLink(String relation, String linkURL, String title)
+ {
+ return addLink(relation, linkURL, title, null);
+ }
+
+ /**
+ * Adds a generic external reference
+ *
+ * @param relation type of the reference (prev, next, first, last, top, etc.)
+ * @param linkURL URL of the reference
+ * @param title title of the reference
+ * @param type content type
+ * @return a <code>HtmlPageAttributes</code> (self).
+ */
+ public HtmlPageAttributes addLink(String relation, String linkURL, String title,
+ String type)
+ {
+ LinkTag ss = new LinkTag(relation, linkURL);
+ ss.setTitle(title);
+ ss.setType(type);
+ this.linkTags.add(ss);
+ return this;
+ }
+
+ /**
* Returns a collection of script URLs
*
- * @return list StyleSheet objects (inner class)
+ * @return list LinkTag objects (inner class)
+ * @deprecated use getLinks() instead
*/
public List getStyleSheets()
{
- return this.styleSheets;
+ return this.linkTags;
+ }
+
+ /**
+ * Returns a collection of link URLs
+ *
+ * @return list LinkTag objects (inner class)
+ */
+ public List getLinks()
+ {
+ return this.linkTags;
}
/**
@@ -526,22 +582,26 @@
}
/**
- * Helper class to hold data about a stylesheet
+ * Helper class to hold data about a <link ... /> html header tag
*/
- public class StyleSheet
+ public class LinkTag
{
+ private String relation;
private String url;
private String title;
private String media;
private String type;
/**
- * Constructor requiring the URL to be set
+ * Constructor requiring the URL and relation to be set
*
- * @param url URL of the external style sheet
+ * @param relation Relation type the external link such as prev, next,
+ * stylesheet, shortcut icon
+ * @param url URL of the external link
*/
- public StyleSheet(String url)
+ public LinkTag(String relation, String url)
{
+ setRelation(relation);
setUrl(url);
}
@@ -623,6 +683,25 @@
this.media = media;
}
+ /**
+ * Gets the relation type of the tag.
+ *
+ * @return name of the relation
+ */
+ public String getRelation()
+ {
+ return (StringUtils.isEmpty(relation) ? "" : relation);
+ }
+
+ /**
+ * Sets the relation type of the tag.
+ *
+ * @param relation name of the relation
+ */
+ public void setRelation(String relation)
+ {
+ this.relation = relation;
+ }
}
/**
Modified: jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/macros/TurbineMacros.vm
URL: http://svn.apache.org/viewvc/jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/macros/TurbineMacros.vm?view=diff&rev=533520&r1=533519&r2=533520
==============================================================================
--- jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/macros/TurbineMacros.vm (original)
+++ jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/macros/TurbineMacros.vm Sun Apr 29 09:38:52 2007
@@ -31,12 +31,12 @@
<meta http-equiv="$httpEquiv" content="$page.HttpEquivs.get($httpEquiv)" />
#end
#end
- #if ($page.StyleSheets.size() > 0)
- #foreach( $styleSheet in $page.StyleSheets )
- <link rel="stylesheet" href="$styleSheet.Url"
- #if($!styleSheet.Type) type="$styleSheet.Type" #end
- #if($!styleSheet.Media) media="$styleSheet.Media" #end
- #if($!styleSheet.Title) title="$styleSheet.Title" #end
+ #if ($page.Links.size() > 0)
+ #foreach( $linkTag in $page.Links )
+ <link rel="$linkTag.Relation" href="$linkTag.Url"
+ #if($!linkTag.Type) type="$linkTag.Type" #end
+ #if($!linkTag.Media) media="$linkTag.Media" #end
+ #if($!linkTag.Title) title="$linkTag.Title" #end
/>
#end
#end
Modified: jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/changes.xml?view=diff&rev=533520&r1=533519&r2=533520
==============================================================================
--- jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/changes.xml (original)
+++ jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/changes.xml Sun Apr 29 09:38:52 2007
@@ -25,6 +25,10 @@
<body>
<release version="2.3.3-dev" date="in Subversion">
+ <action type="add" dev="tv">
+ Extended HtmlPageAttributes to allow generic <link /> tags in the
+ HTML head section.
+ </action>
<action type="add" dev="seade" issue="TRB-27" due-to="Thomas Vandahl">
Added Thomas's variation on Siegfried's TurbineYaafiComponentService that
allows Fulcrum components to be used in Turbine 2.3 in a fulcrum-yaafi
Modified: jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/howto/velocityonlylayout-howto.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/howto/velocityonlylayout-howto.xml?view=diff&rev=533520&r1=533519&r2=533520
==============================================================================
--- jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/howto/velocityonlylayout-howto.xml (original)
+++ jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/howto/velocityonlylayout-howto.xml Sun Apr 29 09:38:52 2007
@@ -174,12 +174,12 @@
#foreach($httpEquiv in $page.HttpEquivs.keySet())
<meta http-equiv="$httpEquiv" content="$page.HttpEquivs.get($httpEquiv)">
#end
- #foreach($styleSheet in $page.StyleSheets)
- <link rel="stylesheet" href="$styleSheet.Url"
- #if($styleSheet.Type != "" ) type="$styleSheet.Type" #end
- #if($styleSheet.Media != "") media="$styleSheet.Media" #end
- #if($styleSheet.Title != "") title="$styleSheet.Title" #end
- >
+ #foreach( $linkTag in $page.Links )
+ <link rel="$linkTag.Relation" href="$linkTag.Url"
+ #if($!linkTag.Type) type="$linkTag.Type" #end
+ #if($!linkTag.Media) media="$linkTag.Media" #end
+ #if($!linkTag.Title) title="$linkTag.Title" #end
+ >
#end
#if ($page.Styles.size() > 0)
<style type="text/css">
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org