roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghu...@apache.org
Subject svn commit: r1563801 - in /roller/trunk/app/src/main: java/org/apache/roller/weblogger/ui/struts2/editor/ resources/ webapp/roller-ui/styles/
Date Mon, 03 Feb 2014 08:49:09 GMT
Author: ghuber
Date: Mon Feb  3 08:49:08 2014
New Revision: 1563801

URL: http://svn.apache.org/r1563801
Log:
Make sure we get a default style sheet when switching themes.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
    roller/trunk/app/src/main/resources/ApplicationResources.properties
    roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java?rev=1563801&r1=1563800&r2=1563801&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
Mon Feb  3 08:49:08 2014
@@ -44,166 +44,169 @@ import org.apache.roller.weblogger.util.
  */
 public class StylesheetEdit extends UIAction {
 
-	private static final long serialVersionUID = 4657591015852311907L;
+    private static final long serialVersionUID = 4657591015852311907L;
 
-	private static Log log = LogFactory.getLog(StylesheetEdit.class);
+    private static Log log = LogFactory.getLog(StylesheetEdit.class);
     private static final String MOBILE_THEME_TYPE = "mobile";
     private static final String STANDARD_THEME_TYPE = "standard";
 
-	// the template we are working on
-	private WeblogTemplate template = null;
+    // the template we are working on
+    private WeblogTemplate template = null;
 
-	// the contents of the stylesheet override
-	private String contentsStandard = null;
-	private String contentsMobile = null;
-
-	// Do we have a custom stylesheet already for a custom theme
-	private boolean customStylesheet = false;
-
-	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_THEME_TYPE);
-					standardTemplateCode.setTemplate(stylesheetTmpl
-							.getContents());
-					standardTemplateCode.setTemplateLanguage(stylesheetTmpl
-							.getTemplateLanguage());
-
-					WeblogThemeTemplateCode mobileTemplateCode = new WeblogThemeTemplateCode(
-							stylesheetTmpl.getId(), MOBILE_THEME_TYPE);
-					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);
-				}
-
-				// See if we have a custom style sheet from a custom theme.
-				if (!WeblogTheme.CUSTOM.equals(getActionWeblog()
-						.getEditorTheme())
-						&& getActionWeblog().getTheme().getStylesheet() != null) {
-
-					ThemeTemplate override = WebloggerFactory
-							.getWeblogger()
-							.getWeblogManager()
-							.getPageByLink(
-									getActionWeblog(),
-									getActionWeblog().getTheme()
-											.getStylesheet().getLink());
-
-					if (override != null) {
-						customStylesheet = true;
-					}
-				}
-
-			} 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_THEME_TYPE) != null) {
-				setContentsStandard(getTemplate().getTemplateCode(STANDARD_THEME_TYPE)
-						.getTemplate());
-			} else {
-				setContentsStandard(getTemplate().getContents());
-			}
-			if (getTemplate().getTemplateCode(MOBILE_THEME_TYPE) != null) {
-				setContentsMobile(getTemplate().getTemplateCode(MOBILE_THEME_TYPE)
-						.getTemplate());
-			}
+    // the contents of the stylesheet override
+    private String contentsStandard = null;
+    private String contentsMobile = null;
+
+    // Do we have a custom stylesheet already for a custom theme
+    private boolean customStylesheet = false;
+
+    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_THEME_TYPE);
+                    standardTemplateCode.setTemplate(stylesheetTmpl
+                            .getContents());
+                    standardTemplateCode.setTemplateLanguage(stylesheetTmpl
+                            .getTemplateLanguage());
+
+                    WeblogThemeTemplateCode mobileTemplateCode = new WeblogThemeTemplateCode(
+                            stylesheetTmpl.getId(), MOBILE_THEME_TYPE);
+                    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);
+
+                    // success message
+                    addMessage("stylesheetEdit.create.success");
+                }
+
+                // See if we have a custom style sheet from a custom theme.
+                if (!WeblogTheme.CUSTOM.equals(getActionWeblog()
+                        .getEditorTheme())
+                        && getActionWeblog().getTheme().getStylesheet() != null)
{
+
+                    ThemeTemplate override = WebloggerFactory
+                            .getWeblogger()
+                            .getWeblogManager()
+                            .getPageByLink(
+                                    getActionWeblog(),
+                                    getActionWeblog().getTheme()
+                                            .getStylesheet().getLink());
+
+                    if (override != null) {
+                        customStylesheet = true;
+                    }
+                }
+
+            } 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 (log.isDebugEnabled()) {
+            if (getTemplate().getTemplateCode(STANDARD_THEME_TYPE) != null) {
+                setContentsStandard(getTemplate().getTemplateCode(
+                        STANDARD_THEME_TYPE).getTemplate());
+            } else {
+                setContentsStandard(getTemplate().getContents());
+            }
+            if (getTemplate().getTemplateCode(MOBILE_THEME_TYPE) != null) {
+                setContentsMobile(getTemplate().getTemplateCode(
+                        MOBILE_THEME_TYPE).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;
-		}
+        } 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()) {
+        if (!hasActionErrors()) {
             try {
 
                 WeblogTemplate stylesheet = getTemplate();
@@ -262,28 +265,28 @@ public class StylesheetEdit extends UIAc
             }
         }
 
-		return INPUT;
-	}
+        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");
-		}
+    /**
+     * Revert the stylesheet to its original state.
+     */
+    public String revert() {
+
+        if (getTemplate() == null) {
+            // TODO: i18n
+            addError("Unable to locate stylesheet template");
+            return ERROR;
+        }
 
-		if (!hasActionErrors()) {
+        // 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();
@@ -338,28 +341,28 @@ public class StylesheetEdit extends UIAc
             }
         }
 
