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
|
package koushinbase
import (
"html/template"
"net/url"
"git.sr.ht/~emersion/koushin"
"github.com/labstack/echo/v4"
)
const messagesPerPage = 50
func init() {
p := koushin.GoPlugin{Name: "base"}
p.TemplateFuncs(template.FuncMap{
"tuple": func(values ...interface{}) []interface{} {
return values
},
"pathescape": func(s string) string {
return url.PathEscape(s)
},
})
p.GET("/mailbox/:mbox", handleGetMailbox)
p.POST("/mailbox/:mbox", handleGetMailbox)
p.GET("/message/:mbox/:uid", func(ectx echo.Context) error {
ctx := ectx.(*koushin.Context)
return handleGetPart(ctx, false)
})
p.GET("/message/:mbox/:uid/raw", func(ectx echo.Context) error {
ctx := ectx.(*koushin.Context)
return handleGetPart(ctx, true)
})
p.GET("/login", handleLogin)
p.POST("/login", handleLogin)
p.GET("/logout", handleLogout)
p.GET("/compose", handleCompose)
p.POST("/compose", handleCompose)
p.GET("/message/:mbox/:uid/reply", handleCompose)
p.POST("/message/:mbox/:uid/reply", handleCompose)
p.POST("/message/:mbox/:uid/move", handleMove)
p.POST("/message/:mbox/:uid/delete", handleDelete)
koushin.RegisterPlugin(p.Plugin())
}
|