redirectToRoot(ctx);
return;
}
// Tell the user that the node is shutting down
PageNode page = ctx.getPageMaker().getPageNode("Node Shutdown", ctx, new RenderParameters().renderNavigationLinks(false));
HTMLNode pageNode = page.outer;
HTMLNode contentNode = page.content;
ctx.getPageMaker().getInfobox("infobox-information", l10n("shutdownDone"), contentNode, "shutdown-progressing", true).
addChild("#", l10n("thanks"));
WelcomeToadlet.maybeDisplayWrapperLogfile(ctx, contentNode);
this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
return;
} else if (request.isParameterSet("restarted")) {
if ((!request.isParameterSet("formPassword")) || !request.getParam("formPassword").equals(ctx.getFormPassword())) {
redirectToRoot(ctx);
return;
}
sendRestartingPage(ctx);
return;
} else if (request.getParam("newbookmark").length() > 0) {
PageNode page = ctx.getPageMaker().getPageNode(l10n("confirmAddBookmarkTitle"), ctx);
HTMLNode pageNode = page.outer;
HTMLNode contentNode = page.content;
HTMLNode infoboxContent = ctx.getPageMaker().getInfobox("#", l10n("confirmAddBookmarkSubTitle"), contentNode, "add-bookmark-confirm", true);
HTMLNode addForm = ctx.addFormChild(infoboxContent, "/bookmarkEditor/", "editBookmarkForm");
addForm.addChild("#", l10n("confirmAddBookmarkWithKey", "key", request.getParam("newbookmark")));
addForm.addChild("br");
String key = request.getParam("newbookmark");
if (key.startsWith("freenet:")) {
key = key.substring(8);
}
addForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"hidden", "key", key});
if(request.isParameterSet("hasAnActivelink")) {
addForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"hidden","hasAnActivelink",request.getParam("hasAnActivelink")});
}
addForm.addChild("label", "for", "name", NodeL10n.getBase().getString("BookmarkEditorToadlet.nameLabel") + ' ');
addForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"text", "name", request.getParam("desc")});
addForm.addChild("br");
addForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"hidden", "bookmark", "/"});
addForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"hidden", "action", "addItem"});
addForm.addChild("label", "for", "descB", NodeL10n.getBase().getString("BookmarkEditorToadlet.descLabel") + ' ');
addForm.addChild("br");
addForm.addChild("textarea", new String[]{"id", "name", "row", "cols"}, new String[]{"descB", "descB", "3", "70"});
if(node.getDarknetConnections().length > 0) {
addForm.addChild("br");
addForm.addChild("br");
HTMLNode peerTable = addForm.addChild("table", "class", "darknet_connections");
peerTable.addChild("th", "colspan", "2", NodeL10n.getBase().getString("BookmarkEditorToadlet.recommendToFriends"));
for(DarknetPeerNode peer : node.getDarknetConnections()) {
HTMLNode peerRow = peerTable.addChild("tr", "class", "darknet_connections_normal");
peerRow.addChild("td", "class", "peer-marker").addChild("input", new String[] { "type", "name" }, new String[] { "checkbox", "node_" + peer.hashCode() });
peerRow.addChild("td", "class", "peer-name").addChild("#", peer.getName());
}
addForm.addChild("label", "for", "descB", (NodeL10n.getBase().getString("BookmarkEditorToadlet.publicDescLabel") + ' '));
addForm.addChild("br");
addForm.addChild("textarea", new String[]{"id", "name", "row", "cols"}, new String[]{"descB", "publicDescB", "3", "70"}, "");
}
addForm.addChild("br");
addForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"submit", "addbookmark", NodeL10n.getBase().getString("BookmarkEditorToadlet.addBookmark")});
this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
return;
} else if (uri.getQuery() != null && uri.getQuery().startsWith("_CHECKED_HTTP_=")) {
//Redirect requests for escaped URLs using the old destination to ExternalLinkToadlet.
super.writeTemporaryRedirect(ctx, "Depreciated", ExternalLinkToadlet.PATH+'?'+uri.getQuery());
return;
}
}
PageNode page = ctx.getPageMaker().getPageNode(l10n("homepageFullTitle"), ctx);
HTMLNode pageNode = page.outer;
HTMLNode contentNode = page.content;
String useragent = ctx.getHeaders().get("user-agent");
if (useragent != null) {
useragent = useragent.toLowerCase();
if ((useragent.indexOf("msie") > -1) && (useragent.indexOf("opera") == -1)) {
ctx.getPageMaker().getInfobox("infobox-alert", l10n("ieWarningTitle"), contentNode, "internet-explorer-used", true).
addChild("#", l10n("ieWarning"));
}
}
// Alerts
if (ctx.isAllowedFullAccess()) {
contentNode.addChild(ctx.getAlertManager().createSummary());
}
if (ctx.getPageMaker().getTheme().fetchKeyBoxAboveBookmarks) {
this.putFetchKeyBox(ctx, contentNode);
}
// Bookmarks
HTMLNode bookmarkBox = contentNode.addChild("div", "class", "infobox infobox-normal bookmarks-box");
HTMLNode bookmarkBoxHeader = bookmarkBox.addChild("div", "class", "infobox-header");
bookmarkBoxHeader.addChild("a", new String[]{"class", "title"}, new String[]{"bookmarks-header-text", NodeL10n.getBase().getString("BookmarkEditorToadlet.myBookmarksExplanation")}, NodeL10n.getBase().getString("BookmarkEditorToadlet.myBookmarksTitle"));
if (ctx.isAllowedFullAccess()) {
bookmarkBoxHeader.addChild("span", "class", "edit-bracket", "[");
bookmarkBoxHeader.addChild("span", "id", "bookmarkedit").addChild("a", new String[]{"href", "class"}, new String[]{"/bookmarkEditor/", "interfacelink"}, NodeL10n.getBase().getString("BookmarkEditorToadlet.edit"));
bookmarkBoxHeader.addChild("span", "class", "edit-bracket", "]");
}
HTMLNode bookmarkBoxContent = bookmarkBox.addChild("div", "class", "infobox-content");
HTMLNode bookmarksList = bookmarkBoxContent.addChild("ul", "id", "bookmarks");
if (ctx.isAllowedFullAccess() || !ctx.getContainer().publicGatewayMode()) {
addCategoryToList(BookmarkManager.MAIN_CATEGORY, bookmarksList, (!container.enableActivelinks()) || (useragent != null && useragent.contains("khtml") && !useragent.contains("chrome")), ctx);
}
else {
addCategoryToList(BookmarkManager.DEFAULT_CATEGORY, bookmarksList, (!container.enableActivelinks()) || (useragent != null && useragent.contains("khtml") && !useragent.contains("chrome")), ctx);
}
// Search Box
// FIXME search box is BELOW bookmarks for now, until we get search fixed properly.
HTMLNode searchBox = contentNode.addChild("div", "class", "infobox infobox-normal");
searchBox.addAttribute("id", "search-freenet");
searchBox.addChild("div", "class", "infobox-header").addChild("span", "class", "search-title-label", NodeL10n.getBase().getString("WelcomeToadlet.searchBoxLabel"));
HTMLNode searchBoxContent = searchBox.addChild("div", "class", "infobox-content");
// Search form
if(node.pluginManager != null &&
node.pluginManager.isPluginLoaded("plugins.Library.Main")) {
// FIXME: Remove this once we have a non-broken index.
searchBoxContent.addChild("span", "class", "search-warning-text", l10n("searchBoxWarningSlow"));
HTMLNode searchForm = container.addFormChild(searchBoxContent, "/library/", "searchform");
searchForm.addChild("input", new String[] { "type", "size", "name" }, new String[] { "text", "80", "search" });
searchForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "find", l10n("searchFreenet") });
// Search must be in a new window so that the user is able to browse the bookmarks.
searchForm.addAttribute("target", "_blank");
} else if(node.pluginManager == null ||
node.pluginManager.isPluginLoadedOrLoadingOrWantLoad("Library")) {
// Warn that search plugin is not loaded.
HTMLNode textSpan = searchBoxContent.addChild("span", "class", "search-not-availible-warning");
NodeL10n.getBase().addL10nSubstitution(textSpan, "WelcomeToadlet.searchPluginLoading", new String[] { "link" }, new HTMLNode[] { HTMLNode.link("/plugins/") });
} else {
// Warn that search plugin is not loaded.
HTMLNode textSpan = searchBoxContent.addChild("span", "class", "search-not-availible-warning");
NodeL10n.getBase().addL10nSubstitution(textSpan, "WelcomeToadlet.searchPluginNotLoaded", new String[] { "link" }, new HTMLNode[] { HTMLNode.link("/plugins/") });
}
if (!ctx.getPageMaker().getTheme().fetchKeyBoxAboveBookmarks) {
this.putFetchKeyBox(ctx, contentNode);
}
// Version info and Quit Form
HTMLNode versionContent = ctx.getPageMaker().getInfobox("infobox-information", l10n("versionHeader"), contentNode, "freenet-version", true);
versionContent.addChild("span", "class", "freenet-full-version",
NodeL10n.getBase().getString("WelcomeToadlet.version", new String[]{"fullVersion", "build", "rev"},
new String[]{Version.publicVersion(), Integer.toString(Version.buildNumber()), Version.cvsRevision()}));
versionContent.addChild("br");
versionContent.addChild("span", "class", "freenet-ext-version",
NodeL10n.getBase().getString("WelcomeToadlet.extVersion", new String[]{"build", "rev"},
new String[]{Integer.toString(NodeStarter.extBuildNumber), NodeStarter.extRevisionNumber}));
versionContent.addChild("br");
if (ctx.isAllowedFullAccess()) {
HTMLNode shutdownForm = ctx.addFormChild(versionContent, ".", "shutdownForm");
shutdownForm.addChild("input", new String[]{"type", "name"}, new String[]{"hidden", "exit"});
shutdownForm.addChild("input", new String[]{"type", "value"}, new String[]{"submit", l10n("shutdownNode")});
if (node.isUsingWrapper()) {
HTMLNode restartForm = ctx.addFormChild(versionContent, ".", "restartForm");
restartForm.addChild("input", new String[]{"type", "name"}, new String[]{"hidden", "restart"});
restartForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"submit", "restart2", l10n("restartNode")});
}
}
this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
}