roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r463804 - in /incubator/roller/trunk: ./ src/org/apache/roller/business/ src/org/apache/roller/model/ src/org/apache/roller/ui/authoring/struts/actions/ src/org/apache/roller/ui/core/plugins/ tests/org/apache/roller/business/ web/WEB-INF/cl...
Date Fri, 13 Oct 2006 19:49:31 GMT
Author: agilliland
Date: Fri Oct 13 12:49:30 2006
New Revision: 463804

URL: http://svn.apache.org/viewvc?view=rev&rev=463804
Log:
Adding new interface for defining entry editors.

1. Added new WeblogEntryEditor interface.

  * defined a new interface to represent pluggable entry editors.
  * created implementations for text and xinha editors.
  * added keys for editor names in resource bundle

2. Added accessor methods for entry editors to PluginManager interface.

  * added new methods for getting entry editors in PluginManager.
  * implemented methods in PluginManagerImpl.
  * add new PluginManagerTest unit test.
  * added new properties in roller.properties to define list of configured editors and set
the default editor.

3. Update UI to use new pluggable editors framework.

  * updated Weblog Settings form & jsp to base editor options off of list of configured
editors from PluginManager.getWeblogEntryEditors().
  * updated Entry Edit form & jsp to draw the editor using the values from the new WeblogEntryEditor
interface.



Added:
    incubator/roller/trunk/src/org/apache/roller/model/WeblogEntryEditor.java
    incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/
    incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/TextEditor.java
    incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/XinhaEditor.java
    incubator/roller/trunk/tests/org/apache/roller/business/PluginManagerTest.java
Modified:
    incubator/roller/trunk/build.xml
    incubator/roller/trunk/src/org/apache/roller/business/PluginManagerImpl.java
    incubator/roller/trunk/src/org/apache/roller/model/PluginManager.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WebsiteFormAction.java
    incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
    incubator/roller/trunk/web/WEB-INF/classes/roller.properties
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-website.jsp

Modified: incubator/roller/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/build.xml?view=diff&rev=463804&r1=463803&r2=463804
==============================================================================
--- incubator/roller/trunk/build.xml (original)
+++ incubator/roller/trunk/build.xml Fri Oct 13 12:49:30 2006
@@ -957,6 +957,7 @@
 		<include name="org/apache/roller/business/IndexManagerTest.class"/>
 	        <include name="org/apache/roller/business/PlanetManagerTest.class"/>
 		<include name="org/apache/roller/business/RefererTest.class"/>
+		<include name="org/apache/roller/business/PluginManagerTest.class"/>
             </fileset>
         </batchtest>
     </junit>

