A webmail client. Forked from https://git.sr.ht/~migadu/alps
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

49 lines
1017 B

  1. package koushinbase
  2. import (
  3. "html/template"
  4. "net/url"
  5. "git.sr.ht/~emersion/koushin"
  6. "github.com/labstack/echo/v4"
  7. )
  8. const messagesPerPage = 50
  9. func init() {
  10. p := koushin.GoPlugin{Name: "base"}
  11. p.TemplateFuncs(template.FuncMap{
  12. "tuple": func(values ...interface{}) []interface{} {
  13. return values
  14. },
  15. "pathescape": func(s string) string {
  16. return url.PathEscape(s)
  17. },
  18. })
  19. p.GET("/mailbox/:mbox", handleGetMailbox)
  20. p.GET("/message/:mbox/:uid", func(ectx echo.Context) error {
  21. ctx := ectx.(*koushin.Context)
  22. return handleGetPart(ctx, false)
  23. })
  24. p.GET("/message/:mbox/:uid/raw", func(ectx echo.Context) error {
  25. ctx := ectx.(*koushin.Context)
  26. return handleGetPart(ctx, true)
  27. })
  28. p.GET("/login", handleLogin)
  29. p.POST("/login", handleLogin)
  30. p.GET("/logout", handleLogout)
  31. p.GET("/compose", handleCompose)
  32. p.POST("/compose", handleCompose)
  33. p.GET("/message/:mbox/:uid/reply", handleCompose)
  34. p.POST("/message/:mbox/:uid/reply", handleCompose)
  35. koushin.RegisterPlugin(p.Plugin())
  36. }