Author: batosai Date: 2008-08-03 12:08:52 +0000 (Sun, 03 Aug 2008) New Revision: 21593
Added: trunk/apps/WoT/src/plugins/WoT/Version.java trunk/apps/WoT/src/plugins/WoT/WoTplugin.java Log: First step to make it a plugin. Added: trunk/apps/WoT/src/plugins/WoT/Version.java =================================================================== --- trunk/apps/WoT/src/plugins/WoT/Version.java (rev 0) +++ trunk/apps/WoT/src/plugins/WoT/Version.java 2008-08-03 12:08:52 UTC (rev 21593) @@ -0,0 +1,25 @@ +/** + * This code is part of WoT, a plugin for Freenet. It is distributed + * under the GNU General Public License, version 2 (or at your option + * any later version). See http://www.gnu.org/ for details of the GPL. + */ +package plugins.WoT; + +/** + * @author Julien Cornuwel (batosai at freenetproject.org) + * + */ +public class Version { + private static final String svnRevision = "@custom@"; + + static String getSvnRevision() { + return svnRevision; + } + + public static void main(String[] args) { + System.out.println("====="); + System.out.println(svnRevision); + System.out.println("====="); + } +} + Added: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java =================================================================== --- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java (rev 0) +++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java 2008-08-03 12:08:52 UTC (rev 21593) @@ -0,0 +1,94 @@ +/** + * This code is part of WoT, a plugin for Freenet. It is distributed + * under the GNU General Public License, version 2 (or at your option + * any later version). See http://www.gnu.org/ for details of the GPL. + */ + +package plugins.WoT; + +import freenet.client.HighLevelSimpleClient; +import freenet.clients.http.PageMaker; +import freenet.config.Config; +import freenet.config.SubConfig; +import freenet.node.fcp.FCPServer; +import freenet.pluginmanager.FredPlugin; +import freenet.pluginmanager.FredPluginHTTP; +import freenet.pluginmanager.FredPluginThreadless; +import freenet.pluginmanager.FredPluginVersioned; +import freenet.pluginmanager.PluginHTTPException; +import freenet.pluginmanager.PluginRespirator; +import freenet.support.HTMLNode; +import freenet.support.Logger; +import freenet.support.api.HTTPRequest; + +/** + * @author Julien Cornuwel (batosai at freenetproject.org) + * + */ +public class WoTplugin implements FredPlugin, FredPluginHTTP, FredPluginThreadless, FredPluginVersioned { + + public static String SELF_URI = "/plugins/plugins.WoT.WoTplugin/"; + private PluginRespirator pr; + private PageMaker pm; + private HighLevelSimpleClient client; + private FCPServer fcp; + + public void runPlugin(PluginRespirator pr) { + + Logger.error(this, "Start"); + + this.pr = pr; + + Config nc = pr.getNode().config; + SubConfig fc = nc.get("fproxy"); + String cssName = fc.getString("css"); + + pm = new PageMaker(cssName); + + pm.addNavigationLink("/", "Fproxy", "Back to Fproxy", false, null); + + client = pr.getHLSimpleClient(); + + fcp = pr.getNode().clientCore.getFCPServer(); + + } + + public void terminate() { + } + + @Override + public String handleHTTPGet(HTTPRequest request) throws PluginHTTPException { + return makeHomePage(); + } + + @Override + public String handleHTTPPost(HTTPRequest request) throws PluginHTTPException { + return null; + } + + @Override + public String handleHTTPPut(HTTPRequest request) throws PluginHTTPException { + return null; + } + + private String makeHomePage() { + HTMLNode pageNode = getPageNode(); + HTMLNode contentNode = pm.getContentNode(pageNode); + + HTMLNode box = pm.getInfobox("Summary"); + HTMLNode boxContent = pm.getContentNode(box); + boxContent.addChild("#", "The WoT plugin is running..."); + + contentNode.addChild(box); + return pageNode.generate(); + } + + private HTMLNode getPageNode() { + return pm.getPageNode("Web of Trust", null); + } + + public String getVersion() { + return "0.1 r"+Version.getSvnRevision(); + } + +}