Modified: incubator/roller/trunk/src/org/apache/roller/business/PluginManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/PluginManagerImpl.java?view=diff&rev=463804&r1=463803&r2=463804
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/PluginManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/PluginManagerImpl.java Fri Oct 13
12:49:30 2006
@@ -18,20 +18,20 @@
 
 package org.apache.roller.business;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.context.Context;
 import org.apache.roller.config.RollerConfig;
 import org.apache.roller.model.WeblogEntryPlugin;
 import org.apache.roller.model.PluginManager;
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.commons.lang.StringUtils;
+import org.apache.roller.model.WeblogEntryEditor;
 
 
 /**
@@ -39,68 +39,39 @@
  */
 public class PluginManagerImpl implements PluginManager {
     
-    private static Log mLogger = LogFactory.getLog(PluginManagerImpl.class);
+    private static Log log = LogFactory.getLog(PluginManagerImpl.class);
     
     // Plugin classes keyed by plugin name
     static Map mPagePlugins = new LinkedHashMap();
     
+    // list of configured WeblogEntryEditor classes
+    Map editors = new LinkedHashMap();
+    
+    // the default WeblogEntryEditor
+    WeblogEntryEditor defaultEditor = null;
+    
     
     /**
      * Creates a new instance of PluginManagerImpl
      */
     public PluginManagerImpl() {
         loadPagePluginClasses();
+        loadEntryEditorClasses();
     }
     
     
     public boolean hasPagePlugins() {
-        mLogger.debug("mPluginClasses.size(): " + mPagePlugins.size());
+        log.debug("mPluginClasses.size(): " + mPagePlugins.size());
         return (mPagePlugins != null && mPagePlugins.size() > 0);
     }
     
     
     /**
-     * Initialize PagePlugins declared in roller.properties.
-     * By using the full class name we also allow for the implementation of
-     * "external" Plugins (maybe even packaged seperately). These classes are
-     * then later instantiated by PageHelper.
-     */
-    private void loadPagePluginClasses() {
-        mLogger.debug("Initializing page plugins");
-        
-        String pluginStr = RollerConfig.getProperty("plugins.page");
-        if (mLogger.isDebugEnabled()) mLogger.debug(pluginStr);
-        if (pluginStr != null) {
-            String[] plugins = StringUtils.stripAll(
-                    StringUtils.split(pluginStr, ",") );
-            for (int i=0; i<plugins.length; i++) {
-                if (mLogger.isDebugEnabled()) mLogger.debug("try " + plugins[i]);
-                try {
-                    Class pluginClass = Class.forName(plugins[i]);
-                    if (isPagePlugin(pluginClass)) {
-                        WeblogEntryPlugin plugin = (WeblogEntryPlugin)pluginClass.newInstance();
-                        mPagePlugins.put(plugin.getName(), pluginClass);
-                    } else {
-                        mLogger.warn(pluginClass + " is not a PagePlugin");
-                    }
-                } catch (ClassNotFoundException e) {
-                    mLogger.error("ClassNotFoundException for " + plugins[i]);
-                } catch (InstantiationException e) {
-                    mLogger.error("InstantiationException for " + plugins[i]);
-                } catch (IllegalAccessException e) {
-                    mLogger.error("IllegalAccessException for " + plugins[i]);
-                }
-            }
-        }
-    }
-    
-    
-    /**
      * Create and init plugins for processing entries in a specified website.
      */
     public Map getWeblogEntryPlugins(WebsiteData website) {
         Map ret = new LinkedHashMap();
-        Iterator it = getPagePluginClasses().values().iterator();
+        Iterator it = this.mPagePlugins.values().iterator();
         while (it.hasNext()) {
             try {
                 Class pluginClass = (Class)it.next();
@@ -108,7 +79,7 @@
                 plugin.init(website);
                 ret.put(plugin.getName(), plugin);
             } catch (Exception e) {
-                mLogger.error("Unable to init() PagePlugin: ", e);
+                log.error("Unable to init() PagePlugin: ", e);
             }
         }
         return ret;
@@ -127,7 +98,7 @@
                 if (pagePlugin != null) {
                     ret = pagePlugin.render(entry, ret);
                 } else {
-                    mLogger.error("ERROR: plugin not found: " + key);
+                    log.error("ERROR: plugin not found: " + key);
                 }
             }
         }
@@ -135,17 +106,121 @@
     }
     
     
