Author: dbkr
Date: 2008-08-22 10:18:27 +0000 (Fri, 22 Aug 2008)
New Revision: 22092

Added:
   branches/Freemail/webmail/src/freemail/FreemailGui.java
   branches/Freemail/webmail/src/freemail/MenuItem.java
   branches/Freemail/webmail/src/freemail/statictext/
   branches/Freemail/webmail/src/freemail/statictext/fm2.css
   branches/Freemail/webmail/src/freemail/statictext/template.html
Modified:
   branches/Freemail/webmail/build.xml
   branches/Freemail/webmail/src/freemail/FreemailPlugin.java
Log:
Commit Cole's work on the webmail interface.


Modified: branches/Freemail/webmail/build.xml
===================================================================
--- branches/Freemail/webmail/build.xml 2008-08-22 08:57:03 UTC (rev 22091)
+++ branches/Freemail/webmail/build.xml 2008-08-22 10:18:27 UTC (rev 22092)
@@ -79,6 +79,9 @@
                <copy todir="${build}/freemailgui/images">
                        <fileset dir="${src}/freemailgui/images" />
               </copy>
+              <copy todir="${build}/freemail/statictext">
+                       <fileset dir="${src}/freemail/statictext"/>
+               </copy>
        </target>



Added: branches/Freemail/webmail/src/freemail/FreemailGui.java
===================================================================
--- branches/Freemail/webmail/src/freemail/FreemailGui.java                     
        (rev 0)
+++ branches/Freemail/webmail/src/freemail/FreemailGui.java     2008-08-22 
10:18:27 UTC (rev 22092)
@@ -0,0 +1,61 @@
+package freemail;
+
+import java.io.*;
+import java.util.ArrayList;
+
+public class FreemailGui {
+       private String css;
+       private String html;
+       public String title;
+       public String contentBox;
+       public String menu;
+       public String titleBar;
+       
+       public FreemailGui() {
+               title = "";
+               contentBox = "";
+               menu = "";
+               html = "";
+               titleBar = "";
+               css = "";
+               loadTemplates();
+       }
+       
+       public void loadTemplates() {
+               try {
+               InputStream is = this.getClass().getResourceAsStream("fm2.css");
+               BufferedReader buf = new BufferedReader(new 
InputStreamReader(is));
+               String nl;
+                       while (buf.ready()) {
+                               css = css + buf.readLine() + "\n";
+                       }
+               is = this.getClass().getResourceAsStream("template.html");
+               buf = new BufferedReader(new InputStreamReader(is));
+                       while (buf.ready()) {
+                               html = html + buf.readLine() + "\n";
+                       }
+               
+               }
+               catch (IOException e) {
+                       //nottin
+               }
+       }
+       
+       public String generatePage() {
+               String htmlPage = html;
+               htmlPage = htmlPage.replaceAll("\\#title\\#",title);
+               htmlPage = htmlPage.replaceAll("\\#style\\#",css);
+               htmlPage = htmlPage.replaceAll("\\#titlebar\\#",titleBar);
+               htmlPage = htmlPage.replaceAll("\\#content\\#",contentBox);
+               htmlPage = htmlPage.replaceAll("\\#menu\\#",menu);
+       
+               /*String htmlPage = "<html 
xmlns=\"http://www.w3.org/1999/xhtml\";>\n<head>\n<meta 
http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<title>";
+               htmlPage = htmlPage + title;
+               htmlPage = htmlPage + "</title><style type=\"text/css\">";
+               htmlPage = htmlPage + css;
+               htmlPage = htmlPage + "</style></head><body><div 
id=\"fm_main\"><div id=\"fm_title\"><div 
class=\"fm_titletxt\">freemail</div><div class=\"fm_square\">&nbsp;</div><div 
class=\"fm_square\">&nbsp;</div><div class=\"fm_square\">&nbsp;</div></div><div 
id=\"contentwrapper\"><div id=\"contentcolumn\"><div class=\"innertube\">";
+               htmlPage = htmlPage + contentBox;*/
+               
+               return htmlPage;
+       }
+}

Modified: branches/Freemail/webmail/src/freemail/FreemailPlugin.java
===================================================================
--- branches/Freemail/webmail/src/freemail/FreemailPlugin.java  2008-08-22 
08:57:03 UTC (rev 22091)
+++ branches/Freemail/webmail/src/freemail/FreemailPlugin.java  2008-08-22 
10:18:27 UTC (rev 22092)
@@ -23,6 +23,7 @@


 import java.io.IOException;
+import java.lang.ClassLoader;

 import freenet.pluginmanager.FredPlugin;
 import freenet.pluginmanager.FredPluginHTTP;
@@ -32,6 +33,8 @@
 import freenet.pluginmanager.PluginRespirator;
 import freenet.support.HTMLNode;
 import freenet.support.api.HTTPRequest;