-		return execute();
-	}
+        return execute();
+    }
+
+    /**
+     * set theme to default stylesheet, ie delete it.
+     */
+    public String delete() {
+
+        if (getTemplate() == null) {
+            log.error("Unable to locate stylesheet template");
+            addError("error.recordnotfound");
+            return ERROR;
+        }
 
-	/**
-	 * set theme to default stylesheet, ie delete it.
-	 */
-	public String delete() {
-
-		if (getTemplate() == null) {
-			log.error("Unable to locate stylesheet template");
-			addError("error.recordnotfound");
-			return ERROR;
-		}
-
-		// make sure we are still using a shared theme so that deleting is
-		// possible
-		if (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())) {
-			log.error("Unable to delete stylesheet");
-			addError("stylesheetEdit.error.customTheme");
-		}
+        // make sure we are still using a shared theme so that deleting is
+        // possible
+        if (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())) {
+            log.error("Unable to delete stylesheet");
+            addError("stylesheetEdit.error.customTheme");
+        }
 
-		if (!hasActionErrors()) {
+        if (!hasActionErrors()) {
             try {
 
                 WeblogTemplate stylesheet = getTemplate();
@@ -397,92 +400,92 @@ public class StylesheetEdit extends UIAc
             }
         }
 
-		return "delete";
+        return "delete";
 
-	}
+    }
 
-	/**
-	 * 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;
-	}
-
-	/**
-	 * Checks if is custom stylesheet.
-	 * 
-	 * @return true, if checks if is custom stylesheet
-	 */
-	public boolean isCustomStylesheet() {
-		return customStylesheet;
-	}
-
-	/**
-	 * Sets the custom stylesheet.
-	 * 
-	 * @param customStylesheet
-	 *            the custom stylesheet
-	 */
-	public void setCustomStylesheet(boolean customStylesheet) {
-		this.customStylesheet = customStylesheet;
-	}
+    /**
+     * 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;
+    }
+
+    /**
+     * Checks if is custom stylesheet.
+     * 
+     * @return true, if checks if is custom stylesheet
+     */
+    public boolean isCustomStylesheet() {
+        return customStylesheet;
+    }
+
+    /**
+     * Sets the custom stylesheet.
+     * 
+     * @param customStylesheet
+     *            the custom stylesheet
+     */
+    public void setCustomStylesheet(boolean customStylesheet) {
+        this.customStylesheet = customStylesheet;
+    }
 }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java?rev=1563801&r1=1563800&r2=1563801&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
Mon Feb  3 08:49:08 2014
@@ -20,10 +20,12 @@ package org.apache.roller.weblogger.ui.s
 
 import java.util.Collections;
 import java.util.List;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.themes.SharedTheme;
 import org.apache.roller.weblogger.business.themes.ThemeManager;
