diff options
-rw-r--r-- | plugins/base/routes.go | 5 | ||||
-rw-r--r-- | renderer.go | 3 | ||||
-rw-r--r-- | session.go | 11 | ||||
-rw-r--r-- | themes/alps/assets/style.css | 7 | ||||
-rw-r--r-- | themes/alps/mailbox.html | 2 | ||||
-rw-r--r-- | themes/alps/nav.html | 6 |
6 files changed, 33 insertions, 1 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 0345189..1562a15 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -306,6 +306,7 @@ func handleDeleteMailbox(ctx *alps.Context) error { ctx.Session.DoIMAP(func(c *imapclient.Client) error { return c.Delete(mbox.Name) }) + ctx.Session.PutNotice("Mailbox deleted.") return ctx.Redirect(http.StatusFound, "/mailbox/INBOX") } @@ -519,6 +520,7 @@ func submitCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOpti return fmt.Errorf("failed to save message to Sent mailbox: %v", err) } + ctx.Session.PutNotice("Message sent.") return ctx.Redirect(http.StatusFound, "/mailbox/INBOX") } @@ -651,6 +653,7 @@ func handleCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOpti if err != nil { return fmt.Errorf("failed to save message to Draft mailbox: %v", err) } + ctx.Session.PutNotice("Message saved as draft.") return ctx.Redirect(http.StatusFound, fmt.Sprintf( "/message/%s/%d/edit?part=1", drafts.Name, uid)) } else { @@ -981,6 +984,7 @@ func handleMove(ctx *alps.Context) error { return err } + ctx.Session.PutNotice("Message(s) moved.") if path := formOrQueryParam(ctx, "next"); path != "" { return ctx.Redirect(http.StatusFound, path) } @@ -1032,6 +1036,7 @@ func handleDelete(ctx *alps.Context) error { return err } + ctx.Session.PutNotice("Message(s) deleted.") if path := formOrQueryParam(ctx, "next"); path != "" { return ctx.Redirect(http.StatusFound, path) } diff --git a/renderer.go b/renderer.go index 1123b0b..d8ea325 100644 --- a/renderer.go +++ b/renderer.go @@ -28,6 +28,8 @@ type GlobalRenderData struct { HavePlugin func(name string) bool + Notice string + // additional plugin-specific data Extra map[string]interface{} } @@ -95,6 +97,7 @@ func NewBaseRenderData(ectx echo.Context) *BaseRenderData { if isactx && ctx.Session != nil { global.LoggedIn = true global.Username = ctx.Session.username + global.Notice = ctx.Session.PopNotice() } return &BaseRenderData{ @@ -57,6 +57,7 @@ type Session struct { pings chan struct{} timer *time.Timer store Store + notice string imapLocker sync.Mutex imapConn *imapclient.Client // protected by locker, can be nil @@ -183,6 +184,16 @@ func (s *Session) PopAttachment(uuid string) *Attachment { return a } +func (s *Session) PutNotice(n string) { + s.notice = n +} + +func (s *Session) PopNotice() string { + n := s.notice + s.notice = "" + return n +} + // Store returns a store suitable for storing persistent user data. func (s *Session) Store() Store { return s.store diff --git a/themes/alps/assets/style.css b/themes/alps/assets/style.css index e07f4e2..e4a0d35 100644 --- a/themes/alps/assets/style.css +++ b/themes/alps/assets/style.css @@ -118,6 +118,13 @@ header nav div { float: right; } header nav div > a{ margin-left: 1rem; } header a.active { font-weight: bold; color: black; text-decoration: none; } +header .notice { + color: #0c5460; + background-color: #d1ecf1; + border: 1px solid #bee5eb; + padding: 0.5rem; + text-align: center; +} footer { text-align: right; } diff --git a/themes/alps/mailbox.html b/themes/alps/mailbox.html index 9a4c9ce..a3a2e6a 100644 --- a/themes/alps/mailbox.html +++ b/themes/alps/mailbox.html @@ -21,7 +21,7 @@ {{ $classes = printf "%s %s" $classes "message-list-deleted" }} {{ end }} - {{ if not (.HasFlag "\\Deleted") }} + {{ if and (not (.HasFlag "\\Deleted")) .Envelope }} <div class="message-list-checkbox {{$classes}}"> <input type="checkbox" name="uids" value="{{.Uid}}" form="messages-form"> </div> diff --git a/themes/alps/nav.html b/themes/alps/nav.html index d7eee9c..8fccea4 100644 --- a/themes/alps/nav.html +++ b/themes/alps/nav.html @@ -30,4 +30,10 @@ </div> {{ end }} </nav> + {{ if .GlobalData.Notice }} + <div class="notice"> + {{ .GlobalData.Notice }} + <a href="{{.GlobalData.URL.String}}">Dismiss</a> + </div> + {{ end }} </header> |