roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r540634 - in /roller/trunk: src/org/apache/roller/pojos/wrapper/ src/org/apache/roller/ui/authoring/struts2/ web/WEB-INF/ web/WEB-INF/classes/ web/WEB-INF/jsps/authoring/struts2/
Date Tue, 22 May 2007 16:22:16 GMT
Author: agilliland
Date: Tue May 22 09:22:15 2007
New Revision: 540634

URL: http://svn.apache.org/viewvc?view=rev&rev=540634
Log:
new stylesheet editor page and adding new menu tab for 'design' which holds pages relevant
to weblog design.


Added:
    roller/trunk/src/org/apache/roller/ui/authoring/struts2/StylesheetEdit.java
    roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEdit.jsp
    roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEditError.jsp
Modified:
    roller/trunk/src/org/apache/roller/pojos/wrapper/WebsiteDataWrapper.java
    roller/trunk/src/org/apache/roller/ui/authoring/struts2/editor-menu.xml
    roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
    roller/trunk/web/WEB-INF/classes/struts.xml
    roller/trunk/web/WEB-INF/tiles.xml

Modified: roller/trunk/src/org/apache/roller/pojos/wrapper/WebsiteDataWrapper.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/pojos/wrapper/WebsiteDataWrapper.java?view=diff&rev=540634&r1=540633&r2=540634
==============================================================================
--- roller/trunk/src/org/apache/roller/pojos/wrapper/WebsiteDataWrapper.java (original)
+++ roller/trunk/src/org/apache/roller/pojos/wrapper/WebsiteDataWrapper.java Tue May 22 09:22:15
2007
@@ -424,7 +424,7 @@
     
     public String getCustomStylesheet() {
         // custom stylesheet comes from the weblog theme
-        return this.pojo.getTheme().getCustomStylesheet();
+        return URLUtilities.getWeblogPageURL(this.pojo, null, this.pojo.getTheme().getCustomStylesheet(),
null, null, null, null, 0, false);
     }
     
     
@@ -440,7 +440,7 @@
             return iconPath;
         } else {
             // otherwise it's just a plain old url
-            return URLUtilities.getWeblogResourceURL(this.pojo, iconPath, true);
+            return URLUtilities.getWeblogResourceURL(this.pojo, iconPath, false);
         }
         
     }

Added: roller/trunk/src/org/apache/roller/ui/authoring/struts2/StylesheetEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/authoring/struts2/StylesheetEdit.java?view=auto&rev=540634
==============================================================================
--- roller/trunk/src/org/apache/roller/ui/authoring/struts2/StylesheetEdit.java (added)
+++ roller/trunk/src/org/apache/roller/ui/authoring/struts2/StylesheetEdit.java Tue May 22
09:22:15 2007
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.authoring.struts2;
+
+import java.util.Date;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.RollerException;
+import org.apache.roller.business.RollerFactory;
+import org.apache.roller.business.UserManager;
+import org.apache.roller.pojos.PermissionsData;
+import org.apache.roller.pojos.WeblogTemplate;
+import org.apache.roller.ui.core.util.struts2.UIAction;
+import org.apache.roller.util.cache.CacheManager;
+
+
+/**
+ * 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;
+    
+    
+    public StylesheetEdit() {
+        this.actionName = "stylesheetEdit";
+        this.desiredMenu = "editor";
+        this.pageTitle = "stylesheetEdit.title";
+    }
+    
+    
+    @Override
+    public short requiredWeblogPermissions() {
+        return PermissionsData.ADMIN;
+    }
+    
+    
+    public void myPrepare() {
+        String stylesheetPath = getActionWeblog().getTheme().getCustomStylesheet();
+        log.debug("custom stylesheet path is - "+stylesheetPath);
+        
+        if(stylesheetPath != null) {
+            try {
+                UserManager mgr = RollerFactory.getRoller().getUserManager();
+                setTemplate(mgr.getPageByLink(getActionWeblog(), stylesheetPath));
+                
+                if(getTemplate() == null) {
+                    log.debug("custom stylesheet not found, creating it");
+                    // template doesn't exist yet, so create it
+                    WeblogTemplate stylesheet = new WeblogTemplate();
+                    stylesheet.setWebsite(getActionWeblog());
+                    stylesheet.setAction(stylesheet.ACTION_CUSTOM);
+                    stylesheet.setName(stylesheetPath);
+                    stylesheet.setDescription(stylesheetPath);
+                    stylesheet.setLink(stylesheetPath);
+                    stylesheet.setContents("");
+                    stylesheet.setHidden(false);
+                    stylesheet.setNavbar(false);
+                    stylesheet.setLastModified(new Date());
+                    
+                    // all templates start out as velocity templates
+                    stylesheet.setTemplateLanguage("velocity");
+                    
+                    mgr.savePage(stylesheet);
+                    RollerFactory.getRoller().flush();
+                }
+            } catch (RollerException 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;
+        }
+        
+        setContents(getTemplate().getContents());
+        
+        return SUCCESS;
+    }
+    
+    
+    /**
+     * Save an existing template.
+     */
+    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());
+            stylesheet.setContents(getContents());
+            
+            // save template and flush
+            UserManager mgr = RollerFactory.getRoller().getUserManager();
+            mgr.savePage(stylesheet);
+            RollerFactory.getRoller().flush();
+            
+            // notify caches
+            CacheManager.invalidate(stylesheet);
+            
+            // success message
+            addMessage("pageForm.save.success", stylesheet.getName());
+            
+        } catch (RollerException ex) {
+            log.error("Error updating stylesheet template for weblog - "+getActionWeblog().getHandle(),
ex);
+            // TODO: i18n
+            addError("Error saving template");
+        }
+        
+        return SUCCESS;
+    }
+
+    
+    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;
+    }
+    
+}