@@ -42,99 +44,101 @@ import org.apache.roller.weblogger.util.
  */
 public class ThemeEdit extends UIAction {
 
-	private static Log log = LogFactory.getLog(Templates.class);
+    private static final long serialVersionUID = 4644653507344432426L;
 
-	// list of available themes
-	private List themes = Collections.EMPTY_LIST;
+    private static Log log = LogFactory.getLog(Templates.class);
 
-	// type of theme desired, either 'shared' or 'custom'
-	private String themeType = null;
+    // list of available themes
+    private List<Theme> themes = Collections.emptyList();
 
-	// the chosen shared theme id
-	private String themeId = null;
-
-	// import the selected theme to the action weblog
-	private boolean importTheme = false;
-
-	// the chosen import theme id
-	private String importThemeId = null;
-
-	// Do we have a custom stylesheet already
-	private boolean customStylesheet = false;
-
-	public ThemeEdit() {
-		this.actionName = "themeEdit";
-		this.desiredMenu = "editor";
-		this.pageTitle = "themeEditor.title";
-	}
-
-	public List<String> requiredWeblogPermissionActions() {
-		return Collections.singletonList(WeblogPermission.ADMIN);
-	}
-
-	public void myPrepare() {
-
-		ThemeManager themeMgr = WebloggerFactory.getWeblogger()
-				.getThemeManager();
-		setThemes(themeMgr.getEnabledThemesList());
-	}
-
-	public String execute() {
-
-		// set theme to current value
-		if (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())) {
-			setThemeId(null);
-		} else {
-			setThemeId(getActionWeblog().getTheme().getId());
-			setImportThemeId(getActionWeblog().getTheme().getId());
-		}
-
-		// See if we have a custom style sheet from a custom theme.
-		try {
-			if (!WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())
-					&& getActionWeblog().getTheme().getStylesheet() != null) {
-
-				ThemeTemplate override = WebloggerFactory
-						.getWeblogger()
-						.getWeblogManager()
-						.getPageByLink(
-								getActionWeblog(),
-								getActionWeblog().getTheme().getStylesheet()
-										.getLink());
-				if (override != null) {
-					customStylesheet = true;
-				}
-			}
-		} catch (WebloggerException ex) {
-			log.error("Error looking up stylesheet on weblog - "
-					+ getActionWeblog().getHandle(), ex);
-		}
-
-		if (!WebloggerRuntimeConfig
-				.getBooleanProperty("themes.customtheme.allowed")) {
-			return "input-sharedonly";
-		} else {
-			return INPUT;
-		}
-	}
-
-	/**
-	 * Save new theme configuration.
-	 */
-	public String save() {
-
-		Weblog weblog = getActionWeblog();
-
-		// we are dealing with a custom theme scenario
-		if (WeblogTheme.CUSTOM.equals(getThemeType())) {
-
-			// only continue if custom themes are allowed
-			if (WebloggerRuntimeConfig
-					.getBooleanProperty("themes.customtheme.allowed")) {
-
-				// do theme import if necessary
-				SharedTheme t = null;
-				if (isImportTheme() && !StringUtils.isEmpty(getImportThemeId())) {
+    // type of theme desired, either 'shared' or 'custom'
+    private String themeType = null;
+
+    // the chosen shared theme id
+    private String themeId = null;
+
+    // import the selected theme to the action weblog
+    private boolean importTheme = false;
+
+    // the chosen import theme id
+    private String importThemeId = null;
+
+    // Do we have a custom stylesheet already
+    private boolean customStylesheet = false;
+
+    public ThemeEdit() {
+        this.actionName = "themeEdit";
+        this.desiredMenu = "editor";
+        this.pageTitle = "themeEditor.title";
+    }
+
+    public List<String> requiredWeblogPermissionActions() {
+        return Collections.singletonList(WeblogPermission.ADMIN);
+    }
+
+    public void myPrepare() {
+
+        ThemeManager themeMgr = WebloggerFactory.getWeblogger()
+                .getThemeManager();
+        setThemes(themeMgr.getEnabledThemesList());
+    }
+
+    public String execute() {
+
+        // set theme to current value
+        if (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())) {
+            setThemeId(null);
+        } else {
+            setThemeId(getActionWeblog().getTheme().getId());
+            setImportThemeId(getActionWeblog().getTheme().getId());
+        }
+
+        // See if we have a custom style sheet from a custom theme.
+        try {
+            if (!WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())
+                    && getActionWeblog().getTheme().getStylesheet() != null) {
+
+                ThemeTemplate override = WebloggerFactory
+                        .getWeblogger()
+                        .getWeblogManager()
+                        .getPageByLink(
+                                getActionWeblog(),
+                                getActionWeblog().getTheme().getStylesheet()
+                                        .getLink());
+                if (override != null) {
+                    customStylesheet = true;
+                }
+            }
+        } catch (WebloggerException ex) {
+            log.error("Error looking up stylesheet on weblog - "
+                    + getActionWeblog().getHandle(), ex);
+        }
+
+        if (!WebloggerRuntimeConfig
+                .getBooleanProperty("themes.customtheme.allowed")) {
+            return "input-sharedonly";
+        } else {
+            return INPUT;
+        }
+    }
+
+    /**
+     * Save new theme configuration.
+     */
+    public String save() {
+
+        Weblog weblog = getActionWeblog();
+
+        // we are dealing with a custom theme scenario
+        if (WeblogTheme.CUSTOM.equals(getThemeType())) {
+
+            // only continue if custom themes are allowed
+            if (WebloggerRuntimeConfig
+                    .getBooleanProperty("themes.customtheme.allowed")) {
+
+                // do theme import if necessary
+                SharedTheme t = null;
+                if (isImportTheme() && !StringUtils.isEmpty(getImportThemeId()))
{
                     try {
                         ThemeManager themeMgr = WebloggerFactory.getWeblogger()
                                 .getThemeManager();
@@ -148,7 +152,7 @@ public class ThemeEdit extends UIAction 
                     }
                 }
 
-				if (!hasActionErrors()) {
+                if (!hasActionErrors()) {
                     try {
                         weblog.setEditorTheme(WeblogTheme.CUSTOM);
                         log.debug("Saving custom theme for weblog "
@@ -181,41 +185,64 @@ public class ThemeEdit extends UIAction 
                         addError("Error setting theme");
                     }
                 }
-			} else {
-				// TODO: i18n
-				addError("Sorry, custom themes are not allowed");
-			}
-
-			// we are dealing with a shared theme scenario
-		} else if ("shared".equals(getThemeType())) {
-
-			// make sure theme is valid and enabled
-			Theme newTheme = null;
-			if (getThemeId() == null) {
-				// TODO: i18n
-				addError("No theme specified");
-
-			} else {
-				try {
-					ThemeManager themeMgr = WebloggerFactory.getWeblogger()
-							.getThemeManager();
-					newTheme = themeMgr.getTheme(getThemeId());
-
-					if (!newTheme.isEnabled()) {
-						// TODO: i18n
-						addError("Theme not enabled");
-					}
-
-				} catch (Exception ex) {
-					log.warn(ex);
-					// TODO: i18n
-					addError("Theme not found");
-				}
-			}
+            } else {
+                // TODO: i18n
+                addError("Sorry, custom themes are not allowed");
+            }
+
+            // we are dealing with a shared theme scenario
+        } else if ("shared".equals(getThemeType())) {
+
+            // make sure theme is valid and enabled
+            Theme newTheme = null;
+            if (getThemeId() == null) {
+                // TODO: i18n
+                addError("No theme specified");
+
+            } else {
+                try {
+                    ThemeManager themeMgr = WebloggerFactory.getWeblogger()
+                            .getThemeManager();
+                    newTheme = themeMgr.getTheme(getThemeId());
+
+                    if (!newTheme.isEnabled()) {
+                        // TODO: i18n
+                        addError("Theme not enabled");
+                    }
+
+                } catch (Exception ex) {
+                    log.warn(ex);
+                    // TODO: i18n
+                    addError("Theme not found");
+                }
+            }
 
-			if (!hasActionErrors()) {
+            if (!hasActionErrors()) {
                 try {
+
+                    String originalTheme = weblog.getEditorTheme();
+
+                    WeblogManager mgr = WebloggerFactory.getWeblogger()
+                            .getWeblogManager();
+
+                    // Remove old style sheet
+                    if (!originalTheme.equals(getThemeId())
+                            && getActionWeblog().getTheme().getStylesheet() != null)
{
+
+                        WeblogTemplate stylesheet = mgr.getPageByLink(
+                                getActionWeblog(), getActionWeblog().getTheme()
+                                        .getStylesheet().getLink());
+
+                        if (stylesheet != null) {
+                            // Remove template and page codes
+                            mgr.removePage(stylesheet);
+                            // Reset
+                            weblog.setCustomStylesheetPath(null);
+                        }
+                    }
+
                     weblog.setEditorTheme(getThemeId());
+
                     log.debug("Saving theme " + getThemeId() + " for weblog "
                             + weblog.getHandle());
 
@@ -228,9 +255,10 @@ public class ThemeEdit extends UIAction 
                     // change
                     CacheManager.invalidate(weblog);
 
-                    // TODO: i18n
-                    addMessage("Successfully set theme to - "
-                            + newTheme.getName());
+                    // Theme set to..
+                    if (!originalTheme.equals(getThemeId())) {
+                        addMessage("themeEditor.settheme", newTheme.getName());
+                    }
 
                 } catch (WebloggerException re) {
                     log.error("Error saving weblog - "
@@ -239,91 +267,91 @@ public class ThemeEdit extends UIAction 
                 }
             }
 
-			// unknown theme scenario, error
-		} else {
-			// invalid theme type
-			// TODO: i18n
-			addError("no valid theme type submitted");
-		}
-
-		return execute();
-	}
-
-	public boolean isCustomTheme() {
-		return (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme()));
-	}
-
-	// has this weblog had a custom theme before?
-	public boolean isFirstCustomization() {
-		try {
-			return (WebloggerFactory
-					.getWeblogger()
-					.getWeblogManager()
-					.getPageByAction(getActionWeblog(),
-							WeblogTemplate.ACTION_WEBLOG) == null);
-		} catch (WebloggerException ex) {
-			log.error("Error looking up weblog template", ex);
-		}
-		return false;
-	}
-
-	public List getThemes() {
-		return themes;
-	}
-
-	public void setThemes(List themes) {
-		this.themes = themes;
-	}
-
-	public String getThemeType() {
-		return themeType;
-	}
-
-	public void setThemeType(String themeType) {
-		this.themeType = themeType;
-	}
-
-	public String getThemeId() {
-		return themeId;
-	}
-
-	public void setThemeId(String theme) {
-		this.themeId = theme;
-	}
-
-	public boolean isImportTheme() {
-		return importTheme;
-	}
-
-	public void setImportTheme(boolean importTheme) {
-		this.importTheme = importTheme;
-	}
-
-	public String getImportThemeId() {
-		return importThemeId;
-	}
-
-	public void setImportThemeId(String importThemeId) {
-		this.importThemeId = importThemeId;
-	}
-
-	/**
-	 * Checks if we have a custom stylesheet.
-	 * 
-	 * @return true, if checks if is custom stylesheet
-	 */
-	public boolean isCustomStylesheet() {
-		return customStylesheet;
-	}
-
-	/**
-	 * Sets the custom stylesheet.
-	 * 
-	 * @param customStylesheet
-	 *            the custom stylesheet
-	 */
-	public void setCustomStylesheet(boolean customStylesheet) {
-		this.customStylesheet = customStylesheet;
-	}
+            // unknown theme scenario, error
+        } else {
+            // invalid theme type
+            // TODO: i18n
+            addError("no valid theme type submitted");
+        }
+
+        return execute();
+    }
+
+    public boolean isCustomTheme() {
+        return (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme()));
+    }
+
+    // has this weblog had a custom theme before?
+    public boolean isFirstCustomization() {
+        try {
+            return (WebloggerFactory
+                    .getWeblogger()
+                    .getWeblogManager()
+                    .getPageByAction(getActionWeblog(),
+                            WeblogTemplate.ACTION_WEBLOG) == null);
+        } catch (WebloggerException ex) {
+            log.error("Error looking up weblog template", ex);
+        }
+        return false;
+    }
+
+    public List<Theme> getThemes() {
+        return themes;
+    }
+
+    public void setThemes(List<Theme> themes) {
+        this.themes = themes;
+    }
+
+    public String getThemeType() {
+        return themeType;
+    }
+
+    public void setThemeType(String themeType) {
+        this.themeType = themeType;
+    }
+
+    public String getThemeId() {
+        return themeId;
+    }
+
+    public void setThemeId(String theme) {
+        this.themeId = theme;
+    }
+
+    public boolean isImportTheme() {
+        return importTheme;
+    }
+
+    public void setImportTheme(boolean importTheme) {
+        this.importTheme = importTheme;
+    }
+
+    public String getImportThemeId() {
+        return importThemeId;
+    }
+
+    public void setImportThemeId(String importThemeId) {
+        this.importThemeId = importThemeId;
+    }
+
+    /**
+     * Checks if we have a custom stylesheet.
+     * 
+     * @return true, if checks if is custom stylesheet
+     */
+    public boolean isCustomStylesheet() {
+        return customStylesheet;
+    }
+
+    /**
+     * Sets the custom stylesheet.
+     * 
+     * @param customStylesheet
+     *            the custom stylesheet
+     */
+    public void setCustomStylesheet(boolean customStylesheet) {
+        this.customStylesheet = customStylesheet;
+    }
 
 }

