You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by gh...@apache.org on 2012/01/29 18:18:04 UTC

svn commit: r1237361 - in /roller/trunk: weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java weblogger-webapp/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp

Author: ghuber
Date: Sun Jan 29 17:18:03 2012
New Revision: 1237361

URL: http://svn.apache.org/viewvc?rev=1237361&view=rev
Log:
Saving template code see ROL-1930

Modified:
    roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
    roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp

Modified: roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java?rev=1237361&r1=1237360&r2=1237361&view=diff
==============================================================================
--- roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java (original)
+++ roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java Sun Jan 29 17:18:03 2012
@@ -18,259 +18,363 @@
 
 package org.apache.roller.weblogger.ui.struts2.editor;
 
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.themes.ThemeManager;
-import org.apache.roller.weblogger.pojos.*;
+import org.apache.roller.weblogger.pojos.TemplateCode;
+import org.apache.roller.weblogger.pojos.Theme;
+import org.apache.roller.weblogger.pojos.ThemeTemplate;
+import org.apache.roller.weblogger.pojos.WeblogPermission;
+import org.apache.roller.weblogger.pojos.WeblogTemplate;
+import org.apache.roller.weblogger.pojos.WeblogTheme;
+import org.apache.roller.weblogger.pojos.WeblogThemeTemplateCode;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.cache.CacheManager;
 
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import org.apache.roller.weblogger.pojos.TemplateCode;
-
-
 /**
  * Action which handles editing for a weblog stylesheet override template.
  */
 public class StylesheetEdit extends UIAction {
-    
-    private static Log log = LogFactory.getLog(StylesheetEdit.class);
-    
-    // the template we are working on
-    private WeblogTemplate template = null;
-    
-    // the contents of the stylesheet override
-    private String contents = null;
-
-    // type of the stylesheet template code in active
-    private String type = "standard";
-    
-    
-    public StylesheetEdit() {
-        this.actionName = "stylesheetEdit";
-        this.desiredMenu = "editor";
-        this.pageTitle = "stylesheetEdit.title";
-    }
-    
-    
-    @Override
-    public List<String> requiredWeblogPermissionActions() {
-        return Collections.singletonList(WeblogPermission.ADMIN);
-    }
-    
-    
-    @Override
-    public void myPrepare() {
-        
-        ThemeTemplate stylesheet = null;
-        try {
-            stylesheet = getActionWeblog().getTheme().getStylesheet();
-        } catch (WebloggerException ex) {
-            log.error("Error looking up stylesheet on weblog - "+getActionWeblog().getHandle(), ex);
-        }
-        
-        if(stylesheet != null) {
-            log.debug("custom stylesheet path is - "+stylesheet.getLink());
-            try {
-                 setTemplate(WebloggerFactory.getWeblogger().getWeblogManager()
-                        .getPageByLink(getActionWeblog(), stylesheet.getLink()));
-
-                if(getTemplate() == null) {
-                    log.debug("custom stylesheet not found, creating it");
-                    
-                    // template doesn't exist yet, so create it
-                    WeblogTemplate stylesheetTmpl = new WeblogTemplate();
-                    stylesheetTmpl.setWebsite(getActionWeblog());
-                    stylesheetTmpl.setAction(stylesheet.ACTION_CUSTOM);
-                    stylesheetTmpl.setName(stylesheet.getName());
-                    stylesheetTmpl.setDescription(stylesheet.getDescription());
-                    stylesheetTmpl.setLink(stylesheet.getLink());
-                    stylesheetTmpl.setContents(stylesheet.getContents());
-                    stylesheetTmpl.setHidden(false);
-                    stylesheetTmpl.setNavbar(false);
-                    stylesheetTmpl.setLastModified(new Date());
-                    stylesheetTmpl.setTemplateLanguage(stylesheet.getTemplateLanguage());
-
-                    // create template codes for available template code Types
-                    WeblogThemeTemplateCode standardTemplateCode = new WeblogThemeTemplateCode(stylesheetTmpl.getId(),"standard");
-                    standardTemplateCode.setTemplate(stylesheetTmpl.getContents());
-                    standardTemplateCode.setTemplateLanguage(stylesheetTmpl.getTemplateLanguage());
-
-                    WeblogThemeTemplateCode mobileTemplateCode = new WeblogThemeTemplateCode(stylesheetTmpl.getId(),"mobile");
-                    mobileTemplateCode.setTemplate(stylesheetTmpl.getContents());
-                    mobileTemplateCode.setTemplateLanguage(stylesheetTmpl.getTemplateLanguage());
-
-                    WebloggerFactory.getWeblogger().getWeblogManager().saveTemplateCode(standardTemplateCode);
-                    WebloggerFactory.getWeblogger().getWeblogManager().saveTemplateCode(mobileTemplateCode);
-
-                    WebloggerFactory.getWeblogger().getWeblogManager().savePage(stylesheetTmpl);
-                    WebloggerFactory.getWeblogger().flush();
-                    
-                    setTemplate(stylesheetTmpl);
-                }
-            } catch (WebloggerException ex) {
-                log.error("Error finding/adding stylesheet tempalate from weblog - "+getActionWeblog().getHandle(), ex);
-            }
-        }
-    }
-    
-    
-    /**
-     * Show stylesheet edit page.
-     */
-    public String execute() {
-        
-        if(getTemplate() == null) {
-            return ERROR;
-        }
-        WeblogThemeTemplateCode templateCode = null;
-        try {
-            templateCode = getTemplate().getTemplateCode(getType());
-        } catch (WebloggerException e) {
-            log.error("Error loading Weblog template code for stylesheet", e);
-        }
-         // if there is a template code load that template
-        if(templateCode != null) {
-            setContents(templateCode.getTemplate());
-        }
-        // if not fall back for default template code
-        else{
-           setContents(getTemplate().getContents());
-        }
-        
-        return INPUT;
-    }
-    
-    
-    /**
-     * Save an existing stylesheet.
-     */
-    public String save() {
-        
-        if(getTemplate() == null) {
-            // TODO: i18n
-            addError("Unable to locate stylesheet template");
-            return ERROR;
-        }
-        
-        if(!hasActionErrors()) try {
-            
-            WeblogTemplate stylesheet = getTemplate();
-            
-            stylesheet.setLastModified(new Date());
-            WeblogThemeTemplateCode templateCode = stylesheet.getTemplateCode(getType());
-            templateCode.setTemplate(getContents());
-
-            //  stylesheet.setContents(getContents());
-            
-            // save template and flush
-            WebloggerFactory.getWeblogger().getWeblogManager().savePage(stylesheet);
-            WebloggerFactory.getWeblogger().getWeblogManager().saveTemplateCode(templateCode);
-            WebloggerFactory.getWeblogger().flush();
-            
-            // notify caches
-            CacheManager.invalidate(stylesheet);
-            
-            // success message
-            addMessage("stylesheetEdit.save.success", stylesheet.getName());
-            
-        } catch (WebloggerException ex) {
-            log.error("Error updating stylesheet template for weblog - "+getActionWeblog().getHandle(), ex);
-            // TODO: i18n
-            addError("Error saving template");
-        }
-        
-        return INPUT;
-    }
-    
-    
-    /**
-     * Revert the stylesheet to its original state.
-     */
-    public String revert() {
-        
-        if(getTemplate() == null) {
-            // TODO: i18n
-            addError("Unable to locate stylesheet template");
-            return ERROR;
-        }
-        
-        // make sure we are still using a shared theme so that reverting is possible
-        if(WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())) {
-            // TODO: i18n
-            addError("stylesheetEdit.error.customTheme");
-        }
-        
-        if(!hasActionErrors()) try {
-            
-            WeblogTemplate stylesheet = getTemplate();
-            
-            // lookup the theme used by this weblog
-            ThemeManager tmgr = WebloggerFactory.getWeblogger().getThemeManager();
-            Theme theme = tmgr.getTheme(getActionWeblog().getEditorTheme());
-
-            //get weblogTemplateCode
-            TemplateCode templateCode = theme.getStylesheet().getTemplateCode(type);
-            stylesheet.setContents(templateCode.getTemplate());
-            
-            // lookup 
-            stylesheet.setLastModified(new Date());
-            //stylesheet.setContents(theme.getStylesheet().getContents());
-
-            //save template code which was persisted in DB
-            WeblogThemeTemplateCode existingTemplateCode = stylesheet.getTemplateCode(getType());
-            existingTemplateCode.setTemplate(templateCode.getTemplate());
-            WebloggerFactory.getWeblogger().getWeblogManager().saveTemplateCode(existingTemplateCode);
-            // save template and flush
-            WebloggerFactory.getWeblogger().getWeblogManager().savePage(stylesheet);
-            WebloggerFactory.getWeblogger().flush();
-            
-            // notify caches
-            CacheManager.invalidate(stylesheet);
-            
-            // success message
-            addMessage("stylesheetEdit.revert.success", stylesheet.getName());
-            
-        } catch (WebloggerException ex) {
-            log.error("Error updating stylesheet template for weblog - "+getActionWeblog().getHandle(), ex);
-            // TODO: i18n
-            addError("Error saving template");
-        }
-        
-        return execute();
-    }
-    
-    
-    public boolean isCustomTheme() {
-        return (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme()));
-    }
-    
-    
-    public WeblogTemplate getTemplate() {
-        return template;
-    }
-
-    public void setTemplate(WeblogTemplate template) {
-        this.template = template;
-    }
-
-    public String getContents() {
-        return contents;
-    }
-
-    public void setContents(String contents) {
-        this.contents = contents;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
+
+	private static final long serialVersionUID = 4657591015852311907L;
+
+	private static Log log = LogFactory.getLog(StylesheetEdit.class);
+
+	// the template we are working on
+	private WeblogTemplate template = null;
+
+	// the contents of the stylesheet override
+	private String contentsStandard = null;
+	private String contentsMobile = null;
+
+	public StylesheetEdit() {
+		this.actionName = "stylesheetEdit";
+		this.desiredMenu = "editor";
+		this.pageTitle = "stylesheetEdit.title";
+	}
+
+	@Override
+	public List<String> requiredWeblogPermissionActions() {
+		return Collections.singletonList(WeblogPermission.ADMIN);
+	}
+
+	@Override
+	public void myPrepare() {
+
+		ThemeTemplate stylesheet = null;
+		try {
+			stylesheet = getActionWeblog().getTheme().getStylesheet();
+		} catch (WebloggerException ex) {
+			log.error("Error looking up stylesheet on weblog - "
+					+ getActionWeblog().getHandle(), ex);
+		}
+
+		if (stylesheet != null) {
+			log.debug("custom stylesheet path is - " + stylesheet.getLink());
+			try {
+				setTemplate(WebloggerFactory.getWeblogger().getWeblogManager()
+						.getPageByLink(getActionWeblog(), stylesheet.getLink()));
+
+				if (getTemplate() == null) {
+					log.debug("custom stylesheet not found, creating it");
+
+					// template doesn't exist yet, so create it
+					WeblogTemplate stylesheetTmpl = new WeblogTemplate();
+					stylesheetTmpl.setWebsite(getActionWeblog());
+					stylesheetTmpl.setAction(ThemeTemplate.ACTION_CUSTOM);
+					stylesheetTmpl.setName(stylesheet.getName());
+					stylesheetTmpl.setDescription(stylesheet.getDescription());
+					stylesheetTmpl.setLink(stylesheet.getLink());
+					stylesheetTmpl.setContents(stylesheet.getContents());
+					stylesheetTmpl.setHidden(false);
+					stylesheetTmpl.setNavbar(false);
+					stylesheetTmpl.setLastModified(new Date());
+					stylesheetTmpl.setTemplateLanguage(stylesheet
+							.getTemplateLanguage());
+
+					// create template codes for available template code Types
+					WeblogThemeTemplateCode standardTemplateCode = new WeblogThemeTemplateCode(
+							stylesheetTmpl.getId(), "standard");
+					standardTemplateCode.setTemplate(stylesheetTmpl
+							.getContents());
+					standardTemplateCode.setTemplateLanguage(stylesheetTmpl
+							.getTemplateLanguage());
+
+					WeblogThemeTemplateCode mobileTemplateCode = new WeblogThemeTemplateCode(
+							stylesheetTmpl.getId(), "mobile");
+					mobileTemplateCode
+							.setTemplate(stylesheetTmpl.getContents());
+					mobileTemplateCode.setTemplateLanguage(stylesheetTmpl
+							.getTemplateLanguage());
+
+					WebloggerFactory.getWeblogger().getWeblogManager()
+							.saveTemplateCode(standardTemplateCode);
+					WebloggerFactory.getWeblogger().getWeblogManager()
+							.saveTemplateCode(mobileTemplateCode);
+
+					WebloggerFactory.getWeblogger().getWeblogManager()
+							.savePage(stylesheetTmpl);
+					WebloggerFactory.getWeblogger().flush();
+
+					setTemplate(stylesheetTmpl);
+				}
+			} catch (WebloggerException ex) {
+				log.error(
+						"Error finding/adding stylesheet tempalate from weblog - "
+								+ getActionWeblog().getHandle(), ex);
+			}
+		}
+	}
+
+	/**
+	 * Show stylesheet edit page.
+	 */
+	public String execute() {
+
+		if (getTemplate() == null) {
+			return ERROR;
+		}
+
+		try {
+
+			if (getTemplate().getTemplateCode("standard") != null) {
+				setContentsStandard(getTemplate().getTemplateCode("standard")
+						.getTemplate());
+			} else {
+				setContentsStandard(getTemplate().getContents());
+			}
+			if (getTemplate().getTemplateCode("mobile") != null) {
+				setContentsMobile(getTemplate().getTemplateCode("mobile")
+						.getTemplate());
+			}
+
+			if (log.isDebugEnabled())
+				log.debug("Standard: " + getContentsStandard() + " Mobile: "
+						+ getContentsMobile());
+
+		} catch (WebloggerException e) {
+			log.error("Error loading Weblog template codes for stylesheet", e);
+		}
+
+		return INPUT;
+	}
+
+	/**
+	 * Save an existing stylesheet.
+	 */
+	public String save() {
+
+		if (getTemplate() == null) {
+			// TODO: i18n
+			addError("Unable to locate stylesheet template");
+			return ERROR;
+		}
+
+		if (!hasActionErrors())
+			try {
+
+				WeblogTemplate stylesheet = getTemplate();
+
+				stylesheet.setLastModified(new Date());
+
+				if (stylesheet.getTemplateCode("standard") != null) {
+					// if we have a template, then set it
+					WeblogThemeTemplateCode tc = stylesheet
+							.getTemplateCode("standard");
+					tc.setTemplate(getContentsStandard());
+					WebloggerFactory.getWeblogger().getWeblogManager()
+							.saveTemplateCode(tc);
+				} else {
+					// otherwise create it, then set it
+					WeblogThemeTemplateCode tc = new WeblogThemeTemplateCode(
+							stylesheet.getId(), "standard");
+					tc.setTemplate(stylesheet.getContents());
+					WebloggerFactory.getWeblogger().getWeblogManager()
+							.saveTemplateCode(tc);
+				}
+
+				if (stylesheet.getTemplateCode("mobile") != null) {
+					WeblogThemeTemplateCode tc = stylesheet
+							.getTemplateCode("mobile");
+					tc.setTemplate(getContentsMobile());
+				} else {
+					WeblogThemeTemplateCode tc = new WeblogThemeTemplateCode(
+							stylesheet.getId(), "mobile");
+					tc.setTemplate(""); // empty, we've got no default mobile
+										// template
+					WebloggerFactory.getWeblogger().getWeblogManager()
+							.saveTemplateCode(tc);
+				}
+
+				// TODO do we want to set the contents on the here?
+				stylesheet.setContents(getContentsStandard());
+
+				// save template and flush
+				WebloggerFactory.getWeblogger().getWeblogManager()
+						.savePage(stylesheet);
+
+				WebloggerFactory.getWeblogger().flush();
+
+				// notify caches
+				CacheManager.invalidate(stylesheet);
+
+				// success message
+				addMessage("stylesheetEdit.save.success", stylesheet.getName());
+
+			} catch (WebloggerException ex) {
+				log.error("Error updating stylesheet template for weblog - "
+						+ getActionWeblog().getHandle(), ex);
+				// TODO: i18n
+				addError("Error saving template");
+			}
+
+		return INPUT;
+	}
+
+	/**
+	 * Revert the stylesheet to its original state.
+	 */
+	public String revert() {
+
+		if (getTemplate() == null) {
+			// TODO: i18n
+			addError("Unable to locate stylesheet template");
+			return ERROR;
+		}
+
+		// make sure we are still using a shared theme so that reverting is
+		// possible
+		if (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())) {
+			// TODO: i18n
+			addError("stylesheetEdit.error.customTheme");
+		}
+
+		if (!hasActionErrors())
+			try {
+
+				WeblogTemplate stylesheet = getTemplate();
+
+				// lookup the theme used by this weblog
+				ThemeManager tmgr = WebloggerFactory.getWeblogger()
+						.getThemeManager();
+				Theme theme = tmgr.getTheme(getActionWeblog().getEditorTheme());
+
+				stylesheet.setLastModified(new Date());
+
+				if (stylesheet.getTemplateCode("standard") != null) {
+					TemplateCode templateCode = theme.getStylesheet()
+							.getTemplateCode("standard");
+					// if we have a template, then set it
+					WeblogThemeTemplateCode existingTemplateCode = stylesheet
+							.getTemplateCode("standard");
+					existingTemplateCode
+							.setTemplate(templateCode.getTemplate());
+					WebloggerFactory.getWeblogger().getWeblogManager()
+							.saveTemplateCode(existingTemplateCode);
+
+					// TODO do we want to set the contents on the here?
+					stylesheet.setContents(templateCode.getTemplate());
+				}
+				if (stylesheet.getTemplateCode("mobile") != null) {
+					TemplateCode templateCode = theme.getStylesheet()
+							.getTemplateCode("mobile");
+					WeblogThemeTemplateCode existingTemplateCode = stylesheet
+							.getTemplateCode("mobile");
+					existingTemplateCode
+							.setTemplate(templateCode.getTemplate());
+				}
+
+				// save template and flush
+				WebloggerFactory.getWeblogger().getWeblogManager()
+						.savePage(stylesheet);
+				WebloggerFactory.getWeblogger().flush();
+
+				// notify caches
+				CacheManager.invalidate(stylesheet);
+
+				// success message
+				addMessage("stylesheetEdit.revert.success",
+						stylesheet.getName());
+
+			} catch (WebloggerException ex) {
+				log.error("Error updating stylesheet template for weblog - "
+						+ getActionWeblog().getHandle(), ex);
+				// TODO: i18n
+				addError("Error saving template");
+			}
+
+		return execute();
+	}
+
+	/**
+	 * Checks if is custom theme.
+	 * 
+	 * @return true, if is custom theme
+	 */
+	public boolean isCustomTheme() {
+		return (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme()));
+	}
+
+	/**
+	 * Gets the template.
+	 * 
+	 * @return the template
+	 */
+	public WeblogTemplate getTemplate() {
+		return template;
+	}
+
+	/**
+	 * Sets the template.
+	 * 
+	 * @param template
+	 *            the new template
+	 */
+	public void setTemplate(WeblogTemplate template) {
+		this.template = template;
+	}
+
+	/**
+	 * Gets the contents standard.
+	 * 
+	 * @return the contents standard
+	 */
+	public String getContentsStandard() {
+		return this.contentsStandard;
+	}
+
+	/**
+	 * Sets the contents standard.
+	 * 
+	 * @param contents
+	 *            the new contents standard
+	 */
+	public void setContentsStandard(String contents) {
+		this.contentsStandard = contents;
+	}
+
+	/**
+	 * Gets the contents mobile.
+	 * 
+	 * @return the contents mobile
+	 */
+	public String getContentsMobile() {
+		return this.contentsMobile;
+	}
+
+	/**
+	 * Sets the contents mobile.
+	 * 
+	 * @param contents
+	 *            the new contents mobile
+	 */
+	public void setContentsMobile(String contents) {
+		this.contentsMobile = contents;
+	}
 }

