roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r522109 - in /incubator/roller/trunk: src/org/apache/roller/ui/authoring/struts/actions/ web/WEB-INF/classes/ web/WEB-INF/jsps/authoring/
Date Sat, 24 Mar 2007 21:48:13 GMT
Author: agilliland
Date: Sat Mar 24 14:48:12 2007
New Revision: 522109

URL: http://svn.apache.org/viewvc?view=rev&rev=522109
Log:
a little cleanup in templates UI for supporting templates by action.


Modified:
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java
    incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-pages-sidebar.jsp

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java?view=diff&rev=522109&r1=522108&r2=522109
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java
Sat Mar 24 14:48:12 2007
@@ -20,7 +20,10 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
 import java.util.ResourceBundle;
 
@@ -36,12 +39,12 @@
 import org.apache.roller.business.RollerFactory;
 import org.apache.roller.business.UserManager;
 import org.apache.roller.config.RollerConfig;
+import org.apache.roller.pojos.Theme;
 import org.apache.roller.pojos.UserData;
 import org.apache.roller.pojos.WeblogTemplate;
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.ui.authoring.struts.formbeans.WeblogTemplateFormEx;
 import org.apache.roller.ui.core.BasePageModel;
-import org.apache.roller.ui.core.RollerContext;
 import org.apache.roller.ui.core.RollerRequest;
 import org.apache.roller.ui.core.RollerSession;
 import org.apache.roller.util.Utilities;
@@ -107,11 +110,15 @@
                 WeblogTemplate page = new WeblogTemplate();
                 form.copyTo(page, request.getLocale());
                 page.setWebsite(website);
-                page.setAction(WeblogTemplate.ACTION_CUSTOM);
                 page.setLastModified( new Date() );
                 page.setDescription(page.getName());
                 page.setContents(bundle.getString("pageForm.newTemplateContent"));
                 
+                // if no action specified then it's a custom page
+                if(page.getAction() == null) {
+                    page.setAction(WeblogTemplate.ACTION_CUSTOM);
+                }
+                
                 validateLink(page);
                 
                 // all templates start out as velocity templates
@@ -146,6 +153,9 @@
                 request.setAttribute("model",
                     new WeblogTemplateFormModel("pagesForm.title", request, response, mapping,
page));
                 
+                // TODO: when a new template is successfully added then we should
+                // take the user directly to edit that new page
+                
             } else {
                 forward = mapping.findForward("access-denied");
             }
@@ -218,8 +228,31 @@
                 website = template.getWebsite();
             }
             
-            request.setAttribute("model", 
-                new WeblogTemplateFormModel("pagesForm.title", request, response, mapping,
null));
+            WeblogTemplateFormModel model = 
+                    new WeblogTemplateFormModel("pagesForm.title", request, response, mapping,
null);
+            request.setAttribute("model", model);
+            
+            List availableActions = new ArrayList();
+            availableActions.add(WeblogTemplate.ACTION_CUSTOM);
+            
+            if(Theme.CUSTOM.equals(website.getEditorTheme())) {
+                // if the weblog is using a custom theme then determine which
+                // action templates are still available to be created
+                availableActions.add(WeblogTemplate.ACTION_PERMALINK);
+                availableActions.add(WeblogTemplate.ACTION_SEARCH);
+                availableActions.add(WeblogTemplate.ACTION_WEBLOG);
+                
+                WeblogTemplate tmpPage = null;
+                Iterator pagesIter = model.getPages().iterator();
+                while(pagesIter.hasNext()) {
+                    tmpPage = (WeblogTemplate) pagesIter.next();
+                    
+                    if(!WeblogTemplate.ACTION_CUSTOM.equals(tmpPage.getAction())) {
+                        availableActions.remove(tmpPage.getAction());
+                    }
+                }
+            }
+            request.setAttribute("availableActions", availableActions);
             
             if (!rses.isUserAuthorizedToAdmin(website)) {
                 forward = mapping.findForward("access-denied");
@@ -434,7 +467,7 @@
         private WeblogTemplate page;
         private List           pages;
         private List           languages = new ArrayList();
-
+        
         public WeblogTemplateFormModel(
                 String titleKey,
                 HttpServletRequest request,
@@ -456,7 +489,7 @@
  
             this.setUser(rses.getAuthenticatedUser());        
             this.setPages(mgr.getPages(getWebsite()));
-            this.setPage(page); 
+            this.setPage(page);
             
             if (page != null) {
                 String langs = RollerConfig.getProperty("rendering.templateLanguages","velocity");

Modified: incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties?view=diff&rev=522109&r1=522108&r2=522109
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties Sat Mar 24
14:48:12 2007
@@ -887,6 +887,7 @@
 
 pageForm.advancedSettings=Advanced Settings
 pagesForm.name=Name
+pagesForm.action=Action
 pagesForm.link=Link
 pagesForm.description=Description
 pagesForm.edit=Edit

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp?view=diff&rev=522109&r1=522108&r2=522109
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp Sat Mar 24 14:48:12 2007
@@ -38,6 +38,7 @@
     <html:hidden property="id"/>
     <html:hidden property="decoratorName" />
     <html:hidden property="required" />
+    <html:hidden property="action" />
     <input type="hidden" name="method" value="update" />
     <input type="hidden" name="weblog" value='<c:out value="${model.website.handle}"
/>' />
     
@@ -276,19 +277,6 @@
                             </tr>
                         </c:otherwise>
                     </c:choose>
-                </td>
-                <td class="description"></td>
-            </tr>
-            
-            <tr>
-                <td class="field">
-                            <tr>
-                                <td class="label"><fmt:message key="pageForm.action"
/>&nbsp;</td>
-                                <td class="field">
-                                    <html:text property="action" size="30" />
-                                </td>
-                                <td class="description"></td>
-                            </tr>
                 </td>
                 <td class="description"></td>
             </tr>

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-pages-sidebar.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-pages-sidebar.jsp?view=diff&rev=522109&r1=522108&r2=522109
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-pages-sidebar.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-pages-sidebar.jsp Sat Mar 24 14:48:12
2007
@@ -26,10 +26,31 @@
              <hr size="1" noshade="noshade" />
              
              <html:form action="/roller-ui/authoring/page" method="post" focus="name">
-
-                <fmt:message key="pagesForm.name"/>: <input type="text" name="name"
size="12" />
-
-                <input type="submit" value='<fmt:message key="pagesForm.add" />'
/>
+                 <table cellpadding="0" cellspacing="0">
+                     <tr>
+                         <td><fmt:message key="pagesForm.name"/>:</td>
+                         <td><input type="text" name="name" size="12" /></td>
+                     </tr>
+                     
+                     <c:if test="${ not empty availableActions }" >
+                         <tr>
+                             <td><fmt:message key="pagesForm.action"/>:</td>
+                             <td>
+                                 <html:select property="action">
+                                     <c:forEach var="act" items="${availableActions}">
+                                         <option value="<c:out value="${act}"/>"><c:out
value="${act}"/></option>
+                                     </c:forEach>
+                                 </html:select>
+                             </td>
+                         </tr>
+                     </c:if>
+                     
+                     <tr>
+                         <td></td>
+                         <td><input type="submit" value='<fmt:message key="pagesForm.add"
/>' /></td>
+                     </tr>
+                 </table>
+                
                 <input type="hidden" name="weblog" value='<c:out value="${model.website.handle}"
/>' />
                 <html:hidden property="method" value="add"/>
 



Mime
View raw message