Author: agilliland
Date: Tue May 22 09:27:24 2007
New Revision: 540639

URL: http://svn.apache.org/viewvc?view=rev&rev=540639
Log:
some changes to theme selection page.  a work in progress :/


Modified:
    roller/trunk/src/org/apache/roller/ui/authoring/struts2/ThemeEdit.java
    roller/trunk/web/WEB-INF/jsps/authoring/struts2/ThemeEdit.jsp

Modified: roller/trunk/src/org/apache/roller/ui/authoring/struts2/ThemeEdit.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/authoring/struts2/ThemeEdit.java?view=diff&rev=540639&r1=540638&r2=540639
==============================================================================
--- roller/trunk/src/org/apache/roller/ui/authoring/struts2/ThemeEdit.java 
(original)
+++ roller/trunk/src/org/apache/roller/ui/authoring/struts2/ThemeEdit.java Tue 
May 22 09:27:24 2007
@@ -51,6 +51,9 @@
     // list of available themes
     private List themes = Collections.EMPTY_LIST;
     
+    // type of theme desired, either 'shared' or 'custom'
+    private String themeType = null;
+    
     // the chosen theme on a save() or customize()
     private String themeId = null;
     
@@ -62,7 +65,6 @@
     }
     
     
-    // must be a weblog admin to use this action
     public short requiredWeblogPermissions() {
         return PermissionsData.ADMIN;
     }
