From b891a95fcf4a3d4b64100911dae49fb28904a7fd Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 13 May 2020 14:07:44 +0200 Subject: Rename project to alps --- plugins/base/imap.go | 2 +- plugins/base/plugin.go | 8 +-- plugins/base/public/compose.html | 2 +- plugins/base/public/head.html | 2 +- plugins/base/public/login.html | 2 +- plugins/base/public/mailbox.html | 2 +- plugins/base/public/message.html | 2 +- plugins/base/public/settings.html | 2 +- plugins/base/routes.go | 68 +++++++++++------------ plugins/base/smtp.go | 2 +- plugins/base/strconv.go | 2 +- plugins/base/template.go | 2 +- plugins/base/viewer.go | 8 +-- plugins/caldav/caldav.go | 10 ++-- plugins/caldav/plugin.go | 14 ++--- plugins/caldav/public/calendar.html | 2 +- plugins/caldav/public/event.html | 2 +- plugins/caldav/routes.go | 18 +++--- plugins/carddav/carddav.go | 8 +-- plugins/carddav/plugin.go | 26 ++++----- plugins/carddav/public/address-book.html | 2 +- plugins/carddav/public/address-object.html | 2 +- plugins/carddav/public/update-address-object.html | 2 +- plugins/carddav/routes.go | 22 ++++---- plugins/lua/lua.go | 18 +++--- plugins/lua/plugin.go | 6 +- plugins/viewhtml/plugin.go | 16 +++--- plugins/viewhtml/sanitize.go | 6 +- plugins/viewhtml/viewer.go | 12 ++-- plugins/viewtext/plugin.go | 8 +-- plugins/viewtext/viewer.go | 12 ++-- 31 files changed, 145 insertions(+), 145 deletions(-) (limited to 'plugins') 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"}} -

koushin

+

alps

Back 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 @@ - koushin + alps 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"}} -

koushin

+

alps

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"}} -

koushin

+

alps

Logout 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"}} -

koushin

+

alps

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"}} -

koushin

+

alps

