diff options
author | Simon Ser <contact@emersion.fr> | 2020-05-13 14:07:44 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-13 14:07:44 +0200 |
commit | b891a95fcf4a3d4b64100911dae49fb28904a7fd (patch) | |
tree | fe07b29d6f2443047b7f740c79d86b3c499cc9e9 /plugins/base | |
parent | 4cf5ad68afd80f27512c464843b0d917182ef0c2 (diff) | |
download | alps-b891a95fcf4a3d4b64100911dae49fb28904a7fd.tar.gz alps-b891a95fcf4a3d4b64100911dae49fb28904a7fd.zip |
Rename project to alps
Diffstat (limited to 'plugins/base')
-rwxr-xr-x | plugins/base/imap.go | 2 | ||||
-rw-r--r-- | plugins/base/plugin.go | 8 | ||||
-rw-r--r-- | plugins/base/public/compose.html | 2 | ||||
-rw-r--r-- | plugins/base/public/head.html | 2 | ||||
-rw-r--r-- | plugins/base/public/login.html | 2 | ||||
-rw-r--r-- | plugins/base/public/mailbox.html | 2 | ||||
-rw-r--r-- | plugins/base/public/message.html | 2 | ||||
-rw-r--r-- | plugins/base/public/settings.html | 2 | ||||
-rw-r--r-- | plugins/base/routes.go | 68 | ||||
-rw-r--r-- | plugins/base/smtp.go | 2 | ||||
-rw-r--r-- | plugins/base/strconv.go | 2 | ||||
-rw-r--r-- | plugins/base/template.go | 2 | ||||
-rw-r--r-- | plugins/base/viewer.go | 8 |
13 files changed, 52 insertions, 52 deletions
diff --git a/plugins/base/imap.go b/plugins/base/imap.go index 14409eb..cf028da 100755 --- a/plugins/base/imap.go +++ b/plugins/base/imap.go @@ -1,4 +1,4 @@ -package koushinbase +package alpsbase import ( "bufio" diff --git a/plugins/base/plugin.go b/plugins/base/plugin.go index 5743977..0e39b85 100644 --- a/plugins/base/plugin.go +++ b/plugins/base/plugin.go @@ -1,14 +1,14 @@ -package koushinbase +package alpsbase import ( - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" ) func init() { - p := koushin.GoPlugin{Name: "base"} + p := alps.GoPlugin{Name: "base"} p.TemplateFuncs(templateFuncs) registerRoutes(&p) - koushin.RegisterPluginLoader(p.Loader()) + alps.RegisterPluginLoader(p.Loader()) } diff --git a/plugins/base/public/compose.html b/plugins/base/public/compose.html index dd3c7aa..2deb24a 100644 --- a/plugins/base/public/compose.html +++ b/plugins/base/public/compose.html @@ -1,6 +1,6 @@ {{template "head.html"}} -<h1>koushin</h1> +<h1>alps</h1> <p> <a href="/mailbox/INBOX">Back</a> diff --git a/plugins/base/public/head.html b/plugins/base/public/head.html index bb47cfc..0bcaa9c 100644 --- a/plugins/base/public/head.html +++ b/plugins/base/public/head.html @@ -2,6 +2,6 @@ <html lang="en"> <head> <meta charset="utf-8"> - <title>koushin</title> + <title>alps</title> </head> <body> diff --git a/plugins/base/public/login.html b/plugins/base/public/login.html index 94f1b23..0391ed1 100644 --- a/plugins/base/public/login.html +++ b/plugins/base/public/login.html @@ -1,6 +1,6 @@ {{template "head.html"}} -<h1>koushin</h1> +<h1>alps</h1> <form method="post" action=""> <label for="username">Username:</label> diff --git a/plugins/base/public/mailbox.html b/plugins/base/public/mailbox.html index 2ef640a..1e376ba 100644 --- a/plugins/base/public/mailbox.html +++ b/plugins/base/public/mailbox.html @@ -1,6 +1,6 @@ {{template "head.html"}} -<h1>koushin</h1> +<h1>alps</h1> <p> <a href="/logout">Logout</a> diff --git a/plugins/base/public/message.html b/plugins/base/public/message.html index ed2b1a2..4d5edfa 100644 --- a/plugins/base/public/message.html +++ b/plugins/base/public/message.html @@ -1,6 +1,6 @@ {{template "head.html"}} -<h1>koushin</h1> +<h1>alps</h1> <p> <a href="/mailbox/{{.Mailbox.Name | pathescape}}?page={{.MailboxPage}}"> diff --git a/plugins/base/public/settings.html b/plugins/base/public/settings.html index c0d715c..6a7f8ba 100644 --- a/plugins/base/public/settings.html +++ b/plugins/base/public/settings.html @@ -1,6 +1,6 @@ {{template "head.html"}} -<h1>koushin</h1> +<h1>alps</h1> <p> <a href="/mailbox/INBOX">Back</a> diff --git a/plugins/base/routes.go b/plugins/base/routes.go index e75573f..70764e6 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -1,4 +1,4 @@ -package koushinbase +package alpsbase import ( "bytes" @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" "github.com/emersion/go-imap" imapmove "github.com/emersion/go-imap-move" imapclient "github.com/emersion/go-imap/client" @@ -21,18 +21,18 @@ import ( "github.com/labstack/echo/v4" ) -func registerRoutes(p *koushin.GoPlugin) { - p.GET("/", func(ctx *koushin.Context) error { +func registerRoutes(p *alps.GoPlugin) { + p.GET("/", func(ctx *alps.Context) error { return ctx.Redirect(http.StatusFound, "/mailbox/INBOX") }) p.GET("/mailbox/:mbox", handleGetMailbox) p.POST("/mailbox/:mbox", handleGetMailbox) - p.GET("/message/:mbox/:uid", func(ctx *koushin.Context) error { + p.GET("/message/:mbox/:uid", func(ctx *alps.Context) error { return handleGetPart(ctx, false) }) - p.GET("/message/:mbox/:uid/raw", func(ctx *koushin.Context) error { + p.GET("/message/:mbox/:uid/raw", func(ctx *alps.Context) error { return handleGetPart(ctx, true) }) @@ -64,7 +64,7 @@ func registerRoutes(p *koushin.GoPlugin) { } type MailboxRenderData struct { - koushin.BaseRenderData + alps.BaseRenderData Mailbox *MailboxStatus Mailboxes []MailboxInfo Messages []IMAPMessage @@ -72,7 +72,7 @@ type MailboxRenderData struct { Query string } -func handleGetMailbox(ctx *koushin.Context) error { +func handleGetMailbox(ctx *alps.Context) error { mboxName, err := url.PathUnescape(ctx.Param("mbox")) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) @@ -136,7 +136,7 @@ func handleGetMailbox(ctx *koushin.Context) error { } return ctx.Render(http.StatusOK, "mailbox.html", &MailboxRenderData{ - BaseRenderData: *koushin.NewBaseRenderData(ctx), + BaseRenderData: *alps.NewBaseRenderData(ctx), Mailbox: mbox, Mailboxes: mailboxes, Messages: msgs, @@ -146,13 +146,13 @@ func handleGetMailbox(ctx *koushin.Context) error { }) } -func handleLogin(ctx *koushin.Context) error { +func handleLogin(ctx *alps.Context) error { username := ctx.FormValue("username") password := ctx.FormValue("password") if username != "" && password != "" { s, err := ctx.Server.Sessions.Put(username, password) if err != nil { - if _, ok := err.(koushin.AuthError); ok { + if _, ok := err.(alps.AuthError); ok { return ctx.Render(http.StatusOK, "login.html", nil) } return fmt.Errorf("failed to put connection in pool: %v", err) @@ -165,17 +165,17 @@ func handleLogin(ctx *koushin.Context) error { return ctx.Redirect(http.StatusFound, "/mailbox/INBOX") } - return ctx.Render(http.StatusOK, "login.html", koushin.NewBaseRenderData(ctx)) + return ctx.Render(http.StatusOK, "login.html", alps.NewBaseRenderData(ctx)) } -func handleLogout(ctx *koushin.Context) error { +func handleLogout(ctx *alps.Context) error { ctx.Session.Close() ctx.SetSession(nil) return ctx.Redirect(http.StatusFound, "/login") } type MessageRenderData struct { - koushin.BaseRenderData + alps.BaseRenderData Mailboxes []MailboxInfo Mailbox *MailboxStatus Message *IMAPMessage @@ -185,7 +185,7 @@ type MessageRenderData struct { Flags map[string]bool } -func handleGetPart(ctx *koushin.Context, raw bool) error { +func handleGetPart(ctx *alps.Context, raw bool) error { mboxName, uid, err := parseMboxAndUid(ctx.Param("mbox"), ctx.Param("uid")) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) @@ -271,7 +271,7 @@ func handleGetPart(ctx *koushin.Context, raw bool) error { } return ctx.Render(http.StatusOK, "message.html", &MessageRenderData{ - BaseRenderData: *koushin.NewBaseRenderData(ctx), + BaseRenderData: *alps.NewBaseRenderData(ctx), Mailboxes: mailboxes, Mailbox: mbox, Message: msg, @@ -283,7 +283,7 @@ func handleGetPart(ctx *koushin.Context, raw bool) error { } type ComposeRenderData struct { - koushin.BaseRenderData + alps.BaseRenderData Message *OutgoingMessage } @@ -300,12 +300,12 @@ type composeOptions struct { // Send message, append it to the Sent mailbox, mark the original message as // answered -func submitCompose(ctx *koushin.Context, msg *OutgoingMessage, options *composeOptions) error { +func submitCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOptions) error { err := ctx.Session.DoSMTP(func(c *smtp.Client) error { return sendMessage(c, msg) }) if err != nil { - if _, ok := err.(koushin.AuthError); ok { + if _, ok := err.(alps.AuthError); ok { return echo.NewHTTPError(http.StatusForbidden, err) } return fmt.Errorf("failed to send message: %v", err) @@ -338,7 +338,7 @@ func submitCompose(ctx *koushin.Context, msg *OutgoingMessage, options *composeO return ctx.Redirect(http.StatusFound, "/mailbox/INBOX") } -func handleCompose(ctx *koushin.Context, msg *OutgoingMessage, options *composeOptions) error { +func handleCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOptions) error { if msg.From == "" && strings.ContainsRune(ctx.Session.Username(), '@') { msg.From = ctx.Session.Username() } @@ -438,12 +438,12 @@ func handleCompose(ctx *koushin.Context, msg *OutgoingMessage, options *composeO } return ctx.Render(http.StatusOK, "compose.html", &ComposeRenderData{ - BaseRenderData: *koushin.NewBaseRenderData(ctx), + BaseRenderData: *alps.NewBaseRenderData(ctx), Message: msg, }) } -func handleComposeNew(ctx *koushin.Context) error { +func handleComposeNew(ctx *alps.Context) error { // These are common mailto URL query parameters // TODO: cc, bcc return handleCompose(ctx, &OutgoingMessage{ @@ -462,7 +462,7 @@ func unwrapIMAPAddressList(addrs []*imap.Address) []string { return l } -func handleReply(ctx *koushin.Context) error { +func handleReply(ctx *alps.Context) error { var inReplyToPath messagePath var err error inReplyToPath.Mailbox, inReplyToPath.Uid, err = parseMboxAndUid(ctx.Param("mbox"), ctx.Param("uid")) @@ -521,7 +521,7 @@ func handleReply(ctx *koushin.Context) error { return handleCompose(ctx, &msg, &composeOptions{InReplyTo: &inReplyToPath}) } -func handleForward(ctx *koushin.Context) error { +func handleForward(ctx *alps.Context) error { var sourcePath messagePath var err error sourcePath.Mailbox, sourcePath.Uid, err = parseMboxAndUid(ctx.Param("mbox"), ctx.Param("uid")) @@ -585,7 +585,7 @@ func handleForward(ctx *koushin.Context) error { return handleCompose(ctx, &msg, &composeOptions{Forward: &sourcePath}) } -func handleEdit(ctx *koushin.Context) error { +func handleEdit(ctx *alps.Context) error { var sourcePath messagePath var err error sourcePath.Mailbox, sourcePath.Uid, err = parseMboxAndUid(ctx.Param("mbox"), ctx.Param("uid")) @@ -653,14 +653,14 @@ func handleEdit(ctx *koushin.Context) error { return handleCompose(ctx, &msg, &composeOptions{Draft: &sourcePath}) } -func formOrQueryParam(ctx *koushin.Context, k string) string { +func formOrQueryParam(ctx *alps.Context, k string) string { if v := ctx.FormValue(k); v != "" { return v } return ctx.QueryParam(k) } -func handleMove(ctx *koushin.Context) error { +func handleMove(ctx *alps.Context) error { mboxName, err := url.PathUnescape(ctx.Param("mbox")) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) @@ -706,7 +706,7 @@ func handleMove(ctx *koushin.Context) error { return ctx.Redirect(http.StatusFound, fmt.Sprintf("/mailbox/%v", url.PathEscape(to))) } -func handleDelete(ctx *koushin.Context) error { +func handleDelete(ctx *alps.Context) error { mboxName, err := url.PathUnescape(ctx.Param("mbox")) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) @@ -757,7 +757,7 @@ func handleDelete(ctx *koushin.Context) error { return ctx.Redirect(http.StatusFound, fmt.Sprintf("/mailbox/%v", url.PathEscape(mboxName))) } -func handleSetFlags(ctx *koushin.Context) error { +func handleSetFlags(ctx *alps.Context) error { mboxName, err := url.PathUnescape(ctx.Param("mbox")) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) @@ -840,11 +840,11 @@ type Settings struct { MessagesPerPage int } -func loadSettings(s koushin.Store) (*Settings, error) { +func loadSettings(s alps.Store) (*Settings, error) { settings := &Settings{ MessagesPerPage: 50, } - if err := s.Get(settingsKey, settings); err != nil && err != koushin.ErrNoStoreEntry { + if err := s.Get(settingsKey, settings); err != nil && err != alps.ErrNoStoreEntry { return nil, err } if err := settings.check(); err != nil { @@ -861,11 +861,11 @@ func (s *Settings) check() error { } type SettingsRenderData struct { - koushin.BaseRenderData + alps.BaseRenderData Settings *Settings } -func handleSettings(ctx *koushin.Context) error { +func handleSettings(ctx *alps.Context) error { settings, err := loadSettings(ctx.Session.Store()) if err != nil { return fmt.Errorf("failed to load settings: %v", err) @@ -888,7 +888,7 @@ func handleSettings(ctx *koushin.Context) error { } return ctx.Render(http.StatusOK, "settings.html", &SettingsRenderData{ - BaseRenderData: *koushin.NewBaseRenderData(ctx), + BaseRenderData: *alps.NewBaseRenderData(ctx), Settings: settings, }) } diff --git a/plugins/base/smtp.go b/plugins/base/smtp.go index 489a6a1..19c9e0b 100644 --- a/plugins/base/smtp.go +++ b/plugins/base/smtp.go @@ -1,4 +1,4 @@ -package koushinbase +package alpsbase import ( "bufio" diff --git a/plugins/base/strconv.go b/plugins/base/strconv.go index 9efa4cd..b423f13 100644 --- a/plugins/base/strconv.go +++ b/plugins/base/strconv.go @@ -1,4 +1,4 @@ -package koushinbase +package alpsbase import ( "fmt" diff --git a/plugins/base/template.go b/plugins/base/template.go index d867ff3..482674a 100644 --- a/plugins/base/template.go +++ b/plugins/base/template.go @@ -1,4 +1,4 @@ -package koushinbase +package alpsbase import ( "html/template" diff --git a/plugins/base/viewer.go b/plugins/base/viewer.go index a76ecf9..f9b24a2 100644 --- a/plugins/base/viewer.go +++ b/plugins/base/viewer.go @@ -1,9 +1,9 @@ -package koushinbase +package alpsbase import ( "fmt" - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" "github.com/emersion/go-message" ) @@ -16,7 +16,7 @@ type Viewer interface { // ViewMessagePart renders a message part. The returned value is displayed // in a template. ErrViewUnsupported is returned if the message part isn't // supported. - ViewMessagePart(*koushin.Context, *IMAPMessage, *message.Entity) (interface{}, error) + ViewMessagePart(*alps.Context, *IMAPMessage, *message.Entity) (interface{}, error) } var viewers []Viewer @@ -26,7 +26,7 @@ func RegisterViewer(viewer Viewer) { viewers = append(viewers, viewer) } -func viewMessagePart(ctx *koushin.Context, msg *IMAPMessage, part *message.Entity) (interface{}, error) { +func viewMessagePart(ctx *alps.Context, msg *IMAPMessage, part *message.Entity) (interface{}, error) { for _, viewer := range viewers { v, err := viewer.ViewMessagePart(ctx, msg, part) if err == ErrViewUnsupported { |