Implementation stub of the login page.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 13 Oct 2010 10:07:39 +0000 (12:07 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 13 Oct 2010 10:07:39 +0000 (12:07 +0200)
src/main/java/net/pterodactylus/sone/web/LoginPage.java
src/main/resources/i18n/sone.en.properties
src/main/resources/static/css/sone.css [new file with mode: 0644]
src/main/resources/templates/login.html

index df06c87..8cebf49 100644 (file)
 
 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<Sone> 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;
+       }
+
 }
index eeb0714..826f277 100644 (file)
@@ -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 (file)
index 0000000..137b9ab
--- /dev/null
@@ -0,0 +1,7 @@
+/* Sone Main CSS File */
+
+#sone h1 {
+       font-family: inherit;
+       font-size: 200%;
+       font-weight: bold;
+}
index 9ed93dd..aad1525 100644 (file)
@@ -1,3 +1,43 @@
-<div id="Sone">
-       <h1>Login</h1>
+<div id="sone">
+       <%if !sones.empty>
+               <h1><%= Page.Login.Page.Title|l10n|html></h1>
+               <form method="post">
+                       <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+                       <label for="sone-id"><%= Page.Login.Label.SelectSone|l10n|html></label>
+                       <select name="sone-id">
+                               <option disabled="disabled"><%= Page.Login.Option.NoSone|l10n|html></option>
+                               <%foreach sones sone>
+                                       <option value="<% sone.id|html>"><% sone.name|html></option>
+                               <%/foreach>
+                       </select>
+                       <button type="submit">Select</button>
+               </form>
+       <%/if>
+       <h1><%= Page.Login.LoadSone.Title|l10n|html></h1>
+       <div><%= Page.Login.LoadSone.Description|l10n|html|replace needle="{mark}" replacement="<i>"|replace needle="{/mark}" replacement="</i>"></div>
+       <form action="loadSone.html" method="post">
+               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+               <div>
+                       <label for="insert-uri"><%= Page.Login.LoadSone.Label.InsertURI|l10n|html></label>
+                       <input type="text" name="insert-uri" />
+                       <button type="submit"><%= Page.Login.LoadSone.Button.LoadSone|l10n|html></button>
+               </div>
+       </form>
+       <h1><%= Page.Login.CreateSone.Title|l10n|html></h1>
+       <div><%= Page.Login.CreateSone.Description|l10n|html></div>
+       <form action="createSone.html" method="post">
+               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+               <div>
+                       <label for="name"><%= Page.Login.CreateSone.Label.Name|l10n|html></label>
+                       <input type="text" name="name" />
+               </div>
+               <div>
+                       <label for="insert-uri"><%= Page.Login.CreateSone.Label.InsertURI|l10n|html></label>
+                       <input type="text" name="insert-uri" value="" />
+                       <button type="submit" name="create-from-uri" value="1"><%= Page.Login.CreateSone.Button.CreateFromURI|l10n|html></button>
+               </div>
+               <div>
+                       <button type="submit" name="create-random" value="1"><%= Page.Login.CreateSone.Button.CreateRandom|l10n|html></button>
+               </div>
+       </form>
 </div>