Modified: roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp?rev=1237361&r1=1237360&r2=1237361&view=diff
==============================================================================
--- roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp (original)
+++ roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp Sun Jan 29 17:18:03 2012
@@ -16,6 +16,9 @@
   directory of this distribution.
 --%>
 <%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+<script type="text/javascript" src="<s:url value='/roller-ui/yui/yahoo-dom-event/yahoo-dom-event.js'></s:url>"></script>
+<script type="text/javascript" src="<s:url value='/roller-ui/yui/element/element-min.js'></s:url>"></script>
+<script type="text/javascript" src="<s:url value='/roller-ui/yui/tabview/tabview-min.js'></s:url>"></script>
 
 <p class="subtitle"><s:text name="stylesheetEdit.subtitle" /></p>
 
@@ -24,71 +27,43 @@
     <s:if test="!customTheme"><s:text name="stylesheetEdit.revertTip" /></s:if>
     <s:if test="$(type == null)"><s:param name="type">standard</s:param></s:if>
 </p>
-                
+
 <s:form action="stylesheetEdit!save">
     <s:hidden name="weblog" />
-    <s:hidden name="type"/>
-    <s:set name="type" value="type"/>
-
-     <table class="menuTabTable" cellspacing="0" >
-     <tr>
-          <s:if test="%{#type=='standard'}">
-        <td class="menuTabSelected">
-    </s:if>
-    <s:else>
-        <td class="menuTabUnselected">
-    </s:else>
-
-          <div class="menu-tr">
-           <s:url id="styleEdit" action="stylesheetEdit">
-               <s:param name="weblog" value="actionWeblog.handle" />
-               <s:param name="type">standard</s:param>
-           </s:url>
-	       <div class="menu-tl">&nbsp;&nbsp;<s:a href="%{styleEdit}">Standard</s:a>&nbsp;&nbsp; </div>
-	    </div></td>
-
-          <td class="menuTabSeparator"></td>
-        <s:if test="%{#type == 'mobile'}">
-        <td class="menuTabSelected">
-    </s:if>
-    <s:else>
-        <td class="menuTabUnselected">
-    </s:else>
-        <div class="menu-tr">
-
-           <s:url id="styleEdit" action="stylesheetEdit">
-                 <s:param name="weblog" value="actionWeblog.handle" />
-                 <s:param name="type">mobile</s:param>
-           </s:url>
-	       <div class="menu-tl">&nbsp;&nbsp;<s:a href="%{styleEdit}">Mobile</s:a>&nbsp;&nbsp; </div>
-	    </div></td>
-
-     </tr>
-        </table>
 
     <%-- ================================================================== --%>
