aboutsummaryrefslogtreecommitdiff
path: root/plugins/carddav
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-05-13 14:07:44 +0200
committerSimon Ser <contact@emersion.fr>2020-05-13 14:07:44 +0200
commitb891a95fcf4a3d4b64100911dae49fb28904a7fd (patch)
treefe07b29d6f2443047b7f740c79d86b3c499cc9e9 /plugins/carddav
parent4cf5ad68afd80f27512c464843b0d917182ef0c2 (diff)
downloadalps-b891a95fcf4a3d4b64100911dae49fb28904a7fd.tar.gz
alps-b891a95fcf4a3d4b64100911dae49fb28904a7fd.zip
Rename project to alps
Diffstat (limited to 'plugins/carddav')
-rw-r--r--plugins/carddav/carddav.go8
-rw-r--r--plugins/carddav/plugin.go26
-rw-r--r--plugins/carddav/public/address-book.html2
-rw-r--r--plugins/carddav/public/address-object.html2
-rw-r--r--plugins/carddav/public/update-address-object.html2
-rw-r--r--plugins/carddav/routes.go22
6 files changed, 31 insertions, 31 deletions
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"}}
-<h1>koushin</h1>
+<h1>alps</h1>
<p>
<a href="/">Back</a> ยท <a href="/contacts/create">Create new contact</a>
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"}}
-<h1>koushin</h1>
+<h1>alps</h1>
<p>
<a href="/contacts">Back</a>
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"}}
-<h1>koushin</h1>
+<h1>alps</h1>
<p>
<a href="/contacts">Back</a>
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,
})