Add “unknown” Sone state, initialize local and remote Sones differently.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / page / TemplatePage.java
index d1febb2..79dd208 100644 (file)
@@ -30,7 +30,7 @@ import freenet.l10n.BaseL10n;
 
 /**
  * Base class for all {@link Page}s that are rendered with {@link Template}s.
- * 
+ *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public class TemplatePage implements Page, LinkEnabledCallback {
@@ -39,7 +39,7 @@ public class TemplatePage implements Page, LinkEnabledCallback {
        private final String path;
 
        /** The template to render. */
-       private final Template template;
+       protected final Template template;
 
        /** The L10n handler. */
        private final BaseL10n l10n;
@@ -49,7 +49,7 @@ public class TemplatePage implements Page, LinkEnabledCallback {
 
        /**
         * Creates a new template page.
-        * 
+        *
         * @param path
         *            The path of the page
         * @param template
@@ -90,6 +90,10 @@ public class TemplatePage implements Page, LinkEnabledCallback {
                for (String styleSheet : getStyleSheets()) {
                        pageNode.addCustomStyleSheet(styleSheet);
                }
+               String shortcutIcon = getShortcutIcon();
+               if (shortcutIcon != null) {
+                       pageNode.addForwardLink("icon", shortcutIcon);
+               }
 
                try {
                        processTemplate(request, template);
@@ -107,7 +111,7 @@ public class TemplatePage implements Page, LinkEnabledCallback {
        /**
         * Can be overridden to return a custom set of style sheets that are to be
         * included in the page’s header.
-        * 
+        *
         * @return Additional style sheets to load
         */
        protected Collection<String> getStyleSheets() {
@@ -115,9 +119,18 @@ public class TemplatePage implements Page, LinkEnabledCallback {
        }
 
        /**
+        * Returns the name of the shortcut icon to include in the page’s header.
+        *
+        * @return The URL of the shortcut icon, or {@code null} for no icon
+        */
+       protected String getShortcutIcon() {
+               return null;
+       }
+
+       /**
         * Can be overridden when extending classes need to set variables in the
         * template before it is rendered.
-        * 
+        *
         * @param request
         *            The request that is rendered
         * @param template
@@ -132,7 +145,7 @@ public class TemplatePage implements Page, LinkEnabledCallback {
        /**
         * Can be overridden to redirect the user to a different page, in case a log
         * in is required, or something else is wrong.
-        * 
+        *
         * @param request
         *            The request that is processed
         * @return The URL to redirect to, or {@code null} to not redirect