You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/07/14 16:42:11 UTC
cvs commit: jakarta-turbine/src/adapter/org/apache/turbine/util/template TemplatePageAttributes.java PageAttributes.java
jvanzyl 01/07/14 07:42:11
Modified: src/adapter/org/apache/turbine/util/template
TemplatePageAttributes.java
Removed: src/adapter/org/apache/turbine/util/template
PageAttributes.java
Log:
- getting rid of ECS if TemplatePageAttributes, this class should
be turned into a general storage for page attributes. For all
output types not just HTML.
Revision Changes Path
1.2 +23 -243 jakarta-turbine/src/adapter/org/apache/turbine/util/template/TemplatePageAttributes.java
Index: TemplatePageAttributes.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/adapter/org/apache/turbine/util/template/TemplatePageAttributes.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TemplatePageAttributes.java 2001/07/10 00:38:53 1.1
+++ TemplatePageAttributes.java 2001/07/14 14:42:11 1.2
@@ -54,19 +54,8 @@
* <http://www.apache.org/>.
*/
-import org.apache.ecs.Document;
-import org.apache.ecs.Element;
-import org.apache.ecs.ElementAttributes;
-import org.apache.ecs.HtmlColor;
-import org.apache.ecs.html.Body;
-import org.apache.ecs.html.Head;
-import org.apache.ecs.html.Link;
-import org.apache.ecs.html.Meta;
-import org.apache.ecs.html.Title;
-
-import org.apache.turbine.services.pull.ApplicationTool;
-
import org.apache.turbine.RunData;
+import org.apache.turbine.services.pull.ApplicationTool;
/**
* Template context tool that will set various attributes of the HTML
@@ -81,8 +70,16 @@
* $page.setKeywords("turbine, cool, servlet framework");
* $page.setStyleSheet("/style.css");
*
+ * This should become a general attribute storage class
+ * for a page. We should have something general like:
+ *
+ * $page.setAttr("bgcolor", "#ffffff")
+ *
+ * Instead of set methods for HTML because we might want
+ * to set attributes for WML output or anything else.
+ *
* @author <a href="mailto:sean@somacity.com">Sean Legassick</a>
- * @version $Id: TemplatePageAttributes.java,v 1.1 2001/07/10 00:38:53 jvanzyl Exp $
+ * @version $Id: TemplatePageAttributes.java,v 1.2 2001/07/14 14:42:11 jvanzyl Exp $
*/
public class TemplatePageAttributes
implements ApplicationTool
@@ -91,9 +88,9 @@
private RunData data = null;
/** The title. */
- private String cachedTitle = null;
+ private String title = null;
+ private String bgColor = null;
-
/**
* Default constructor. The init method must be called before use
*/
@@ -121,10 +118,11 @@
{
// we blithely cast to RunData as the runtime error thrown
// if data is null or not RunData is appropriate.
- this.data = (RunData)data;
+ data = (RunData)data;
// clear cached title
- this.cachedTitle = null;
+ title = null;
+ bgColor = null;
}
/**
@@ -142,14 +140,9 @@
*
* @param intitle A String with the title.
*/
- public TemplatePageAttributes setTitle(String intitle)
+ public TemplatePageAttributes setTitle(String title)
{
- Title title = data.getPage().getTitle();
- if (cachedTitle != null)
- cachedTitle += intitle;
- else
- cachedTitle = intitle;
- title.addElement(intitle);
+ this.title = title;
return this;
}
@@ -161,154 +154,8 @@
* @return A String with the title.
*/
public String getTitle()
- {
- if (cachedTitle == null)
- return "";
- return cachedTitle;
- }
-
- /**
- * Adds a LINK to a CSS styleshet to the HEAD of the page.
- *
- * @param url A String.
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setStyleSheet(String url)
- {
- data.getPage().getHead().addElement(new Link()
- .setRel("stylesheet").setType("text/css").setHref(url));
- return this;
- }
-
- /**
- * Adds a LINK tag, which is essential for accessibility. these
- * tags are _essential_ for creating pages accessible to blind
- * users or those with physical disabilities that frustrate
- * surving with a 2D point/click cursor. In a nutshell, using
- * link tags lets handicapped visitors jump quickly to the guts of
- * your pages, for example
- *
- * <pre>
- * $page.setLink("NEXT","QuickStart","#mainpage")
- * $page.setLink("INDEX","Sections","#toc")
- * $page.setLink("HOME","HomePage","/")
- * </pre>
- *
- * sets up three links right at the start of what they see/hear
- * and lets them get around the page without having to muddle
- * through your front matter. All you need do is add these links
- * and then place <&a name="mainpage"> (or whatever) at the
- * key sections of your template.
- *
- * There is another link tag, "made" which asks for a mailto
- * address, but I am not certain of the syntax; if you find out
- * please patch this code.
- *
- * @param rel a <code>String</code>, one of NEXT,INDEX,HOME,TOC
- * @param title a <code>String</code> is the displayed anchor
- * @param href a <code>String</code> URL value
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setLink(String rel,
- String title,
- String href)
- {
- data.getPage().getHead()
- .addElement(new Link()
- .setRel(rel).setHref(href).setTitle(title));
- return this;
- }
-
- /**
- * Set a keywords META tag in the HEAD of the page.
- *
- * @param keywords A String.
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setKeywords(String keywords)
- {
- data.getPage().getHead().addElement(
- new Meta().setName("keywords").setContent(keywords));
- return this;
- }
-
- /**
- * Sets a HttpEquiv META tag in the HEAD of the page, usage:
- * <br><code>setHttpEquiv("refresh", "5; http://localhost/nextpage.html")</code>
- * <br><code>setHttpEquiv("Expires", "Tue, 20 Aug 1996 14:25:27 GMT")</code>
- *
- * @param httpEquiv The value to use for the http-equiv attribute.
- * @param content The text for the content attribute of the meta tag.
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setHttpEquiv(String httpEquiv, String content)
- {
- data.getPage().getHead().addElement(
- new Meta().setHttpEquiv(httpEquiv).setContent(content));
- return this;
- }
-
- /**
- * Add a description META tag to the HEAD of the page.
- *
- * @param description A String.
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setDescription(String description)
- {
- data.getPage().getHead().addElement(
- new Meta().setName("description").setContent(description));
- return this;
- }
-
- /**
- * Add an author META tag to the HEAD of the page.
- *
- * @param description the author name and email address
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setAuthor(String description)
{
- data.getPage().getHead().addElement(
- new Meta().setName("author").setContent(description));
- return this;
- }
-
- /**
- * Add the generator META tag to the HEAD of the page
- *
- * the no-parms option will put a plug for Turbine into your pages
- * allowing the project crew to do web-searches that tell them how
- * many Turbine sites are listed.
- *
- * @param description (optional) A String
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setGenerator()
- {
- return setGenerator("Jakarta Turbine @VERSION@");
- }
-
- /**
- * Add the generator META tag to the HEAD of the page
- */
- public TemplatePageAttributes setGenerator(String description)
- {
- data.getPage().getHead().addElement(
- new Meta().setName("generator").setContent(description));
- return this;
- }
-
- /**
- * Set the background image for the BODY tag.
- *
- * @param url A String.
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setBackground(String url)
- {
- data.getPage().getBody().setBackground(url);
- return this;
+ return title;
}
/**
@@ -318,84 +165,17 @@
*
* @param color A String.
* @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setBgColor(String color)
- {
- String hexColor = HtmlColor.getColor(color);
- if (hexColor == null)
- {
- hexColor = color;
- }
- data.getPage().getBody().setBgColor(hexColor);
- return this;
- }
-
- /**
- * Set the text color for the BODY tag. You can use either color
- * names or color values (e.g. "white" or "#ffffff" or "ffffff").
- *
- * @param color A String.
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setTextColor(String color)
- {
- String hexColor = HtmlColor.getColor(color);
- if (hexColor == null)
- {
- hexColor = color;
- }
- data.getPage().getBody().setText(hexColor);
- return this;
- }
-
- /**
- * Set the link color for the BODY tag. You can use either color
- * names or color values (e.g. "white" or "#ffffff" or "ffffff").
- *
- * @param color A String.
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes setLinkColor(String color)
- {
- String hexColor = HtmlColor.getColor(color);
- if (hexColor == null)
- {
- hexColor = color;
- }
- data.getPage().getBody().setLink(hexColor);
- return this;
- }
-
- /**
- * Set the visited link color for the BODY tag.
- *
- * @param color A String.
- * @return A TemplatePageAttributes (self).
*/
- public TemplatePageAttributes setVlinkColor(String color)
+ public TemplatePageAttributes setBgColor(String bgColor)
{
- String hexColor = HtmlColor.getColor(color);
- if (hexColor == null)
- {
- hexColor = color;
- }
- data.getPage().getBody().setVlink(hexColor);
+ this.bgColor = bgColor;
return this;
}
- /**
- * Adds an attribute to the BODY tag.
- *
- * @param name A String.
- * @param value A String.
- * @return A TemplatePageAttributes (self).
- */
- public TemplatePageAttributes addAttribute(String name,
- String value)
+ public String getBgColor()
{
- data.getPage().getBody().addAttribute(name, value);
- return this;
- }
+ return bgColor;
+ }
/**
* A dummy toString method that returns an empty string.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org