+    public List getWeblogEntryEditors() {
+        return new ArrayList(this.editors.values());
+    }
+    
+    
+    public WeblogEntryEditor getWeblogEntryEditor(String id) {
+        
+        WeblogEntryEditor editor = null;
+        
+        // see if this editor is configured
+        editor = (id == null) ? null : (WeblogEntryEditor) this.editors.get(id);
+        if(editor == null) {
+            editor = this.defaultEditor;
+        }
+        
+        return editor;
+    }
+    
+    
+    /**
+     * Initialize PagePlugins declared in roller.properties.
+     * By using the full class name we also allow for the implementation of
+     * "external" Plugins (maybe even packaged seperately). These classes are
+     * then later instantiated by PageHelper.
+     */
+    private void loadPagePluginClasses() {
+        log.debug("Initializing page plugins");
+        
+        String pluginStr = RollerConfig.getProperty("plugins.page");
+        if (log.isDebugEnabled()) log.debug(pluginStr);
+        if (pluginStr != null) {
+            String[] plugins = StringUtils.stripAll(
+                    StringUtils.split(pluginStr, ",") );
+            for (int i=0; i<plugins.length; i++) {
+                if (log.isDebugEnabled()) log.debug("try " + plugins[i]);
+                try {
+                    Class pluginClass = Class.forName(plugins[i]);
+                    if (isPagePlugin(pluginClass)) {
+                        WeblogEntryPlugin plugin = (WeblogEntryPlugin)pluginClass.newInstance();
+                        mPagePlugins.put(plugin.getName(), pluginClass);
+                    } else {
+                        log.warn(pluginClass + " is not a PagePlugin");
+                    }
+                } catch (ClassNotFoundException e) {
+                    log.error("ClassNotFoundException for " + plugins[i]);
+                } catch (InstantiationException e) {
+                    log.error("InstantiationException for " + plugins[i]);
+                } catch (IllegalAccessException e) {
+                    log.error("IllegalAccessException for " + plugins[i]);
+                }
+            }
+        }
+    }
+    
+    
+    /**
+     * Initialize the set of configured editors and define the default editor.
+     */
+    private void loadEntryEditorClasses() {
+        
+        log.debug("Initializing entry editor plugins");
+        
+        String editorStr = RollerConfig.getProperty("plugins.weblogEntryEditors");
+        if (editorStr != null) {
+            
+            String[] editorList = StringUtils.stripAll(StringUtils.split(editorStr, ","));
+            for (int i=0; i < editorList.length; i++) {
+                
+                log.debug("trying editor " + editorList[i]);
+                
+                try {
+                    Class editorClass = Class.forName(editorList[i]);
+                    WeblogEntryEditor editor = (WeblogEntryEditor) editorClass.newInstance();
+                    
+                    // looks okay, add it to the map
+                    this.editors.put(editor.getId(), editor);
+                    
+                } catch(ClassCastException cce) {
+                    log.error("It appears that your editor does not implement "+
+                            "the WeblogEntryEditor interface", cce);
+                } catch(Exception e) {
+                    log.error("Unable to instantiate editor ["+editorList[i]+"]", e);
+                }
+            }
+        }
+        
+        if(this.editors.size() < 1) {
+            log.warn("No entry editors configured, this means that publishing "+
+                    "entries will be impossible.");
+            return;
+        }
+        
+        // make sure the default editor is defined
+        String defaultEditorId = RollerConfig.getProperty("plugins.defaultEditor");
+        if(defaultEditorId != null) {
+            this.defaultEditor = (WeblogEntryEditor) this.editors.get(defaultEditorId);
+        }
+        
+        if(this.defaultEditor == null) {
+            // someone didn't configure the default editor properly
+            // guess we'll just have to pick one for them
+            log.warn("Default editor was not properly configured, picking one at random instead.");
+            
+            Object editor = this.editors.values().iterator().next();
+            this.defaultEditor = (WeblogEntryEditor) editor;
+        }
+    }
+    
+    
     private static boolean isPagePlugin(Class pluginClass) {
         Class[] interfaces = pluginClass.getInterfaces();
         for (int i=0; i<interfaces.length; i++) {
             if (interfaces[i].equals(WeblogEntryPlugin.class)) return true;
         }
         return false;
-    }
-    
-    
-    private Map getPagePluginClasses() {
-        return mPagePlugins;
     }
     
     

Modified: incubator/roller/trunk/src/org/apache/roller/model/PluginManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/model/PluginManager.java?view=diff&rev=463804&r1=463803&r2=463804
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/model/PluginManager.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/model/PluginManager.java Fri Oct 13 12:49:30
2006
@@ -1 +1,84 @@
-/*
 * 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.model;

import java.util.Map;
import org.apache.roller.pojos.WeblogEntryData;
import
org.apache.roller.pojos.WebsiteData;

 /**
 * Manages Roller plugins.
 */
public interface PluginManager {
    
