about summary refs log tree commit diff stats
path: root/lib/templates
diff options
context:
space:
mode:
authorLeszek CimaƂa <ernierasta@zori.cz>2020-01-08 21:44:14 +0100
committerDrew DeVault <sir@cmpwn.com>2020-01-09 14:31:19 -0500
commitbf28e23933a9808820ef4855257accf4634068e9 (patch)
treed09d522d0f48d6f3e1013f5f7197e64636e51e99 /lib/templates
parentda6fb1a1551767609e1d5a97631bdaffdc301f4c (diff)
downloadaerc-bf28e23933a9808820ef4855257accf4634068e9.tar.gz
create OriginalMail struct
Diffstat (limited to 'lib/templates')
-rw-r--r--lib/templates/template.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/templates/template.go b/lib/templates/template.go
index 21f7b35..8a345d9 100644
--- a/lib/templates/template.go
+++ b/lib/templates/template.go
@@ -10,6 +10,7 @@ import (
 	"text/template"
 	"time"
 
+	"git.sr.ht/~sircmpwn/aerc/models"
 	"github.com/mitchellh/go-homedir"
 )
 
@@ -28,20 +29,23 @@ type TemplateData struct {
 
 func TestTemplateData() TemplateData {
 	defaults := map[string]string{
-		"To":           "John Doe <john@example.com>",
-		"Cc":           "Josh Doe <josh@example.com>",
-		"From":         "Jane Smith <jane@example.com>",
-		"Subject":      "This is only a test",
-		"OriginalText": "This is only a test text",
-		"OriginalFrom": "John Doe <john@example.com>",
-		"OriginalDate": time.Now().Format("Mon Jan 2, 2006 at 3:04 PM"),
+		"To":      "John Doe <john@example.com>",
+		"Cc":      "Josh Doe <josh@example.com>",
+		"From":    "Jane Smith <jane@example.com>",
+		"Subject": "This is only a test",
 	}
 
-	return ParseTemplateData(defaults)
+	original := models.OriginalMail{
+		Date: time.Now().Format("Mon Jan 2, 2006 at 3:04 PM"),
+		From: "John Doe <john@example.com>",
+		Text: "This is only a test text",
+	}
+
+	return ParseTemplateData(defaults, original)
 }
 
-func ParseTemplateData(defaults map[string]string) TemplateData {
-	originalDate, _ := time.Parse("Mon Jan 2, 2006 at 3:04 PM", defaults["OriginalDate"])
+func ParseTemplateData(defaults map[string]string, original models.OriginalMail) TemplateData {
+	originalDate, _ := time.Parse("Mon Jan 2, 2006 at 3:04 PM", original.Date)
 	td := TemplateData{
 		To:           parseAddressList(defaults["To"]),
 		Cc:           parseAddressList(defaults["Cc"]),
@@ -49,8 +53,8 @@ func ParseTemplateData(defaults map[string]string) TemplateData {
 		From:         parseAddressList(defaults["From"]),
 		Date:         time.Now(),
 		Subject:      defaults["Subject"],
-		OriginalText: defaults["Original"],
-		OriginalFrom: parseAddressList(defaults["OriginalFrom"]),
+		OriginalText: original.Text,
+		OriginalFrom: parseAddressList(original.From),
 		OriginalDate: originalDate,
 	}
 	return td
- starting to reorg C++ mu to use layers' href='/akkartik/mu/commit/cpp/literate/002trace.tests?h=main&id=515309164793b2e03c15954bf8a89f0f288a7f2c'>51530916 ^
5af83346 ^
35064671 ^

5af83346 ^
51530916 ^

5af83346 ^
35064671 ^
5af83346 ^
51530916 ^

d7494165 ^
35064671 ^
d7494165 ^


51530916 ^
35064671 ^


5af83346 ^
51530916 ^

51530916 ^
35064671 ^

51530916 ^



35064671 ^

51530916 ^


eba30983 ^
35064671 ^
4c569925 ^
eba30983 ^

51530916 ^

36594a43 ^
5f98a10c ^

36594a43 ^
5f98a10c ^
51530916 ^
51530916 ^




05d17773 ^
51530916 ^




05d17773 ^
51530916 ^




05d17773 ^

51530916 ^




05d17773 ^


51530916 ^




05d17773 ^


51530916 ^
d7494165 ^















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124