Modified: roller/trunk/src/org/apache/roller/ui/authoring/struts2/editor-menu.xml
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/authoring/struts2/editor-menu.xml?view=diff&rev=540634&r1=540633&r2=540634
==============================================================================
--- roller/trunk/src/org/apache/roller/ui/authoring/struts2/editor-menu.xml (original)
+++ roller/trunk/src/org/apache/roller/ui/authoring/struts2/editor-menu.xml Tue May 22 09:22:15
2007
@@ -64,24 +64,35 @@
                    enabledProperty="referrers.processing.enabled" />
     </menu>
     
-    <menu name="tabbedmenu.website" perms="admin" roles="editor">
-        
-        <menu-item action="weblogConfig"       
-                   name="tabbedmenu.website.settings" 
-                   roles="editor"
-                   perms="admin" 
-                   subactions="weblogRemove" />
+    
+    <menu name="tabbedmenu.design" perms="admin" roles="editor">
         
         <menu-item action="themeEdit"         
                    name="tabbedmenu.website.themes" 
                    roles="editor"
                    perms="admin" />
         
+        <menu-item action="stylesheetEdit"         
+                   name="tabbedmenu.design.stylesheet" 
+                   roles="editor"
+                   perms="admin" />
+                   
         <menu-item action="templates"         
                    name="tabbedmenu.website.pages" 
                    roles="editor"
                    perms="admin" 
                    subactions="templateAdd,templateEdit,templateRemove" />
+                   
+    </menu>
+    
+    
+    <menu name="tabbedmenu.website" perms="admin" roles="editor">
+        
+        <menu-item action="weblogConfig"       
+                   name="tabbedmenu.website.settings" 
+                   roles="editor"
+                   perms="admin" 
+                   subactions="weblogRemove" />
         
         <menu-item action="members" 
                    name="tabbedmenu.website.members" 

Modified: roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties?view=diff&rev=540634&r1=540633&r2=540634
==============================================================================
--- roller/trunk/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ roller/trunk/web/WEB-INF/classes/ApplicationResources.properties Tue May 22 09:22:15 2007
@@ -1214,6 +1214,18 @@
 statCount.weblogEntryCommentCountType=Weblog entry comment count
 statCount.weblogDayHits=Today's hit count
 
+# ------------------------------------------------------------------ Stylesheet Editor
+
+stylesheetEdit.title=Stylesheet
+stylesheetEdit.subtitle=Edit weblog custom stylesheet
+stylesheetEdit.tip=This form allows you to edit the custom stylesheet for your \
+weblog so that you can easily alter the css styling of your weblog theme.
+stylesheetEdit.save=Save
+
+stylesheetEdit.noStylesheetOverride=Sorry, but the theme you are using does not \
+provide a custom stylesheet for you to edit.  lame huh?  feel free to complain \
+about it to your system administrator.
+
 # ------------------------------------------------------------------ Tabbed Menu
 
 tabbedmenu.main=Main
@@ -1230,6 +1242,9 @@
 tabbedmenu.bookmarks.import=Import
 tabbedmenu.weblog.referers=Referrers
 tabbedmenu.website.files=File Uploads