    /**
     * Returns
true if plugins are present
     */
    public boolean hasPagePlugins();
    
    
    /**
    * Returns a list of all registered weblog entry plugins initialized for
     * use with
the specified weblog.
     *
     * @param website        Website being processed
     */
   public Map getWeblogEntryPlugins(WebsiteData website);
    
    
    /**
     * Apply a
set of weblog entry plugins to the specified string and
     * return the results.  This method
must *NOT* alter the contents of
     * the original entry object.
     *
     * @param entry
      Original weblog entry
     * @param plugins     Map of plugins to apply
     * @param
str         String to which to apply plugins
     * @return        the transformed text
 
   */
    public String applyWeblogEntryPlugins(Map pagePlugins, WeblogEntryData entry, String
str);
    
    
    /**
     * Release all resources associa
 ted with Roller session.
     */
    public void release();
    
}
\ No newline at end of file
+/*
+ * 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.model;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.roller.pojos.WeblogEntryData;
+import org.apache.roller.pojos.WebsiteData;
+
+
+/**
+ * Manages Roller plugins.
+ */
+public interface PluginManager {
+    
+    /**
+     * Returns true if plugins are present
+     */
+    public boolean hasPagePlugins();
+    
+    
+    /**
+     * Returns a list of all registered weblog entry plugins initialized for
+     * use with the specified weblog.
+     *
+     * @param website        Website being processed
+     */
+    public Map getWeblogEntryPlugins(WebsiteData website);
+    
+    
+    /**
+     * Apply a set of weblog entry plugins to the specified string and
+     * return the results.  This method must *NOT* alter the contents of
+     * the original entry object.
+     *
+     * @param entry       Original weblog entry
+     * @param plugins     Map of plugins to apply
+     * @param str         String to which to apply plugins
+     * @return        the transformed text
+     */
+    public String applyWeblogEntryPlugins(Map pagePlugins, WeblogEntryData entry, String
str);
+    
+    
+    /**
+     * Get the list of all configured WeblogEntryEditors.
+     *
+     * @return List of all configure WeblogEntryEditor objects.
+     */
+    public List getWeblogEntryEditors();
+    
+    
+    /**
+     * Get a WeblogEntryEditor by name.  If the specified editor cannot be found
+     * or the id is null, then the default editor should be returned.
+     *
+     * @param id The id of the desired WeblogEntryEditor.
+     * @return The WeblogEntry editor desired, or the default editor if the
+     *      desired editor could not be found.
+     */
+    public WeblogEntryEditor getWeblogEntryEditor(String id);
+    
+    
+    /**
+     * Release all resources associated with Roller session.
+     */
+    public void release();
+    
+}

Added: incubator/roller/trunk/src/org/apache/roller/model/WeblogEntryEditor.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/model/WeblogEntryEditor.java?view=auto&rev=463804
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/model/WeblogEntryEditor.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/model/WeblogEntryEditor.java Fri Oct 13 12:49:30
2006
@@ -0,0 +1,63 @@
+/*
+ * 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.model;
+
+/**
+ * Represents an editor for a WeblogEntry.
+ */
+public interface WeblogEntryEditor {
+    
+    /**
+     * The unique identifier for this editor.
+     *
+     * It is important that each editor have a unique identifier.  The id for 
+     * the editor is how it will be tracked and associated with each weblog 
+     * that is using it, so having 2 editors with the same id would cause some
+     * nasty problems.  It is also preferable if the id not be a full class
+     * name because then if you ever want to refactor the location of the class
+     * then you have a problem, so just pick a simple unique name.
+     *
+     * @return The unique identifier for this WeblogEntryEditor.
+     */
+    public String getId();
+    
+    
+    /**
+     * The display name for the editor, as seen by users.
+     *
+     * This is the name that users will see on the editors option list, so
+     * pick something that's easy for users to remember and recognize.
+     *
+     * It is also a good idea for the name to be internationalized if possible.
+     *
+     * @return The display name of this WeblogEntryEditor.
+     */
+    public String getName();
+    
+    
+    /**
+     * The location of the jsp page inside the webapp that renders this editor.
+     *
+     * Example: /roller-ui/authoring/editors/editor-text.jsp
+     *
+     * @return The location of the jsp for this editor.
+     */
+    public String getJspPage();
+
+}

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java?view=diff&rev=463804&r1=463803&r2=463804
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
Fri Oct 13 12:49:30 2006
@@ -19,7 +19,6 @@
 package org.apache.roller.ui.authoring.struts.actions;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -47,6 +46,7 @@
 import org.apache.roller.config.RollerRuntimeConfig;
 import org.apache.roller.model.PluginManager;
 import org.apache.roller.model.Roller;