@@ -94,12 +96,8 @@
     
     
     public String execute() {
-        try {
-            // set theme to current value
-            setThemeId(getActionWeblog().getTheme().getId());
-        } catch (Exception ex) {
-            log.error("Error getting theme for weblog - 
"+getActionWeblog().getHandle(), ex);
-        }
+        // set theme to current value
+        setThemeId(getActionWeblog().getTheme().getId());
         
         return SUCCESS;
     }
@@ -118,14 +116,20 @@
             try {
                 WebsiteData weblog = getActionWeblog();
                 
-                weblog.setEditorTheme(getThemeId());
+                if(WeblogTheme.CUSTOM.equals(getThemeType())) {
+                    weblog.setEditorTheme(WeblogTheme.CUSTOM);
+                    
+                    log.debug("Saving custom theme for weblog 
"+weblog.getHandle());
+                } else if("shared".equals(getThemeType())) {
+                    weblog.setEditorTheme(getThemeId());
+                    
+                    log.debug("Saving theme "+getThemeId()+" for weblog 
"+weblog.getHandle());
+                }
                 
                 UserManager userMgr = 
RollerFactory.getRoller().getUserManager();
                 userMgr.saveWebsite(weblog);
                 RollerFactory.getRoller().flush();
                 
-                log.debug("Saved theme "+getThemeId()+" for weblog 
"+weblog.getHandle());
-                
                 // make sure to flush the page cache so ppl can see the change
                 CacheManager.invalidate(weblog);
                 
@@ -226,6 +230,14 @@
         this.themes = themes;
     }
 
+    public String getThemeType() {
+        return themeType;
+    }
+
+    public void setThemeType(String themeType) {
+        this.themeType = themeType;
+    }
+    
     public String getThemeId() {
         return themeId;
     }

Modified: roller/trunk/web/WEB-INF/jsps/authoring/struts2/ThemeEdit.jsp
URL: 
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/authoring/struts2/ThemeEdit.jsp?view=diff&rev=540639&r1=540638&r2=540639
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/authoring/struts2/ThemeEdit.jsp (original)
+++ roller/trunk/web/WEB-INF/jsps/authoring/struts2/ThemeEdit.jsp Tue May 22 
09:27:24 2007
@@ -19,13 +19,19 @@
 
 <script type="text/javascript">
 <!--
-function previewImage(theme) {
-    document.preview.src="<s:property value="siteURL" />/themes/" + theme + 
"/sm-theme-" + theme + ".png";
+function previewImage(element, theme) {
+    element.src="<s:property value="siteURL" />/themes/" + theme + 
"/sm-theme-" + theme + ".png";
 }
 
 function fullPreview() {
-    selected=document.themes.themeId.selectedIndex;
-    window.open('<s:url 
value="/roller-ui/authoring/preview/%{actionWeblog.handle}"/>?theme='+document.themes.themeId.options[selected].value,
 '_preview', '');
+    selected=document.getElementById('themeEdit_themeId').selectedIndex;
+    window.open('<s:url 
value="/roller-ui/authoring/preview/%{actionWeblog.handle}"/>?theme='+document.getElementById('themeEdit_themeId').options[selected].value,
 '_preview', '');
+}
+
+function toggleThemeOptioner() {
+    // just call toggle on both theme optioner choices
+    new Effect.toggle('sharedThemeOptioner', 'appear');
+    new Effect.toggle('customThemeOptioner', 'appear');
 }
 -->
 </script>
@@ -44,17 +50,78 @@
     
     <p><s:text name="themeEditor.yourCurrentTheme" />: <b><s:property 
value="actionWeblog.theme.name"/></b></p>
     
-    <p>
-        <s:select name="themeId" list="themes" listKey="id" listValue="name" 
size="1" onchange="previewImage(this[selectedIndex].value)"/>
-        <input type="button" value="<s:text name="weblogEdit.fullPreviewMode" 
/>" onclick="fullPreview()" />
-    </p>
-    <p>
-        <img name="preview" src="" />
-        <!-- initialize preview image at page load -->
-        <script type="text/javascript">
-            previewImage('<s:property value="actionWeblog.theme.id"/>');
-        </script>
-    </p>
-    <p><s:submit key="themeEditor.save" /></p>
+    <table width="85%">
+        <tr>
+            <td>
+                <s:if test="actionWeblog.theme.id == 'custom'">
+                    <input type="radio" name="themeType" value="shared" 
onchange="toggleThemeOptioner()" />Shared Theme<br/>
+                </s:if>
+                <s:else>
+                    <input type="radio" name="themeType" value="shared" 
checked="true" onchange="toggleThemeOptioner()" />Shared Theme<br/>
+                </s:else>
+                This option is for users who don't want to fuss with designing 
their weblog on their own and prefer the easier option of using a predefined 
theme.
+            </td>
+            <td align="right">
+                <input type="radio" name="themeType" value="custom" 
onchange="toggleThemeOptioner()" />Custom Theme<br/>
+                This option is for the creative bloggers who want to be able 
to create a blog design of their own.  Beware though, managing a blog design of 
your own takes a bit of effort.
+            </td>
+        </tr>
+    </table>
+    
+    <s:if test="actionWeblog.theme.id == 'custom'">
+        <div id="sharedThemeOptioner" style="display:none;">
+    </s:if>
+    <s:else>
+        <div id="sharedThemeOptioner">
+    </s:else>
+    <div>
+        <p>
+            <s:select name="themeId" list="themes" listKey="id" 
listValue="name" size="1" 
onchange="previewImage(document.getElementById('previewImg'), 
this[selectedIndex].value)"/>
+        </p>
+        <p>
+            <img id="previewImg" src="" />
+            <!-- initialize preview image at page load -->
+            <script type="text/javascript">
+            previewImage(document.getElementById('previewImg'), '<s:property 
value="themeId"/>');
+            </script>
+        </p>
+        <p>
+            &raquo; <a href="#" onclick="fullPreview()">See how your blog will 
look with this theme.</a><br/>
+            How can you know if this is really the theme for you until you see 
it on your blog right?  Click the link above to launch a full page preview of 
how your blog will look with the selected theme.
+        </p>
+        <s:if test="actionWeblog.theme.customStylesheet != null">
+            <p>
+                <s:url action="stylesheetEdit" id="stylesheetEdit" >
+                    <s:param name="weblog" value="%{actionWeblog.handle}" />
+                </s:url>
+                &raquo; <s:a href="%{stylesheetEdit}">Modify the styling of 
your selected theme.</s:a><br/>
+                If you are happy with your theme but want to make a few 
styling choices of your own such as choosing different fonts, colors, etc, then 
try making your own stylesheet or borrow one from someoone else using your 
theme.
+            </p>
+        </s:if>
+        <p><s:submit key="themeEditor.save" /></p>
+    </div>
+    </div>
+    
+    <s:if test="actionWeblog.theme.id == 'custom'">
+        <div id="customThemeOptioner">
+    </s:if>
+    <s:else>
+        <div id="customThemeOptioner" style="display:none;">
+    </s:else>
+    <div>
+        <p>
+            <s:select name="customizeThemeId" list="themes" listKey="id" 
listValue="name" size="1" 
onchange="previewImage(document.getElementById('customizePreviewImg'), 
this[selectedIndex].value)"/>
+            <input type="button" value="<s:text 
name="weblogEdit.fullPreviewMode" />" onclick="fullPreview()" />
+        </p>
+        <p>
+            <img id="customizePreviewImg" src="" />
+            <!-- initialize preview image at page load -->
+            <script type="text/javascript">
+            previewImage(document.getElementById('customizePreviewImg'), 
'<s:property value="actionWeblog.theme.id"/>');
+            </script>
+        </p>
+        <p><s:submit key="themeEditor.save" /></p>
+    </div>
+    </div>
     
 </s:form>


Reply via email to