forked from I2P_Developers/i2p.i2p
plugin description on configclients
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
package net.i2p.router.web;
|
package net.i2p.router.web;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -79,8 +81,56 @@ public class ConfigClientsHelper extends HelperBase {
|
|||||||
if (name.startsWith(PluginStarter.PREFIX) && name.endsWith(PluginStarter.ENABLED)) {
|
if (name.startsWith(PluginStarter.PREFIX) && name.endsWith(PluginStarter.ENABLED)) {
|
||||||
String app = name.substring(PluginStarter.PREFIX.length(), name.lastIndexOf(PluginStarter.ENABLED));
|
String app = name.substring(PluginStarter.PREFIX.length(), name.lastIndexOf(PluginStarter.ENABLED));
|
||||||
String val = props.getProperty(name);
|
String val = props.getProperty(name);
|
||||||
renderForm(buf, app, app, !"addressbook".equals(app),
|
Properties appProps = PluginStarter.pluginProperties(_context, app);
|
||||||
"true".equals(val), false, app, false, false);
|
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> ");
|
||||||
|
}
|
||||||
|
s = appProps.getProperty("updateURL");
|
||||||
|
if (s != null) {
|
||||||
|
desc.append("<tr><td>")
|
||||||
|
.append("<a href=\"").append(s).append("\">").append(_("Update link")).append("</a><td> ");
|
||||||
|
}
|
||||||
|
desc.append("</table>");
|
||||||
|
renderForm(buf, app, app, false,
|
||||||
|
"true".equals(val), false, desc.toString(), false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf.append("</table>\n");
|
buf.append("</table>\n");
|
||||||
|
@ -25,8 +25,7 @@ public class NavHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fixme, this translates with the router console bundle, not
|
* Translated string is loaded by PluginStarter
|
||||||
* the plugin bundle
|
|
||||||
*/
|
*/
|
||||||
public static String getClientAppLinks(I2PAppContext ctx) {
|
public static String getClientAppLinks(I2PAppContext ctx) {
|
||||||
StringBuilder buf = new StringBuilder(1024);
|
StringBuilder buf = new StringBuilder(1024);
|
||||||
@ -34,7 +33,7 @@ public class NavHelper {
|
|||||||
String name = iter.next();
|
String name = iter.next();
|
||||||
String path = _apps.get(name);
|
String path = _apps.get(name);
|
||||||
buf.append(" <a target=\"_top\" href=\"").append(path).append("\">");
|
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();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
@ -131,20 +131,31 @@ public class PluginStarter implements Runnable {
|
|||||||
// add themes in console/themes
|
// add themes in console/themes
|
||||||
|
|
||||||
// add summary bar link
|
// add summary bar link
|
||||||
File pluginConfig = new File(pluginDir, "plugin.config");
|
Properties props = pluginProperties(ctx, appName);
|
||||||
if (pluginConfig.exists()) {
|
String name = props.getProperty("consoleLinkName_" + Messages.getLanguage(ctx));
|
||||||
Properties props = new Properties();
|
if (name == null)
|
||||||
DataHelper.loadProps(props, pluginConfig);
|
name = props.getProperty("consoleLinkName");
|
||||||
String name = props.getProperty("consoleLinkName");
|
String url = props.getProperty("consoleLinkURL");
|
||||||
String url = props.getProperty("consoleLinkURL");
|
if (name != null && url != null && name.length() > 0 && url.length() > 0)
|
||||||
if (name != null && url != null && name.length() > 0 && url.length() > 0)
|
NavHelper.registerApp(name, url);
|
||||||
NavHelper.registerApp(name, url);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
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() {
|
public static Properties pluginProperties() {
|
||||||
File dir = I2PAppContext.getGlobalContext().getConfigDir();
|
File dir = I2PAppContext.getGlobalContext().getConfigDir();
|
||||||
Properties rv = new Properties();
|
Properties rv = new Properties();
|
||||||
@ -167,6 +178,16 @@ public class PluginStarter implements Runnable {
|
|||||||
return rv;
|
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 */
|
/** see comments in ConfigClientsHandler */
|
||||||
static Server getConsoleServer() {
|
static Server getConsoleServer() {
|
||||||
Collection c = Server.getHttpServers();
|
Collection c = Server.getHttpServers();
|
||||||
|
@ -313,8 +313,12 @@ public class PluginUpdateHandler extends UpdateHandler {
|
|||||||
if (Boolean.valueOf(props.getProperty("dont-start-at-install")).booleanValue()) {
|
if (Boolean.valueOf(props.getProperty("dont-start-at-install")).booleanValue()) {
|
||||||
if (Boolean.valueOf(props.getProperty("router-restart-required")).booleanValue())
|
if (Boolean.valueOf(props.getProperty("router-restart-required")).booleanValue())
|
||||||
updateStatus("<b>" + _("Plugin {0} successfully installed, router restart required", appName) + "</b>");
|
updateStatus("<b>" + _("Plugin {0} successfully installed, router restart required", appName) + "</b>");
|
||||||
else
|
else {
|
||||||
updateStatus("<b>" + _("Plugin {0} successfully installed", appName) + "</b>");
|
updateStatus("<b>" + _("Plugin {0} successfully installed", appName) + "</b>");
|
||||||
|
Properties pluginProps = PluginStarter.pluginProperties();
|
||||||
|
pluginProps.setProperty(PluginStarter.PREFIX + appName + PluginStarter.ENABLED, "false");
|
||||||
|
PluginStarter.storePluginProperties(pluginProps);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// start everything
|
// start everything
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user