Skip to content

Commit 2584c9b

Browse files
committed
Updating.
1 parent f840922 commit 2584c9b

File tree

11 files changed

+187
-172
lines changed

11 files changed

+187
-172
lines changed

app.go

+1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ func (b *App) RunCommandLine(cmd string, args []string, env []string, dir string
308308
cmdline.Env = env
309309
cmdline.Dir = dir
310310
result, err := cmdline.CombinedOutput()
311+
fmt.Println("\n RunCommandLine: ", cmd, "\n", string(result))
311312
if err != nil {
312313
fmt.Print("\nRunCommandLine had an error: ", err.Error(), "\n")
313314
}

build/README.md

-61
This file was deleted.

buildcli.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ func SendHTTPQuery(method string, uri string, body string) string {
548548
}
549549

550550
if res == nil {
551-
return fmt.Sprint("error: calling %s returned empty response", uri)
551+
return fmt.Sprintf("error: calling %s returned empty response", uri)
552552
}
553553

554554
responseData, err := io.ReadAll(res.Body)

dirserver.go

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/gin-contrib/static"
8+
"github.com/gin-gonic/gin"
9+
)
10+
11+
func markdownTranslate(app *App) gin.HandlerFunc {
12+
return func(c *gin.Context) {
13+
14+
// before request
15+
16+
// Perform the request.
17+
c.Next()
18+
19+
// after request
20+
if strings.Contains(c.Request.URL.String(), ".md") {
21+
bodydata := app.ReadFile(app.AppendPath(app.GetHomeDir(), c.Request.URL.String()))
22+
c.Data(200, "text/html", []byte(bodydata))
23+
}
24+
}
25+
}
26+
27+
func dirserver(app *App, dir string) {
28+
//
29+
// This will have the web server backend for EmailIt
30+
//
31+
r := gin.Default()
32+
r.Use(markdownTranslate(app))
33+
r.Use(static.Serve("/", static.LocalFile(dir, true)))
34+
35+
//
36+
// Run the server. TODO: I need to add a new unique port for each server.
37+
//
38+
err := r.Run(":9000")
39+
if err != nil {
40+
fmt.Print("\n Server error:\n", err.Error())
41+
}
42+
}