-    <%-- Template editing area w/resize buttons --%>
-    <s:textarea name="contents" cols="80" rows="30" cssStyle="width:100%" />
+    <%-- Tabs for each of the two content areas: Standard and Mobile --%>
+
+    <div id="template-code-tabs" class="yui-navset">
+    <ul class="yui-nav">
+        <li class="selected"><a href="#tabStandard"><em>Standard</em></a></li>
+        <li><a href="#tabMobile"><em>Mobile</em></a></li>
+    </ul>            
+    <div class="yui-content">
+        <div id="tabStandard">
+            <%-- Standard Tab --%> 
+            <s:textarea name="contentsStandard" cols="80" rows="30" cssStyle="width:100%" />
+        </div>
+        <div id="tabMobile">
+            <%-- Standard Tab --%> 
+            <s:textarea name="contentsMobile" cols="80" rows="30" cssStyle="width:100%" />
+        </div>
+    </div>
+    </div>
     
-    <script type="text/javascript"><!--
-        if (getCookie("editorSize1") != null) {
-            document.getElementById('stylesheetEdit_contents').rows = getCookie("editorSize1");
-        }
-        function changeSize(e, num) {
-            a = e.rows + num;
-            if (a > 0) e.rows = a;
-            var expires = new Date();
-            expires.setTime(expires.getTime() + 24 * 90 * 60 * 60 * 1000); // sets it for approx 90 days.
-            setCookie("editorSize",e.rows,expires);
-        }
-        function changeSize1(e, num) {
-            a = e.rows + num;
-            if (a > 0) e.rows = a;
-            var expires = new Date();
-            expires.setTime(expires.getTime() + 24 * 90 * 60 * 60 * 1000); // sets it for approx 90 days.
-            setCookie("editorSize1",e.rows,expires);
+    <%-- ================================================================== --%>
+    <%-- Save, Close and Resize text area buttons--%>
+
+    <script type="text/javascript">
+    //<!--
+        if (getCookie("templateEditorRows") != null) {
+            document.getElementById('stylesheetEdit_contentsMobile').rows = getCookie("templateEditorRows");
+            document.getElementById('stylesheetEdit_contentsStandard').rows = getCookie("templateEditorRows");
+        } else {
+            document.getElementById('stylesheetEdit_contentsMobile').rows = 20;
+            document.getElementById('stylesheetEdit_contentsStandard').rows = 20;
         }
-    // --></script>
+    //--></script>
     <table style="width:100%">
         <tr>
             <td>
@@ -99,12 +74,29 @@
             </td>
             <td align="right">
                 <!-- Add buttons to make this textarea taller or shorter -->
-                <input type="button" name="taller" value=" &darr; " 
-                       onclick="changeSize1(document.getElementById('stylesheetEdit_contents'), 5)" />
-                <input type="button" name="shorter" value=" &uarr; " 
-                       onclick="changeSize1(document.getElementById('stylesheetEdit_contents'), -5)" />
+                <input type="button" name="taller" value=" &darr; " onclick="changeSize1(5)" />
+                <input type="button" name="shorter" value=" &uarr; " onclick="changeSize1(-5)" />
             </td>
         </tr>
     </table>
     
 </s:form>
+
+<script>
+//<!--
+var tabView = new YAHOO.widget.TabView('template-code-tabs');
+
+function changeSize1(num) {
+    var standardElem = document.getElementById('stylesheetEdit_contentsStandard');
+    var mobileElem = document.getElementById('stylesheetEdit_contentsMobile');
+    a = standardElem.rows + num;
+    if (a > 0) {
+        standardElem.rows = a;
+        mobileElem.rows = a;
+    }
+    var expires = new Date();
+    expires.setTime(expires.getTime() + 24 * 90 * 60 * 60 * 1000); // sets it for approx 90 days.
+    setCookie("templateEditorRows", standardElem.rows, expires);
+}
+//-->
+</script>