+
+tabbedmenu.design=Design
+tabbedmenu.design.stylesheet=Stylesheet
 
 tabbedmenu.website=Preferences
 tabbedmenu.website.settings=Settings

Modified: roller/trunk/web/WEB-INF/classes/struts.xml
URL: http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/classes/struts.xml?view=diff&rev=540634&r1=540633&r2=540634
==============================================================================
--- roller/trunk/web/WEB-INF/classes/struts.xml (original)
+++ roller/trunk/web/WEB-INF/classes/struts.xml Tue May 22 09:22:15 2007
@@ -328,6 +328,12 @@
             <result name="success" type="tiles">.ThemeEdit</result>
         </action>
         
+        <action name="stylesheetEdit!*" method="{1}"
+                class="org.apache.roller.ui.authoring.struts2.StylesheetEdit">
+            <result name="success" type="tiles">.StylesheetEdit</result>
+            <result name="error" type="tiles">.StylesheetEditError</result>
+        </action>
+        
         <action name="templates!*" method="{1}"
                 class="org.apache.roller.ui.authoring.struts2.Templates">
             <result name="list" type="tiles">.Templates</result>

Added: roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEdit.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEdit.jsp?view=auto&rev=540634
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEdit.jsp (added)
+++ roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEdit.jsp Tue May 22 09:22:15
2007
@@ -0,0 +1,67 @@
+<%--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  The ASF licenses this file to You
+  under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.  For additional information regarding
+  copyright in this work, please see the NOTICE file in the top level
+  directory of this distribution.
+--%>
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+
+<p class="subtitle"><s:text name="stylesheetEdit.subtitle" /></p>
+
+<p class="pagetip"><s:text name="stylesheetEdit.tip" /></p>
+                
+<s:form action="stylesheetEdit!save">
+    <s:hidden name="weblog" />
+    
+    <%-- ================================================================== --%>
+    <%-- Template editing area w/resize buttons --%>
+    
+    <br />
+    <s:textarea name="contents" cols="80" rows="30" cssStyle="width:100%" />
+    
+    <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);
+        }
+    // --></script>
+    <table style="width:100%">
+        <tr>
+            <td>
+                <s:submit key="stylesheetEdit.save" />
+            </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)" />
+            </td>
+        </tr>
+    </table>
+    
+</s:form>

Added: roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEditError.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEditError.jsp?view=auto&rev=540634
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEditError.jsp (added)
+++ roller/trunk/web/WEB-INF/jsps/authoring/struts2/StylesheetEditError.jsp Tue May 22 09:22:15
2007
@@ -0,0 +1,22 @@
+<%--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  The ASF licenses this file to You
+  under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.  For additional information regarding
+  copyright in this work, please see the NOTICE file in the top level
+  directory of this distribution.
+--%>
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+
+<p class="subtitle"><s:text name="stylesheetEdit.subtitle" /></p>
+
+<p class="pagetip"><s:text name="stylesheetEdit.noStylesheetOverride" /></p>

Modified: roller/trunk/web/WEB-INF/tiles.xml
URL: http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/tiles.xml?view=diff&rev=540634&r1=540633&r2=540634
==============================================================================
--- roller/trunk/web/WEB-INF/tiles.xml (original)
+++ roller/trunk/web/WEB-INF/tiles.xml Tue May 22 09:22:15 2007
@@ -274,6 +274,16 @@
         <put name="content" value="/WEB-INF/jsps/authoring/struts2/ThemeEdit.jsp" />
     </definition>
     
+    <definition name=".StylesheetEdit" extends=".tiles-tabbedpage"  >
+        <put name="content" value="/WEB-INF/jsps/authoring/struts2/StylesheetEdit.jsp"
/>
+        <put name="styles" value="/WEB-INF/jsps/tiles/struts2/css-nosidebar.jsp" />
+    </definition>
+    
+    <definition name=".StylesheetEditError" extends=".tiles-tabbedpage"  >
+        <put name="content" value="/WEB-INF/jsps/authoring/struts2/StylesheetEditError.jsp"
/>
+        <put name="styles" value="/WEB-INF/jsps/tiles/struts2/css-nosidebar.jsp" />
+    </definition>
+    
     <definition name=".Templates" extends=".tiles-tabbedpage"  >
         <put name="content" value="/WEB-INF/jsps/authoring/struts2/Templates.jsp" />
         <put name="sidebar" value="/WEB-INF/jsps/authoring/struts2/TemplatesSidebar.jsp"
/>



Mime
View raw message