Back 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 { diff --git a/plugins/caldav/caldav.go b/plugins/caldav/caldav.go index 1c043e9..906e747 100644 --- a/plugins/caldav/caldav.go +++ b/plugins/caldav/caldav.go @@ -1,11 +1,11 @@ -package koushincaldav +package alpscaldav import ( "fmt" "net/http" "net/url" - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" "github.com/emersion/go-webdav/caldav" ) @@ -13,7 +13,7 @@ var errNoCalendar = fmt.Errorf("caldav: no calendar found") type authRoundTripper struct { upstream http.RoundTripper - session *koushin.Session + session *alps.Session } func (rt *authRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { @@ -21,7 +21,7 @@ func (rt *authRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) return rt.upstream.RoundTrip(req) } -func newClient(u *url.URL, session *koushin.Session) (*caldav.Client, error) { +func newClient(u *url.URL, session *alps.Session) (*caldav.Client, error) { rt := authRoundTripper{ upstream: http.DefaultTransport, session: session, @@ -34,7 +34,7 @@ func newClient(u *url.URL, session *koushin.Session) (*caldav.Client, error) { return c, nil } -func getCalendar(u *url.URL, session *koushin.Session) (*caldav.Client, *caldav.Calendar, error) { +func getCalendar(u *url.URL, session *alps.Session) (*caldav.Client, *caldav.Calendar, error) { c, err := newClient(u, session) if err != nil { return nil, nil, err diff --git a/plugins/caldav/plugin.go b/plugins/caldav/plugin.go index 27c5663..68de6cf 100644 --- a/plugins/caldav/plugin.go +++ b/plugins/caldav/plugin.go @@ -1,11 +1,11 @@ -package koushincaldav +package alpscaldav import ( "fmt" "net/http" "net/url" - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" ) func sanityCheckURL(u *url.URL) error { @@ -27,9 +27,9 @@ func sanityCheckURL(u *url.URL) error { return nil } -func newPlugin(srv *koushin.Server) (koushin.Plugin, error) { +func newPlugin(srv *alps.Server) (alps.Plugin, error) { u, err := srv.Upstream("caldavs", "caldav+insecure", "https", "http+insecure") - if _, ok := err.(*koushin.NoUpstreamError); ok { + if _, ok := err.(*alps.NoUpstreamError); ok { return nil, nil } else if err != nil { return nil, fmt.Errorf("caldav: failed to parse upstream caldav server: %v", err) @@ -53,7 +53,7 @@ func newPlugin(srv *koushin.Server) (koushin.Plugin, error) { srv.Logger().Printf("Configured upstream CalDAV server: %v", u) - p := koushin.GoPlugin{Name: "caldav"} + p := alps.GoPlugin{Name: "caldav"} registerRoutes(&p, u) @@ -61,7 +61,7 @@ func newPlugin(srv *koushin.Server) (koushin.Plugin, error) { } func init() { - koushin.RegisterPluginLoader(func(s *koushin.Server) ([]koushin.Plugin, error) { + alps.RegisterPluginLoader(func(s *alps.Server) ([]alps.Plugin, error) { p, err := newPlugin(s) if err != nil { return nil, err @@ -69,6 +69,6 @@ func init() { if p == nil { return nil, nil } - return []koushin.Plugin{p}, err + return []alps.Plugin{p}, err }) } diff --git a/plugins/caldav/public/calendar.html b/plugins/caldav/public/calendar.html index 6715258..7787bb1 100644 --- a/plugins/caldav/public/calendar.html +++ b/plugins/caldav/public/calendar.html @@ -1,6 +1,6 @@ {{template "head.html"}} -

koushin

+

alps

Back diff --git a/plugins/caldav/public/event.html b/plugins/caldav/public/event.html index 8c88833..a07f663 100644 --- a/plugins/caldav/public/event.html +++ b/plugins/caldav/public/event.html @@ -1,6 +1,6 @@ {{template "head.html"}} -

koushin

+

alps

Back diff --git a/plugins/caldav/routes.go b/plugins/caldav/routes.go index 51a9490..ee18574 100644 --- a/plugins/caldav/routes.go +++ b/plugins/caldav/routes.go @@ -1,4 +1,4 @@ -package koushincaldav +package alpscaldav import ( "fmt" @@ -6,12 +6,12 @@ import ( "net/url" "time" - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" "github.com/emersion/go-webdav/caldav" ) type CalendarRenderData struct { - koushin.BaseRenderData + alps.BaseRenderData Time time.Time Calendar *caldav.Calendar Events []caldav.CalendarObject @@ -19,15 +19,15 @@ type CalendarRenderData struct { } type EventRenderData struct { - koushin.BaseRenderData + alps.BaseRenderData Calendar *caldav.Calendar Event *caldav.CalendarObject } var monthPageLayout = "2006-01" -func registerRoutes(p *koushin.GoPlugin, u *url.URL) { - p.GET("/calendar", func(ctx *koushin.Context) error { +func registerRoutes(p *alps.GoPlugin, u *url.URL) { + p.GET("/calendar", func(ctx *alps.Context) error { var start time.Time if s := ctx.QueryParam("month"); s != "" { var err error @@ -77,7 +77,7 @@ func registerRoutes(p *koushin.GoPlugin, u *url.URL) { } return ctx.Render(http.StatusOK, "calendar.html", &CalendarRenderData{ - BaseRenderData: *koushin.NewBaseRenderData(ctx), + BaseRenderData: *alps.NewBaseRenderData(ctx), Time: start, Calendar: calendar, Events: events, @@ -86,7 +86,7 @@ func registerRoutes(p *koushin.GoPlugin, u *url.URL) { }) }) - p.GET("/calendar/:uid", func(ctx *koushin.Context) error { + p.GET("/calendar/:uid", func(ctx *alps.Context) error { uid := ctx.Param("uid") c, calendar, err := getCalendar(u, ctx.Session) @@ -131,7 +131,7 @@ func registerRoutes(p *koushin.GoPlugin, u *url.URL) { event := &events[0] return ctx.Render(http.StatusOK, "event.html", &EventRenderData{ - BaseRenderData: *koushin.NewBaseRenderData(ctx), + BaseRenderData: *alps.NewBaseRenderData(ctx), Calendar: calendar, Event: event, }) diff --git a/plugins/carddav/carddav.go b/plugins/carddav/carddav.go index 2509872..b863827 100644 --- a/plugins/carddav/carddav.go +++ b/plugins/carddav/carddav.go @@ -1,11 +1,11 @@ -package koushincarddav +package alpscarddav import ( "fmt" "net/http" "net/url" - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" "github.com/emersion/go-webdav/carddav" ) @@ -13,7 +13,7 @@ var errNoAddressBook = fmt.Errorf("carddav: no address book found") type authRoundTripper struct { upstream http.RoundTripper - session *koushin.Session + session *alps.Session } func (rt *authRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { @@ -21,7 +21,7 @@ func (rt *authRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) return rt.upstream.RoundTrip(req) } -func newClient(u *url.URL, session *koushin.Session) (*carddav.Client, error) { +func newClient(u *url.URL, session *alps.Session) (*carddav.Client, error) { rt := authRoundTripper{ upstream: http.DefaultTransport, session: session, diff --git a/plugins/carddav/plugin.go b/plugins/carddav/plugin.go index 3002da1..225c98f 100644 --- a/plugins/carddav/plugin.go +++ b/plugins/carddav/plugin.go @@ -1,4 +1,4 @@ -package koushincarddav +package alpscarddav import ( "fmt" @@ -6,8 +6,8 @@ import ( "net/url" "strings" - "git.sr.ht/~emersion/koushin" - koushinbase "git.sr.ht/~emersion/koushin/plugins/base" + "git.sr.ht/~emersion/alps" + alpsbase "git.sr.ht/~emersion/alps/plugins/base" "github.com/emersion/go-vcard" "github.com/emersion/go-webdav/carddav" ) @@ -32,16 +32,16 @@ func sanityCheckURL(u *url.URL) error { } type plugin struct { - koushin.GoPlugin + alps.GoPlugin url *url.URL homeSetCache map[string]string } -func (p *plugin) client(session *koushin.Session) (*carddav.Client, error) { +func (p *plugin) client(session *alps.Session) (*carddav.Client, error) { return newClient(p.url, session) } -func (p *plugin) clientWithAddressBook(session *koushin.Session) (*carddav.Client, *carddav.AddressBook, error) { +func (p *plugin) clientWithAddressBook(session *alps.Session) (*carddav.Client, *carddav.AddressBook, error) { c, err := newClient(p.url, session) if err != nil { return nil, nil, fmt.Errorf("failed to create CardDAV client: %v", err) @@ -73,9 +73,9 @@ func (p *plugin) clientWithAddressBook(session *koushin.Session) (*carddav.Clien return c, &addressBooks[0], nil } -func newPlugin(srv *koushin.Server) (koushin.Plugin, error) { +func newPlugin(srv *alps.Server) (alps.Plugin, error) { u, err := srv.Upstream("carddavs", "carddav+insecure", "https", "http+insecure") - if _, ok := err.(*koushin.NoUpstreamError); ok { + if _, ok := err.(*alps.NoUpstreamError); ok { return nil, nil } else if err != nil { return nil, fmt.Errorf("carddav: failed to parse upstream CardDAV server: %v", err) @@ -105,7 +105,7 @@ func newPlugin(srv *koushin.Server) (koushin.Plugin, error) { srv.Logger().Printf("Configured upstream CardDAV server: %v", u) p := &plugin{ - GoPlugin: koushin.GoPlugin{Name: "carddav"}, + GoPlugin: alps.GoPlugin{Name: "carddav"}, url: u, homeSetCache: make(map[string]string), } @@ -118,8 +118,8 @@ func newPlugin(srv *koushin.Server) (koushin.Plugin, error) { }, }) - p.Inject("compose.html", func(ctx *koushin.Context, _data koushin.RenderData) error { - data := _data.(*koushinbase.ComposeRenderData) + p.Inject("compose.html", func(ctx *alps.Context, _data alps.RenderData) error { + data := _data.(*alpsbase.ComposeRenderData) c, addressBook, err := p.clientWithAddressBook(ctx.Session) if err == errNoAddressBook { @@ -156,7 +156,7 @@ func newPlugin(srv *koushin.Server) (koushin.Plugin, error) { } func init() { - koushin.RegisterPluginLoader(func(s *koushin.Server) ([]koushin.Plugin, error) { + alps.RegisterPluginLoader(func(s *alps.Server) ([]alps.Plugin, error) { p, err := newPlugin(s) if err != nil { return nil, err @@ -164,6 +164,6 @@ func init() { if p == nil { return nil, nil } - return []koushin.Plugin{p}, err + return []alps.Plugin{p}, err }) } diff --git a/plugins/carddav/public/address-book.html b/plugins/carddav/public/address-book.html index d4e13b9..a9ab9c5 100644 --- a/plugins/carddav/public/address-book.html +++ b/plugins/carddav/public/address-book.html @@ -1,6 +1,6 @@ {{template "head.html"}} -

koushin

+

alps

Back ยท Create new contact diff --git a/plugins/carddav/public/address-object.html b/plugins/carddav/public/address-object.html index e4ec135..b6e731e 100644 --- a/plugins/carddav/public/address-object.html +++ b/plugins/carddav/public/address-object.html @@ -1,6 +1,6 @@ {{template "head.html"}} -

koushin

+

alps

Back diff --git a/plugins/carddav/public/update-address-object.html b/plugins/carddav/public/update-address-object.html index 82adf8e..4769e97 100644 --- a/plugins/carddav/public/update-address-object.html +++ b/plugins/carddav/public/update-address-object.html @@ -1,6 +1,6 @@ {{template "head.html"}} -

koushin

+

alps

Back diff --git a/plugins/carddav/routes.go b/plugins/carddav/routes.go index ccc053c..78fe1eb 100644 --- a/plugins/carddav/routes.go +++ b/plugins/carddav/routes.go @@ -1,4 +1,4 @@ -package koushincarddav +package alpscarddav import ( "fmt" @@ -7,7 +7,7 @@ import ( "path" "strings" - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" "github.com/emersion/go-vcard" "github.com/emersion/go-webdav/carddav" "github.com/google/uuid" @@ -15,19 +15,19 @@ import ( ) type AddressBookRenderData struct { - koushin.BaseRenderData + alps.BaseRenderData AddressBook *carddav.AddressBook AddressObjects []AddressObject Query string } type AddressObjectRenderData struct { - koushin.BaseRenderData + alps.BaseRenderData AddressObject AddressObject } type UpdateAddressObjectRenderData struct { - koushin.BaseRenderData + alps.BaseRenderData AddressObject *carddav.AddressObject // nil if creating a new contact Card vcard.Card } @@ -42,7 +42,7 @@ func parseObjectPath(s string) (string, error) { } func registerRoutes(p *plugin) { - p.GET("/contacts", func(ctx *koushin.Context) error { + p.GET("/contacts", func(ctx *alps.Context) error { queryText := ctx.QueryParam("query") c, addressBook, err := p.clientWithAddressBook(ctx.Session) @@ -82,14 +82,14 @@ func registerRoutes(p *plugin) { } return ctx.Render(http.StatusOK, "address-book.html", &AddressBookRenderData{ - BaseRenderData: *koushin.NewBaseRenderData(ctx), + BaseRenderData: *alps.NewBaseRenderData(ctx), AddressBook: addressBook, AddressObjects: newAddressObjectList(aos), Query: queryText, }) }) - p.GET("/contacts/:path", func(ctx *koushin.Context) error { + p.GET("/contacts/:path", func(ctx *alps.Context) error { path, err := parseObjectPath(ctx.Param("path")) if err != nil { return err @@ -119,12 +119,12 @@ func registerRoutes(p *plugin) { ao := &aos[0] return ctx.Render(http.StatusOK, "address-object.html", &AddressObjectRenderData{ - BaseRenderData: *koushin.NewBaseRenderData(ctx), + BaseRenderData: *alps.NewBaseRenderData(ctx), AddressObject: AddressObject{ao}, }) }) - updateContact := func(ctx *koushin.Context) error { + updateContact := func(ctx *alps.Context) error { addressObjectPath, err := parseObjectPath(ctx.Param("path")) if err != nil { return err @@ -200,7 +200,7 @@ func registerRoutes(p *plugin) { } return ctx.Render(http.StatusOK, "update-address-object.html", &UpdateAddressObjectRenderData{ - BaseRenderData: *koushin.NewBaseRenderData(ctx), + BaseRenderData: *alps.NewBaseRenderData(ctx), AddressObject: ao, Card: card, }) diff --git a/plugins/lua/lua.go b/plugins/lua/lua.go index d236702..451c884 100644 --- a/plugins/lua/lua.go +++ b/plugins/lua/lua.go @@ -1,11 +1,11 @@ -package koushinlua +package alpslua import ( "fmt" "html/template" "path/filepath" - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" "github.com/labstack/echo/v4" "github.com/yuin/gopher-lua" "layeh.com/gopher-luar" @@ -69,7 +69,7 @@ func (p *luaPlugin) setRoute(l *lua.LState) int { return 0 } -func (p *luaPlugin) inject(name string, data koushin.RenderData) error { +func (p *luaPlugin) inject(name string, data alps.RenderData) error { f, ok := p.renderCallbacks[name] if !ok { return nil @@ -87,7 +87,7 @@ func (p *luaPlugin) inject(name string, data koushin.RenderData) error { return nil } -func (p *luaPlugin) Inject(ctx *koushin.Context, name string, data koushin.RenderData) error { +func (p *luaPlugin) Inject(ctx *alps.Context, name string, data alps.RenderData) error { if err := p.inject("*", data); err != nil { return err } @@ -144,8 +144,8 @@ func loadLuaPlugin(filename string) (*luaPlugin, error) { filters: make(template.FuncMap), } - mt := l.NewTypeMetatable("koushin") - l.SetGlobal("koushin", mt) + mt := l.NewTypeMetatable("alps") + l.SetGlobal("alps", mt) l.SetField(mt, "on_render", l.NewFunction(p.onRender)) l.SetField(mt, "set_filter", l.NewFunction(p.setFilter)) l.SetField(mt, "set_route", l.NewFunction(p.setRoute)) @@ -158,15 +158,15 @@ func loadLuaPlugin(filename string) (*luaPlugin, error) { return p, nil } -func loadAllLuaPlugins(s *koushin.Server) ([]koushin.Plugin, error) { +func loadAllLuaPlugins(s *alps.Server) ([]alps.Plugin, error) { log := s.Logger() - filenames, err := filepath.Glob(koushin.PluginDir + "/*/main.lua") + filenames, err := filepath.Glob(alps.PluginDir + "/*/main.lua") if err != nil { return nil, fmt.Errorf("filepath.Glob failed: %v", err) } - plugins := make([]koushin.Plugin, 0, len(filenames)) + plugins := make([]alps.Plugin, 0, len(filenames)) for _, filename := range filenames { log.Printf("Loading Lua plugin %q", filename) diff --git a/plugins/lua/plugin.go b/plugins/lua/plugin.go index dbfee6d..aaf5597 100644 --- a/plugins/lua/plugin.go +++ b/plugins/lua/plugin.go @@ -1,9 +1,9 @@ -package koushinlua +package alpslua import ( - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" ) func init() { - koushin.RegisterPluginLoader(loadAllLuaPlugins) + alps.RegisterPluginLoader(loadAllLuaPlugins) } diff --git a/plugins/viewhtml/plugin.go b/plugins/viewhtml/plugin.go index 1007d4a..a121d92 100644 --- a/plugins/viewhtml/plugin.go +++ b/plugins/viewhtml/plugin.go @@ -1,4 +1,4 @@ -package koushinviewhtml +package alpsviewhtml import ( "io" @@ -8,8 +8,8 @@ import ( "strconv" "strings" - "git.sr.ht/~emersion/koushin" - koushinbase "git.sr.ht/~emersion/koushin/plugins/base" + "git.sr.ht/~emersion/alps" + alpsbase "git.sr.ht/~emersion/alps/plugins/base" "github.com/labstack/echo/v4" ) @@ -19,10 +19,10 @@ var ( ) func init() { - p := koushin.GoPlugin{Name: "viewhtml"} + p := alps.GoPlugin{Name: "viewhtml"} - p.Inject("message.html", func(ctx *koushin.Context, _data koushin.RenderData) error { - data := _data.(*koushinbase.MessageRenderData) + p.Inject("message.html", func(ctx *alps.Context, _data alps.RenderData) error { + data := _data.(*alpsbase.MessageRenderData) data.Extra["RemoteResourcesAllowed"] = ctx.QueryParam("allow-remote-resources") == "1" hasRemoteResources := false if v := ctx.Get("viewhtml.hasRemoteResources"); v != nil { @@ -32,7 +32,7 @@ func init() { return nil }) - p.GET("/proxy", func(ctx *koushin.Context) error { + p.GET("/proxy", func(ctx *alps.Context) error { if !proxyEnabled { return echo.NewHTTPError(http.StatusForbidden, "proxy disabled") } @@ -67,5 +67,5 @@ func init() { return ctx.Stream(http.StatusOK, mediaType, &lr) }) - koushin.RegisterPluginLoader(p.Loader()) + alps.RegisterPluginLoader(p.Loader()) } diff --git a/plugins/viewhtml/sanitize.go b/plugins/viewhtml/sanitize.go index ba2aca9..61a011d 100644 --- a/plugins/viewhtml/sanitize.go +++ b/plugins/viewhtml/sanitize.go @@ -1,4 +1,4 @@ -package koushinviewhtml +package alpsviewhtml import ( "bytes" @@ -7,7 +7,7 @@ import ( "regexp" "strings" - koushinbase "git.sr.ht/~emersion/koushin/plugins/base" + alpsbase "git.sr.ht/~emersion/alps/plugins/base" "github.com/aymerick/douceur/css" cssparser "github.com/chris-ramon/douceur/parser" "github.com/microcosm-cc/bluemonday" @@ -71,7 +71,7 @@ var allowedStyles = map[string]bool{ } type sanitizer struct { - msg *koushinbase.IMAPMessage + msg *alpsbase.IMAPMessage allowRemoteResources bool hasRemoteResources bool } diff --git a/plugins/viewhtml/viewer.go b/plugins/viewhtml/viewer.go index abc9f2d..de6ee4a 100644 --- a/plugins/viewhtml/viewer.go +++ b/plugins/viewhtml/viewer.go @@ -1,4 +1,4 @@ -package koushinviewhtml +package alpsviewhtml import ( "bytes" @@ -7,8 +7,8 @@ import ( "io/ioutil" "strings" - "git.sr.ht/~emersion/koushin" - koushinbase "git.sr.ht/~emersion/koushin/plugins/base" + "git.sr.ht/~emersion/alps" + alpsbase "git.sr.ht/~emersion/alps/plugins/base" "github.com/emersion/go-message" ) @@ -24,7 +24,7 @@ var tpl = template.Must(template.New("view-html.html").Parse(tplSrc)) type viewer struct{} -func (viewer) ViewMessagePart(ctx *koushin.Context, msg *koushinbase.IMAPMessage, part *message.Entity) (interface{}, error) { +func (viewer) ViewMessagePart(ctx *alps.Context, msg *alpsbase.IMAPMessage, part *message.Entity) (interface{}, error) { allowRemoteResources := ctx.QueryParam("allow-remote-resources") == "1" mimeType, _, err := part.Header.ContentType() @@ -32,7 +32,7 @@ func (viewer) ViewMessagePart(ctx *koushin.Context, msg *koushinbase.IMAPMessage return nil, err } if !strings.EqualFold(mimeType, "text/html") { - return nil, koushinbase.ErrViewUnsupported + return nil, alpsbase.ErrViewUnsupported } body, err := ioutil.ReadAll(part.Body) @@ -61,5 +61,5 @@ func (viewer) ViewMessagePart(ctx *koushin.Context, msg *koushinbase.IMAPMessage } func init() { - koushinbase.RegisterViewer(viewer{}) + alpsbase.RegisterViewer(viewer{}) } diff --git a/plugins/viewtext/plugin.go b/plugins/viewtext/plugin.go index c7a2bcc..1454a93 100644 --- a/plugins/viewtext/plugin.go +++ b/plugins/viewtext/plugin.go @@ -1,10 +1,10 @@ -package koushinviewtext +package alpsviewtext import ( - "git.sr.ht/~emersion/koushin" + "git.sr.ht/~emersion/alps" ) func init() { - p := koushin.GoPlugin{Name: "viewtext"} - koushin.RegisterPluginLoader(p.Loader()) + p := alps.GoPlugin{Name: "viewtext"} + alps.RegisterPluginLoader(p.Loader()) } diff --git a/plugins/viewtext/viewer.go b/plugins/viewtext/viewer.go index 9a91f08..a03f272 100644 --- a/plugins/viewtext/viewer.go +++ b/plugins/viewtext/viewer.go @@ -1,4 +1,4 @@ -package koushinviewtext +package alpsviewtext import ( "bufio" @@ -7,8 +7,8 @@ import ( "net/url" "strings" - "git.sr.ht/~emersion/koushin" - koushinbase "git.sr.ht/~emersion/koushin/plugins/base" + "git.sr.ht/~emersion/alps" + alpsbase "git.sr.ht/~emersion/alps/plugins/base" "github.com/emersion/go-message" "gitlab.com/golang-commonmark/linkify" ) @@ -53,13 +53,13 @@ func executeTemplate(name string, data interface{}) (template.HTML, error) { type viewer struct{} -func (viewer) ViewMessagePart(ctx *koushin.Context, msg *koushinbase.IMAPMessage, part *message.Entity) (interface{}, error) { +func (viewer) ViewMessagePart(ctx *alps.Context, msg *alpsbase.IMAPMessage, part *message.Entity) (interface{}, error) { mimeType, _, err := part.Header.ContentType() if err != nil { return nil, err } if !strings.EqualFold(mimeType, "text/plain") { - return nil, koushinbase.ErrViewUnsupported + return nil, alpsbase.ErrViewUnsupported } var tokens []interface{} @@ -114,5 +114,5 @@ func (viewer) ViewMessagePart(ctx *koushin.Context, msg *koushinbase.IMAPMessage } func init() { - koushinbase.RegisterViewer(viewer{}) + alpsbase.RegisterViewer(viewer{}) } -- cgit v1.2.3