Modified: roller/trunk/app/src/main/resources/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/ApplicationResources.properties?rev=1563801&r1=1563800&r2=1563801&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/ApplicationResources.properties (original)
+++ roller/trunk/app/src/main/resources/ApplicationResources.properties Mon Feb  3 08:49:08
2014
@@ -1266,7 +1266,7 @@ pagesForm.subtitle=Manage templates that
 pagesForm.tip=You can edit the templates that define the layout, colors and \
 fonts of your weblog. You can also create new templates to define entirely \
 new pages. This is for advanced users only, if you''re not comfortable \
-with HTML, you might want to leave your templates alone.
+with HTML, you might want to leave your templates alone.  Please <b>backup</b>
your templates!
 
 pageForm.advancedSettings=Advanced Settings
 pagesForm.name=Name
@@ -1631,7 +1631,7 @@ stylesheetEdit.title=Stylesheet
 stylesheetEdit.subtitle=Edit weblog custom stylesheet
 stylesheetEdit.tip=This form allows you to edit the stylesheet for your theme.
 stylesheetEdit.revertTip=If you run into any problems you don''t know how to \
-fix you can start over at any time by clicking the restore button.
+fix you can start over at any time by clicking the restore button.  Please <b>backup</b>
your stylesheet!
 stylesheetEdit.revertTip1=<font color="red">If you have not customized your stylesheet