+import org.apache.roller.model.WeblogEntryEditor;
 import org.apache.roller.pojos.WebsiteData;
 
 /**
@@ -257,6 +257,15 @@
         return editorPage;
     }
 
+    public WeblogEntryEditor getEditor() {
+        try {
+            PluginManager pmgr = RollerFactory.getRoller().getPagePluginManager();
+            return pmgr.getWeblogEntryEditor(this.website.getEditorPage());
+        } catch (RollerException ex) {
+            throw new RuntimeException("Couldn't access plugin manager");
+        }
+    }
+    
     public UserData getUser()
     {
         RollerSession rollerSession = RollerSession.getRollerSession(getRequest());

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WebsiteFormAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WebsiteFormAction.java?view=diff&rev=463804&r1=463803&r2=463804
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WebsiteFormAction.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WebsiteFormAction.java
Fri Oct 13 12:49:30 2006
@@ -1,27 +1,26 @@
 /*
-* 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.
-*/
+ * 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.struts.actions;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -50,6 +49,7 @@
 import org.apache.roller.model.Roller;
 import org.apache.roller.model.RollerFactory;
 import org.apache.roller.model.UserManager;
+import org.apache.roller.model.WeblogEntryEditor;
 import org.apache.roller.model.WeblogManager;
 import org.apache.roller.pojos.UserData;
 import org.apache.roller.pojos.WebsiteData;
@@ -116,14 +116,8 @@
                 List pages = umgr.getPages(website);
                 request.setAttribute("pages",pages);
                 
-                ServletContext ctx = request.getSession().getServletContext();
-                String editorPages =
-                        RollerRuntimeConfig.getProperty("users.editor.pages");
-                
-                List epages = Arrays.asList(StringUtils.split(
-                        StringUtils.deleteWhitespace(editorPages), ","));
-                request.setAttribute("editorPagesList", epages);
-                
+                // set the Editor Page list
+                request.setAttribute("editorPagesList", this.getEditorsList());
                 
                 WebsitePageModel pageModel = new WebsitePageModel(
                         "websiteSettings.title", request, response, mapping, website);
@@ -179,40 +173,34 @@
                     if (wd.getActive() != null && !wd.getActive().booleanValue())
{
                         wd.setAllowComments(Boolean.FALSE);
                         messages.add(null, new ActionMessage(
-                            "websiteSettings.commentsOffForInactiveWeblog"));
+                                "websiteSettings.commentsOffForInactiveWeblog"));
                     }
-                                        
-                    umgr.saveWebsite(wd);  
+                    
+                    umgr.saveWebsite(wd);
                     
                     // ROL-1050: apply comment defaults to existing entries
                     if (form.getApplyCommentDefaults() != null && form.getApplyCommentDefaults().booleanValue())
{
                         wmgr.applyCommentDefaultsToEntries(wd);
                     }
-
+                    
                     RollerFactory.getRoller().getRefererManager().applyRefererFilters(wd);
                     
                     RollerFactory.getRoller().flush();
                     
                     messages.add(null,
-                        new ActionMessage("websiteSettings.savedChanges"));
+                            new ActionMessage("websiteSettings.savedChanges"));
                     
                     request.getSession().setAttribute(
-                        RequestConstants.WEBLOG_ID, form.getId());
+                            RequestConstants.WEBLOG_ID, form.getId());
                     
                     // Clear cache entries associated with website
                     CacheManager.invalidate(wd);
-            
+                    
                     actionForm.reset(mapping,request);
                 }
                 
                 // set the Editor Page list
