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 @@
<exclude-exploded />
<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/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>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
......
......@@ -8,6 +8,7 @@
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.messenger.container;
import java.io.File;
......@@ -25,6 +26,7 @@ public class PluginDevEnvironment {
/**
* Returns the document root of a plugins web development
* application.
*
* @return the document root of a plugin.
*/
public File getWebRoot() {
......
......@@ -146,7 +146,7 @@ public class PluginServlet extends HttpServlet {
Element servletElement = (Element)classes.get(i);
String name = servletElement.element("servlet-name").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.
List names = doc.selectNodes("//servlet-mapping");
......@@ -420,8 +420,8 @@ public class PluginServlet extends HttpServlet {
jspc.execute();
try {
Object servletInstance = pluginManager.loadClass("org.apache.jsp." +
relativeDir + filename, plugin).newInstance();
Object servletInstance = pluginManager.loadClass(plugin, "org.apache.jsp." +
relativeDir + filename).newInstance();
HttpServlet servlet = (HttpServlet)servletInstance;
servlet.init(servletConfig);
servlet.service(request, response);
......
......@@ -2,8 +2,8 @@
<plugin>
<class>org.jivesoftware.messenger.plugin.RegistrationPlugin</class>
<name>Registration Plugin</name>
<description>Allows admins to configure various actions whenever a new user creates an account.</description>
<name>Registration</name>
<description>Performs various actions whenever a new user account is created.</description>
<author>Ryan Graham</author>
<version>1.0</version>
<minServerVersion>2.1.3</minServerVersion>
......
......@@ -67,6 +67,7 @@ public class RegistrationPlugin implements Plugin {
public void destroyPlugin() {
UserEventDispatcher.removeListener(listener);
serverAddress = null;
listener = null;
router = null;
}
......
......@@ -2,7 +2,7 @@
<plugin>
<class>org.jivesoftware.messenger.plugin.SearchPlugin</class>
<name>Search Plugin</name>
<name>Search</name>
<description>Provides support for Jabber Search (JEP-0055)</description>
<author>Ryan Graham</author>
<version>1.1</version>
......
......@@ -4,7 +4,7 @@
<class>org.jivesoftware.messenger.plugin.ImportExportPlugin</class>
<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>
<version>1.0</version>
<minServerVersion>2.1.4</minServerVersion>
......
......@@ -19,7 +19,8 @@
org.jivesoftware.messenger.container.PluginManager,
org.jivesoftware.util.*,
org.jivesoftware.messenger.container.Plugin,
java.util.*"
java.util.*,
java.net.URLEncoder"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
......@@ -31,6 +32,8 @@
<%
String deletePlugin = ParamUtils.getParameter(request, "deleteplugin");
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();
......@@ -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" />
<%
String title = LocaleUtils.getLocalizedString("plugin.admin.title");
......@@ -174,6 +238,19 @@
</td>
<td width="20%" nowrap>
<%= (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 width="60%">
<%= 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