here, \
 please use the <em>Shared Theme</em> default by clicking the delete stylesheet
button. \
 This will ensure you are using the latest version and any changes will be picked up.</font>

@@ -1645,11 +1645,12 @@ Unfortunately, the theme you''re using d
 stylesheet for you to edit. You can customize your theme or contact \
 your system administrator to see about enabling this feature.
 
+stylesheetEdit.create.success=Custom stylesheet created successfully.
 stylesheetEdit.save.success=Stylesheet updated successfully.
 stylesheetEdit.revert.success=Stylesheet reverted successfully.
 stylesheetEdit.default.success=Stylesheet deleted successfully.  Your theme is now using
the Shared Theme default.
 stylesheetEdit.default.noStylesheetOverride=Note: clicking the stylesheet tab will \
-recreate your custom override stylesheet again from the theme default!
+recreate your custom override stylesheet again from the theme default.
 
 stylesheetEdit.error.customTheme=Cannot revert stylesheet on custom themes.
 stylesheetEdit.confirmDelete=Are you sure you want to delete your stylesheet?
@@ -1767,6 +1768,7 @@ Please select the theme you would like t
 
 themeEditor.save=Update Theme
 
+themeEditor.settheme=Successfully set theme to - {0}
 
 # ---------------------------------------------------------------------- Uploads
 

Modified: roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css?rev=1563801&r1=1563800&r2=1563801&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css (original)
+++ roller/trunk/app/src/main/webapp/roller-ui/styles/roller.css Mon Feb  3 08:49:08 2014
@@ -482,11 +482,7 @@ Error and status message styles
     border: 1px solid #f0c000;
 }
 div.notification {
-    width: 80%;
-    margin-left: auto;
-    margin-right: auto;
-    padding: 25px;
-    font-size: larger;
+    padding: 10px;
     background-color: #ffffce;
     border: 1px solid #f0c000;
 }



Mime
View raw message