frontend/src/components/EmailIt.svelte

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { afterUpdate, onMount } from "svelte";
2+
import { afterUpdate, onMount, tick } from "svelte";
33
import CodeMirror from "../components/CodeMirror.svelte";
44
import AddressBook from "../components/AddressBook.svelte";
55
import showdown from "showdown";
@@ -20,6 +20,7 @@
2020
2121
let receiver = "";
2222
let subject = "";
23+
let listEl = false;
2324
let emailState = "edit";
2425
let focusAgain = false;
2526
let showChangeAccount = false;
@@ -59,6 +60,7 @@
5960
emailState = "edit";
6061
oldState = "edit";
6162
initFinished = false;
63+
receiver = "";
6264
generateEmailList();
6365
if ($email.new) {
6466
focusAgain = true;
@@ -67,16 +69,14 @@
6769
}
6870
});
6971
70-
afterUpdate(() => {
72+
afterUpdate(async () => {
7173
if ($commandLineEmail !== undefined && $commandLineEmail !== "") {
7274
receiver = $commandLineEmail;
7375
$email.to = $commandLineEmail;
7476
$commandLineEmail = undefined;
7577
}
7678
if ($email.new && $emailEditor !== null) {
7779
receiver = $email.to;
78-
var rec = document.getElementById("receiverInput");
79-
rec.value = $email.to;
8080
subject.value = $email.subject;
8181
$emailEditor.setValue($email.body);
8282
$email = {
@@ -92,7 +92,7 @@
9292
$emailEditor.setValue(bodyValue);
9393
oldState = "edit";
9494
}
95-
if (focusAgain) $emailEditor.focus();
95+
//if (focusAgain) $emailEditor.focus();
9696
focusAgain = false;
9797
}
9898
});
@@ -124,6 +124,7 @@
124124
125125
function addToInput(newEmail) {
126126
var parts = receiver.split(",");
127+
console.log("addToInput: ", newEmail, receiver, parts);
127128
if (parts.length > 1) {
128129
receiver =
129130
parts
@@ -201,7 +202,7 @@
201202
202203
async function createPreview() {
203204
var toAddress;
204-
toAddress = document.getElementById("receiverInput").value;
205+
toAddress = receiver;
205206
if (validate(toAddress)) {
206207
//
207208
// Keep a copy of the body value for when we exit preview mode.
@@ -260,8 +261,7 @@
260261
) {
261262
toAddress = $email.to;
262263
} else {
263-
var em = document.getElementById("receiverInput").value;
264-
toAddress = em;
264+
toAddress = receiver;
265265
}
266266
if (validate(toAddress)) {
267267
addToEmails(toAddress);
@@ -369,8 +369,6 @@
369369
}
370370
371371
function clearEmail() {
372-
var rec = document.getElementById("receiverInput");
373-
rec.value = "";
374372
receiver = "";
375373
subject.value = "";
376374
$emailEditor.setValue("");
@@ -477,8 +475,7 @@
477475
478476
function saveEmailState() {
479477
if ($emailEditor !== null) {
480-
var rec = document.getElementById("receiverInput");
481-
$email.to = rec.value;
478+
$email.to = receiver;
482479
$email.body = $emailEditor.getValue();
483480
$email.subject = subject.value;
484481
$email.new = true;
@@ -718,8 +715,8 @@
718715
autocorrect="off"
719716
bind:value={receiver}
720717
bind:this={receiverDOM}
718+
tabindex="0"
721719
on:blur={() => {
722-
showEmailList = false;
723720
saveEmailState();
724721
}}
725722
on:focus={() => {
@@ -744,8 +741,8 @@
744741
{#each elist as item}
745742
<li
746743
on:click={() => {
744+
listEl = true;
747745
addToInput(item);
748-
receiverDOM.focus();
749746
}}
750747
>
751748
{item}
@@ -762,16 +759,19 @@
762759
autocomplete="off"
763760
spellcheck="false"
764761
autocorrect="off"
762+
tabindex="0"
765763
bind:this={subject}
766764
on:blur={() => {
767765
saveEmailState();
768766
showEmailList = false;
767+
listEl = false;
769768
$emailEditor.focus();
770769
focusAgain = true;
771770
}}
772771
style="background-color: {$theme.textAreaColor}; font-family: {$theme.font}; color: {$theme.textColor}; border-color: {$theme.borderColor}; font-size: {$theme.fontSize};"
773772
on:focus={() => {
774773
showEmailList = false;
774+
listEl = false;
775775
}}
776776
/>
777777
</div>
@@ -789,16 +789,21 @@
789789
styling="position: relative; margin-bottom: 20px; border: solid 1px transparent; border-radius: 20px; overflow: hidden;"
790790
on:textChange={(event) => {
791791
showEmailList = false;
792+
listEl = false;
792793
textChanged(event.detail.data);
793794
}}
794795
on:editorChange={(event) => {
795796
showEmailList = false;
797+
listEl = false;
796798
editorChange(event.detail.data);
797799
}}
798800
on:focus={() => {
799801
showEmailList = false;
802+
listEl = false;
800803
}}
801804
on:blur={() => {
805+
showEmailList = false;
806+
listEl = false;
802807
saveEmailState();
803808
}}
804809
/>

frontend/src/components/ScriptLine.svelte

+7-2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
}
122122
123123
function shortenPath(oldpath) {
124+
oldpath = oldpath.replaceAll(" ", "&nbsp;");
124125
let result = oldpath;
125126
126127
//
@@ -132,7 +133,7 @@
132133
//
133134
// Add 40 to the width to account for the padding on each side.
134135
//
135-
while (determineWidth(result) + 40 >= $config.width) {
136+
while (determineWidth(result) + 60 >= $config.width) {
136137
result = "/";
137138
oldpath.split("/").forEach((element, index) => {
138139
if (element !== "") {
@@ -1451,7 +1452,7 @@
14511452
id="statusline"
14521453
style="background-color: {$theme.backgroundColor}; color: {$theme.textColor}; border-color: {$theme.borderColor};"
14531454
>
1454-
WD: {shortwd}
1455+
WD:&nbsp;{shortwd}
14551456
</div>
14561457
{#if showError}
14571458
<div id="errorContainer">
@@ -1605,8 +1606,12 @@
16051606
#statusline {
16061607
display: flex;
16071608
flex-direction: row;
1609+
user-select: none;
1610+
word-break: keep-all;
16081611
height: 30px;
1612+
max-height: 30px;
16091613
width: 900px;
1614+
max-width: 900px;
16101615
margin: 10px;
16111616
}
16121617

0 commit comments

Comments
 (0)