You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2007/06/07 23:57:13 UTC

svn commit: r545328 - in /roller/trunk/apps/weblogger: src/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java web/WEB-INF/classes/ApplicationResources.properties web/WEB-INF/jsps/editor/ThemeEdit.jsp web/roller-ui/styles/roller.css

Author: agilliland
Date: Thu Jun  7 14:57:12 2007
New Revision: 545328

URL: http://svn.apache.org/viewvc?view=rev&rev=545328
Log:
more updates to theme editor to fix a couple bugs and improve the usability and verbage a bit.


Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
    roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/ThemeEdit.jsp
    roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java?view=diff&rev=545328&r1=545327&r2=545328
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java Thu Jun  7 14:57:12 2007
@@ -80,6 +80,7 @@
     
     
     public String execute() {
+        
         // set theme to current value
         if(WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())) {
             setThemeId(null);
@@ -103,14 +104,17 @@
         
         Weblog weblog = getActionWeblog();
         
+        // we are dealing with a custom theme scenario
         if(WeblogTheme.CUSTOM.equals(getThemeType())) {
             
             // only continue if custom themes are allowed
             if(RollerRuntimeConfig.getBooleanProperty("themes.customtheme.allowed")) {
+                
                 // do theme import if necessary
+                SharedTheme importTheme = null;
                 if(isImportTheme() && !StringUtils.isEmpty(getImportThemeId())) try {
                     ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
-                    SharedTheme importTheme = themeMgr.getTheme(getImportThemeId());
+                    importTheme = themeMgr.getTheme(getImportThemeId());
                     themeMgr.importTheme(getActionWeblog(), importTheme);
                 } catch(WebloggerException re) {
                     log.error("Error customizing theme for weblog - "+getActionWeblog().getHandle(), re);
@@ -118,34 +122,67 @@
                     addError("Error importing theme");
                 }
                 
-                if(!hasActionErrors()) {
+                if(!hasActionErrors()) try {
                     weblog.setEditorTheme(WeblogTheme.CUSTOM);
                     log.debug("Saving custom theme for weblog "+weblog.getHandle());
                     
-                    // reset import theme checkbox
+                    // save updated weblog and flush
+                    UserManager userMgr = RollerFactory.getRoller().getUserManager();
+                    userMgr.saveWebsite(weblog);
+                    RollerFactory.getRoller().flush();
+                    
+                    // make sure to flush the page cache so ppl can see the change
+                    CacheManager.invalidate(weblog);
+                    
+                    // TODO: i18n
+                    addMessage("Successfully set theme to - "+WeblogTheme.CUSTOM);
+                    if(importTheme != null) {
+                        addMessage("Successfully copied templates from theme - "+importTheme.getName());
+                    }
+                    
+                    // reset import theme options
                     setImportTheme(false);
+                    setImportThemeId(null);
+                    
+                } catch(WebloggerException re) {
+                    log.error("Error saving weblog - "+getActionWeblog().getHandle(), re);
+                    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())) {
-            // validation
-            myValidate();
             
-            if(!hasActionErrors()) {
+            // make sure theme is valid and enabled
+            Theme newTheme = null;
+            if(getThemeId() == null) {
+                // TODO: i18n
+                addError("No theme specified");
+                
+            } else {
+                try {
+                    ThemeManager themeMgr = RollerFactory.getRoller().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()) try {
                 weblog.setEditorTheme(getThemeId());
                 log.debug("Saving theme "+getThemeId()+" for weblog "+weblog.getHandle());
-            }
-        } else {
-            // invalid theme type
-            // TODO: i18n
-            addError("no valid theme type submitted");
-        }
-        
-        if(!hasActionErrors()) {
-            try {
+                
                 // save updated weblog and flush
                 UserManager userMgr = RollerFactory.getRoller().getUserManager();
                 userMgr.saveWebsite(weblog);
@@ -155,44 +192,21 @@
                 CacheManager.invalidate(weblog);
                 
                 // TODO: i18n
-                addMessage("Successfully updated theme");
+                addMessage("Successfully set theme to - "+newTheme.getName());
                 
             } catch(WebloggerException re) {
                 log.error("Error saving weblog - "+getActionWeblog().getHandle(), re);
                 addError("Error setting theme");
             }
-        }
-        
-        return execute();
-    }
-    
-    
-    // validation
-    private void myValidate() {
-        
-        String newTheme = getThemeId();
-        
-        // make sure theme is valid and enabled
-        if(newTheme == null) {
-            // TODO: i18n
-            addError("No theme specified");
             
+        // unknown theme scenario, error
         } else {
-            try {
-                ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
-                Theme newThemeObj = themeMgr.getTheme(getThemeId());
-                
-                if(!newThemeObj.isEnabled()) {
-                    // TODO: i18n
-                    addError("Theme not enabled");
-                }
-                
-            } catch(Exception ex) {
-                log.warn(ex);
-                // TODO: i18n
-                addError("Theme not found");
-            }
+            // invalid theme type
+            // TODO: i18n
+            addError("no valid theme type submitted");
         }
+        
+        return execute();
     }
     
     
@@ -203,7 +217,8 @@
     // has this weblog had a custom theme before?
     public boolean isFirstCustomization() {
         try {
-            return (getActionWeblog().getPageByAction(WeblogTemplate.ACTION_WEBLOG) == null);
+            UserManager umgr = RollerFactory.getRoller().getUserManager();
+            return (umgr.getPageByAction(getActionWeblog(), WeblogTemplate.ACTION_WEBLOG) == null);
         } catch (WebloggerException ex) {
             log.error("Error looking up weblog template", ex);
         }

Modified: roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties?view=diff&rev=545328&r1=545327&r2=545328
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties Thu Jun  7 14:57:12 2007
@@ -1352,10 +1352,16 @@
 Beware though, managing a blog design of your own takes a bit of effort.
 
 themeEditor.yourCurrentTheme=Your current theme is
-themeEditor.selectTheme=Select a new theme to preview
+themeEditor.selectTheme=Select a new shared theme for your blog
 themeEditor.youMayCustomize=If you like you may customize a personal copy of \
 this theme.
 
+themeEditor.templatesLink=Start editing your blog templates.
+themeEditor.templatesDescription=Now that you are using a custom theme the \
+design of your blog is defined entirely by you using a series of templates. \
+You can modify your templates as much as you like and if you ever decide you \
+want to start over you can do so by copying one of the existing themes.
+
 themeEditor.previewLink=See how your blog will look with this theme.
 themeEditor.previewDescription=How can you know if this is really the \
 theme for you until you see it on your blog right?  Click the link above \
@@ -1367,14 +1373,14 @@
 different fonts, colors, etc, then try making your own stylesheet or \
 borrow one from someoone else using your theme.
 
-themeEditor.import=I want to copy the templates from the selected theme into my weblog.
+themeEditor.import=I want to copy the templates from an existing theme into my weblog.
 themeEditor.importWarning=WARNING: this operation may overwrite some of your \
 existing templates.
 themeEditor.importRequired=Since this is the first time you are going to try a \
-custom theme you must copy the templates from an existing theme to start with. \
+custom theme you must copy the templates from an existing theme. \
 Please select the theme you would like to use as a starting point for your customizations.
 
-themeEditor.save=Save
+themeEditor.save=Update Theme
 
 
 # ---------------------------------------------------------------------- Uploads

Modified: roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/ThemeEdit.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/ThemeEdit.jsp?view=diff&rev=545328&r1=545327&r2=545328
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/ThemeEdit.jsp (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/ThemeEdit.jsp Thu Jun  7 14:57:12 2007
@@ -47,6 +47,10 @@
         $('sharedOptioner').hide();
     }
 }
+
+function toggleImportThemeDisplay() {
+    $('themeImport').toggle();
+}
 -->
 </script>
 
@@ -77,7 +81,14 @@
     </table>
     
     <div id="sharedOptioner" class="optioner" style="display:none;">
-        <p><s:text name="themeEditor.yourCurrentTheme" />: <b><s:property value="actionWeblog.theme.name"/></b></p>
+        <p>
+            <s:if test="!customTheme">
+                <s:text name="themeEditor.yourCurrentTheme" />: <b><s:property value="actionWeblog.theme.name"/></b>
+            </s:if>
+            <s:else>
+                <s:text name="themeEditor.selectTheme" />
+            </s:else>
+        </p>
         
         <p>
             <s:select id="sharedSelector" name="themeId" list="themes" listKey="id" listValue="name" size="1" onchange="previewImage($('sharedPreviewImg'), this[selectedIndex].value)"/>
@@ -112,41 +123,63 @@
     </div>
     
     <div id="customOptioner" class="optioner" style="display:none;">
-        <p>
-            <s:if test="!firstCustomization">
+        
+        <s:if test="firstCustomization">
+            <p>
                 <s:hidden name="importTheme" value="true" />
                 <span class="warning"><s:text name="themeEditor.importRequired" /></span>
+            </p>
+        </s:if>
+        <s:else>
+            <s:if test="customTheme">
+                <p>
+                    <s:url id="templatesUrl" action="templates">
+                        <s:param name="weblog" value="%{actionWeblog.handle}" />
+                    </s:url>
+                    &raquo; <s:a href="%{templatesUrl}"><s:text name="themeEditor.templatesLink" /></s:a><br/>
+                    <s:text name="themeEditor.templatesDescription" />
+                </p>
             </s:if>
-            <s:else>
-                <s:checkbox name="importTheme" /><s:text name="themeEditor.import" /><br/>
-                <span class="warning"><s:text name="themeEditor.importWarning" /></span>
-            </s:else>
-        </p>
-        <p>
-            <s:select id="customSelector" name="importThemeId" list="themes" listKey="id" listValue="name" size="1" onchange="previewImage($('customPreviewImg'), this[selectedIndex].value)"/>
-        </p>
-        <p>
-            <img id="customPreviewImg" src="" />
-            <!-- initialize preview image at page load -->
-            <script type="text/javascript">
+            
+            <p>
+                <s:checkbox name="importTheme" onclick="$('themeImport').toggle();" /><s:text name="themeEditor.import" />
+            </p>
+        </s:else>
+        
+        <div id="themeImport" style="display:none;">
+            <s:if test="customTheme">
+                <p>
+                    <span class="warning"><s:text name="themeEditor.importWarning" /></span>
+                </p>
+            </s:if>
+            
+            <p>
+                <s:select id="customSelector" name="importThemeId" list="themes" listKey="id" listValue="name" size="1" onchange="previewImage($('customPreviewImg'), this[selectedIndex].value)"/>
+            </p>
+            <p>
+                <img id="customPreviewImg" src="" />
+                <!-- initialize preview image at page load -->
+                <script type="text/javascript">
                 <s:if test="customTheme">
                     previewImage($('customPreviewImg'), '<s:property value="themes[0].id"/>');
                 </s:if>
                 <s:else>
                     previewImage($('customPreviewImg'), '<s:property value="themeId"/>');
                 </s:else>
-            </script>
-        </p>
-        <p>
-            &raquo; <a href="#" onclick="fullPreview($('customSelector'))"><s:text name="themeEditor.previewLink" /></a><br/>
-            <s:text name="themeEditor.previewDescription" />
-        </p>
+                </script>
+            </p>
+            <p>
+                &raquo; <a href="#" onclick="fullPreview($('customSelector'))"><s:text name="themeEditor.previewLink" /></a><br/>
+                <s:text name="themeEditor.previewDescription" />
+            </p>
+        </div>
+        
         <p><s:submit key="themeEditor.save" /></p>
     </div>
     
 </s:form>
 
-<%-- initializes the chooser/optioner display at page load time --%>
+<%-- initializes the chooser/optioner/themeImport display at page load time --%>
 <script type="text/javascript">
     <s:if test="customTheme">
         updateThemeChooser($('customRadio'));
@@ -154,4 +187,8 @@
     <s:else>
         updateThemeChooser($('sharedRadio'));
     </s:else>
+    
+    <s:if test="firstCustomization">
+        $('themeImport').show();
+    </s:if>
 </script>

Modified: roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css?view=diff&rev=545328&r1=545327&r2=545328
==============================================================================
--- roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css (original)
+++ roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css Thu Jun  7 14:57:12 2007
@@ -733,3 +733,9 @@
 .optioner {
   margin: 0px 30px 30px 30px;
 }
+
+#themeImport {
+  width: 85%;
+  margin-left: auto;
+  margin-right: auto;
+}