+import freemail.FreemailGui;
+import freemail.MenuItem;

 // although we have threads, we still 'implement' FredPluginThreadless because 
our runPlugin method
 // returns rather than just continuing to run for the lifetime of the plugin.
@@ -56,30 +59,42 @@
        }

        public String handleHTTPGet(HTTPRequest request) throws 
PluginHTTPException {
-               HTMLNode pageNode = 
pluginResp.getPageMaker().getPageNode("Freemail plugin", false, null);
-               HTMLNode contentNode = 
pluginResp.getPageMaker().getContentNode(pageNode);
+               if (request.isParameterSet("createAccount")) {
+                       HTMLNode pageNode = 
pluginResp.getPageMaker().getPageNode("Freemail plugin", false, null);
+                       HTMLNode contentNode = 
pluginResp.getPageMaker().getContentNode(pageNode);

-               HTMLNode addBox = contentNode.addChild("div", "class", 
"infobox");
-               addBox.addChild("div", "class", "infobox-header", "Add 
account");
+                       HTMLNode addBox = contentNode.addChild("div", "class", 
"infobox");
+                       addBox.addChild("div", "class", "infobox-header", "Add 
account");

-               HTMLNode boxContent = addBox.addChild("div", "class", 
"infobox-content");
-               HTMLNode form = pluginResp.addFormChild(boxContent, "", 
"addAccountForm");
+                       HTMLNode boxContent = addBox.addChild("div", "class", 
"infobox-content");
+                       HTMLNode form = pluginResp.addFormChild(boxContent, "", 
"addAccountForm");

-               HTMLNode table = form.addChild("table", "class", "plugintable");
-               HTMLNode tableRowName = table.addChild("tr");
-               tableRowName.addChild("td", "Name");
-               tableRowName.addChild("td").addChild("input", new String[] { 
"type", "name", "value", "size" }, new String[] { "text", "name", "", "30" });
-               HTMLNode tableRowPassword = table.addChild("tr");
-               tableRowPassword.addChild("td", "Password");
-               tableRowPassword.addChild("td").addChild("input", new String[] 
{ "type", "name", "value", "size" }, new String[] { "password", "password", "", 
"30" });
-               HTMLNode tableRowDomain = table.addChild("tr");
-               tableRowDomain.addChild("td", "Domain");
-               tableRowDomain.addChild("td").addChild("input", new String[] { 
"type", "name", "value", "size" }, new String[] { "text", "domain", "", "30" });
-               HTMLNode tableRowSubmit = table.addChild("tr");
-               tableRowSubmit.addChild("td");
-               tableRowSubmit.addChild("td").addChild("input", new String[] { 
"type", "name", "value" }, new String[] { "submit", "add", "Add account"});
+                       HTMLNode table = form.addChild("table", "class", 
"plugintable");
+                       HTMLNode tableRowName = table.addChild("tr");
+                       tableRowName.addChild("td", "Name");
+                       tableRowName.addChild("td").addChild("input", new 
String[] { "type", "name", "value", "size" }, new String[] { "text", "name", 
"", "30" });
+                       HTMLNode tableRowPassword = table.addChild("tr");
+                       tableRowPassword.addChild("td", "Password");
+                       tableRowPassword.addChild("td").addChild("input", new 
String[] { "type", "name", "value", "size" }, new String[] { "password", 
"password", "", "30" });
+                       HTMLNode tableRowDomain = table.addChild("tr");
+                       tableRowDomain.addChild("td", "Domain");
+                       tableRowDomain.addChild("td").addChild("input", new 
String[] { "type", "name", "value", "size" }, new String[] { "text", "domain", 
"", "30" });
+                       HTMLNode tableRowSubmit = table.addChild("tr");
+                       tableRowSubmit.addChild("td");
+                       tableRowSubmit.addChild("td").addChild("input", new 
String[] { "type", "name", "value" }, new String[] { "submit", "add", "Add 
account"});

-               return pageNode.generate();
+                       return pageNode.generate();
+               } else {
+                       FreemailGui fg = new FreemailGui();
+                       fg.title = "Log in to Freemail";
+                       fg.contentBox = "<form action='?login' method=post>";
+                       fg.contentBox += "Username: <input type='text'><br>";
+                       fg.contentBox += "Password: <input type='pass'><br>";
+                       fg.contentBox += "<input type='submit' value='Log 
in'>";        
+                       MenuItem menu = new MenuItem("Create an Account", 
"createAccount");
+                       fg.menu = menu.generateMenuItem();
+                       return fg.generatePage();
+               }
        }

        public String handleHTTPPost(HTTPRequest request) throws 
PluginHTTPException {

Added: branches/Freemail/webmail/src/freemail/MenuItem.java
===================================================================
--- branches/Freemail/webmail/src/freemail/MenuItem.java                        
        (rev 0)
+++ branches/Freemail/webmail/src/freemail/MenuItem.java        2008-08-22 
10:18:27 UTC (rev 22092)
@@ -0,0 +1,25 @@
+package freemail;
+
+public class MenuItem {
+
+       private String label;
+       private String action;
+       
+       public MenuItem(String label, String action) {
+               this.label = label;
+               this.action = action;
+       }
+       
+       public String generateMenuItem() {
+               return "<li><a href=\"?" + action + "\">" + label + "</a></li>";
+       }
+
+       public void setLabel(String label) {
+               this.label = label;
+       }
+       
+       public void setAction(String action) {
+               this.action = action;
+       }
+
+}

Added: branches/Freemail/webmail/src/freemail/statictext/fm2.css
===================================================================
--- branches/Freemail/webmail/src/freemail/statictext/fm2.css                   
        (rev 0)
+++ branches/Freemail/webmail/src/freemail/statictext/fm2.css   2008-08-22 
10:18:27 UTC (rev 22092)
@@ -0,0 +1,119 @@
+/* Page layout heavily modified version of the one found at
+   
http://www.dynamicdrive.com/style/layouts/item/css-fixed-layout-21-fixed-fixed/
+   Thanks to Dynamic Drive!
+*/
+
+
+body{
+margin:0;
+padding:0;
+line-height: 1.5em;
+}
+
+#fm_main{
+width: 840px; /*Width of main container*/
+margin: auto; /*Center container on page*/
+margin-top: 10px;
+}
+
+#fm_title{
+       //height: 25px; /*Height of top section*/
+       background-color: #999999;
+       padding: 5px;
+       color: #FFFFFF;
+       overflow: hidden;
+}
+
+.fm_titletxt {
+       font-family: Verdana, Arial, Helvetica, sans-serif;
+       font-size: 18px;
+       float: left;
+}
+
+.fm_square {
+       background-color: #FFFFFF;
+       float: right;
+       //margin: 0px;
+       margin-left: 5px;
+       //padding: 12px;
+       height: 25px;
+       width: 25px;
+}
+* html .fm_square {
+       width: 2px;
+       height: 2px;
+       overflow: hidden;
+}
+
+#contentwrapper{
+float: left;
+width: 100%;
+}
+
+#contentcolumn{
+margin-top: 5px;
+border: 3px solid #999999;
+margin-left: 110px; /*Set left margin to LeftColumnWidth*/
+margin-bottom: 5px;
+}
+
+#leftcolumn{
+float: left;
+width: 100px; /*Width of left column*/
+margin-left: -840px; /*Set left margin to -(MainContainerWidth)*/
+border: 3px solid #999999;
+margin-top: 5px;
+padding: 0px;
+margin-bottom: 5px;
+}
+
+#footer{
+clear: left;
+width: 835px;
+color: #FFFFFF;
+padding: 3px;
+background: #999999;
+}
+
+.innertube{
+margin: 10px; /*Margins for inner DIV inside each column (to provide padding)*/
+margin-top: 0;
+}
+
+.fm_menu{
+background-color: white;
+border-bottom-width: 0;
+width: 100%;
+margin: auto;
+padding: 0px;
+}
+
+* html .fm_menu{ /*IE only rule. Original menu width minus all left/right 
paddings */
+width: 84px;
+}
+
+.fm_menu ul{
+padding: 0px;
+margin: 2px;
+list-style-type: none;
+}
+.fm_menu a{
+font-family: Verdana, Arial, Helvetica, sans-serif;
+font-size: 10px;
+padding: 0px;
+padding-left: 2px;
+display: block;
+width: 100%; /*Define width for IE6's sake*/
+color: #999999;
+text-decoration: none;
+/*border-bottom: 1px solid #C0C0C0;*/
+}
+
+* html body .fm_menu a{ /*Non IE rule*/
+width: auto;
+}
+
+.fm_menu a:hover{
+background-color: #999999;
+color: white;
+}

Added: branches/Freemail/webmail/src/freemail/statictext/template.html
===================================================================
--- branches/Freemail/webmail/src/freemail/statictext/template.html             
                (rev 0)
+++ branches/Freemail/webmail/src/freemail/statictext/template.html     
2008-08-22 10:18:27 UTC (rev 22092)
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>#title#</title>
+<style type="text/css">#style#</style>
+</head>
+
+<body>
+<div id="fm_main">
+    <div id="fm_title">
+       <div class="fm_titletxt">#titlebar#</div>
+       <div class="fm_square">&nbsp;</div><div 
class="fm_square">&nbsp;</div><div class="fm_square">&nbsp;</div>
+    </div>
+    <div id="contentwrapper">
+        <div id="contentcolumn">
+            <div class="innertube">#content#</div>
+        </div>
+    </div>
+    <div id="leftcolumn">
+                <div class="fm_menu">
+                       <ul>#menu#</ul>
+               </div>
+       </div>
+   <div id="footer">freemail by dave baker, web interface by cole brown</div>
+</div>
+</body>
+</html>


Reply via email to