plugin description on configclients

This commit is contained in:
zzz
2010-02-08 16:15:23 +00:00
parent 9012baf51e
commit 85482a67f5
4 changed files with 90 additions and 16 deletions

View File

@ -1,5 +1,7 @@
package net.i2p.router.web;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
@ -79,8 +81,56 @@ public class ConfigClientsHelper extends HelperBase {
if (name.startsWith(PluginStarter.PREFIX) && name.endsWith(PluginStarter.ENABLED)) {
String app = name.substring(PluginStarter.PREFIX.length(), name.lastIndexOf(PluginStarter.ENABLED));
String val = props.getProperty(name);
renderForm(buf, app, app, !"addressbook".equals(app),
"true".equals(val), false, app, false, false);
Properties appProps = PluginStarter.pluginProperties(_context, app);
StringBuilder desc = new StringBuilder(256);
desc.append("<table border=\"0\">")
.append("<tr><td><b>").append(_("Version")).append("<td>").append(appProps.getProperty("version"))
.append("<tr><td><b>")
.append(_("Signed by")).append("<td>").append(appProps.getProperty("keyName"));
String s = appProps.getProperty("date");
if (s != null) {
long ms = 0;
try {
ms = Long.parseLong(s);
} catch (NumberFormatException nfe) {}
if (ms > 0) {
String date = (new SimpleDateFormat("yyyy-MM-dd HH:mm")).format(new Date(ms));
desc.append("<tr><td><b>")
.append(_("Date")).append("<td>").append(date);
}
}
s = appProps.getProperty("author");
if (s != null) {
// fixme translate info using bundle specified in appProps
desc.append("<tr><td><b>")
.append(_("Author")).append("<td>").append(s);
}
s = appProps.getProperty("description_" + Messages.getLanguage(_context));
if (s == null)
s = appProps.getProperty("description");
if (s != null) {
// fixme translate info using bundle specified in appProps
desc.append("<tr><td><b>")
.append(_("Description")).append("<td>").append(s);
}
s = appProps.getProperty("license");
if (s != null) {
desc.append("<tr><td><b>")
.append(_("License")).append("<td>").append(s);
}
s = appProps.getProperty("websiteURL");
if (s != null) {
desc.append("<tr><td>")
.append("<a href=\"").append(s).append("\">").append(_("Website")).append("</a><td>&nbsp;");
}
s = appProps.getProperty("updateURL");
if (s != null) {
desc.append("<tr><td>")
.append("<a href=\"").append(s).append("\">").append(_("Update link")).append("</a><td>&nbsp;");
}
desc.append("</table>");
renderForm(buf, app, app, false,
"true".equals(val), false, desc.toString(), false, false);
}
}
buf.append("</table>\n");

View File

@ -25,8 +25,7 @@ public class NavHelper {
}
/**
* Fixme, this translates with the router console bundle, not
* the plugin bundle
* Translated string is loaded by PluginStarter
*/
public static String getClientAppLinks(I2PAppContext ctx) {
StringBuilder buf = new StringBuilder(1024);
@ -34,7 +33,7 @@ public class NavHelper {
String name = iter.next();
String path = _apps.get(name);
buf.append(" <a target=\"_top\" href=\"").append(path).append("\">");
buf.append(Messages.getString(name, ctx)).append("</a>");
buf.append(name).append("</a>");
}
return buf.toString();
}

View File

@ -131,20 +131,31 @@ public class PluginStarter implements Runnable {
// add themes in console/themes
// add summary bar link
File pluginConfig = new File(pluginDir, "plugin.config");
if (pluginConfig.exists()) {
Properties props = new Properties();
DataHelper.loadProps(props, pluginConfig);
String name = props.getProperty("consoleLinkName");
Properties props = pluginProperties(ctx, appName);
String name = props.getProperty("consoleLinkName_" + Messages.getLanguage(ctx));
if (name == null)
name = props.getProperty("consoleLinkName");
String url = props.getProperty("consoleLinkURL");
if (name != null && url != null && name.length() > 0 && url.length() > 0)
NavHelper.registerApp(name, url);
}
return true;
}
/** this auto-adds a propery for every dir in the plugin directory */
/** plugin.config */
public static Properties pluginProperties(I2PAppContext ctx, String appName) {
File cfgFile = new File(ctx.getAppDir(), PluginUpdateHandler.PLUGIN_DIR + '/' + appName + '/' + "plugin.config");
Properties rv = new Properties();
try {
DataHelper.loadProps(rv, cfgFile);
} catch (IOException ioe) {}
return rv;
}
/**
* plugins.config
* this auto-adds a propery for every dir in the plugin directory
*/
public static Properties pluginProperties() {
File dir = I2PAppContext.getGlobalContext().getConfigDir();
Properties rv = new Properties();
@ -167,6 +178,16 @@ public class PluginStarter implements Runnable {
return rv;
}
/**
* plugins.config
*/
public static void storePluginProperties(Properties props) {
File cfgFile = new File(I2PAppContext.getGlobalContext().getConfigDir(), "plugins.config");
try {
DataHelper.storeProps(props, cfgFile);
} catch (IOException ioe) {}
}
/** see comments in ConfigClientsHandler */
static Server getConsoleServer() {
Collection c = Server.getHttpServers();

View File

@ -313,8 +313,12 @@ public class PluginUpdateHandler extends UpdateHandler {
if (Boolean.valueOf(props.getProperty("dont-start-at-install")).booleanValue()) {
if (Boolean.valueOf(props.getProperty("router-restart-required")).booleanValue())
updateStatus("<b>" + _("Plugin {0} successfully installed, router restart required", appName) + "</b>");
else
else {
updateStatus("<b>" + _("Plugin {0} successfully installed", appName) + "</b>");
Properties pluginProps = PluginStarter.pluginProperties();
pluginProps.setProperty(PluginStarter.PREFIX + appName + PluginStarter.ENABLED, "false");
PluginStarter.storePluginProperties(pluginProps);
}
} else {
// start everything
try {