Author: gmazza Date: Sun Aug 31 20:31:59 2014 New Revision: 1621634 URL: http://svn.apache.org/r1621634 Log: Merged StylesheetEditError.jsp into StylesheetEdit.jsp
Removed: roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/StylesheetEditError.jsp Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java roller/trunk/app/src/main/resources/ApplicationResources.properties roller/trunk/app/src/main/resources/ApplicationResources_de.properties roller/trunk/app/src/main/resources/ApplicationResources_ja_JP.properties roller/trunk/app/src/main/resources/struts.xml roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml 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=1621634&r1=1621633&r2=1621634&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 Sun Aug 31 20:31:59 2014 @@ -54,8 +54,13 @@ public class StylesheetEdit extends UIAc private String contentsStandard = null; private String contentsMobile = null; - // Do we have a custom stylesheet already for a custom theme - private boolean customStylesheet = false; + private boolean sharedTheme; + + // read by JSP to determine if user just deleted his shared theme customized stylesheet + private boolean sharedStylesheetDeleted; + + // Do we have a custom stylesheet already for a shared theme + private boolean sharedThemeCustomStylesheet = false; public StylesheetEdit() { this.actionName = "stylesheetEdit"; @@ -65,6 +70,8 @@ public class StylesheetEdit extends UIAc @Override public void myPrepare() { + sharedTheme = !WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme()); + sharedStylesheetDeleted = false; ThemeTemplate stylesheet = null; try { @@ -126,7 +133,7 @@ public class StylesheetEdit extends UIAc addMessage("stylesheetEdit.create.success"); } - // See if we have a custom style sheet from a custom theme. + // See if we're using a shared theme with a custom stylesheet if (!WeblogTheme.CUSTOM.equals(getActionWeblog() .getEditorTheme()) && getActionWeblog().getTheme().getStylesheet() != null) { @@ -140,13 +147,13 @@ public class StylesheetEdit extends UIAc .getStylesheet().getLink()); if (override != null) { - customStylesheet = true; + sharedThemeCustomStylesheet = true; } } } catch (WebloggerException ex) { log.error( - "Error finding/adding stylesheet tempalate from weblog - " + "Error finding/adding stylesheet template from weblog - " + getActionWeblog().getHandle(), ex); } } @@ -156,33 +163,26 @@ public class StylesheetEdit extends UIAc * Show stylesheet edit page. */ public String execute() { - - if (getTemplate() == null) { - return ERROR; - } - - try { - - if (getTemplate().getTemplateRendition(RenditionType.STANDARD) != null) { - setContentsStandard(getTemplate().getTemplateRendition( - RenditionType.STANDARD).getTemplate()); - } else { - setContentsStandard(""); - } - if (getTemplate().getTemplateRendition(RenditionType.MOBILE) != null) { - setContentsMobile(getTemplate().getTemplateRendition( - RenditionType.MOBILE).getTemplate()); - } - - if (log.isDebugEnabled()) { - log.debug("Standard: " + getContentsStandard() + " Mobile: " - + getContentsMobile()); + if (template != null) { + try { + if (getTemplate().getTemplateRendition(RenditionType.STANDARD) != null) { + setContentsStandard(getTemplate().getTemplateRendition( + RenditionType.STANDARD).getTemplate()); + } else { + setContentsStandard(""); + } + if (getTemplate().getTemplateRendition(RenditionType.MOBILE) != null) { + setContentsMobile(getTemplate().getTemplateRendition( + RenditionType.MOBILE).getTemplate()); + } + if (log.isDebugEnabled()) { + log.debug("Standard: " + getContentsStandard() + " Mobile: " + + getContentsMobile()); + } + } catch (WebloggerException e) { + log.error("Error loading Weblog template codes for stylesheet", e); } - - } catch (WebloggerException e) { - log.error("Error loading Weblog template codes for stylesheet", e); } - return INPUT; } @@ -190,12 +190,6 @@ public class StylesheetEdit extends UIAc * Save an existing stylesheet. */ public String save() { - - if (getTemplate() == null) { - addError("stylesheetEdit.error.cannotFind"); - return ERROR; - } - if (!hasActionErrors()) { try { @@ -245,27 +239,14 @@ public class StylesheetEdit extends UIAc addError("Error saving template - check Roller logs"); } } - return INPUT; } /** - * Revert the stylesheet to its original state. + * Revert the stylesheet to its original state. UI provides this only for shared themes. */ public String revert() { - - if (getTemplate() == null) { - addError("stylesheetEdit.error.cannotFind"); - return ERROR; - } - - // make sure we are still using a shared theme so that reverting is - // possible - if (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())) { - addError("stylesheetEdit.error.customTheme"); - } - - if (!hasActionErrors()) { + if (sharedTheme && !hasActionErrors()) { try { WeblogTemplate stylesheet = getTemplate(); @@ -312,10 +293,9 @@ public class StylesheetEdit extends UIAc } catch (WebloggerException ex) { log.error("Error updating stylesheet template for weblog - " + getActionWeblog().getHandle(), ex); - addError("stylesheetEdit.revert.failure"); + addError("generic.error.check.logs"); } } - return execute(); } @@ -323,31 +303,14 @@ public class StylesheetEdit extends UIAc * 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"); - } - - if (!hasActionErrors()) { + if (template != null && sharedTheme && !hasActionErrors()) { try { - - WeblogTemplate stylesheet = getTemplate(); - // Delete template and flush WeblogManager mgr = WebloggerFactory.getWeblogger() .getWeblogManager(); // Remove template and page codes - mgr.removeTemplate(stylesheet); + mgr.removeTemplate(template); Weblog weblog = getActionWeblog(); @@ -355,25 +318,25 @@ public class StylesheetEdit extends UIAc mgr.saveWeblog(weblog); // notify caches - CacheManager.invalidate(stylesheet); + CacheManager.invalidate(template); // Flush for operation WebloggerFactory.getWeblogger().flush(); // success message addMessage("stylesheetEdit.default.success", - stylesheet.getName()); + template.getName()); + + template = null; + sharedStylesheetDeleted = true; } catch (Exception e) { log.error("Error deleting stylesheet template for weblog - " + getActionWeblog().getHandle(), e); - - return ERROR; + addError("generic.error.check.logs"); } } - - return "delete"; - + return INPUT; } /** @@ -443,21 +406,20 @@ public class StylesheetEdit extends UIAc } /** - * Checks if is custom stylesheet. + * Checks if using a shared theme with a custom stylesheet. * - * @return true, if checks if is custom stylesheet + * @return true, if checks if shared theme and custom stylesheet */ - public boolean isCustomStylesheet() { - return customStylesheet; + public boolean isSharedThemeCustomStylesheet() { + return sharedThemeCustomStylesheet; } /** - * Sets the custom stylesheet. - * - * @param customStylesheet - * the custom stylesheet + * Checks if user just deleted his custom shared stylesheet + * + * @return true, if custom shared stylesheet was deleted. */ - public void setCustomStylesheet(boolean customStylesheet) { - this.customStylesheet = customStylesheet; + public boolean isSharedStylesheetDeleted() { + return sharedStylesheetDeleted; } } Modified: roller/trunk/app/src/main/resources/ApplicationResources.properties URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/ApplicationResources.properties?rev=1621634&r1=1621633&r2=1621634&view=diff ============================================================================== --- roller/trunk/app/src/main/resources/ApplicationResources.properties (original) +++ roller/trunk/app/src/main/resources/ApplicationResources.properties Sun Aug 31 20:31:59 2014 @@ -1198,21 +1198,18 @@ This will ensure you are using the lates stylesheetEdit.revert=Restore Stylesheet stylesheetEdit.delete=Delete Stylesheet -stylesheetEdit.noStylesheetOverride=\ -Unfortunately, the theme you''re using does not provide a custom \ -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.revert.failure=Error reverting template - check Roller logs 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. -stylesheetEdit.error.customTheme=Cannot revert stylesheet on custom themes. -stylesheetEdit.error.cannotFind=Unable to locate stylesheet template +stylesheetEdit.noOverridableStylesheetAvailable=\ +The theme you''re using does not define a customizable stylesheet in its descriptor. You can choose another shared theme, or for \ + custom themes, create the stylesheet on the templates tab instead. + +stylesheetEdit.canRecreateStylesheetOverride=Note: clicking the stylesheet tab again will \ +recreate a custom override stylesheet from the theme default. + stylesheetEdit.confirmDelete=Are you sure you want to delete your stylesheet? stylesheetEdit.confirmRevert=Are you sure you want to revert your stylesheet to the theme default? @@ -1286,8 +1283,8 @@ themeEditor.importWarning=WARNING: Updat themeEditor.importRequired=Since this is the first time you are going to try a \ custom theme you must first copy templates from an existing theme. themeEditor.importAndOverwriteTemplates=Also import a theme into my already existing custom templates, overwriting any with the same name. -themeEditor.importAndOverwriteTemplates.tooltip=You already have custom templates that can be used to render a blog (see Templates tab). \ - Select this option to import a shared theme's templates, overwriting any of your existing templates that have the same name as the shared theme's\ +themeEditor.importAndOverwriteTemplates.tooltip=This blog already has custom templates defined on the Templates tab. \ + Select this option to import a shared theme's templates, overwriting any of your existing templates that have the same name as the shared theme's \ templates. Leave this unchecked to just switch to custom with your present templates. themeEditor.setTheme.success=Theme set to {0} themeEditor.setCustomTheme.success=Shared theme {0} imported into custom templates Modified: roller/trunk/app/src/main/resources/ApplicationResources_de.properties URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/ApplicationResources_de.properties?rev=1621634&r1=1621633&r2=1621634&view=diff ============================================================================== --- roller/trunk/app/src/main/resources/ApplicationResources_de.properties (original) +++ roller/trunk/app/src/main/resources/ApplicationResources_de.properties Sun Aug 31 20:31:59 2014 @@ -623,8 +623,6 @@ searchSummary.text=Angezeigt: {0} - {1} statCount.weblogCommentCountType=Weblog Kommentar Anzahl statCount.weblogDayHits=Heutiger Hit Z\u00E4hler statCount.weblogEntryCommentCountType=Weblog Eintrag Kommentar Anzahl -stylesheetEdit.error.customTheme=Das Stylesheet eine angepassten Themas l\u00E4sst sich nicht zur\u00FCcksetzen. -stylesheetEdit.noStylesheetOverride=Leider bietet das von Ihnen gew\u00E4hlte Thema kein anpassbares Stylesheet, welches Sie bearbeiten k\u00F6nnen. Sie k\u00F6nnen Ihr Thema insgesamt anpassen oder Ihren Systemadministrator kontaktieren um diese Funktion zu aktivieren. stylesheetEdit.revert=Stylesheet zur\u00FCcksetzen stylesheetEdit.revert.success=Stylesheet erfolgreich zur\u00FCckgesetzt stylesheetEdit.revertTip=Falls Sie auf Probleme sto\u00DFen, welche Sie nicht mehr beheben k\u00F6nnen, so beginnen Sie einfach von vorne, indem Sie auf 'Stylesheet wiederherstellen' klicken. Modified: roller/trunk/app/src/main/resources/ApplicationResources_ja_JP.properties URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/ApplicationResources_ja_JP.properties?rev=1621634&r1=1621633&r2=1621634&view=diff ============================================================================== --- roller/trunk/app/src/main/resources/ApplicationResources_ja_JP.properties (original) +++ roller/trunk/app/src/main/resources/ApplicationResources_ja_JP.properties Sun Aug 31 20:31:59 2014 @@ -952,7 +952,6 @@ pageForm.useAutoContentType=\u81EA\u52D5 comment.validator.blacklistName=\u30D6\u30E9\u30C3\u30AF\u30EA\u30B9\u30C8\u30B3\u30E1\u30F3\u30C8\u6392\u9664 installer.cannotConnectToDatabase=\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u306B\u63A5\u7D9A\u3067\u304D\u307E\u305B\u3093 userAdmin.cantChangeOwnRole=\u6A29\u9650\u306E\u5909\u66F4\u304C\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F -stylesheetEdit.error.customTheme=\u30AB\u30B9\u30BF\u30E0\u30C6\u30FC\u30DE\u306E\u30B9\u30BF\u30A4\u30EB\u30B7\u30FC\u30C8\u3092\u5143\u306B\u623B\u305B\u307E\u305B\u3093\u3067\u3057\u305F comment.validator.blacklistMessage=\u30B3\u30E1\u30F3\u30C8\u3092\u30D6\u30E9\u30C3\u30AF\u30EA\u30B9\u30C8\uFF06NG\u30EF\u30FC\u30C9\u306B\u767B\u9332 comment.validator.excessSizeMessage=\u30B3\u30E1\u30F3\u30C8\u306F{0}\u6587\u5B57\u4EE5\u4E0A\u5FC5\u8981\u3067\u3059 comment.validator.excessLinksMessage=\u30B3\u30E1\u30F3\u30C8\u304C{0}\u500B\u4EE5\u4E0A\u306E\u30EA\u30F3\u30AF\u3092\u6301\u3063\u3066\u3044\u307E\u3059 Modified: roller/trunk/app/src/main/resources/struts.xml URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/struts.xml?rev=1621634&r1=1621633&r2=1621634&view=diff ============================================================================== --- roller/trunk/app/src/main/resources/struts.xml (original) +++ roller/trunk/app/src/main/resources/struts.xml Sun Aug 31 20:31:59 2014 @@ -460,8 +460,6 @@ <action name="stylesheetEdit!*" method="{1}" class="org.apache.roller.weblogger.ui.struts2.editor.StylesheetEdit"> <result name="input" type="tiles">.StylesheetEdit</result> - <result name="error" type="tiles">.StylesheetEditError</result> - <result name="delete" type="tiles">.StylesheetEditError</result> </action> <action name="templates!*" method="{1}" Modified: roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp?rev=1621634&r1=1621633&r2=1621634&view=diff ============================================================================== --- roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp (original) +++ roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/StylesheetEdit.jsp Sun Aug 31 20:31:59 2014 @@ -18,86 +18,97 @@ <%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %> <link rel="stylesheet" media="all" href='<s:url value="/roller-ui/jquery-ui-1.11.0/jquery-ui.min.css"/>' /> -<script> - function revertStylesheet() { - if (window.confirm('<s:text name="stylesheetEdit.confirmRevert"/>')) { - document.stylesheetEdit.action = "<s:url action='stylesheetEdit!revert' />"; - document.stylesheetEdit.submit(); - } - }; - <s:if test="%{customStylesheet}"> - function deleteStylesheet() { - if (window.confirm('<s:text name="stylesheetEdit.confirmDelete"/>')) { - document.stylesheetEdit.action = "<s:url action='stylesheetEdit!delete' />"; - document.stylesheetEdit.submit(); - } - }; - </s:if> -</script> - <p class="subtitle"><s:text name="stylesheetEdit.subtitle" /></p> -<p class="pagetip"> - <s:text name="stylesheetEdit.tip" /> - <s:if test="!customTheme"> - <s:text name="stylesheetEdit.revertTip" /> - <s:if test="customStylesheet"> - <br /><br /><s:text name="stylesheetEdit.revertTip1" /> +<s:if test="template == null"> + <div class="notification"> + <s:if test="sharedStylesheetDeleted"> + <%-- clicking the stylesheet tab will recreate your custom override stylesheet ... --%> + <s:text name="stylesheetEdit.canRecreateStylesheetOverride" /> </s:if> - </s:if> -</p> - -<s:form action="stylesheetEdit!save"> - <s:hidden name="salt" /> - <s:hidden name="weblog" /> - - <%-- ================================================================== --%> - <%-- Tabs for each of the two content areas: Standard and Mobile --%> - - <div id="template-code-tabs"> - <ul> - <li class="selected"><a href="#tabStandard"><em>Standard</em></a></li> - <s:if test="contentsMobile != null"> - <li><a href="#tabMobile"><em>Mobile</em></a></li> + <s:else> + <%-- shared theme does not offer a stylesheet ... --%> + <s:text name="stylesheetEdit.noOverridableStylesheetAvailable" /> + </s:else> + </div> +</s:if> +<s:else> + <p class="pagetip"> + <s:text name="stylesheetEdit.tip" /> + <s:if test="!customTheme"> + <s:text name="stylesheetEdit.revertTip" /> + <s:if test="sharedThemeCustomStylesheet"> + <br /><br /><s:text name="stylesheetEdit.revertTip1" /> + </s:if> </s:if> - </ul> - <div> - <div id="tabStandard"> - <s:textarea name="contentsStandard" cols="80" rows="30" cssStyle="width:100%" /> - </div> - <s:if test="contentsMobile != null"> - <div id="tabMobile"> - <s:textarea name="contentsMobile" cols="80" rows="30" cssStyle="width:100%" /> + </p> + + <s:form action="stylesheetEdit!save"> + <s:hidden name="salt" /> + <s:hidden name="weblog" /> + + <%-- ================================================================== --%> + <%-- Tabs for each of the two content areas: Standard and Mobile --%> + + <div id="template-code-tabs"> + <ul> + <li class="selected"><a href="#tabStandard"><em>Standard</em></a></li> + <s:if test="contentsMobile != null"> + <li><a href="#tabMobile"><em>Mobile</em></a></li> + </s:if> + </ul> + <div> + <div id="tabStandard"> + <s:textarea name="contentsStandard" cols="80" rows="30" cssStyle="width:100%" /> </div> + <s:if test="contentsMobile != null"> + <div id="tabMobile"> + <s:textarea name="contentsMobile" cols="80" rows="30" cssStyle="width:100%" /> + </div> + </s:if> + </div> + </div> + + <%-- ================================================================== --%> + <%-- Save, Close and Resize text area buttons--%> + + <table style="width:100%"> + <tr> + <td> + <s:submit value="%{getText('generic.save')}" /> + <s:if test="!customTheme"> + <s:submit value="%{getText('stylesheetEdit.revert')}" onclick="revertStylesheet();return false;" /> + </s:if> + <%-- Only delete if we have no custom templates ie website.customStylesheetPath=null --%> + <s:if test="sharedThemeCustomStylesheet"> + <s:submit value="%{getText('stylesheetEdit.delete')}" onclick="deleteStylesheet();return false;" /> + </s:if> + </td> + </tr> + </table> + + </s:form> + + <script src="<s:url value='/roller-ui/scripts/jquery-2.1.1.min.js'></s:url>"></script> + <script src="<s:url value='/roller-ui/jquery-ui-1.11.0/jquery-ui.min.js'></s:url>"></script> + + <script> + function revertStylesheet() { + if (window.confirm('<s:text name="stylesheetEdit.confirmRevert"/>')) { + document.stylesheetEdit.action = "<s:url action='stylesheetEdit!revert' />"; + document.stylesheetEdit.submit(); + } + }; + <s:if test="%{sharedThemeCustomStylesheet}"> + function deleteStylesheet() { + if (window.confirm('<s:text name="stylesheetEdit.confirmDelete"/>')) { + document.stylesheetEdit.action = "<s:url action='stylesheetEdit!delete' />"; + document.stylesheetEdit.submit(); + } + }; </s:if> - </div> - </div> - - <%-- ================================================================== --%> - <%-- Save, Close and Resize text area buttons--%> - - <table style="width:100%"> - <tr> - <td> - <s:submit value="%{getText('generic.save')}" /> - <s:if test="!customTheme"> - <s:submit value="%{getText('stylesheetEdit.revert')}" onclick="revertStylesheet();return false;" /> - </s:if> - <%-- Only delete if we have no custom templates ie website.customStylesheetPath=null --%> - <s:if test="customStylesheet"> - <s:submit value="%{getText('stylesheetEdit.delete')}" onclick="deleteStylesheet();return false;" /> - </s:if> - </td> - </tr> - </table> - -</s:form> - -<script src="<s:url value='/roller-ui/scripts/jquery-2.1.1.min.js'></s:url>"></script> -<script src="<s:url value='/roller-ui/jquery-ui-1.11.0/jquery-ui.min.js'></s:url>"></script> - -<script> - $(function() { - $( "#template-code-tabs" ).tabs(); - }); -</script> + $(function() { + $( "#template-code-tabs" ).tabs(); + }); + </script> +</s:else> Modified: roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml?rev=1621634&r1=1621633&r2=1621634&view=diff ============================================================================== --- roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml (original) +++ roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml Sun Aug 31 20:31:59 2014 @@ -363,12 +363,7 @@ <put-attribute name="content" value="/WEB-INF/jsps/editor/StylesheetEdit.jsp" /> <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-nosidebar.jsp" /> </definition> - - <definition name=".StylesheetEditError" extends=".tiles-tabbedpage" > - <put-attribute name="content" value="/WEB-INF/jsps/editor/StylesheetEditError.jsp" /> - <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-nosidebar.jsp" /> - </definition> - + <definition name=".Templates" extends=".tiles-tabbedpage" > <put-attribute name="content" value="/WEB-INF/jsps/editor/Templates.jsp" /> <put-attribute name="sidebar" value="/WEB-INF/jsps/editor/TemplatesSidebar.jsp" />