Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Some more progress

  • Loading branch information...
commit 3aa1aaec714848d0c5ec8aa6bb8c0354621dfda6 1 parent 43b54cd
Scott Lawrence authored

Showing 3 changed files with 11 additions and 7 deletions. Show diff stats Hide diff stats

  1. +5 1 html.go
  2. +5 5 mbox.go
  3. +1 1  thread.go
6 html.go
@@ -39,7 +39,7 @@ func writeHtml(odn, tdn string, all []*Threaded, msgs []*Threaded) {
39 39 msgTmpl := mktmpl(tdn, "message")
40 40
41 41 for _, msg := range all {
42   - f, err := os.Create(filepath.Join(odn, fmt.Sprintf("%s.html", msg.Id)))
  42 + f, err := os.Create(filepath.Join(odn, fmt.Sprintf("%s.html", msgid(msg))))
43 43 if err != nil {
44 44 panic(err)
45 45 }
@@ -47,3 +47,7 @@ func writeHtml(odn, tdn string, all []*Threaded, msgs []*Threaded) {
47 47 f.Close()
48 48 }
49 49 }
  50 +
  51 +func msgid(msg *Threaded) string {
  52 + return "" // TODO
  53 +}
10 mbox.go
@@ -12,9 +12,9 @@ const _MAX_LINE_LEN = 1024
12 12
13 13 var crlf = []byte{'\r', '\n'}
14 14
15   -func ReadMbox(r io.Reader) (msgs []mail.Message, err error) {
  15 +func ReadMbox(r io.Reader) (msgs []*mail.Message, err error) {
16 16 var mbuf *bytes.Buffer
17   - var m mail.Message
  17 + var m *mail.Message
18 18 lastblank := true
19 19 br := bufio.NewReaderSize(r, _MAX_LINE_LEN)
20 20 l, _, err := br.ReadLine()
@@ -23,7 +23,7 @@ func ReadMbox(r io.Reader) (msgs []mail.Message, err error) {
23 23 if len(fs) == 3 && string(fs[0]) == "From" && lastblank {
24 24 // flush the previous message, if necessary
25 25 if mbuf != nil {
26   - m, err = mail.Parse(mbuf.Bytes())
  26 + m, err = mail.ReadMessage(mbuf)
27 27 if err != nil {
28 28 println(err.Error())
29 29 } else {
@@ -49,7 +49,7 @@ func ReadMbox(r io.Reader) (msgs []mail.Message, err error) {
49 49 l, _, err = br.ReadLine()
50 50 }
51 51 if err == io.EOF {
52   - m, err = mail.Parse(mbuf.Bytes())
  52 + m, err = mail.ReadMessage(mbuf)
53 53 if err != nil {
54 54 return
55 55 }
@@ -58,7 +58,7 @@ func ReadMbox(r io.Reader) (msgs []mail.Message, err error) {
58 58 return
59 59 }
60 60
61   -func ReadMboxFile(filename string) ([]mail.Message, error) {
  61 +func ReadMboxFile(filename string) ([]*mail.Message, error) {
62 62 f, err := os.Open(filename)
63 63 if err != nil {
64 64 return nil, err
2  thread.go
@@ -49,7 +49,7 @@ func (s sortable) Swap(i, j int) {
49 49 s[i], s[j] = s[j], s[i]
50 50 }
51 51
52   -func Thread(msgs []mail.Message) ([]*Threaded, []*Threaded) {
  52 +func Thread(msgs []*mail.Message) ([]*Threaded, []*Threaded) {
53 53 tmap := map[string]*Threaded{}
54 54 for _, msg := range msgs {
55 55 mid := msg.MessageId

0 comments on commit 3aa1aae

Please sign in to comment.
Something went wrong with that request. Please try again.