From f64bdc298e7db6fa63e4141e0f1ef921f8de7971 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 13 Oct 2010 12:07:39 +0200 Subject: [PATCH] Implementation stub of the login page. --- .../java/net/pterodactylus/sone/web/LoginPage.java | 39 +++++++++++++++++++ src/main/resources/i18n/sone.en.properties | 17 +++++++++ src/main/resources/static/css/sone.css | 7 ++++ src/main/resources/templates/login.html | 44 +++++++++++++++++++++- 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/static/css/sone.css diff --git a/src/main/java/net/pterodactylus/sone/web/LoginPage.java b/src/main/java/net/pterodactylus/sone/web/LoginPage.java index df06c87..8cebf49 100644 --- a/src/main/java/net/pterodactylus/sone/web/LoginPage.java +++ b/src/main/java/net/pterodactylus/sone/web/LoginPage.java @@ -17,6 +17,10 @@ package net.pterodactylus.sone.web; +import java.util.Set; + +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.web.page.Page.Request.Method; import net.pterodactylus.util.template.Template; /** @@ -38,4 +42,39 @@ public class LoginPage extends SoneTemplatePage { super("login.html", template, "Page.Login.Title", webInterface); } + // + // TEMPLATEPAGE METHODS + // + + /** + * {@inheritDoc} + */ + @Override + protected void processTemplate(Request request, Template template) { + Set localSones = webInterface.core().localSones(); + template.set("sones", localSones); + } + + /** + * {@inheritDoc} + */ + @Override + protected String getRedirectTarget(Request request) { + if (request.getMethod() == Method.POST) { + String soneId = request.getHttpRequest().getParam("sone-id"); + Sone selectedSone = null; + for (Sone sone : webInterface.core().localSones()) { + if (sone.getId().equals(soneId)) { + selectedSone = sone; + break; + } + } + if (selectedSone != null) { + setCurrentSone(request, selectedSone); + return "index.html"; + } + } + return null; + } + } diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index eeb0714..826f277 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -2,3 +2,20 @@ Navigation.Menu.Name=Sone Navigation.Menu.Tooltip=Freenet Social Network Plugin Navigation.Menu.Item.Login.Name=Login Navigation.Menu.Item.Login.Tooltip=Login to your Sone + +Page.Login.Title=Login - Sone +Page.Login.Page.Title=Login +Page.Login.Label.SelectSone=Select Sone: +Page.Login.Option.NoSone=Select Sone… + +Page.Login.LoadSone.Title=Load Sone +Page.Login.LoadSone.Description=This function can be used to load an existing Sone. You need to specify the {mark}insert key{/mark} of the Sone to load it! +Page.Login.LoadSone.Label.InsertURI=Sone Insert URI: +Page.Login.LoadSone.Button.LoadSone=Load Sone + +Page.Login.CreateSone.Title=Create Sone +Page.Login.CreateSone.Description=Use this function if you want to create a completely new Sone, either at a location of your choosing or a new, random location. +Page.Login.CreateSone.Label.InsertURI=Sone Insert URI: +Page.Login.CreateSone.Label.Name=Sone name: +Page.Login.CreateSone.Button.CreateFromURI=Create at given URI +Page.Login.CreateSone.Button.CreateRandom=Create new Sone diff --git a/src/main/resources/static/css/sone.css b/src/main/resources/static/css/sone.css new file mode 100644 index 0000000..137b9ab --- /dev/null +++ b/src/main/resources/static/css/sone.css @@ -0,0 +1,7 @@ +/* Sone Main CSS File */ + +#sone h1 { + font-family: inherit; + font-size: 200%; + font-weight: bold; +} diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index 9ed93dd..aad1525 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -1,3 +1,43 @@ -
-

Login

+
+ <%if !sones.empty> +

<%= Page.Login.Page.Title|l10n|html>

+
+ + + + +
+ <%/if> +

<%= Page.Login.LoadSone.Title|l10n|html>

+
<%= Page.Login.LoadSone.Description|l10n|html|replace needle="{mark}" replacement=""|replace needle="{/mark}" replacement="">
+
+ +
+ + + +
+
+

<%= Page.Login.CreateSone.Title|l10n|html>

+
<%= Page.Login.CreateSone.Description|l10n|html>
+
+ +
+ + +
+
+ + + +
+
+ +
+
-- 2.7.4