Skip to content
Browse files

Some more progress

  • Loading branch information...
1 parent 43b54cd commit 3aa1aaec714848d0c5ec8aa6bb8c0354621dfda6 @bytbox committed Apr 4, 2012
Showing with 11 additions and 7 deletions.
  1. +5 −1 html.go
  2. +5 −5 mbox.go
  3. +1 −1 thread.go
View
6 html.go
@@ -39,11 +39,15 @@ func writeHtml(odn, tdn string, all []*Threaded, msgs []*Threaded) {
msgTmpl := mktmpl(tdn, "message")
for _, msg := range all {
- f, err := os.Create(filepath.Join(odn, fmt.Sprintf("%s.html", msg.Id)))
+ f, err := os.Create(filepath.Join(odn, fmt.Sprintf("%s.html", msgid(msg))))
if err != nil {
panic(err)
}
msgTmpl.Execute(f, msg)
f.Close()
}
}
+
+func msgid(msg *Threaded) string {
+ return "" // TODO
+}
View
10 mbox.go
@@ -12,9 +12,9 @@ const _MAX_LINE_LEN = 1024
var crlf = []byte{'\r', '\n'}
-func ReadMbox(r io.Reader) (msgs []mail.Message, err error) {
+func ReadMbox(r io.Reader) (msgs []*mail.Message, err error) {
var mbuf *bytes.Buffer
- var m mail.Message
+ var m *mail.Message
lastblank := true
br := bufio.NewReaderSize(r, _MAX_LINE_LEN)
l, _, err := br.ReadLine()
@@ -23,7 +23,7 @@ func ReadMbox(r io.Reader) (msgs []mail.Message, err error) {
if len(fs) == 3 && string(fs[0]) == "From" && lastblank {
// flush the previous message, if necessary
if mbuf != nil {
- m, err = mail.Parse(mbuf.Bytes())
+ m, err = mail.ReadMessage(mbuf)
if err != nil {
println(err.Error())
} else {
@@ -49,7 +49,7 @@ func ReadMbox(r io.Reader) (msgs []mail.Message, err error) {
l, _, err = br.ReadLine()
}
if err == io.EOF {
- m, err = mail.Parse(mbuf.Bytes())
+ m, err = mail.ReadMessage(mbuf)
if err != nil {
return
}
@@ -58,7 +58,7 @@ func ReadMbox(r io.Reader) (msgs []mail.Message, err error) {
return
}
-func ReadMboxFile(filename string) ([]mail.Message, error) {
+func ReadMboxFile(filename string) ([]*mail.Message, error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
View
2 thread.go
@@ -49,7 +49,7 @@ func (s sortable) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
-func Thread(msgs []mail.Message) ([]*Threaded, []*Threaded) {
+func Thread(msgs []*mail.Message) ([]*Threaded, []*Threaded) {
tmap := map[string]*Threaded{}
for _, msg := range msgs {
mid := msg.MessageId

0 comments on commit 3aa1aae

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