/** The Sone core. */
protected final WebInterface webInterface;
+ /** The page title l10n key. */
+ private final String pageTitleKey;
+
/** Whether to require a login. */
private final boolean requireLogin;
* The path of the page
* @param template
* The template to render
+ * @param webInterface
+ * The Sone web interface
+ */
+ public SoneTemplatePage(String path, Template template, WebInterface webInterface) {
+ this(path, template, null, webInterface, false);
+ }
+
+ /**
+ * Creates a new template page for Freetalk that does not require the user
+ * to be logged in.
+ *
+ * @param path
+ * The path of the page
+ * @param template
+ * The template to render
* @param pageTitleKey
* The l10n key of the page title
* @param webInterface
* The path of the page
* @param template
* The template to render
+ * @param webInterface
+ * The Sone web interface
+ * @param requireLogin
+ * Whether this page requires a login
+ */
+ public SoneTemplatePage(String path, Template template, WebInterface webInterface, boolean requireLogin) {
+ this(path, template, null, webInterface, requireLogin);
+ }
+
+ /**
+ * Creates a new template page for Freetalk.
+ *
+ * @param path
+ * The path of the page
+ * @param template
+ * The template to render
* @param pageTitleKey
* The l10n key of the page title
* @param webInterface
* Whether this page requires a login
*/
public SoneTemplatePage(String path, Template template, String pageTitleKey, WebInterface webInterface, boolean requireLogin) {
- super(path, webInterface.getTemplateContextFactory(), template, webInterface.getL10n(), pageTitleKey, "noPermission.html");
+ super(path, webInterface.getTemplateContextFactory(), template, "noPermission.html");
+ this.pageTitleKey = pageTitleKey;
this.webInterface = webInterface;
this.requireLogin = requireLogin;
template.getInitialContext().set("webInterface", webInterface);
* {@inheritDoc}
*/
@Override
+ protected String getPageTitle(Request request) {
+ if (pageTitleKey != null) {
+ return webInterface.getL10n().getString(pageTitleKey);
+ }
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected Collection<String> getStyleSheets() {
return Arrays.asList("css/sone.css");
}
import freenet.clients.http.PageMaker;
import freenet.clients.http.PageNode;
import freenet.clients.http.ToadletContext;
-import freenet.l10n.BaseL10n;
/**
* Base class for all {@link Page}s that are rendered with {@link Template}s.
/** The template to render. */
private final Template template;
- /** The L10n handler. */
- private final BaseL10n l10n;
-
- /** The l10n key for the page title. */
- private final String pageTitleKey;
-
/** Where to redirect for invalid form passwords. */
private final String invalidFormPasswordRedirectTarget;
* The template context factory
* @param template
* The template to render
- * @param l10n
- * The L10n handler
- * @param pageTitleKey
- * The l10n key of the title page
* @param invalidFormPasswordRedirectTarget
* The target to redirect to if a POST request does not contain
* the correct form password
*/
- public TemplatePage(String path, TemplateContextFactory templateContextFactory, Template template, BaseL10n l10n, String pageTitleKey, String invalidFormPasswordRedirectTarget) {
+ public TemplatePage(String path, TemplateContextFactory templateContextFactory, Template template, String invalidFormPasswordRedirectTarget) {
this.path = path;
this.templateContextFactory = templateContextFactory;
this.template = template;
- this.l10n = l10n;
- this.pageTitleKey = pageTitleKey;
this.invalidFormPasswordRedirectTarget = invalidFormPasswordRedirectTarget;
}
}
/**
+ * Returns the title of the page.
+ *
+ * @param request
+ * The request to serve
+ * @return The title of the page
+ */
+ protected String getPageTitle(Request request) {
+ return null;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
}
}
PageMaker pageMaker = toadletContext.getPageMaker();
- PageNode pageNode = pageMaker.getPageNode(l10n.getString(pageTitleKey), toadletContext);
+ PageNode pageNode = pageMaker.getPageNode(getPageTitle(request), toadletContext);
for (String styleSheet : getStyleSheets()) {
pageNode.addCustomStyleSheet(styleSheet);
}