Commit 3422760c authored by Matt Tucker's avatar Matt Tucker Committed by matt

Plugin work, added support for seeing changelog and readme of plugins (JM-300).


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1485 b35dd754-fafc-0310-a699-88a17e54d16e
parent c11d38ab
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
<exclude-exploded /> <exclude-exploded />
<content url="file://$MODULE_DIR$/src/plugins"> <content url="file://$MODULE_DIR$/src/plugins">
<sourceFolder url="file://$MODULE_DIR$/src/plugins/broadcast/src/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/plugins/broadcast/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/plugins/registration/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/plugins/search/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/plugins/userImportExport/src/java" isTestSource="false" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
*/ */
package org.jivesoftware.messenger.container; package org.jivesoftware.messenger.container;
import java.io.File; import java.io.File;
...@@ -25,6 +26,7 @@ public class PluginDevEnvironment { ...@@ -25,6 +26,7 @@ public class PluginDevEnvironment {
/** /**
* Returns the document root of a plugins web development * Returns the document root of a plugins web development
* application. * application.
*
* @return the document root of a plugin. * @return the document root of a plugin.
*/ */
public File getWebRoot() { public File getWebRoot() {
......
...@@ -146,7 +146,7 @@ public class PluginServlet extends HttpServlet { ...@@ -146,7 +146,7 @@ public class PluginServlet extends HttpServlet {
Element servletElement = (Element)classes.get(i); Element servletElement = (Element)classes.get(i);
String name = servletElement.element("servlet-name").getTextTrim(); String name = servletElement.element("servlet-name").getTextTrim();
String className = servletElement.element("servlet-class").getTextTrim(); String className = servletElement.element("servlet-class").getTextTrim();
classMap.put(name, manager.loadClass(className, plugin)); classMap.put(name, manager.loadClass(plugin, className));
} }
// Find all <servelt-mapping> entries to discover name to URL mapping. // Find all <servelt-mapping> entries to discover name to URL mapping.
List names = doc.selectNodes("//servlet-mapping"); List names = doc.selectNodes("//servlet-mapping");
...@@ -420,8 +420,8 @@ public class PluginServlet extends HttpServlet { ...@@ -420,8 +420,8 @@ public class PluginServlet extends HttpServlet {
jspc.execute(); jspc.execute();
try { try {
Object servletInstance = pluginManager.loadClass("org.apache.jsp." + Object servletInstance = pluginManager.loadClass(plugin, "org.apache.jsp." +
relativeDir + filename, plugin).newInstance(); relativeDir + filename).newInstance();
HttpServlet servlet = (HttpServlet)servletInstance; HttpServlet servlet = (HttpServlet)servletInstance;
servlet.init(servletConfig); servlet.init(servletConfig);
servlet.service(request, response); servlet.service(request, response);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<plugin> <plugin>
<class>org.jivesoftware.messenger.plugin.RegistrationPlugin</class> <class>org.jivesoftware.messenger.plugin.RegistrationPlugin</class>
<name>Registration Plugin</name> <name>Registration</name>
<description>Allows admins to configure various actions whenever a new user creates an account.</description> <description>Performs various actions whenever a new user account is created.</description>
<author>Ryan Graham</author> <author>Ryan Graham</author>
<version>1.0</version> <version>1.0</version>
<minServerVersion>2.1.3</minServerVersion> <minServerVersion>2.1.3</minServerVersion>
......
...@@ -67,6 +67,7 @@ public class RegistrationPlugin implements Plugin { ...@@ -67,6 +67,7 @@ public class RegistrationPlugin implements Plugin {
public void destroyPlugin() { public void destroyPlugin() {
UserEventDispatcher.removeListener(listener); UserEventDispatcher.removeListener(listener);
serverAddress = null;
listener = null; listener = null;
router = null; router = null;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<plugin> <plugin>
<class>org.jivesoftware.messenger.plugin.SearchPlugin</class> <class>org.jivesoftware.messenger.plugin.SearchPlugin</class>
<name>Search Plugin</name> <name>Search</name>
<description>Provides support for Jabber Search (JEP-0055)</description> <description>Provides support for Jabber Search (JEP-0055)</description>
<author>Ryan Graham</author> <author>Ryan Graham</author>
<version>1.1</version> <version>1.1</version>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<class>org.jivesoftware.messenger.plugin.ImportExportPlugin</class> <class>org.jivesoftware.messenger.plugin.ImportExportPlugin</class>
<name>User Import Export</name> <name>User Import Export</name>
<description>Allows the importing and exporting of Messenger user data.</description> <description>Enables import and export of user data.</description>
<author>Ryan Graham</author> <author>Ryan Graham</author>
<version>1.0</version> <version>1.0</version>
<minServerVersion>2.1.4</minServerVersion> <minServerVersion>2.1.4</minServerVersion>
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
org.jivesoftware.messenger.container.PluginManager, org.jivesoftware.messenger.container.PluginManager,
org.jivesoftware.util.*, org.jivesoftware.util.*,
org.jivesoftware.messenger.container.Plugin, org.jivesoftware.messenger.container.Plugin,
java.util.*" java.util.*,
java.net.URLEncoder"
%> %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
...@@ -31,6 +32,8 @@ ...@@ -31,6 +32,8 @@
<% <%
String deletePlugin = ParamUtils.getParameter(request, "deleteplugin"); String deletePlugin = ParamUtils.getParameter(request, "deleteplugin");
String refreshPlugin = ParamUtils.getParameter(request, "refreshplugin"); String refreshPlugin = ParamUtils.getParameter(request, "refreshplugin");
boolean showReadme = ParamUtils.getBooleanParameter(request, "showReadme", false);
boolean showChangelog = ParamUtils.getBooleanParameter(request, "showChangelog", false);
final PluginManager pluginManager = webManager.getXMPPServer().getPluginManager(); final PluginManager pluginManager = webManager.getXMPPServer().getPluginManager();
...@@ -69,6 +72,67 @@ ...@@ -69,6 +72,67 @@
} }
%> %>
<% if (showReadme) {
String pluginName = ParamUtils.getParameter(request, "plugin");
Plugin plugin = pluginManager.getPlugin(pluginName);
if (plugin != null) {
File readme = new File(pluginManager.getPluginDirectory(plugin), "readme.html");
if (readme.exists()) {
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(readme));
String line;
while ((line = in.readLine()) != null) {
%>
<%= line + "\n" %>
<%
}
}
catch (IOException ioe) {
ioe.printStackTrace();
}
finally {
if (in != null) {
try { in.close(); } catch (Exception e) { }
}
}
}
}
return;
}
%>
<% if (showChangelog) {
String pluginName = ParamUtils.getParameter(request, "plugin");
Plugin plugin = pluginManager.getPlugin(pluginName);
if (plugin != null) {
File changelog = new File(pluginManager.getPluginDirectory(plugin), "changelog.html");
if (changelog.exists()) {
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(changelog));
String line;
while ((line = in.readLine()) != null) {
%>
<%= line + "\n" %>
<%
}
}
catch (IOException ioe) {
}
finally {
if (in != null) {
try { in.close(); } catch (Exception e) { }
}
}
}
}
return;
}
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" /> <jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% <%
String title = LocaleUtils.getLocalizedString("plugin.admin.title"); String title = LocaleUtils.getLocalizedString("plugin.admin.title");
...@@ -174,6 +238,19 @@ ...@@ -174,6 +238,19 @@
</td> </td>
<td width="20%" nowrap> <td width="20%" nowrap>
<%= (pluginName != null ? pluginName : dirName) %> &nbsp; <%= (pluginName != null ? pluginName : dirName) %> &nbsp;
<%
File pluginDir = pluginManager.getPluginDirectory(plugin);
boolean readmeExists = new File(pluginDir, "readme.html").exists();
boolean changelogExists = new File(pluginDir, "changelog.html").exists();
%>
<% if (readmeExists) { %>
<a href="plugin-admin.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showReadme=true"
><img src="images/doc-readme-16x16.gif" width="16" height="16" border="0" alt="README"></a>
<% } %>
<% if (changelogExists) { %>
<a href="plugin-admin.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showChangelog=true"
><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a>
<% } %>
</td> </td>
<td width="60%"> <td width="60%">
<%= pluginDescription != null ? pluginDescription : "" %> &nbsp; <%= pluginDescription != null ? pluginDescription : "" %> &nbsp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment