roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r820143 - in /roller/trunk: apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/ apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/ apps/weblogger/web/WEB-INF/ apps/weblogger/web/WEB-INF/classes/ apps/webl...
Date Wed, 30 Sep 2009 01:38:49 GMT
Author: snoopdave
Date: Wed Sep 30 01:38:48 2009
New Revision: 820143

URL: http://svn.apache.org/viewvc?rev=820143&view=rev
Log:
Fix for ROL-1304 "Set frontpage blog in Roller install page"

I used most of the code from Vivien's patch (thanks!) but did things a little differently.
Instead of having a separate Frontpage Config page, I added the Weblog picker an aggregation
checkbox right into the Setup page. I also fixed the Global Config page to use a combo-box
instead of requiring the user to type a weblog handle.

Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Setup.java
    roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
    roller/trunk/apps/weblogger/web/WEB-INF/classes/struts.xml
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/admin/GlobalConfig.jsp
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/core/Setup.jsp
    roller/trunk/apps/weblogger/web/WEB-INF/tiles.xml
    roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css
    roller/trunk/tools/lib/taglibs-string.jar

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java?rev=820143&r1=820142&r2=820143&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
Wed Sep 30 01:38:48 2009
@@ -18,6 +18,7 @@
 
 package org.apache.roller.weblogger.ui.struts2.admin;
 
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -29,6 +30,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.PropertiesManager;
+import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.plugins.PluginManager;
 import org.apache.roller.weblogger.business.plugins.comment.WeblogEntryCommentPlugin;
@@ -37,6 +39,7 @@
 import org.apache.roller.weblogger.config.runtime.RuntimeConfigDefs;
 import org.apache.roller.weblogger.pojos.GlobalPermission;
 import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
+import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.struts2.interceptor.ParameterAware;
 import org.apache.struts2.interceptor.ServletRequestAware;
@@ -68,7 +71,10 @@
     // GET on the GlobalConfig!save URL and thus sets all checkboxes to false
     private String httpMethod = "GET";
 
+    // weblogs for frontpage blog chooser
+    private Collection<Weblog> weblogs;
 
+    
     public GlobalConfig() {
         this.actionName = "globalConfig";
         this.desiredMenu = "admin";
@@ -102,6 +108,14 @@
             addError("Unexpected error accessing Roller properties");
         }
         
+        try {
+            WeblogManager mgr =  WebloggerFactory.getWeblogger().getWeblogManager();
+            setWeblogs(mgr.getWeblogs(true, null, null, null, 0, -1));
+        } catch (WebloggerException ex) {
+            log.error("Error getting weblogs", ex);
+            addError("frontpageConfig.weblogs.error");
+        }
+
         // set config def used to draw the view
         RuntimeConfigDefs defs = WebloggerRuntimeConfig.getRuntimeConfigDefs();
         List<ConfigDef> configDefs = defs.getConfigDefs();
@@ -260,4 +274,11 @@
         httpMethod = req.getMethod();
     }
     
+    public Collection<Weblog> getWeblogs() {
+        return weblogs;
+    }
+
+    public void setWeblogs(Collection<Weblog> weblogs) {
+        this.weblogs = weblogs;
+    }
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Setup.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Setup.java?rev=820143&r1=820142&r2=820143&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Setup.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Setup.java
Wed Sep 30 01:38:48 2009
@@ -18,11 +18,15 @@
 
 package org.apache.roller.weblogger.ui.struts2.core;
 
+import java.util.Collection;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.PropertiesManager;
+import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.business.UserManager;
+import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
+import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 
 
@@ -35,6 +39,13 @@
     
     private long userCount = 0;
     private long blogCount = 0;
