commit 712dfc319bfe64fd38139d0e389a63fb38b54c12
parent 8f4384a373f1cc963e49440d3bcf7bc2d33baf5f
Author: Peter Kosyh <p.kosyh@gmail.com>
Date: Sat, 5 Sep 2020 08:39:15 +0300
fixes in new form
Diffstat:
4 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/ii-node/lib/style.css b/ii-node/lib/style.css
@@ -110,9 +110,33 @@
margin-bottom: 1em;
text-align: left;
padding: 1em;
- box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
+// box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
overflow: auto;
}
+.center {
+ text-align: center;
+}
+#edit {
+ text-align: left;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 1em;
+ background: #ffffea;
+ border: 1px solid #55aaaa;
+// box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
+}
+#edit textarea, #edit input {
+ font-size: larger;
+ background-color: #ffffea;
+ margin: 0.5em;
+ border: none;
+ overflow: auto;
+}
+
+#edit textarea {
+ min-height: 20em;
+}
+
#topic .selected {
background: #eaffff;
}
diff --git a/ii-node/tpl/login.tpl b/ii-node/tpl/login.tpl
@@ -12,7 +12,7 @@
</td></tr>
<tr class="odd"><td class="links" colspan="2">
-<button>Login</button>
+<button class="form-button">Login</button>
</td></tr>
</table>
diff --git a/ii-node/tpl/new.tpl b/ii-node/tpl/new.tpl
@@ -1,11 +1,11 @@
{{template "header.tpl" $}}
-
<form method="post" enctype="application/x-www-form-urlencoded" action="/{{.Echo}}/new">
-<input type="text" name="subj" class="subj" placeholder="subject"><br>
+<table id="edit"><tr><td class="even">
<input type="text" name="to" class="to" placeholder="To" value="All"><br>
-<textarea type="text" name="msg" class="message" cols=60 row=10 placeholder="Text here."></textarea><br>
-<br>
+<input type="text" name="subj" class="subj" placeholder="Subject"><br>
+<textarea type="text" name="msg" class="message" cols=60 row=16 placeholder="Hi, All!"></textarea>
+</td></tr><tr><td class="odd center">
<button class="form-button">Submit</button>
+</td></tr></table>
</form>
-
{{template "footer.tpl"}}
diff --git a/ii/msg.go b/ii/msg.go
@@ -43,6 +43,10 @@ func IsEcho(e string) bool {
return l >= 3 && l <= 120 && strings.Contains(e, ".")
}
+func IsSubject(s string) bool {
+ return len(strings.TrimSpace(s)) > 0
+}
+
func DecodeMsgline(msg string, enc bool) (*Msg, error) {
var m Msg
var data []byte
@@ -63,12 +67,18 @@ func DecodeMsgline(msg string, enc bool) (*Msg, error) {
if text[3] != "" {
return nil, errors.New("No body delimiter in message")
}
- m.Echo = text[0]
+ m.Echo = strings.TrimSpace(text[0])
if !IsEcho(m.Echo) {
return nil, errors.New("Wrong echoarea format")
}
- m.To = text[1]
- m.Subj = text[2]
+ m.To = strings.TrimSpace(text[1])
+ if len(m.To) == 0 {
+ m.To = "All"
+ }
+ m.Subj = strings.TrimSpace(text[2])
+ if !IsSubject(m.Subj) {
+ return nil, errors.New("Wrong subject")
+ }
m.Date = time.Now().Unix()
start := 4
repto := text[4]
@@ -127,6 +137,9 @@ func DecodeBundle(msg string) (*Msg, error) {
m.Addr = text[4]
m.To = text[5]
m.Subj = text[6]
+ if !IsSubject(m.Subj) {
+ return nil, errors.New("Wrong subject")
+ }
for i := 8; i < len(text); i++ {
m.Text += text[i] + "\n"
}