-                ServletContext ctx = request.getSession().getServletContext();
-                String editorPages =
-                        RollerRuntimeConfig.getProperty("users.editor.pages");
-                
-                List epages = Arrays.asList(StringUtils.split(
-                        org.apache.commons.lang.StringUtils.deleteWhitespace(editorPages),
","));
-                request.setAttribute("editorPagesList", epages);
+                request.setAttribute("editorPagesList", this.getEditorsList());
                 
                 WebsitePageModel pageModel =
                         new WebsitePageModel("websiteSettings.title",
@@ -247,11 +235,11 @@
             // just for testing/counting, this does not persist rules in any way
             Blacklist.populateSpamRules(blacklist, stringRules, regexRules, null);
             messages.add(null, new ActionMessage(
-                "websiteSettings.acceptedBlacklist",
-                new Integer(stringRules.size()), new Integer(regexRules.size())));
+                    "websiteSettings.acceptedBlacklist",
+                    new Integer(stringRules.size()), new Integer(regexRules.size())));
         } catch (Throwable e) {
             errors.add(null, new ActionMessage(
-                "websiteSettings.error.processingBlacklist", e.getMessage()));
+                    "websiteSettings.error.processingBlacklist", e.getMessage()));
         }
     }
     
@@ -322,6 +310,21 @@
         return forward;
     }
     