+
+    private String frontpageBlog;
+    private Boolean aggregated;
+
+    // weblogs for frontpage blog chooser
+    private Collection<Weblog> weblogs;
+
     
     
     public Setup() {
@@ -57,6 +68,14 @@
     public String execute() {
         
         try {
+            WeblogManager mgr =  WebloggerFactory.getWeblogger().getWeblogManager();
+            setWeblogs(mgr.getWeblogs(true, null, null, null, 0, -1));
+        } catch (WebloggerException ex) {
+            log.error("Error getting weblogs", ex);
+            addError("frontpageConfig.weblogs.error");
+        }
+
+        try {
             setUserCount(WebloggerFactory.getWeblogger().getUserManager().getUserCount());
             setBlogCount(WebloggerFactory.getWeblogger().getWeblogManager().getWeblogCount());
         } catch (WebloggerException ex) {
@@ -66,6 +85,27 @@
         return SUCCESS;
     }
 
+    public String save() {
+        PropertiesManager mgr = WebloggerFactory.getWeblogger().getPropertiesManager();
+        try {
+            RuntimeConfigProperty frontpageBlogProp = mgr.getProperty("site.frontpage.weblog.handle");
+            frontpageBlogProp.setValue(frontpageBlog);
+            mgr.saveProperty(frontpageBlogProp);
+
+            RuntimeConfigProperty aggregatedProp = mgr.getProperty("site.frontpage.weblog.aggregated");
+            aggregatedProp.setValue(aggregated.toString());
+            mgr.saveProperty(aggregatedProp);
+
+            WebloggerFactory.getWeblogger().flush();
+
+            addMessage("frontpageConfig.values.saved");
+
+        } catch (WebloggerException ex) {
+            log.error("ERROR saving frontpage configuration", ex);
+            addError("frontpageConfig.values.error");
+        }
+        return "home";
+    }
     
     public long getUserCount() {
         return userCount;
@@ -82,5 +122,28 @@
     public void setBlogCount(long blogCount) {
         this.blogCount = blogCount;
     }
+
+    public Collection<Weblog> getWeblogs() {
+        return weblogs;
+    }
+
+    public void setWeblogs(Collection<Weblog> weblogs) {
+        this.weblogs = weblogs;
+    }
     
+    public String getFrontpageBlog() {
+        return frontpageBlog;
+    }
+
+    public void setFrontpageBlog(String frontpageBlog) {
+        this.frontpageBlog = frontpageBlog;
+    }
+
+    public Boolean getAggregated() {
+        return aggregated;
+    }
+
+    public void setAggregated(Boolean aggregated) {
+        this.aggregated = aggregated;
+    }
 }

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?rev=820143&r1=820142&r2=820143&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties Wed Sep
30 01:38:48 2009
@@ -351,12 +351,13 @@
 configForm.siteName=Site Name (for main page and RSS feed)
 configForm.shortName=Short name (shown in site banner)
 configForm.siteDescription=Site Description (for main page and RSS feed)
-configForm.frontpageWeblogHandle=Handle of weblog to serve as frontpage blog
+configForm.frontpageWeblogHandle=Weblog to serve as frontpage blog
 configForm.frontpageWeblogAggregated=Enable aggregated site-wide frontpage
 configForm.siteAdminEmail=Site Administrator''s email address
 configForm.absoluteUrl=Absolute URL to site (if required)
 configForm.suspendPingProcessing=Suspend all ping processing?
 configForm.allowUserWeblogCreation=Allow users to create new weblogs?
+configForm.none=None specified
 
 configForm.userSettings=User Settings
 configForm.accountActivation=Require new users to activate accounts via email
@@ -676,13 +677,16 @@
    
 index.setFrontpage=Designate a frontpage weblog
 index.setFrontpageHelp=\
-You must specify a weblog to serve as the frontpage of your Roller site. \
-You can do this by going to the <b>Server Admin->Configuration</b> page. \
-In the field labelled "Handle of the weblog to server as the frontpage" enter \
-the handle of the weblog you want to front your site. Once you''re done \
-you won''t see this irritating page any longer.
-index.setFrontpageBy=Designate a frontpage weblog on the
-index.setFrontpagePage=Server Admin Page
+You must specify a weblog to serve as the front page weblog, you can do this \
+via the <b>Server Admin->Configuration</b> page or the form that will appear
\
+below once you have created at least one weblog.
+
+frontpageConfig.frontpageBlogName=Name of weblog to serve as frontpage blog
+frontpageConfig.frontpageAgregated=Enable aggregated site-wide frontpage
+frontpageConfig.save=Save
+frontpageConfig.values.saved=Properties successfully saved
+frontpageConfig.values.error=Error saving properties
+frontpageConfig.weblogs.error=Unexpected error accessing Weblogs
 
 # ------------------------------------------------------ Invitations management
 

Modified: roller/trunk/apps/weblogger/web/WEB-INF/classes/struts.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/classes/struts.xml?rev=820143&r1=820142&r2=820143&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/classes/struts.xml (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/classes/struts.xml Wed Sep 30 01:38:48 2009
@@ -87,6 +87,7 @@
         <action name="setup"
                 class="org.apache.roller.weblogger.ui.struts2.core.Setup">
             <result name="success" type="tiles">.Setup</result>
+            <result name="home" type="redirectAction">home</result>
         </action>
                         
         <action name="login"
@@ -154,7 +155,7 @@
                 class="org.apache.roller.weblogger.ui.struts2.admin.GlobalConfig">
             <result name="success" type="tiles">.GlobalConfig</result>
         </action>
-        
+               
         <action name="userAdmin"
                 class="org.apache.roller.weblogger.ui.struts2.admin.UserAdmin">
             <result name="success" type="tiles">.UserAdmin</result>

Modified: roller/trunk/apps/weblogger/web/WEB-INF/jsps/admin/GlobalConfig.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/jsps/admin/GlobalConfig.jsp?rev=820143&r1=820142&r2=820143&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/jsps/admin/GlobalConfig.jsp (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/jsps/admin/GlobalConfig.jsp Wed Sep 30 01:38:48
2009
@@ -37,34 +37,58 @@
                 
                   <%-- special condition for comment plugins --%>
                   <s:if test="#pd.name == 'users.comments.plugins'">
-                      <td class="field"><s:checkboxlist theme="roller" list="pluginsList"
name="commentPlugins" listKey="id" listValue="name" /></td>
+                      <td class="field"><s:checkboxlist theme="roller" list="pluginsList"
+                        name="commentPlugins" listKey="id" listValue="name" /></td>
                   </s:if>
-                  
+
+                  <%-- special condition for front page blog --%>
+                  <s:elseif test="#pd.name == 'site.frontpage.weblog.handle'">
+                      <td class="field">
+                          <select name='<s:property value="#pd.name"/>'>
+                                <option value=''>
+                                    <s:text name="configForm.none" />
+                                </option>                              <s:iterator
id="weblog" value="weblogs">
+                                <option value='<s:property value="#weblog.handle"/>'
+                                    <s:if test='properties[#pd.name].value == #weblog.handle'>selected='true'</s:if>
>
+                                    <s:property value="#weblog.name"/>
+                                </option>
+                              </s:iterator>
+                          </select>
+                      </td>
+                  </s:elseif>
+
                   <%-- "string" type means use a simple textbox --%>
                   <s:elseif test="#pd.type == 'string'">
-                    <td class="field"><input type="text" name='<s:property value="#pd.name"/>'
value='<s:property value="properties[#pd.name].value"/>' size="35" /></td>
+                    <td class="field"><input type="text" name='<s:property value="#pd.name"/>'
+                        value='<s:property value="properties[#pd.name].value"/>' size="35"
/></td>
                   </s:elseif>
                   
                   <%-- "text" type means use a full textarea --%>
                   <s:elseif test="#pd.type == 'text'">
                     <td class="field">
-                      <textarea name='<s:property value="#pd.name"/>' rows="<s:property
value="#pd.rows"/>" cols="<s:property value="#pd.cols"/>"><s:property value="properties[#pd.name].value"/></textarea>
+                      <textarea name='<s:property value="#pd.name"/>'
+                                rows="<s:property value="#pd.rows"/>"
+                                cols="<s:property value="#pd.cols"/>"><s:property
value="properties[#pd.name].value"/>
+                      </textarea>
                     </td>
                   </s:elseif>
                   
                   <%-- "boolean" type means use a checkbox --%>
                   <s:elseif test="#pd.type == 'boolean'">
                       <s:if test="properties[#pd.name].value == 'true'">
-                          <td class="field"><input type="checkbox" name='<s:property
value="#pd.name"/>' CHECKED></td>
+                          <td class="field"><input type="checkbox" 
+                            name='<s:property value="#pd.name"/>' CHECKED></td>
                       </s:if>
                       <s:else>
-                          <td class="field"><input type="checkbox" name='<s:property
value="#pd.name"/>'></td>
+                          <td class="field"><input type="checkbox"
+                            name='<s:property value="#pd.name"/>'></td>
                       </s:else>
                   </s:elseif>
                   
                   <%-- if it's something we don't understand then use textbox --%>
                   <s:else>
-                    <td class="field"><input type="text" name='<s:property value="#pd.name"/>'
size="50" /></td>
+                    <td class="field"><input type="text"
+                        name='<s:property value="#pd.name"/>' size="50" /></td>
                   </s:else>
                 
                 <td class="description"><%-- <s:text name="" /> --%></td>

Modified: roller/trunk/apps/weblogger/web/WEB-INF/jsps/core/Setup.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/jsps/core/Setup.jsp?rev=820143&r1=820142&r2=820143&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/jsps/core/Setup.jsp (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/jsps/core/Setup.jsp Wed Sep 30 01:38:48 2009
@@ -20,53 +20,86 @@
 <s:text name="index.prompt" /><br /><br />
 <div style="width:75%">
     <ul>
-        <%-- 
+        <%--
                  Tell the user how to complete their Roller install, with helpful
                  notes and links to the appropriate places in the Roller UI.
             --%>
 
         <%-- STEP 1: Create a user if you don't already have one --%>
         <li><b><s:text name="index.createUser" />
-                <s:if test="userCount > 0"> - 
+                <s:if test="userCount > 0"> -
                     <s:text name="index.createUserDone">
                         <s:param value="userCount" />
                     </s:text>
                 </s:if>
             </b><br /><br />
             <s:text name="index.createUserHelp" /><br /><br />
-            <s:text name="index.createUserBy" /> 
+            <s:text name="index.createUserBy" />
             <a href='<s:url action="register"/>'>
                 <s:text name="index.createUserPage" />
             </a>.
             <br /><br /><br />
         </li>
-        
+
         <%-- STEP 2: Create a weblog if you don't already have one --%>
         <li><b><s:text name="index.createWeblog" />
-                <s:if test="blogCount > 0"> - 
+                <s:if test="blogCount > 0"> -
                     <s:text name="index.createWeblogDone">
                         <s:param value="blogCount" />
                     </s:text>
                 </s:if>
             </b><br /><br />
             <s:text name="index.createWeblogHelp" /><br /><br />
-            <s:text name="index.createWeblogBy" /> 
+            <s:text name="index.createWeblogBy" />
             <a href='<s:url action="createWeblog"/>'>
                 <s:text name="index.createWeblogPage" />
             </a>
             <br /><br /><br />
         </li>
-        
+
         <%-- STEP 3: Designate a weblog to be the frontpage weblot --%>
         <li><b><s:text name="index.setFrontpage" /></b><br />
             <br />
             <s:text name="index.setFrontpageHelp" /><br />
             <br />
-            <s:text name="index.setFrontpageBy" /> 
-            <a href='<s:url action="globalConfig" namespace="/roller-ui/admin" />'>
-                <s:text name="index.setFrontpagePage" />
-            </a>
+
+          <s:if test="blogCount > 0">
+            <s:form action="setup!save">
+                <table style="margin-left:2em;width:70%">
+                    <tr>
+                        <td class="label">
+                            <s:text name="frontpageConfig.frontpageBlogName" />
+                        </td>
+                        <td class="field">
+                            <s:select list="weblogs"
+                                      listKey="handle"
+                                      listValue="name"
+                                      name="frontpageBlog"
+                                      value="frontpageBlog" />
+                        </td>
+                    </tr>
+                    <tr>
+                        <td class="label">
+                            <s:text name="frontpageConfig.frontpageAgregated" />
+                            <br /><br />
+                        </td>
+                        <td class="field">
+                            <s:checkbox name="aggregated" value="aggregated" />
+                        </td>
+                    </tr>
+                    <tr>
+                        <td colspan="2" class="label">
+                            <div class="control">
+                                <s:submit key="frontpageConfig.save" />
+                            </div>
+                        </td>
+                    </tr>
+                </table>
+
+            </s:form>
+          </s:if>
+
         </li>
-        
+
     </ul>
 </div>

Modified: roller/trunk/apps/weblogger/web/WEB-INF/tiles.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/tiles.xml?rev=820143&r1=820142&r2=820143&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/tiles.xml (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/tiles.xml Wed Sep 30 01:38:48 2009
@@ -160,6 +160,10 @@
         <put-attribute name="content" value="/WEB-INF/jsps/admin/GlobalConfig.jsp" />
     </definition>
     
+    <definition name=".FrontpageConfig" extends=".tiles-simplepage" >
+        <put-attribute name="content" value="/WEB-INF/jsps/admin/FrontpageConfig.jsp"
/>
+    </definition>
+    
     <definition name=".UserAdmin" extends=".tiles-tabbedpage" >
         <put-attribute name="content" value="/WEB-INF/jsps/admin/UserAdmin.jsp" />
     </definition>

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?rev=820143&r1=820142&r2=820143&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css (original)
+++ roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css Wed Sep 30 01:38:48 2009
@@ -33,6 +33,7 @@
 th, td {
     border: none;
     vertical-align: top;
+    padding: 2px;
 }
 
 a {

Modified: roller/trunk/tools/lib/taglibs-string.jar
URL: http://svn.apache.org/viewvc/roller/trunk/tools/lib/taglibs-string.jar?rev=820143&r1=820142&r2=820143&view=diff
==============================================================================
Binary files - no diff available.



Mime
View raw message