+    private List getEditorsList() {
+        
+        List editorsList = new ArrayList();
+        
+        try {
+            PluginManager pmgr = RollerFactory.getRoller().getPagePluginManager();
+            editorsList = pmgr.getWeblogEntryEditors();
+        } catch (RollerException ex) {
+            mLogger.error(ex);
+        }
+        
+        return editorsList;
+    }
+    
+    
     public class WebsitePageModel extends BasePageModel {
         private List permissions = new ArrayList();
         private boolean groupBloggingEnabled = false;
@@ -340,11 +343,11 @@
             UserData user = rollerSession.getAuthenticatedUser();
             permissions = roller.getUserManager().getAllPermissions(website);
             groupBloggingEnabled =
-                RollerConfig.getBooleanProperty("groupblogging.enabled");
-            emailNotificationEnabled = 
-                RollerRuntimeConfig.getBooleanProperty("users.comments.emailnotify");
-            moderationRequired =  
-                RollerRuntimeConfig.getBooleanProperty("users.moderation.required");
+                    RollerConfig.getBooleanProperty("groupblogging.enabled");
+            emailNotificationEnabled =
+                    RollerRuntimeConfig.getBooleanProperty("users.comments.emailnotify");
+            moderationRequired =
+                    RollerRuntimeConfig.getBooleanProperty("users.moderation.required");
         }
         public boolean isGroupBloggingEnabled() {
             return groupBloggingEnabled;

Added: incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/TextEditor.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/TextEditor.java?view=auto&rev=463804
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/TextEditor.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/TextEditor.java Fri Oct 13
12:49:30 2006
@@ -0,0 +1,46 @@
+/*
+ * 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.core.plugins;
+
+import org.apache.roller.model.WeblogEntryEditor;
+import org.apache.roller.util.MessageUtilities;
+
+
+/**
+ * The default text editor.  Basically just plain html textareas.
+ */
+public class TextEditor implements WeblogEntryEditor {
+    
+    
+    public TextEditor() {}
+    
+    
+    public String getId() {
+        return "TextEditor";
+    }
+    
+    public String getName() {
+        return MessageUtilities.getString("editor.text.name");
+    }
+    
+    public String getJspPage() {
+        return "/roller-ui/authoring/editors/editor-text.jsp";
+    }
+    
+}

Added: incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/XinhaEditor.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/XinhaEditor.java?view=auto&rev=463804
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/XinhaEditor.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/ui/core/plugins/XinhaEditor.java Fri Oct
13 12:49:30 2006
@@ -0,0 +1,46 @@
+/*
+ * 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.core.plugins;
+
+import org.apache.roller.model.WeblogEntryEditor;
+import org.apache.roller.util.MessageUtilities;
+
+
+/**
+ * A rich text wysiwyg editor using Xinha.
+ */
+public class XinhaEditor implements WeblogEntryEditor {
+    
+    
+    public XinhaEditor() {}
+    
+    
+    public String getId() {
+        return "XinhaEditor";
+    }
+    
+    public String getName() {
+        return MessageUtilities.getString("editor.xinha.name");
+    }
+    
+    public String getJspPage() {
+        return "/roller-ui/authoring/editors/editor-xinha.jsp";
+    }
+    
+}

Added: incubator/roller/trunk/tests/org/apache/roller/business/PluginManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/PluginManagerTest.java?view=auto&rev=463804
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/PluginManagerTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/business/PluginManagerTest.java Fri Oct
13 12:49:30 2006
@@ -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.
+ */
+
+package org.apache.roller.business;
+
+import java.io.InputStream;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.model.PluginManager;
+import org.apache.roller.model.RollerFactory;
+
+
+/**
+ * Test Plugin Management business layer operations.
+ */
+public class PluginManagerTest extends TestCase {
+    
+    private static Log log = LogFactory.getLog(PluginManagerTest.class);
+    
+    
+    public PluginManagerTest(String name) {
+        super(name);
+    }
+    
+    
+    public static Test suite() {
+        return new TestSuite(PluginManagerTest.class);
+    }
+    
+    
+    public void setUp() throws Exception { }
+    public void tearDown() throws Exception { }
+    
+    
+    public void testEntryEditors() throws Exception {
+        
+        PluginManager pmgr = RollerFactory.getRoller().getPagePluginManager();
+        
+        // test getEditors() lis
+        assertEquals(2, pmgr.getWeblogEntryEditors().size());
+        
+        // test getting a single editor
+        assertEquals("TextEditor", pmgr.getWeblogEntryEditor("TextEditor").getId());
+        
+        // make sure we return default editor if editor id is not found
+        assertEquals("TextEditor", pmgr.getWeblogEntryEditor(null).getId());
+    }
+    
+}

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=463804&r1=463803&r2=463804
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties Fri Oct 13
12:49:30 2006
@@ -387,6 +387,11 @@
 createWeblog.error.missingEmailAddress=You must enter a valid email address
 createWeblog.error.handleExists=A weblog with that handle already exists
 
+# --------------------------------------------------------------- Entry editors
+
+editor.text.name=Text Editor
+editor.xinha.name=Rich Text Editor (Xinha)
+
 # --------------------------------------------------------------- Comment emails
 
 email.comment.wrote=wrote

Modified: incubator/roller/trunk/web/WEB-INF/classes/roller.properties
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/classes/roller.properties?view=diff&rev=463804&r1=463803&r2=463804
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/classes/roller.properties (original)
+++ incubator/roller/trunk/web/WEB-INF/classes/roller.properties Fri Oct 13 12:49:30 2006
@@ -244,6 +244,13 @@
 #,org.apache.roller.ui.rendering.plugins.AcronymsPlugin \
 #,org.apache.roller.ui.rendering.plugins.BookmarkPlugin
 
+# The list of configured WeblogEntryEditors available to users
+plugins.weblogEntryEditors=\
+org.apache.roller.ui.core.plugins.TextEditor,\
+org.apache.roller.ui.core.plugins.XinhaEditor
+
+# The "id" of the default editor to use.  NOT the class name
+plugins.defaultEditor=TextEditor
 
 #----------------------------------
 # scheduled tasks, each is comma separated list of classes

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp?view=diff&rev=463804&r1=463803&r2=463804
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEdit.jsp Fri Oct 13 12:49:30 2006
@@ -200,7 +200,7 @@
     <div style="width: 100%;"> <%-- need this div to control text-area size in IE
6 --%>
        <%-- include edit page --%>
        <div >
-            <jsp:include page='<%= "/roller-ui/authoring/editors/"+model.getEditorPage()
%>' />
+            <jsp:include page='<%= model.getEditor().getJspPage() %>' />
        </div>
      </div>
     </c:if>

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-website.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-website.jsp?view=diff&rev=463804&r1=463803&r2=463804
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-website.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-website.jsp Fri Oct 13 12:49:30
2006
@@ -68,7 +68,7 @@
         <td class="label"><fmt:message key="websiteSettings.editor" /></td>
         <td class="field">
             <html:select property="editorPage" size="1">
-                <html:options name="editorPagesList" />
+                <html:options collection="editorPagesList" property="id" labelProperty="name"
/>
             </html:select></p>
        </td>
         <td class="description"><%-- <fmt:message key="websiteSettings.tip."
/> --%></td>



Mime
View raw message